Skip to content

Commit

Permalink
Merge pull request #167 from microsoft/dotliquid
Browse files Browse the repository at this point in the history
Update templates and template management CLI tool
  • Loading branch information
sowu880 authored Dec 25, 2020
2 parents c6a87f8 + acb3ec5 commit 6f106e9
Show file tree
Hide file tree
Showing 40 changed files with 2,265 additions and 704 deletions.
26 changes: 24 additions & 2 deletions data/Templates/Hl7v2/ADT_A01.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,32 @@
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|PV1|PV2|PR1|AVR' -%}
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|PV1|PV2|PR1|AVR|MSH' -%}

{% evaluate messageHeaderId using 'ID/MessageHeader' MSH: firstSegments.MSH -%}
{% if messageHeaderId -%}
{% include 'Resource/MessageHeader' MSH: firstSegments.MSH, ID: messageHeaderID -%}
{% endif -%}

{% evaluate patientId using 'ID/Patient' PID: firstSegments.PID, type: 'First' -%}
{% if patientId -%}
{% assign fullPatientId = patientId | prepend: 'Patient/' -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, NK1: firstSegments.NK1, ID: patientId -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, ID: patientId -%}
{% endif -%}

{% evaluate provenanceId using 'ID/Provenance' MSH: firstSegments.MSH, baseID: patientId -%}
{% if provenanceId -%}
{% include 'Resource/Provenance' MSH: firstSegments.MSH, ORC: firstSegments.ORC, ID: provenanceId -%}
{% endif -%}

{% evaluate accountId using 'ID/Account' CX: firstSegments.PID.3 -%}
{% if accountId -%}
{% include 'Resource/Account' PID: firstSegments.PID, ID: accountId -%}
{% endif -%}

{% evaluate organizationId using 'ID/Organization' HD: firstSegments.MSH.6 -%}
{% if organizationId -%}
{% include 'Resource/Organization' MSH: firstSegments.MSH, ID: organizationId -%}
{% endif -%}

{% evaluate encounterId using 'ID/Encounter' PV1: firstSegments.PV1, baseId: patientId -%}
Expand Down Expand Up @@ -45,6 +65,8 @@

{% assign nk1SegmentLists = hl7v2Data | get_segment_lists: 'NK1' -%}
{% for nk1Segment in nk1SegmentLists.NK1 -%}
{% include 'Resource/Patient' NK1: nk1Segment, ID: patientId -%}

{% evaluate relatedPersonId using 'ID/RelatedPerson' NK1: nk1Segment, baseId: patientId -%}
{% if relatedPersonId -%}
{% include 'Resource/RelatedPerson' NK1: nk1Segment, ID: relatedPersonId -%}
Expand Down
2 changes: 1 addition & 1 deletion data/Templates/Hl7v2/ID/_Provenance.liquid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ ORC.Value | generate_id_input: 'Provenance', true, baseId | generate_uuid }}
{{ MSH.Value | generate_id_input: 'Provenance', true, baseId | generate_uuid }}
26 changes: 24 additions & 2 deletions data/Templates/Hl7v2/OML_O21.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,32 @@
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|PV1|PV2|ORC' -%}
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|PV1|PV2|ORC|MSH' -%}

{% evaluate messageHeaderId using 'ID/MessageHeader' MSH: firstSegments.MSH -%}
{% if messageHeaderId -%}
{% include 'Resource/MessageHeader' MSH: firstSegments.MSH, ID: messageHeaderID -%}
{% endif -%}

{% evaluate patientId using 'ID/Patient' PID: firstSegments.PID, type: 'First' -%}
{% if patientId -%}
{% assign fullPatientId = patientId | prepend: 'Patient/' -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, NK1: firstSegments.NK1, ID: patientId -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, ID: patientId -%}
{% endif -%}

{% evaluate provenanceId using 'ID/Provenance' MSH: firstSegments.MSH, baseID: patientId -%}
{% if provenanceId -%}
{% include 'Resource/Provenance' MSH: firstSegments.MSH, ORC: firstSegments.ORC, ID: provenanceId -%}
{% endif -%}

{% evaluate accountId using 'ID/Account' CX: firstSegments.PID.3 -%}
{% if accountId -%}
{% include 'Resource/Account' PID: firstSegments.PID, ID: accountId -%}
{% endif -%}

{% evaluate organizationId using 'ID/Organization' HD: firstSegments.MSH.6 -%}
{% if organizationId -%}
{% include 'Resource/Organization' MSH: firstSegments.MSH, ID: organizationId -%}
{% endif -%}

{% evaluate encounterId using 'ID/Encounter' PV1: firstSegments.PV1, baseId: patientId -%}
Expand All @@ -32,6 +52,8 @@

