Skip to content

Commit

Permalink
Merge pull request #274 from microsoft/dotliquid
Browse files Browse the repository at this point in the history
Improve CCDA Template and small update for converter engine
  • Loading branch information
qiwjin authored Jul 16, 2021
2 parents a2460a7 + f968bf7 commit 0a7363e
Show file tree
Hide file tree
Showing 105 changed files with 1,141 additions and 1,357 deletions.
2 changes: 1 addition & 1 deletion data/SampleData/Ccda/170.314B2_Amb_CCD.ccda
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@
<originalText>
<reference value="#ID0EBALACA"/>
</originalText>
<translation xsi:type="CD" code="2670" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" displayName="Codeine"/>
<translation xsi:type="CD" code="261000" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" displayName="Codeine phosphate"/>
</code>
<name>Codeine</name>
</playingEntity>
Expand Down
4 changes: 2 additions & 2 deletions data/SampleData/Ccda/C-CDA_R2-1_CCD.xml.ccda
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@
<participant typeCode="CSM">
<participantRole classCode="MANU">
<playingEntity classCode="MMAT">
<code code="70618" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
<code code="7980" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
</playingEntity>
</participantRole>
</participant>
Expand Down Expand Up @@ -2626,7 +2626,7 @@
<statusCode code="completed"/>
<effectiveTime value="20120512"/>
<methodCode nullFlavor="UNK"/>
<targetSiteCode code="appropriate_code" displayName="colon" codeSystem="2.16.840.1.113883.3.88.12.3221.8.9" codeSystemName="Body Site Value Set"/>
<targetSiteCode code="485005" displayName="colon" codeSystem="2.16.840.1.113883.3.88.12.3221.8.9" codeSystemName="Body Site Value Set"/>
<specimen typeCode="SPC">
<specimenRole classCode="SPEC">
<id root="c2ee9ee9-ae31-4628-a919-fec1cbb58683"/>
Expand Down
2 changes: 1 addition & 1 deletion data/SampleData/Ccda/Consultation_Note.ccda
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ ALLERGIES AND INTOLERANCES SECTION (ENTRIES REQUIRED) V2
<participant typeCode="CSM">
<participantRole classCode="MANU">
<playingEntity classCode="MMAT">
<code code="70618" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
<code code="7980" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
</playingEntity>
</participantRole>
</participant>
Expand Down
2 changes: 1 addition & 1 deletion data/SampleData/Ccda/Discharge_Summary.ccda
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
<section>
<templateId root="2.16.840.1.113883.10.20.22.2.24" extension="2014-06-09"/>
<id extension="9937012" root="2.16.840.1.113883.19"/>
<code code="C-CDAV2-DDN" displayName="Hospital Discharge Diagnosis" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<code code="11535-2" displayName="Hospital Discharge Diagnosis" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>DISCHARGE DIAGNOSIS</title>
<text>
<content ID="DschDx">Appendicitis</content>
Expand Down
2 changes: 1 addition & 1 deletion data/SampleData/Ccda/Progress_Note.ccda
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ Allergies, Adverse Reactions, Alerts
<participant typeCode="CSM">
<participantRole classCode="MANU">
<playingEntity classCode="MMAT">
<code code="70618" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
<code code="7980" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
</playingEntity>
</participantRole>
</participant>
Expand Down
4 changes: 2 additions & 2 deletions data/SampleData/Ccda/Referral_Note.ccda
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<!-- DocumentID: unique ID for the document -->
<id root="6f1bd58b-c58f-40b7-b314-caf1294ed98b"/>
<!-- Referral Note -->
<code codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" code="57113-1" displayName="Referral Note"/>
<code codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" code="57133-1" displayName="Referral Note"/>
<!-- Use the name of the code as the title -->
<title>Referral Note</title>
<effectiveTime value="201309210500-0800"/>
Expand Down Expand Up @@ -560,7 +560,7 @@ ALLERGIES AND INTOLERANCES SECTION V2
<participant typeCode="CSM">
<participantRole classCode="MANU">
<playingEntity classCode="MMAT">
<code code="70618" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
<code code="7980" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm"/>
</playingEntity>
</participantRole>
</participant>
Expand Down
4 changes: 2 additions & 2 deletions data/SampleData/Ccda/Transfer_Summary.ccda
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ ALLERGIES AND INTOLERANCES SECTION (ENTRIES REQUIRED) V2
<participant typeCode="CSM">
<participantRole classCode="MANU">
<playingEntity classCode="MMAT">
<code code="70618" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88"
<code code="7980" displayName="Penicillin" codeSystem="2.16.840.1.113883.6.88"
codeSystemName="RxNorm" />
</playingEntity>
</participantRole>
Expand Down Expand Up @@ -1321,7 +1321,7 @@ HOSPITAL DISCHARGE DIAGNOSIS SECTION V2
<section>
<!-- Discharge Summary Hospital Discharge Diagnosis Template Id -->
<templateId root="2.16.840.1.113883.10.20.22.2.24" extension="2014-06-09" />
<code code="C-CDAV2-DDN" displayName="Discharge diagnosis narritive" codeSystem="2.16.840.1.113883.6.1"
<code code="11535-2" displayName="Discharge diagnosis narritive" codeSystem="2.16.840.1.113883.6.1"
codeSystemName="LOINC" />
<title>Hospital Discharge Diagnosis</title>
<text>.Kidney Malrotation. Discharged August 1, 2013</text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
{% include 'Resource/MedicationAdministration' medicationAdministration: relationship.substanceAdministration, ID: substanceAdministrationId -%}
{% assign manufacturedMaterialId = relationship.substanceAdministration.consumable.manufacturedProduct.manufacturedMaterial | to_json_string | generate_uuid -%}
{% include 'Resource/Medication' medication: relationship.substanceAdministration.consumable.manufacturedProduct.manufacturedMaterial, ID: manufacturedMaterialId -%}
{% assign organizationId = relationship.substanceAdministration.performer.assignedEntity.representedOrganization | to_json_string | generate_uuid -%}
{% include 'Resource/Organization' organization: relationship.substanceAdministration.performer.assignedEntity.representedOrganization, ID: organizationId -%}
{% if relationship.substanceAdministration.performer.assignedEntity.representedOrganization -%}
{% assign organizationId = relationship.substanceAdministration.performer.assignedEntity.representedOrganization | to_json_string | generate_uuid -%}
{% include 'Resource/Organization' organization: relationship.substanceAdministration.performer.assignedEntity.representedOrganization, ID: organizationId -%}
{% endif -%}
{% include 'Reference/MedicationAdministration/Subject' ID: substanceAdministrationId, REF: fullPatientId -%}
{% assign fullManufacturedMaterialId = manufacturedMaterialId | prepend: 'Medication/' -%}
{% include 'Reference/MedicationAdministration/MedicationReference' ID: substanceAdministrationId, REF: fullManufacturedMaterialId -%}
Expand Down
15 changes: 7 additions & 8 deletions data/Templates/Ccda/Header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
{% include 'Resource/Encounter' encounter: msg.ClinicalDocument.componentOf.encompassingEncounter ID: encounterId -%}
{% assign fullEncounterId = encounterId | prepend: 'Encounter/' -%}
{% include 'Reference/Composition/Encounter' ID: compositionId, REF: fullEncounterId -%}
{% endif -%}

