blue-button-record
Advanced tools
Comparing version 0.2.2 to 0.2.3
14
index.js
@@ -78,2 +78,6 @@ "use strict"; | ||
exports.saveMatches = function(secName, ptKey, inputSection, sourceId, callback) { | ||
section.savePartial(dbinfo, secName, ptKey, inputSection, sourceId, callback); | ||
}; | ||
exports.getMatches = function(secName, ptKey, fields, callback) { | ||
@@ -117,12 +121,2 @@ match.getAll(dbinfo, secName, ptKey, fields, callback); | ||
// partial section | ||
exports.getPartialSection = function(secName, ptKey, callback) { | ||
section.getPartial(dbinfo, secName, ptKey, callback); | ||
}; | ||
exports.savePartialSection = function(secName, ptKey, inputSection, sourceId, callback) { | ||
section.savePartial(dbinfo, secName, ptKey, inputSection, sourceId, callback); | ||
}; | ||
// entry | ||
@@ -129,0 +123,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Master Health Record and Data Reconciliation Engine Persistance Layer", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -16,3 +16,3 @@ blue-button-record.js | ||
- Persist Merge History: Since blue-button data is historical, entries in Master Health Record is expected to appear in multiple sources. Merge History keeps track of all the sources from which entries are created or updated. In addition it is also possible to register sources where the entries appear as it is in the Master Health Record (duplicates). | ||
- Persist Partial Health Record: This module also stores a second health record seperate from Master Health Record called Partial Health Record. Partial Health Record is designed to store entries that are similar to existing entries in Master Health Record but cannot be identified as duplicate or seperate and thus require further review. Both the partial entries, Master Health Record entries that the partial entries match, and match details are stored. Partial Health Record entries are eventually either added to Master Health Record or removed; blue-button-record API provides methods for both. | ||
- Persist Match List: This module also stores a second set of entries seperate from Master Health Record called Match List. Match List is designed to store entries that are similar to existing entries in Master Health Record but cannot be identified as duplicate or seperate and thus require further review. Both the Match List entries, Master Health Record entries that the Match List entries match, and match details are stored. Match List entries are eventually either added to Master Health Record or removed; blue-button-record API provides methods for both. | ||
@@ -166,3 +166,3 @@ This implementation of blue-button-record uses MongoDB. | ||
blue-button-record also stores Partial Health Record; entries which cannot immediately become part of the Master Health Record since they are similar enough to existing entries but not identical to become duplicates. In addition to blue-button health data, blue-button-record requires a pointer to an existing Master Health Record entry and match information to persist partial entries | ||
blue-button-record also stores Match List; entries which cannot immediately become part of the Master Health Record since they are similar enough to existing entries but not identical to become duplicates. In addition to blue-button health data, blue-button-record requires a pointer to an existing Master Health Record entry and match information to persist partial entries | ||
``` javascript | ||
@@ -181,18 +181,12 @@ var partialAllergy = { | ||
Partial entries are persisted as sections | ||
Match List entries are persisted as sections | ||
``` javascript | ||
// for simplicity use the same here, these would be different in reality | ||
var partialAllergies = [partialAllergy, partialAllergy]; | ||
bbr.savePartialSection('allergies', 'patientKey', partialAllergies, fileId, function(err) { | ||
bbr.saveMatches('allergies', 'patientKey', partialAllergies, fileId, function(err) { | ||
if (err) {throw err;} | ||
}); | ||
``` | ||
blue-button health data piece of partial entries are available similar to `getSection`. | ||
Match List is available as a list | ||
``` javascript | ||
bbr.getPartialSection('allergies', 'patientKey', function(err, result) { | ||
console.log(result[0].allergen.name); | ||
}); | ||
``` | ||
the same data together with selected fields from the Master Health Record entry and the match information is available as a list | ||
``` javascript | ||
bbr.getMatches('allergies', 'patientKey', 'allergen severity', function(err, result) { | ||
@@ -209,3 +203,3 @@ console.log(result[0].entry.allergen.name); | ||
``` | ||
Individual match access is also available and will return the full blue-button data both for the Master Health Record enty and the Partial Health Record entry | ||
Individual Match List entry access is also available and will return the full blue-button data both for the Master Health Record enty and the Match List entry | ||
``` javascript | ||
@@ -232,3 +226,3 @@ bbr.getMatch('allergies', 'patientKey', matchId0, function(err, result) { | ||
Matches can be canceled with application specific reasons such as 'ignored' or 'merged' | ||
Match List entries can be canceled with application specific reasons such as 'ignored' or 'merged' | ||
``` javascript | ||
@@ -770,5 +764,5 @@ bbr.cancelMatch('allergies', 'patientKey', matchId0, 'ignored', function(err, count) { | ||
### savePartialSection(secName, ptKey, inputSection, sourceId, callback) | ||
### saveMatches(secName, ptKey, inputSection, sourceId, callback) | ||
Saves section entries in Partial Health Record together with the id of the matching existing entry in Master Health Record and match details. | ||
Saves Match List entries for a section. | ||
@@ -778,3 +772,3 @@ __Arguments__ | ||
* `ptKey` - Identification string for the patient. | ||
* `inputSection` - An array of partial entries and match information. Each element in the array has three top level properties: | ||
* `inputSection` - An array of Match List entries and match information. Each element in the array has three top level properties: | ||
* partial_entry - Section entry with the schema as specified in [`connectDatabase`](#connectDatabase). | ||
@@ -821,3 +815,3 @@ * partial_match - Match information with the schema as specified in [`connectDatabase`](#connectDatabase). | ||
var paid2; | ||
bbr.savePartialSection('allergies', 'testPatient1', inputSection, fileId4, function(err, ids) { | ||
bbr.saveMatches('allergies', 'testPatient1', inputSection, fileId4, function(err, ids) { | ||
assert.ifError(err); | ||
@@ -830,28 +824,5 @@ paid1 = ids[0]; | ||
### getPartialSection(secName, ptKey, callback) | ||
Gets all entries in a section of Partial Health Record without any match information. The entries are identical to [`getSection`](#getSection) in content. | ||
__Arguments__ | ||
* `secName` - Section name. | ||
* `ptKey` - Identification string for the patient. | ||
* `callback(err, entries)` - A callback which is called when entries are retrieved, or an error occurs. Each entry in `entries` array contains the data as specified in [`getSection`](#getSection). | ||
__Examples__ | ||
```js | ||
bbr.getPartialSection('allergies', 'testPatient1', function(err, entries) { | ||
assert.ifError(err); | ||
var i = [entries[0].name, entries[1].name].indexOf('allergy1'); | ||
assert.equal(entries[i].name, 'allergy1'); | ||
assert.equal(entries[i].severity, 'severity3'); | ||
assert.equal(entries[i+1 % 2].name, 'allergy2'); | ||
assert.equal(entries[i+1 % 2].value.code, 'code5'); | ||
}); | ||
``` | ||
--------------------------------------- | ||
### getMatches(secName, ptKey, fields, callback) | ||
Gets a list of all section entries in Partial Health Record. | ||
Gets a list of all section entries in Match List | ||
@@ -862,3 +833,3 @@ __Arguments__ | ||
* `fields` - Fields of entries to be retrieved. | ||
* `callback(err, partialEntries)` - A callback which is called when entries and match information areretrieved, or an error occurs. Each element in `partialEntries` array contains `fields` for `match_entry` and `entry` and match information. | ||
* `callback(err, partialEntries)` - A callback which is called when entries and match information are retrieved, or an error occurs. Each element in `partialEntries` array contains `fields` for `match_entry` and `entry` and match information. | ||
@@ -885,3 +856,3 @@ __Examples__ | ||
Gets all the details of a partial entry, the matching entry in Master Health Record, and match information. | ||
Gets all the details of a Match List entry, the matching entry in Master Health Record, and match information. | ||
@@ -892,3 +863,3 @@ __Arguments__ | ||
* `id` - Id of the match. | ||
* `callback(err, matchInfo)` - A callback which is called when match information is retrieved, or an error occurs. `match_entry` and `entry` contain patient health data for partial and matching existing data. | ||
* `callback(err, matchInfo)` - A callback which is called when match information is retrieved, or an error occurs. `match_entry` and `entry` contain full blue-button data for Match List and Master Health Record entries. | ||
@@ -910,3 +881,3 @@ __Examples__ | ||
Gets number of section entries in Partial Health Record. | ||
Gets number of section entries in Match List. | ||
@@ -936,3 +907,3 @@ __Arguments__ | ||
Moves the partial entry to Master Health Record. | ||
Moves the Match List entry to Master Health Record. | ||
@@ -965,3 +936,3 @@ __Arguments__ | ||
Removes the partial entry from Partial Health Record. | ||
Removes the entry from Match List. | ||
@@ -968,0 +939,0 @@ __Arguments__ |
@@ -299,3 +299,3 @@ "use strict"; | ||
it('savePartialSection', function(done) { | ||
it('saveMatches', function(done) { | ||
var inputSection = [{ | ||
@@ -331,3 +331,3 @@ partial_entry : { | ||
}]; | ||
bbr.savePartialSection('allergies', 'testPatient1', inputSection, fileId4, function(err, ids) { | ||
bbr.saveMatches('allergies', 'testPatient1', inputSection, fileId4, function(err, ids) { | ||
assert.ifError(err); | ||
@@ -340,14 +340,2 @@ paid1 = ids[0]; | ||
it('getPartialSection', function(done) { | ||
bbr.getPartialSection('allergies', 'testPatient1', function(err, entries) { | ||
assert.ifError(err); | ||
var i = [entries[0].name, entries[1].name].indexOf('allergy1'); | ||
assert.equal(entries[i].name, 'allergy1'); | ||
assert.equal(entries[i].severity, 'severity3'); | ||
assert.equal(entries[i+1 % 2].name, 'allergy2'); | ||
assert.equal(entries[i+1 % 2].value.code, 'code5'); | ||
done(); | ||
}); | ||
}); | ||
it('getMatches', function(done) { | ||
@@ -357,2 +345,3 @@ bbr.getMatches('allergies', 'testPatient1', 'name severity value.code', function(err, entries) { | ||
var i = [entries[0].entry.name, entries[1].entry.name].indexOf('allergy1'); | ||
assert.equal(entries[i].entry.name, 'allergy1'); | ||
assert.equal(entries[i].entry.severity, 'updatedSev'); | ||
@@ -362,2 +351,3 @@ assert.equal(entries[i].match_entry.severity, 'severity3'); | ||
assert.deepEqual(entries[i].subelements, ['severity']); | ||
assert.equal(entries[i+1 % 2].entry.name, 'allergy2'); | ||
assert.equal(entries[i+1 % 2].entry.value.code, 'code2'); | ||
@@ -364,0 +354,0 @@ assert.equal(entries[i+1 % 2].match_entry.value.code, 'code5'); |
@@ -196,3 +196,3 @@ "use strict"; | ||
var partialAllergies = [partialAllergy, partialAllergy]; | ||
bbr.savePartialSection('allergies', 'patientKey', partialAllergies, fileId, function(err) { | ||
bbr.saveMatches('allergies', 'patientKey', partialAllergies, fileId, function(err) { | ||
if (err) {throw err;} | ||
@@ -203,9 +203,2 @@ done(); | ||
it('script 18', function(done) { | ||
bbr.getPartialSection('allergies', 'patientKey', function(err, result) { | ||
console.log(result[0].allergen.name); | ||
done(); | ||
}); | ||
}); | ||
var matchId0; | ||
@@ -212,0 +205,0 @@ var matchId1; |
@@ -170,3 +170,3 @@ "use strict"; | ||
exports.savePartialSection = function(context, secName, pat_key, recordIndex, destRecordIndex, extraContent, callback) { | ||
exports.saveMatches = function(context, secName, pat_key, recordIndex, destRecordIndex, extraContent, callback) { | ||
var data = createTestSection(secName, recordIndex, extraContent.length); | ||
@@ -173,0 +173,0 @@ var sourceId = context.storageIds[recordIndex]; |
@@ -282,3 +282,3 @@ "use strict"; | ||
it('savePartialSection', function(done) { | ||
it('saveMatches', function(done) { | ||
var match1 = { | ||
@@ -310,3 +310,3 @@ diff: {severity: 'new'}, | ||
]; | ||
bbr.savePartialSection('allergies', 'pat1', partialInput, sourceIds[6], function(err, result) { | ||
bbr.saveMatches('allergies', 'pat1', partialInput, sourceIds[6], function(err, result) { | ||
done(err); | ||
@@ -316,21 +316,2 @@ }); | ||
it('getPartialSection', function(done) { | ||
bbr.getPartialSection('allergies', 'pat1', function(err, result) { | ||
if (err) { | ||
done(err); | ||
} else { | ||
var actual = bbr.cleanSection(result); | ||
var expected = [partialInput[0].partial_entry, partialInput[1].partial_entry]; | ||
expect(actual).to.deep.include.members(expected); | ||
expect(expected).to.deep.include.members(actual); | ||
if (ccd.allergies[1].allergen.name === result[0].allergen.name) { | ||
partialAllergyIds = [result[0]._id, result[1]._id]; | ||
} else { | ||
partialAllergyIds = [result[1]._id, result[0]._id]; | ||
} | ||
done(err); | ||
} | ||
}); | ||
}); | ||
it('getMatches', function(done) { | ||
@@ -347,2 +328,3 @@ bbr.getMatches('allergies', 'pat1', 'allergen.name severity status', function(err, result) { | ||
} | ||
partialAllergyIds = [result[0].match_entry._id, result[1].match_entry._id]; | ||
expect(result[0].entry.allergen.name).to.equal(allergyNames[1]); | ||
@@ -422,3 +404,3 @@ expect(result[0].entry.severity).to.equal(allergySeverities[1]); | ||
function(cb) {bbr.getSection('allergies', 'pat1', cb);}, | ||
function(cb) {bbr.getPartialSection('allergies', 'pat1', cb);}, | ||
function(cb) {bbr.getMatches('allergies', 'pat1', {}, cb);}, | ||
function(cb) {bbr.getMatch('allergies', 'pat1', matchIds[0], cb);} | ||
@@ -452,3 +434,3 @@ ], | ||
function(cb) {bbr.getSection('allergies', 'pat1', cb);}, | ||
function(cb) {bbr.getPartialSection('allergies', 'pat1', cb);}, | ||
function(cb) {bbr.getMatches('allergies', 'pat1', {}, cb);}, | ||
function(cb) {bbr.getMatch('allergies', 'pat1', matchIds[0], cb);} | ||
@@ -482,3 +464,3 @@ ], | ||
function(cb) {bbr.getSection('allergies', 'pat1', cb);}, | ||
function(cb) {bbr.getPartialSection('allergies', 'pat1', cb);}, | ||
function(cb) {bbr.getMatches('allergies', 'pat1', {}, cb);}, | ||
function(cb) {bbr.getMatch('allergies', 'pat1', matchIds[1], cb);} | ||
@@ -485,0 +467,0 @@ ], |
@@ -124,7 +124,7 @@ "use strict"; | ||
async.parallel([ | ||
function(callback) {refmodel.savePartialSection(context, 'testallergies', 'pat0', '0.1', '0.0', matchInfo0, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testallergies', 'pat2', '2.1', '2.0', matchInfo1, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat0', '0.1', '0.0', matchInfo2, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat1', '1.1', '1.0', matchInfo3, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat1', '1.2', '1.0', matchInfo4, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testallergies', 'pat0', '0.1', '0.0', matchInfo0, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testallergies', 'pat2', '2.1', '2.0', matchInfo1, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat0', '0.1', '0.0', matchInfo2, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat1', '1.1', '1.0', matchInfo3, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat1', '1.2', '1.0', matchInfo4, callback);}, | ||
], | ||
@@ -131,0 +131,0 @@ function(err) {done(err);} |
@@ -280,6 +280,6 @@ "use strict"; | ||
async.parallel([ | ||
function(callback) {refmodel.savePartialSection(context, 'testallergies', 'pat0', '0.1', '0.0', matchInfo0, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat0', '0.1', '0.0', matchInfo1, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat1', '1.1', '1.0', matchInfo2, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat1', '1.2', '1.0', matchInfo3, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testallergies', 'pat0', '0.1', '0.0', matchInfo0, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat0', '0.1', '0.0', matchInfo1, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat1', '1.1', '1.0', matchInfo2, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat1', '1.2', '1.0', matchInfo3, callback);}, | ||
], | ||
@@ -286,0 +286,0 @@ function(err) {done(err);} |
@@ -45,7 +45,7 @@ "use strict"; | ||
async.parallel([ | ||
function(callback) {refmodel.savePartialSection(context, 'testallergies', 'pat0', '0.1', '0.0', matchInfo0, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testallergies', 'pat2', '2.1', '2.0', matchInfo1, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat0', '0.1', '0.0', matchInfo2, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat1', '1.1', '1.0', matchInfo3, callback);}, | ||
function(callback) {refmodel.savePartialSection(context, 'testprocedures', 'pat1', '1.2', '1.0', matchInfo4, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testallergies', 'pat0', '0.1', '0.0', matchInfo0, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testallergies', 'pat2', '2.1', '2.0', matchInfo1, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat0', '0.1', '0.0', matchInfo2, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat1', '1.1', '1.0', matchInfo3, callback);}, | ||
function(callback) {refmodel.saveMatches(context, 'testprocedures', 'pat1', '1.2', '1.0', matchInfo4, callback);}, | ||
], | ||
@@ -52,0 +52,0 @@ function(err) {done(err);} |
335786
3783
1070