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

Ph 455/patient fhir resource #11

Open
wants to merge 4 commits into
base: handlebars
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions src/lib/handlebars-converter/handlebars-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,37 @@ module.exports.external = [
}
}
},

{
name: 'getBirthSexInfoByTemplateId',
description: "Returns BirthSex code",
func: function getBirthSexInfoByTemplateId(msg, parentTemplateId, childTemplateId) {
try {
var birthSexCode;
for (var i = 0; i < msg.ClinicalDocument.component.structuredBody.component.length; i++) {
let sectionObj = msg.ClinicalDocument.component.structuredBody.component[i].section;
if (sectionObj.templateId && JSON.stringify(sectionObj.templateId).includes(parentTemplateId)) {
let entryObjs = sectionObj.entry;
for(var j = 0; j < entryObjs.length; j++){
let entryObj = entryObjs[j];
if(entryObj){
let observationObj = entryObj.observation;
if (observationObj.templateId && JSON.stringify(observationObj.templateId).includes(childTemplateId)) {
birthSexCode = observationObj.value.code;
break;
}
}
}
}
}
return birthSexCode;
}
catch (err) {
throw `helper "getBirthSexInfoByTemplateId" : ${err}`;
}
}
},

{
name: 'getFieldRepeats',
description: 'Returns repeat list for a field: getFieldRepeats fieldData',
Expand Down
3 changes: 3 additions & 0 deletions src/templates/cda/DataType/Address.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
"state": "{{addr.state._}}",
"country": "{{addr.country._}}",
"postalCode": "{{addr.postalCode._}}",
{{#if period}}
"period": "{{addHyphensDate period}}",
{{/if}}
},
10 changes: 7 additions & 3 deletions src/templates/cda/DataType/ContactPoint.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
{{#if (contains contactPoint.value 'tel:')}}
"system":"phone",
"value": "{{replace contactPoint.value 'tel:\s*' ''}}",
"use": {{>ValueSet/TelecomUse.hbs code=contactPoint.use}},
"use": {{>ValueSet/TelecomUse.hbs code=contactPoint.use}},
{{else if (contains contactPoint.value 'mailto:')}}
"system":"email",
"value": "{{replace contactPoint.value 'mailto:\s*' ''}}",
"use": {{>ValueSet/TelecomUse.hbs code=contactPoint.use}},
{{/if}}
"use": {{>ValueSet/TelecomUse.hbs code=contactPoint.use}},
{{else}}
"system":"phone",
"value": "{{contactPoint.value}}",
"use": {{>ValueSet/TelecomUse.hbs code=contactPoint.use}},
{{/if}}
{{/if}}
},
10 changes: 10 additions & 0 deletions src/templates/cda/Extensions/Birthsex.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex",
"valueCode": "{{ getBirthSexInfoByTemplateId msg '2.16.840.1.113883.10.20.22.2.17' '2.16.840.1.113883.10.20.22.4.200' }}"
}






5 changes: 2 additions & 3 deletions src/templates/cda/Header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@

{{#with msg.ClinicalDocument.recordTarget.patientRole}}
{{#with (evaluate 'Utils/GeneratePatientId.hbs' obj=this) as |patientId|}}
{{>Resources/Patient.hbs patientRole=.. ID=patientId.Id}},
{{>Resources/Patient.hbs patientRole=.. ID=patientId.Id msg=../../msg}},
{{#if ../patient.guardian}}
{{>Resources/RelatedPerson.hbs relatedPerson=../patient.guardian ID=(generateUUID (toJsonString ../patient.guardian))}},
{{>References/RelatedPerson/patient.hbs ID=(generateUUID (toJsonString ../patient.guardian)) REF=(concat 'Patient/' patientId.Id)}},
{{/if}}
{{/with}}

{{/with}}
{{/with}}
10 changes: 6 additions & 4 deletions src/templates/cda/Resources/Patient.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{{>DataType/Identifier.hbs id=this}},
{{/each}}
],
"active": true,
"name":
[
{{#each (toArray patientRole.patient.name)}}
Expand All @@ -25,12 +26,13 @@
"extension" : [
{{>Extensions/Race.hbs patient=patientRole.patient}},
{{>Extensions/Ethnicity.hbs patient=patientRole.patient}},
{{>Extensions/Birthsex.hbs msg=msg}},
],
"address":
[
{{#each (toArray patientRole.addr)}}
{{>DataType/Address.hbs addr=this}},
{{/each}}
{{#each (toArray patientRole)}}
{{>DataType/Address.hbs addr=this.addr period=this.patient.birthTime.value }},
{{/each}}
],
"telecom":
[
Expand All @@ -55,7 +57,7 @@
},
"preferred":{{this.preferenceInd.value}},
},
{{/each}}
{{/each}}
],
},
"request":{
Expand Down