{% if msg.ClinicalDocument.componentOf.encompassingEncounter.location -%}
{% assign locationId = msg.ClinicalDocument.componentOf.encompassingEncounter.location | to_json_string | generate_uuid -%}
{% include 'Resource/Location' location: msg.ClinicalDocument.componentOf.encompassingEncounter.location ID: locationId -%}
{% assign fullLocationId = locationId | prepend: 'Location/' -%}
{% include 'Reference/Encounter/Location_Location' ID: encounterId, REF: fullLocationId -%}
{% if msg.ClinicalDocument.componentOf.encompassingEncounter.location -%}
{% assign locationId = msg.ClinicalDocument.componentOf.encompassingEncounter.location | to_json_string | generate_uuid -%}
{% include 'Resource/Location' location: msg.ClinicalDocument.componentOf.encompassingEncounter.location ID: locationId -%}
{% assign fullLocationId = locationId | prepend: 'Location/' -%}
{% include 'Reference/Encounter/Location_Location' ID: encounterId, REF: fullLocationId -%}
{% endif -%}
{% endif -%}

{% if msg.ClinicalDocument.custodian.assignedCustodian.representedCustodianOrganization.name._ -%}
Expand Down Expand Up @@ -46,7 +45,7 @@
{% endif -%}
{% endif -%}

{% if author.assignedAuthor -%}
{% if author.assignedAuthor.assignedPerson -%}
{% evaluate practitionerId using 'Utils/GenerateId' obj: author.assignedAuthor -%}
{% include 'Resource/Practitioner' practitioner: author.assignedAuthor ID: practitionerId -%}
{% assign fullPractitionerId = practitionerId | prepend: 'Practitioner/' -%}
Expand Down
18 changes: 9 additions & 9 deletions data/Templates/Ccda/Resource/_AllergyIntolerance.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[
{
"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
"code":{% include 'ValueSet/AllergyStatus' code: allergyStatus.code -%},
"code":"{{ allergyStatus.code | get_property: 'ValueSet/AllergyStatus' }}",
}
]
},
Expand All @@ -31,7 +31,6 @@
"substance":{ {% include 'DataType/CodeableConcept' CodeableConcept: allergyEntry.participant.participantRole.playingEntity.code -%} },
{% endif -%}


