Skip to content

Commit

Permalink
wip: code to optionally include birthsex, race, and ethnicity only wh…
Browse files Browse the repository at this point in the history
…en known
  • Loading branch information
vburzynski-onemedical committed Aug 20, 2024
1 parent 91eca1d commit b4a274b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
19 changes: 19 additions & 0 deletions src/lib/handlebars-converter/handlebars-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,25 @@ module.exports.external = [
}
}
},
{
name: 'isRaceUnknown',
description: 'determines if the race is unknown',
func: function isRaceUnknown(patient) {
const raceCodeNullFlavor = !!patient.raceCode?.nullFlavor;
const sdtcRaceCodeNullFlavor = !!patient["sdtc:raceCode"]?.nullFlavor;
return raceCodeNullFlavor || sdtcRaceCodeNullFlavor;
}
},
{
name: 'isEthnicityUnknown',
description: 'Determines if the Ethnicity is Unknown (has a null flavor)',
func: function isEthnicityUnknown(patient) {
const ethnicGroupCodeNulllavor = !!patient.ethnicGroupCode?.nullFlavor;
const raceCodeNullFlavor = !!patient.raceCode?.nullFlavor;
const sdtcRaceCodeNullFlavor = !!patient["sdtc:raceCode"]?.nullFlavor;
return ethnicGroupCodeNulllavor || raceCodeNullFlavor || sdtcRaceCodeNullFlavor;
}
},
{
name: 'getBirthSexInfo',
description: "Returns first instance of birthSex id e.g. getBirthSexInfo msg '2.16.840.1.113883.10.20.22.2.14'",
Expand Down
4 changes: 2 additions & 2 deletions src/templates/cda/Extensions/Birthsex.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex",
"valueCode": "{{getBirthSexInfo msg '2.16.840.1.113883.10.20.22.4.200'}}"
}
"valueCode": "{{birthsex}}"
}
7 changes: 3 additions & 4 deletions src/templates/cda/Extensions/Ethnicity.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
{{/if}}
},
{{else}}
{{#if (or (eq this.code '2135-2')
(eq this.code '2186-5'))}}
{{#if (or (eq this.code '2135-2') (eq this.code '2186-5'))}}
"url" : "ombCategory",
{{else}}
"url" : "detailed",
{{/if}}
{{/if}}
"valueCoding" : {{>DataType/Coding.hbs code=this}},
{{/if}}
},
Expand All @@ -40,6 +39,6 @@
"valueString":"{{patient.ethnicGroupCode.displayName}}",
{{/if}}
}
],
],
{{/if}}
}
14 changes: 11 additions & 3 deletions src/templates/cda/Resources/Patient.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@
"birthDate":"{{addHyphensDate patientRole.patient.birthTime.value}}",
"gender":"{{toLower patientRole.patient.administrativeGenderCode.displayName}}",
"extension" : [
{{>Extensions/Race.hbs patient=patientRole.patient}},
{{>Extensions/Ethnicity.hbs patient=patientRole.patient}},
{{>Extensions/Birthsex.hbs patient=patientRole.patient msg=msg}},
{{#unless (isRaceUnknown patientRole.patient)}}
{{>Extensions/Race.hbs patient=patientRole.patient}},
{{/unless}}
{{#unless (isEthnicityUnknown patientRole.patient)}}
{{>Extensions/Ethnicity.hbs patient=patientRole.patient}},
{{/unless}}
{{#with (getBirthSexInfo msg '2.16.840.1.113883.10.20.22.4.200') as |birthsex|}}
{{#if birthsex}}
{{>Extensions/Birthsex.hbs patient=patientRole.patient birthsex=birthsex}},
{{/if}}
{{/with}}
],
"address":
[
Expand Down

0 comments on commit b4a274b

Please sign in to comment.