From 85e89c765a25bb72e39ca22f1d6d09c9937dd4d0 Mon Sep 17 00:00:00 2001 From: Anitha Palanisamy Date: Wed, 31 Aug 2022 16:05:23 -0400 Subject: [PATCH 1/3] Add missing fields to patient resource --- .../handlebars-helpers.js | 33 +++++++++++++++++++ src/templates/cda/DataType/Address.hbs | 3 ++ src/templates/cda/DataType/ContactPoint.hbs | 10 ++++-- src/templates/cda/Extensions/Birthsex.hbs | 13 ++++++++ src/templates/cda/Header.hbs | 5 ++- src/templates/cda/Resources/Patient.hbs | 10 +++--- 6 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 src/templates/cda/Extensions/Birthsex.hbs diff --git a/src/lib/handlebars-converter/handlebars-helpers.js b/src/lib/handlebars-converter/handlebars-helpers.js index 2a9f96ee9..54055e58e 100644 --- a/src/lib/handlebars-converter/handlebars-helpers.js +++ b/src/lib/handlebars-converter/handlebars-helpers.js @@ -571,6 +571,39 @@ 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)) { + console.log("Obs object "+ JSON.stringify(observationObj.value.code)); + console.log("Template Id "+ JSON.stringify(observationObj.templateId)); + birthSexCode = observationObj.value.code; + break; + } + } + } + } + } + return birthSexCode; + } + catch (err) { + throw `helper "getBirthSexInfoByTemplateId" : ${err}`; + } + } + }, + { name: 'getFieldRepeats', description: 'Returns repeat list for a field: getFieldRepeats fieldData', diff --git a/src/templates/cda/DataType/Address.hbs b/src/templates/cda/DataType/Address.hbs index d3130d9eb..dfdb450d5 100644 --- a/src/templates/cda/DataType/Address.hbs +++ b/src/templates/cda/DataType/Address.hbs @@ -9,4 +9,7 @@ "state": "{{addr.state._}}", "country": "{{addr.country._}}", "postalCode": "{{addr.postalCode._}}", + {{#if period}} + "period": "{{addHyphensDate period}}", + {{/if}} }, diff --git a/src/templates/cda/DataType/ContactPoint.hbs b/src/templates/cda/DataType/ContactPoint.hbs index 72c391f02..47fb12737 100644 --- a/src/templates/cda/DataType/ContactPoint.hbs +++ b/src/templates/cda/DataType/ContactPoint.hbs @@ -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}} }, diff --git a/src/templates/cda/Extensions/Birthsex.hbs b/src/templates/cda/Extensions/Birthsex.hbs new file mode 100644 index 000000000..c293048b9 --- /dev/null +++ b/src/templates/cda/Extensions/Birthsex.hbs @@ -0,0 +1,13 @@ + + { + "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex", + "valueCode": "M", + "Birthsex" : "birthsex", + "chirp": "chirp", + "result": "{{ getBirthSexInfoByTemplateId msg '2.16.840.1.113883.10.20.22.2.17' '2.16.840.1.113883.10.20.22.4.200' }}" +} + + + + + diff --git a/src/templates/cda/Header.hbs b/src/templates/cda/Header.hbs index 236b89dc0..0615643be 100644 --- a/src/templates/cda/Header.hbs +++ b/src/templates/cda/Header.hbs @@ -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}} \ No newline at end of file +{{/with}} \ No newline at end of file diff --git a/src/templates/cda/Resources/Patient.hbs b/src/templates/cda/Resources/Patient.hbs index 1e3ea6612..d26599627 100644 --- a/src/templates/cda/Resources/Patient.hbs +++ b/src/templates/cda/Resources/Patient.hbs @@ -14,6 +14,7 @@ {{>DataType/Identifier.hbs id=this}}, {{/each}} ], + "active": true, "name": [ {{#each (toArray patientRole.patient.name)}} @@ -25,12 +26,13 @@ "extension" : [ {{>Extensions/Race.hbs patient=patientRole.patient}}, {{>Extensions/Ethnicity.hbs patient=patientRole.patient}}, + {{>Extensions/Birthsex.hbs patient=patientRole.patient 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": [ @@ -55,7 +57,7 @@ }, "preferred":{{this.preferenceInd.value}}, }, - {{/each}} + {{/each}} ], }, "request":{ From 35fa51eded75deeb81444c878e4da51dc7139372 Mon Sep 17 00:00:00 2001 From: Anitha Palanisamy Date: Wed, 31 Aug 2022 16:54:04 -0400 Subject: [PATCH 2/3] Remove console.log --- src/lib/handlebars-converter/handlebars-helpers.js | 2 -- src/templates/cda/Extensions/Birthsex.hbs | 5 +---- src/templates/cda/Resources/Patient.hbs | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/lib/handlebars-converter/handlebars-helpers.js b/src/lib/handlebars-converter/handlebars-helpers.js index 54055e58e..109b8758e 100644 --- a/src/lib/handlebars-converter/handlebars-helpers.js +++ b/src/lib/handlebars-converter/handlebars-helpers.js @@ -587,8 +587,6 @@ module.exports.external = [ if(entryObj){ let observationObj = entryObj.observation; if (observationObj.templateId && JSON.stringify(observationObj.templateId).includes(childTemplateId)) { - console.log("Obs object "+ JSON.stringify(observationObj.value.code)); - console.log("Template Id "+ JSON.stringify(observationObj.templateId)); birthSexCode = observationObj.value.code; break; } diff --git a/src/templates/cda/Extensions/Birthsex.hbs b/src/templates/cda/Extensions/Birthsex.hbs index c293048b9..ce5fc892b 100644 --- a/src/templates/cda/Extensions/Birthsex.hbs +++ b/src/templates/cda/Extensions/Birthsex.hbs @@ -1,10 +1,7 @@ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex", - "valueCode": "M", - "Birthsex" : "birthsex", - "chirp": "chirp", - "result": "{{ getBirthSexInfoByTemplateId msg '2.16.840.1.113883.10.20.22.2.17' '2.16.840.1.113883.10.20.22.4.200' }}" + "valueCode": "{{ getBirthSexInfoByTemplateId msg '2.16.840.1.113883.10.20.22.2.17' '2.16.840.1.113883.10.20.22.4.200' }} } diff --git a/src/templates/cda/Resources/Patient.hbs b/src/templates/cda/Resources/Patient.hbs index d26599627..921163c22 100644 --- a/src/templates/cda/Resources/Patient.hbs +++ b/src/templates/cda/Resources/Patient.hbs @@ -26,7 +26,7 @@ "extension" : [ {{>Extensions/Race.hbs patient=patientRole.patient}}, {{>Extensions/Ethnicity.hbs patient=patientRole.patient}}, - {{>Extensions/Birthsex.hbs patient=patientRole.patient msg=msg}}, + {{>Extensions/Birthsex.hbs msg=msg}}, ], "address": [ From ecc3d626a03794758f1372cfbf9bec61ecb4d674 Mon Sep 17 00:00:00 2001 From: Anitha Palanisamy Date: Thu, 1 Sep 2022 17:07:06 -0400 Subject: [PATCH 3/3] fix error --- src/templates/cda/Extensions/Birthsex.hbs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/cda/Extensions/Birthsex.hbs b/src/templates/cda/Extensions/Birthsex.hbs index ce5fc892b..403f167dc 100644 --- a/src/templates/cda/Extensions/Birthsex.hbs +++ b/src/templates/cda/Extensions/Birthsex.hbs @@ -1,8 +1,8 @@ - { "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' }} -} + "valueCode": "{{ getBirthSexInfoByTemplateId msg '2.16.840.1.113883.10.20.22.2.17' '2.16.840.1.113883.10.20.22.4.200' }}" + } +