{% assign al1SegmentLists = hl7v2Data | get_segment_lists: 'AL1' -%}
{% for al1Segment in al1SegmentLists.AL1 -%}
{% include 'Resource/Patient' NK1: nk1Segment, ID: patientId -%}

{% evaluate allergyIntoleranceId using 'ID/AllergyIntolerance' AL1: al1Segment, baseId: patientId -%}
{% if allergyIntoleranceId -%}
{% include 'Resource/AllergyIntolerance' AL1: al1Segment, ID: allergyIntoleranceId -%}
Expand Down
26 changes: 24 additions & 2 deletions data/Templates/Hl7v2/ORU_R01.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,32 @@
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|NK1|PV1|PV2' -%}
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|NK1|PV1|PV2|MSH' -%}

{% evaluate messageHeaderId using 'ID/MessageHeader' MSH: firstSegments.MSH -%}
{% if messageHeaderId -%}
{% include 'Resource/MessageHeader' MSH: firstSegments.MSH, ID: messageHeaderID -%}
{% endif -%}

{% evaluate patientId using 'ID/Patient' PID: firstSegments.PID, type: 'First' -%}
{% if patientId -%}
{% assign fullPatientId = patientId | prepend: 'Patient/' -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, NK1: firstSegments.NK1, ID: patientId -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, ID: patientId -%}
{% endif -%}

{% evaluate provenanceId using 'ID/Provenance' MSH: firstSegments.MSH, baseID: patientId -%}
{% if provenanceId -%}
{% include 'Resource/Provenance' MSH: firstSegments.MSH, ORC: firstSegments.ORC, ID: provenanceId -%}
{% endif -%}

{% evaluate accountId using 'ID/Account' CX: firstSegments.PID.3 -%}
{% if accountId -%}
{% include 'Resource/Account' PID: firstSegments.PID, ID: accountId -%}
{% endif -%}

{% evaluate organizationId using 'ID/Organization' HD: firstSegments.MSH.6 -%}
{% if organizationId -%}
{% include 'Resource/Organization' MSH: firstSegments.MSH, ID: organizationId -%}
{% endif -%}

{% evaluate encounterId using 'ID/Encounter' PV1: firstSegments.PV1, baseId: patientId -%}
Expand All @@ -32,6 +52,8 @@

{% assign nk1SegmentLists = hl7v2Data | get_segment_lists: 'NK1' -%}
{% for nk1Segment in nk1SegmentLists.NK1 -%}
{% include 'Resource/Patient' NK1: nk1Segment, ID: patientId -%}

