Skip to content

Commit

Permalink
refactor to remove use of now-superfluous sibling field
Browse files Browse the repository at this point in the history
  • Loading branch information
sirctseb committed Feb 13, 2017
1 parent c18cc34 commit e8860ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lib/parser/ccda/sections/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ var exportResultsSection = function (version) {
//["codedValue", "0..1", "h:value[@xsi:type='CD']", shared.ConceptDescriptor],
//["freeTextValue", "0..1", "h:text", shared.TextWithReference],
["interpretations", "0..*", "h:interpretationCode[@codeSystem='2.16.840.1.113883.5.83']", shared.ConceptDescriptor],
["valueNullFlavor", "0..1", "h:value/@nullFlavor"]
]);
ResultObservation.cleanupStep(cleanup.replaceAbsentFieldWithNullFlavor("text", "valueNullFlavor"));
ResultObservation.cleanupStep(cleanup.replaceStringFieldWithNullFlavorName("text"));
//ResultObservation.cleanupStep(cleanup.extractAllFields(['resultName']));

// TODO: Accomodating both PQ and CD values needed
Expand Down
4 changes: 1 addition & 3 deletions lib/parser/ccda/sections/social_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ var exportSocialHistorySection = function (version) {
["value", "0..1", "h:value[@xsi:type='ST']/text() | h:value[@xsi:type='CD']/@displayName"],
//["observation_value2", "0..1", "h:value[@xsi:type='CD']/@displayName"]
["referencedValue", "0..1", "h:value[@xsi:type='ED']", shared.TextWithReference],
// custom read of nullflavor to replace value field if present
["valueNullFlavor", "0..1", "h:value/@nullFlavor"],
["nullCodeReplacementText", "0..1", "h:code/h:originalText", shared.TextWithReference]
])
.cleanupStep(cleanup.replaceWithObject("code2", {
Expand All @@ -47,7 +45,7 @@ var exportSocialHistorySection = function (version) {
}
})
// custom step to put null flavor name on value field if present
.cleanupStep(cleanup.replaceAbsentFieldWithNullFlavor("value", "valueNullFlavor"));
.cleanupStep(cleanup.replaceStringFieldWithNullFlavorName("value"));

// when other flavors of social history is implemented (pregnancy, social observation, tobacco use)
// this should probably be structured similar to procedures with types. if another structure
Expand Down
9 changes: 3 additions & 6 deletions lib/parser/common/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,14 @@ cleanup.nullFlavorDisplayNames = {

// if a field is absent or is an object that looks like a nullFlavor code,
// replace it with the nullFlavor display name from a sibling nullFlavorField
cleanup.replaceAbsentFieldWithNullFlavor = function (field, nullFlavorField) {
cleanup.replaceStringFieldWithNullFlavorName = function (field) {
return function () {
if (!this.js) {
return null;
}

if (_.has(this, ["js", nullFlavorField])) {
if (_.get(this, ["js", field, "code_system_name"]) === "Null Flavor") {
this.js[field] = cleanup.nullFlavorDisplayNames[this.js[nullFlavorField]];
}
delete this.js[nullFlavorField];
if (_.get(this, ["js", field, "code_system_name"]) === "Null Flavor") {
this.js[field] = cleanup.nullFlavorDisplayNames[this.js[field].code];
}
};
};
Expand Down

0 comments on commit e8860ac

Please sign in to comment.