{% if r.observation.templateId | to_json_string | contains: '"2.16.840.1.113883.10.20.22.4.9"' -%}
"manifestation":
[
Expand All @@ -43,14 +42,15 @@
],
"onset": "{{ r.observation.effectiveTime.low.value | format_as_date_time }}",
{% endif -%}

{% if r.observation.templateId | to_json_string | contains: '"2.16.840.1.113883.10.20.22.4.8"' -%}
{% if r.observation.value.translation -%}
"severity":{% include 'ValueSet/AllergySeverity' code: r.observation.value.translation.displayName -%},
{% else -%}
"severity":{% include 'ValueSet/AllergySeverity' code: r.observation.value.displayName -%},
{% for templateId in r.observation.templateId -%}
{% if templateId.root == "2.16.840.1.113883.10.20.22.4.8" -%}
{% if r.observation.value.translation -%}
"severity":"{{ r.observation.value.translation.displayName | downcase | get_property: 'ValueSet/AllergySeverity' }}",
{% else -%}
"severity":"{{ r.observation.value.displayName | downcase | get_property: 'ValueSet/AllergySeverity' }}",
{% endif -%}
{% endif -%}
{% endif -%}
{% endfor -%}
},
{% endfor -%}

Expand Down
38 changes: 20 additions & 18 deletions data/Templates/Ccda/Resource/_Composition.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,37 @@
"period":
{
"start":"{{ composition.documentationOf.serviceEvent.effectiveTime.low.value | format_as_date_time }}",
"end":"{{ composition.documentationOf.serviceEvent.effectiveTime.high.value | format_as_date_time }}",
},
},
],
"section":
[
{% assign components = composition.component.structuredBody.component | to_array -%}
{% for component in components -%}
{
{% if component.section.title._ -%}
"title":"{{ component.section.title._ }}",
{% endif -%}
{% if component.section.title._ == null -%}
"title":"{{ component.section.code.displayName }}",
{% endif -%}
"text":
{
"status":"generated",
{
{% if component.section -%}
{% if component.section.title._ -%}
"div":"<div xmlns=\"http://www.w3.org/1999/xhtml\">{{ component.section.title._ }}</div>",
"title":"{{ component.section.title._ }}",
{% endif -%}
{% if component.section.title._ == null -%}
"div":"<div xmlns=\"http://www.w3.org/1999/xhtml\">{{ component.section.code.displayName }}</div>",
"title":"{{ component.section.code.displayName }}",
{% endif -%}
},
"code":
{
{% include 'DataType/CodeableConcept' CodeableConcept: component.section.code -%}
},
"mode":"snapshot",
"text":
{
"status":"generated",
{% if component.section.title._ -%}
"div":"<div xmlns=\"http://www.w3.org/1999/xhtml\">{{ component.section.title._ | escape }}</div>",
{% else -%}
"div":"<div xmlns=\"http://www.w3.org/1999/xhtml\">{{ component.section.code.displayName | escape }}</div>",
{% endif -%}
},
"code":
{
{% include 'DataType/CodeableConcept' CodeableConcept: component.section.code -%}
},
"mode":"snapshot",
{% endif -%}
},
{% endfor -%}
],
Expand Down
4 changes: 0 additions & 4 deletions data/Templates/Ccda/Resource/_Encounter.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
{% include 'DataType/Coding' Coding: encounter.code -%}
{% endif -%}
},
"type":
[
{ {% include 'DataType/CodeableConcept' CodeableConcept: encounter.code -%} },
],
"identifier":
[
{% assign ids = encounter.id | to_array -%}
Expand Down
8 changes: 6 additions & 2 deletions data/Templates/Ccda/Resource/_Immunization.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@
{% assign manufacturedProducts = consumable.manufacturedProduct | to_array -%}
{% for manufacturedProduct in manufacturedProducts -%}
{% if manufacturedProduct.templateId | to_json_string | contains '"2.16.840.1.113883.10.20.22.4.54"' -%}
"vaccineCode":{ {% include 'DataType/CodeableConcept' CodeableConcept: manufacturedProduct.manufacturedMaterial.code -%} },
{% if manufacturedProduct.manufacturedMaterial.code.translation -%}
"vaccineCode":{ {% include 'DataType/CodeableConcept' CodeableConcept: manufacturedProduct.manufacturedMaterial.code.translation -%} },
{% else -%}
"vaccineCode":{ {% include 'DataType/CodeableConcept' CodeableConcept: manufacturedProduct.manufacturedMaterial.code -%} },
{% endif -%}
"lotNumber":"{{ manufacturedProduct.manufacturedMaterial.IotNumberText._ }}",
{% endif -%}
{% endfor -%}
{% endfor -%}

"status":"{{immunization.statusCode.code}}",
"status":"{{immunization.statusCode.code | get_property: 'ValueSet/ImmunizationStatus' }}",
"route":{ {% include 'DataType/CodeableConcept' CodeableConcept: immunization.routeCode -%}},
"site":{ {% include 'DataType/CodeableConcept' CodeableConcept: immunization.approachSiteCode -%} },
},
Expand Down
7 changes: 4 additions & 3 deletions data/Templates/Ccda/Resource/_MedicationAdministration.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
{ {% include 'DataType/Identifier' Identifier: id -%} },
{% endfor -%}
],
"status":"{{ medicationAdministration.statusCode.code }}",
"status":"{{ medicationAdministration.statusCode.code | get_property: 'ValueSet/MedicationAdministrationStatus' }}",
"effectivePeriod":
{
"start":"{{ medicationAdministration.effectiveTime.low.value | format_as_date_time }}",
"end":"{{ medicationAdministration.effectiveTime.high.value | format_as_date_time }}",
{% assign effectiveTimes = medicationAdministration.effectiveTime | to_array -%}
"start":"{{ effectiveTimes.first.low.value | format_as_date_time }}",
"end":"{{ effectiveTimes.first.high.value | format_as_date_time }}",
},
"dosage":
{
Expand Down
6 changes: 3 additions & 3 deletions data/Templates/Ccda/Resource/_Patient.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{% endfor -%}
],
"birthDate":"{{ patientRole.patient.birthTime.value | add_hyphens_date }}",
"gender":"{{ patientRole.patient.administrativeGenderCode.displayName | downcase }}",
"gender":"{{ patientRole.patient.administrativeGenderCode.code | get_property: 'ValueSet/Gender' }}",
"extension":
[
{ {% include 'Extension/Race' Race: patientRole.patient -%} },
Expand Down Expand Up @@ -56,8 +56,8 @@
[
{
"system":"urn:ietf:bcp:47",
"code":"{{ languageCommunication.languageCode.code }}",
"display":"{{ languageCommunication.languageCode.code | downcase | get_property: 'ValueSet/Language' }}",
"code":"{{ languageCommunication.languageCode.code | downcase | get_property: 'ValueSet/Language', , 'code' }}",
"display":"{{ languageCommunication.languageCode.code | downcase | get_property: 'ValueSet/Language', , 'display' }}",
},
],
},
Expand Down
15 changes: 9 additions & 6 deletions data/Templates/Ccda/Resource/_Procedure.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
"status":"{{ procedureEntry.statusCode.code }}",
"code":
{
{% if procedureEntry.code.translation -%}
{% include 'DataType/CodeableConcept' CodeableConcept: procedureEntry.code.translation -%}
{% endif -%}
{% if procedureEntry.code.translation == null -%}
{% include 'DataType/CodeableConcept' CodeableConcept: procedureEntry.code -%}
{% endif -%}
},
"performedDateTime":"{{ procedureEntry.effectiveTime.value | format_as_date_time }}",
{% if procedureEntry.effectiveTime.value -%}
"performedDateTime":"{{ procedureEntry.effectiveTime.value | format_as_date_time }}",
{% else -%}
"performedPeriod":
{
"start":"{{ procedureEntry.effectiveTime.low.value | format_as_date_time }}",
"end":"{{ procedureEntry.effectiveTime.high.value | format_as_date_time }}",
},
{% endif -%}
"bodySite":
[
{ {% include 'DataType/CodeableConcept' CodeableConcept: procedureEntry.targetSiteCode -%} },
Expand Down
4 changes: 2 additions & 2 deletions data/Templates/Ccda/Resource/_ServiceRequest.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
{% include 'DataType/CodeableConcept' CodeableConcept: serviceEntry.code -%}
{% endif -%}
},
"priority":"{{ serviceEntry.priorityCode.displayName }}",
"occuranceDateTime":"{{serviceEntry.effectiveTime.value | format_as_date_time }}",
"priority":"{{ serviceEntry.priorityCode.code | get_property: 'ValueSet/ServiceRequestPriority' }}",
"occurrenceDateTime":"{{serviceEntry.effectiveTime.value | format_as_date_time }}",
},
"request":{
"method":"PUT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% assign firstSections = msg | get_first_ccda_sections_by_template_id: '2.16.840.1.113883.10.20.22.4.34' -%}
{{ firstSections.2_16_840_1_113883_10_20_22_4_34.entry | to_array | batch_render: 'Entry/_HospitalAdmissionDiagnosis/entry', 'entry' }}
{{ firstSections.2_16_840_1_113883_10_20_22_4_34.entry | to_array | batch_render: 'Entry/HospitalAdmissionDiagnosis/entry', 'entry' }}
Loading

0 comments on commit 0a7363e

Please sign in to comment.