Skip to content

Commit 3bd64e8

Browse files
fix: Add planned encounters back (#68)
* planned encounter converts to own encounter * remove default values for nonrequired fields * update test * update snapshot * encompassing encounter status * update snapshots * remove spaces * do not convert cdc local sustem to url * fix tests * add actcode name back
1 parent 3e616a1 commit 3bd64e8

File tree

15 files changed

+593
-97
lines changed

15 files changed

+593
-97
lines changed

data/Templates/eCR/Entry/PlanOfTreatment/_entry.liquid

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,22 @@
5656
{% endif %}
5757

5858
{% endif %}
59+
60+
{%- assign encounter = entry.encounter -%}
61+
{%- if encounter -%}
62+
{% assign encounterId = encounter | to_json_string | generate_uuid -%}
63+
{% assign fullEncounterId = encounterId | prepend: 'Encounter/' %}
64+
65+
{% include 'Reference/CarePlan/Encounter' ID: carePlanId, REF: fullEncounterId -%}
66+
{% include 'Resource/Encounter' serviceEntry: encounter, ID: encounterId -%}
67+
68+
{% assign participants = encounter.participant | to_array %}
69+
{%- for participant in participants -%}
70+
{%- if participant.typeCode == "LOC" -%}
71+
{% assign locationId = participant.participantRole | to_json_string | generate_uuid %}
72+
{% assign fullLocationId = locationId | prepend: 'Location/' %}
73+
{% include 'Resource/Location' ID: locationId, location: participant.participantRole %}
74+
{% include 'Reference/Encounter/Location_Location' ID: encounterId, REF: fullLocationId -%}
75+
{% endif %}
76+
{%- endfor -%}
77+
{%- endif -%}

data/Templates/eCR/Reference/Encounter/_Location_Location.liquid

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
{% assign ids = LOC.id | to_array -%}
99
{% if ids.first and ids.first.root -%}
1010
"id": "{{ids.first.root}}",
11-
{% else -%}
12-
"id": "None",
1311
{% endif -%}
1412
"location":
1513
{
@@ -18,10 +16,7 @@
1816
"display":"{{ LOC.location.name._ }}",
1917
{% elsif LOC.serviceProviderOrganization and LOC.serviceProviderOrganization.name and LOC.serviceProviderOrganization.name._ -%}
2018
"display":"{{ LOC.serviceProviderOrganization.name._ }}",
21-
{% else -%}
22-
"display": "None",
2319
{% endif -%}
24-
2520
},
2621
{% assign codes = LOC.code | to_array -%}
2722
{% if codes.first -%}

data/Templates/eCR/Resource/_CarePlan.liquid

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
{% assign entries = carePlan.entry | to_array %}
2020
{% for entry in entries %}
2121
{% assign act = entry.act %}
22-
{% if entry.encounter %}
23-
{% assign act = entry.encounter %}
24-
{% endif %}
2522
{% comment %} Other entry types are handled in `Entry/PlanOfTreatment/entry` {% endcomment %}
2623
{% if act %}
2724
{

data/Templates/eCR/Resource/_Encounter.liquid

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33
"resource":{
44
"resourceType": "Encounter",
55
"id":"{{ ID }}",
6-
{% if encounter.statusCode.code -%}
7-
"status":"{{ encounter.statusCode.code | get_property: 'ValueSet/EncounterStatus' }}",
8-
{% endif -%}
9-
{% if encounter.statusCode.code == null -%}
10-
"status":"unknown",
6+
{%- if encounter.statusCode.code and encounter.statusCode.code != "completed" and encounter.statusCode.code != "active" -%}
7+
"status": "{{ encounter.statusCode.code | get_property: 'ValueSet/EncounterStatus' }}",
8+
{%- elsif encounter.effectiveTime.value and encounter.effectiveTime.value.nullFlavor == nil and encounter.effectiveTime.low == nil and encounter.effectiveTime.high == nil -%}
9+
"status": "finished",
10+
{%- elsif encounter.effectiveTime.high and encounter.effectiveTime.high.nullFlavor == nil -%}
11+
"status": "finished",
12+
{%- elsif encounter.effectiveTime.low and encounter.effectiveTime.low.nullFlavor == nil and encounter.effectiveTime.high == nil -%}
13+
"status": "in-progress",
14+
{%- elseif encounter.statusCode.code -%}
15+
"status": "{{ encounter.statusCode.code | get_property: 'ValueSet/EncounterStatus' }}",
16+
{%- else -%}
17+
"status": "unknown",
1118
{% endif -%}
1219
"class": {
13-
{% if encounter.code -%}
14-
{% include 'DataType/Coding' Coding: encounter.code -%}
15-
{% endif -%}
20+
{% if encounter.code -%}
21+
{% include 'DataType/Coding' Coding: encounter.code -%}
22+
{% endif -%}
1623
},
1724
"identifier":
1825
[

data/Templates/eCR/ValueSet/ValueSet.json

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -243,53 +243,32 @@
243243
}
244244
},
245245
"ValueSet/EncounterStatus": {
246-
"planned": {
247-
"code": "planned"
248-
},
249-
"arrived": {
250-
"code": "arrived"
251-
},
252-
"triaged": {
253-
"code": "triaged"
254-
},
255-
"accepted": {
256-
"code": "triaged"
246+
"aborted": {
247+
"code": "unknown"
257248
},
258249
"active": {
259250
"code": "in-progress"
260251
},
261-
"onleave": {
262-
"code": "onleave"
263-
},
264-
"suspended": {
265-
"code": "onleave"
266-
},
267-
"normal": {
268-
"code": "finished"
269-
},
270-
"complete": {
271-
"code": "finished"
252+
"cancelled": {
253+
"code": "cancelled"
272254
},
273-
"finished": {
255+
"completed": {
274256
"code": "finished"
275257
},
276-
"cancelled": {
277-
"code": "cancelled"
258+
"held": {
259+
"code": "planned"
278260
},
279-
"abandoned": {
280-
"code": "cancelled"
261+
"new": {
262+
"code": "unknown"
281263
},
282-
"entered-in-error": {
283-
"code": "entered-in-error"
264+
"suspended": {
265+
"code": "onleave"
284266
},
285-
"error": {
267+
"nullified": {
286268
"code": "entered-in-error"
287269
},
288-
"unknown": {
289-
"code": "unknown"
290-
},
291270
"__default__": {
292-
"code": ""
271+
"code": "unknown"
293272
}
294273
},
295274
"ValueSet/EventStatus": {

data/Templates/eCR/ValueSet/_SystemReference.liquid

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@
3030
{%- assign url = "http://terminology.hl7.org/CodeSystem/v3-TribalEntityUS" -%}
3131
{%- when "2.16.840.1.113883.6.12" -%}
3232
{%- assign url = "http://www.ama-assn.org/go/cpt" -%}
33+
{%- when "2.16.840.1.113883.5.4" -%}
34+
{%- assign url = "http://terminology.hl7.org/CodeSystem/v3-ActCode" -%}
3335
{%- endcase -%}
3436
{{- url | clean_string_from_tabs -}}

src/Dibbs.FhirConverterApi.FunctionalTests/__snapshots__/FhirConverterApiFunctionalTests.ConvertToFhir_ReturnsSuccess_WhenValidEicrWithRrProvided.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@
350350
{
351351
"id": "2.16.840.1.113883.4.6",
352352
"location": {
353-
"reference": "Location/bea8eaff-b016-f74b-10ab-9d0440257223",
354-
"display": "None"
353+
"reference": "Location/bea8eaff-b016-f74b-10ab-9d0440257223"
355354
},
356355
"extension": [
357356
{

src/Dibbs.FhirConverterApi.FunctionalTests/__snapshots__/FhirConverterApiFunctionalTests.ConvertToFhir_ReturnsSuccess_WhenValidEicrWithoutRrProvided.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@
300300
{
301301
"id": "2.16.840.1.113883.4.6",
302302
"location": {
303-
"reference": "Location/bea8eaff-b016-f74b-10ab-9d0440257223",
304-
"display": "None"
303+
"reference": "Location/bea8eaff-b016-f74b-10ab-9d0440257223"
305304
},
306305
"extension": [
307306
{

src/Microsoft.Health.Fhir.Liquid.Converter.FunctionalTests/TestData/Expected/eCR/EICR/CDAR2_IG_PHCASERPT_R2_D2_SAMPLE-expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@
392392
"resource": {
393393
"resourceType": "Encounter",
394394
"id": "e643736c-3539-57f5-a34d-66a1aa2ca08b",
395-
"status": "unknown",
395+
"status": "in-progress",
396396
"class": {
397397
"code": "AMB",
398-
"system": "urn:oid:2.16.840.1.113883.5.4",
398+
"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
399399
"display": "Ambulatory"
400400
},
401401
"identifier": [

src/Microsoft.Health.Fhir.Liquid.Converter.FunctionalTests/TestData/Expected/eCR/EICR/eCR_EveEverywoman-expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,10 @@
569569
"resource": {
570570
"resourceType": "Encounter",
571571
"id": "76318a56-b9e2-db52-1123-ff869795db80",
572-
"status": "unknown",
572+
"status": "finished",
573573
"class": {
574574
"code": "AMB",
575-
"system": "urn:oid:2.16.840.1.113883.5.4",
575+
"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
576576
"display": "Ambulatory"
577577
},
578578
"identifier": [

0 commit comments

Comments
 (0)