{% evaluate relatedPersonId using 'ID/RelatedPerson' NK1: nk1Segment, baseId: patientId -%}
{% if relatedPersonId -%}
{% include 'Resource/RelatedPerson' NK1: nk1Segment, ID: relatedPersonId -%}
Expand Down
2 changes: 1 addition & 1 deletion data/Templates/Hl7v2/Resource/_Device.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id":"{{ ID }}",
"identifier":
[
{ {% include 'DataType/EIIdentifier' EI: OBX.18 -%} },
{ {% include 'DataType/EIIdentifier' EI: OBX.18.Repeats[0] -%} },
{ {% include 'DataType/EIIdentifier' EI: PRT.10 -%} },
],
"manufactureDate":"{{ PRT.17.Value | format_as_date_time }}",
Expand Down
6 changes: 3 additions & 3 deletions data/Templates/Hl7v2/Resource/_Immunization.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
{
{% include 'DataType/CWECodeableConcept' CWE: RXA.5 -%}
},
"lotNumber":"{{ RXA.15.Value }}",
"expirationDate":"{{ RXA.16.Value | add_hyphens_date }}",
"lotNumber":"{{ RXA.15.Repeats[0].Value }}",
"expirationDate":"{{ RXA.16.Repeats[0].Value | add_hyphens_date }}",
"statusReason":
{
{% include 'DataType/CWECodeableConcept' CWE: RXA.18 -%}
{% include 'DataType/CWECodeableConcept' CWE: RXA.18.Repeats[0] -%}
},
"reasonCode":
[
Expand Down
10 changes: 5 additions & 5 deletions data/Templates/Hl7v2/Resource/_Location.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
{% include 'DataType/PL' PL: PV1.3 -%}
{% include 'DataType/PL' PL: PV1.6 -%}
{% include 'DataType/PL' PL: PL -%}
{% include 'DataType/PL' PL: PR1.23 -%}
{% include 'DataType/PL' PL: PRT.9 -%}
{% include 'DataType/XONLocation' XON: ORC.21 -%}
{% include 'DataType/PL' PL: PR1.23.Repeats[0] -%}
{% include 'DataType/PL' PL: PRT.9.Repeats[0] -%}
{% include 'DataType/XONLocation' XON: ORC.21.Repeats[0] -%}
"address":
{
{% include 'DataType/XAD' XAD: ORC.22 -%}
{% include 'DataType/XAD' XAD: ORC.22.Repeats[0] -%}
{% include 'DataType/XAD' XAD: RXA.28 -%}
},
"telecom":
[
{ {% include 'DataType/XTN' XTN: ORC.23 -%} },
{ {% include 'DataType/XTN' XTN: ORC.23.Repeats[0] -%} },
],
{% include 'DataType/PL' PL: RXA.27 -%}
},
Expand Down
8 changes: 4 additions & 4 deletions data/Templates/Hl7v2/Resource/_Organization.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% if OBX.25 -%}
{ {% include 'DataType/XAD' XAD: OBX.24 -%} },
{% endif -%}
{ {% include 'DataType/XAD' XAD: ORC.22 -%} },
{ {% include 'DataType/XAD' XAD: ORC.22.Repeats[0] -%} },
],
{% if MSH.21 == null -%}
{% include 'DataType/HDOrganization' HD: MSH.4 -%}
Expand Down Expand Up @@ -42,12 +42,12 @@
[
{ {% include 'DataType/CWECodeableConcept' mapping: 'CodeSystem/OrganizationUnitType', CWE: PRT.7 -%} },
],
{% include 'DataType/XONOrganization' XON: PRT.8 -%}
{% include 'DataType/XONOrganization' XON: PRT.8.Repeats[0] -%}
"telecom":
[
{ {% include 'DataType/XTN' XTN: ORC.23 -%} },
{ {% include 'DataType/XTN' XTN: ORC.23.Repeats[0] -%} },
],
{% include 'DataType/CWEOrganization' CWE: RXA.17 -%}
{% include 'DataType/CWEOrganization' CWE: RXA.17.Repeats[0] -%}
},
"request":{
"method":"PUT",
Expand Down
4 changes: 2 additions & 2 deletions data/Templates/Hl7v2/Resource/_Patient.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@
{
"name":
{
{% include 'DataType/XPN' XPN: NK1.2 -%}
{% include 'DataType/XPN' XPN: NK1.2.Repeats[0] -%}
},
"address":
{
{% include 'DataType/XAD' XAD: NK1.4 -%}
{% include 'DataType/XAD' XAD: NK1.4.Repeats[0] -%}
},
"telecom":
[
Expand Down
8 changes: 4 additions & 4 deletions data/Templates/Hl7v2/Resource/_Practitioner.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"address":
[
{ {% include 'DataType/XAD' XAD: ROL.11 -%} },
{ {% include 'DataType/XAD' XAD: PRT.14 -%} },
{ {% include 'DataType/XAD' XAD: ORC.24 -%} },
{ {% include 'DataType/XAD' XAD: PRT.14.Repeats[0] -%} },
{ {% include 'DataType/XAD' XAD: ORC.24.Repeats[0] -%} },
],
{% include 'DataType/XCNPractitionerRole' XCN: OBX.16 -%}
{% include 'DataType/XCNPractitioner' XCN: DG1.16 -%}
{% include 'DataType/XCNPractitioner' XCN: DG1.16.Repeats[0] -%}
{% include 'DataType/XCNPractitioner' XCN: PR1.8 -%}
{% include 'DataType/XCNPractitioner' XCN: PR1.11 -%}
{% include 'DataType/XCNPractitioner' XCN: PR1.12 -%}
{% include 'DataType/XCNPractitioner' XCN: ORC.10 -%}
{% include 'DataType/XCNPractitioner' XCN: ORC.11 -%}
{% include 'DataType/XCNPractitioner' XCN: ORC.12 -%}
{% include 'DataType/XCNPractitioner' XCN: ORC.12.Repeats[0] -%}
{% include 'DataType/XCNPractitioner' XCN: NTE.5 -%}
{% include 'DataType/XCNPractitioner' XCN: RXA.10 -%}
},
Expand Down
6 changes: 3 additions & 3 deletions data/Templates/Hl7v2/Resource/_PractitionerRole.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"telecom":
[
{ {% include 'DataType/XTN' XTN: ROL.12 -%} },
{ {% include 'DataType/XTN' XTN: PRT.15 -%} },
{ {% include 'DataType/XTN' XTN: PRT.15.Repeats[0] -%} },
],
"location":
[
Expand All @@ -40,12 +40,12 @@
],
{% include 'DataType/XCNPractitionerRole' XCN: ROL.4 -%}
{% include 'DataType/XCNPractitionerRole' XCN: OBX.25 -%}
{% include 'DataType/XCNPractitionerRole' XCN: PRT.5 -%}
{% include 'DataType/XCNPractitionerRole' XCN: PRT.5.Repeats[0] -%}
"specialty":
[
{ {% include 'DataType/CWECodeableConcept' CWE: PRT.6 -%} },
],
{% include 'DataType/XCNPractitionerRole' XCN: ORC.12 -%}
{% include 'DataType/XCNPractitionerRole' XCN: ORC.12.Repeats[0] -%}
{% include 'DataType/NDLPractitionerRole' NDL: OBR.32 -%}
{% include 'DataType/NDLPractitionerRole' NDL: OBR.34 -%}
{% include 'DataType/NDLPractitionerRole' NDL: OBR.35 -%}
Expand Down
10 changes: 5 additions & 5 deletions data/Templates/Hl7v2/Resource/_RelatedPerson.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
[
{ {% include 'DataType/XAD' XAD: ROL.11 -%} },
{
{% include 'DataType/XAD' XAD: NK1.4 -%}
{% include 'DataType/XAD' XAD: NK1.4.Repeats[0] -%}
},
{
{% include 'DataType/XAD' XAD: NK1.32 -%}
},
{ {% include 'DataType/XAD' XAD: PRT.14 -%} },
{ {% include 'DataType/XAD' XAD: PRT.14.Repeats[0] -%} },
],
"telecom":
[
Expand All @@ -64,11 +64,11 @@
{
{% include 'DataType/XTN' XTN: NK1.41 -%}
},
{ {% include 'DataType/XTN' XTN: PRT.15 -%} },
{ {% include 'DataType/XTN' XTN: PRT.15.Repeats[0] -%} },
],
"name":
[
{ {% include 'DataType/XPN' XPN: NK1.2 -%} },
{ {% include 'DataType/XPN' XPN: NK1.2.Repeats[0] -%} },
{ {% include 'DataType/XPN' XPN: NK1.30 -%} },
],
"gender":"{{ NK1.15.Value | get_property: 'CodeSystem/Gender', 'code' }}",
Expand All @@ -82,7 +82,7 @@
},
},
],
{% include 'DataType/XCNRelatedPerson' XCN: PRT.5 -%}
{% include 'DataType/XCNRelatedPerson' XCN: PRT.5.Repeats[0] -%}
},
"request":{
"method":"PUT",
Expand Down
2 changes: 1 addition & 1 deletion data/Templates/Hl7v2/Resource/_Specimen.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
],
"accessionIdentifier":
{
{% include 'DataType/CX' CX: SPM.30 -%}
{% include 'DataType/CX' CX: SPM.30.Repeats[0] -%}
},
},
"request":{
Expand Down
26 changes: 24 additions & 2 deletions data/Templates/Hl7v2/VXU_V04.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,32 @@
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|PV1|ORC' -%}
{% assign firstSegments = hl7v2Data | get_first_segments: 'PID|PD1|PV1|ORC|MSH' -%}

{% evaluate messageHeaderId using 'ID/MessageHeader' MSH: firstSegments.MSH -%}
{% if messageHeaderId -%}
{% include 'Resource/MessageHeader' MSH: firstSegments.MSH, ID: messageHeaderID -%}
{% endif -%}

{% evaluate patientId using 'ID/Patient' PID: firstSegments.PID, type: 'First' -%}
{% if patientId -%}
{% assign fullPatientId = patientId | prepend: 'Patient/' -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, NK1: firstSegments.NK1, ID: patientId -%}
{% include 'Resource/Patient' PID: firstSegments.PID, PD1: firstSegments.PD1, ID: patientId -%}
{% endif -%}

{% evaluate provenanceId using 'ID/Provenance' MSH: firstSegments.MSH, baseID: patientId -%}
{% if provenanceId -%}
{% include 'Resource/Provenance' MSH: firstSegments.MSH, ORC: firstSegments.ORC, ID: provenanceId -%}
{% endif -%}

{% evaluate accountId using 'ID/Account' CX: firstSegments.PID.3 -%}
{% if accountId -%}
{% include 'Resource/Account' PID: firstSegments.PID, ID: accountId -%}
{% endif -%}

{% evaluate organizationId using 'ID/Organization' HD: firstSegments.MSH.6 -%}
{% if organizationId -%}
{% include 'Resource/Organization' MSH: firstSegments.MSH, ID: organizationId -%}
{% endif -%}

{% evaluate encounterId using 'ID/Encounter' PV1: firstSegments.PV1, baseId: patientId -%}
Expand All @@ -31,6 +51,8 @@

{% assign nk1SegmentLists = hl7v2Data | get_segment_lists: 'NK1' -%}
{% for nk1Segment in nk1SegmentLists.NK1 -%}
{% include 'Resource/Patient' NK1: nk1Segment, ID: patientId -%}

{% evaluate relatedPersonId using 'ID/RelatedPerson' NK1: nk1Segment, baseId: patientId -%}
{% if relatedPersonId -%}
{% include 'Resource/RelatedPerson' NK1: nk1Segment, ID: relatedPersonId -%}
Expand Down
Loading

0 comments on commit 6f106e9

Please sign in to comment.