Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHIRP 930 fixes to race and ethnicity inclusion #41

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading