Skip to content

Commit 364198f

Browse files
committed
Resolve merge conflict.
2 parents b6ea32b + e2ca05d commit 364198f

File tree

174 files changed

+3842
-2876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+3842
-2876
lines changed

src/main/java/org/mitre/synthea/export/flexporter/Actions.java

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ private static Map<String, Object> createFhirPathMapping(List<Map<String, Object
424424
String location = (String)field.get("location");
425425
Object valueDef = field.get("value");
426426
String transform = (String)field.get("transform");
427+
String ifDef = (String)field.get("if");
428+
429+
if (ifDef != null && !FhirPathUtils.appliesToResource(sourceResource, ifDef)) {
430+
// The "if" condition returned falsy, so don't evaluate this value/set this field
431+
continue;
432+
}
427433

428434
if (valueDef == null) {
429435
// do nothing, leave it null
@@ -457,12 +463,15 @@ private static Map<String, Object> createFhirPathMapping(List<Map<String, Object
457463
} else if (valueDef instanceof Map<?,?>) {
458464
Map<String,Object> valueMap = (Map<String, Object>) valueDef;
459465

460-
populateFhirPathMapping(fhirPathMapping, location, valueMap);
466+
populateFhirPathMapping(fhirPathMapping, location, valueMap, sourceBundle, sourceResource,
467+
person, fjContext);
461468

462469
} else if (valueDef instanceof List<?>) {
463470
List<Object> valueList = (List<Object>) valueDef;
464471

465-
populateFhirPathMapping(fhirPathMapping, location, valueList);
472+
populateFhirPathMapping(fhirPathMapping, location, valueList, sourceBundle, sourceResource,
473+
person, fjContext);
474+
466475
} else {
467476
// unexpected type here - is it even possible to get anything else?
468477
String type = valueDef == null ? "null" : valueDef.getClass().toGenericString();
@@ -474,21 +483,32 @@ private static Map<String, Object> createFhirPathMapping(List<Map<String, Object
474483
}
475484

476485
private static void populateFhirPathMapping(Map<String, Object> fhirPathMapping, String basePath,
477-
Map<String, Object> valueMap) {
486+
Map<String, Object> valueMap, Bundle sourceBundle, Resource sourceResource, Person person,
487+
FlexporterJavascriptContext fjContext) {
478488
for (Map.Entry<String,Object> entry : valueMap.entrySet()) {
479489
String key = entry.getKey();
480490
Object value = entry.getValue();
481491

482492
String path = basePath + "." + key;
483493

484494
if (value instanceof String) {
495+
String valueString = (String)value;
496+
497+
if (valueString.startsWith("$")) {
498+
value = getValue(sourceBundle, valueString, sourceResource, person, fjContext);
499+
}
500+
}
501+
502+
if (value instanceof String || value instanceof Base) {
485503
fhirPathMapping.put(path, value);
486504
} else if (value instanceof Number) {
487505
fhirPathMapping.put(path, value.toString());
488506
} else if (value instanceof Map<?,?>) {
489-
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value);
507+
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value, sourceBundle,
508+
sourceResource, person, fjContext);
490509
} else if (value instanceof List<?>) {
491-
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value);
510+
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value, sourceBundle,
511+
sourceResource, person, fjContext);
492512
} else if (value != null) {
493513
System.err
494514
.println("Unexpected class found in populateFhirPathMapping[map]: " + value.getClass());
@@ -497,20 +517,23 @@ private static void populateFhirPathMapping(Map<String, Object> fhirPathMapping,
497517
}
498518

499519
private static void populateFhirPathMapping(Map<String, Object> fhirPathMapping, String basePath,
500-
List<Object> valueList) {
520+
List<Object> valueList, Bundle sourceBundle, Resource sourceResource, Person person,
521+
FlexporterJavascriptContext fjContext) {
501522
for (int i = 0; i < valueList.size(); i++) {
502523
Object value = valueList.get(i);
503524

504525
String path = basePath + "[" + i + "]";
505526

506-
if (value instanceof String) {
527+
if (value instanceof String || value instanceof Base) {
507528
fhirPathMapping.put(path, value);
508529
} else if (value instanceof Number) {
509530
fhirPathMapping.put(path, value.toString());
510531
} else if (value instanceof Map<?,?>) {
511-
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value);
532+
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value, sourceBundle,
533+
sourceResource, person, fjContext);
512534
} else if (value instanceof List<?>) {
513-
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value);
535+
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value, sourceBundle,
536+
sourceResource, person, fjContext);
514537
} else if (value != null) {
515538
System.err
516539
.println("Unexpected class found in populateFhirPathMapping[list]:" + value.getClass());
@@ -649,13 +672,9 @@ private static void dateFilter(Bundle bundle, String minDateStr, String maxDateS
649672
* Cascade (current), Delete reference field but leave object, Do nothing
650673
*
651674
* @param bundle FHIR Bundle to filter
652-
* @param list List of resource types to delete, other types not listed will be kept
675+
* @param list List of resource types or FHIRPath to delete, other types not listed will be kept
653676
*/
654677
public static void deleteResources(Bundle bundle, List<String> list) {
655-
// TODO: make this FHIRPath instead of just straight resource types
656-
657-
Set<String> resourceTypesToDelete = new HashSet<>(list);
658-
659678
Set<String> deletedResourceIDs = new HashSet<>();
660679

661680
Iterator<BundleEntryComponent> itr = bundle.getEntry().iterator();
@@ -665,9 +684,14 @@ public static void deleteResources(Bundle bundle, List<String> list) {
665684

666685
Resource resource = entry.getResource();
667686
String resourceType = resource.getResourceType().toString();
668-
if (resourceTypesToDelete.contains(resourceType)) {
669-
deletedResourceIDs.add(resource.getId());
670-
itr.remove();
687+
688+
for (String applicability : list) {
689+
if (applicability.equals(resourceType)
690+
|| FhirPathUtils.appliesToResource(resource, applicability)) {
691+
deletedResourceIDs.add(resource.getId());
692+
itr.remove();
693+
break;
694+
}
671695
}
672696
}
673697

src/main/resources/modules/acute_myeloid_leukemia.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"codes": [
9797
{
9898
"system": "SNOMED-CT",
99-
"code": 409089005,
99+
"code": "409089005",
100100
"display": "Febrile neutropenia (disorder)"
101101
}
102102
],
@@ -109,8 +109,8 @@
109109
"codes": [
110110
{
111111
"system": "SNOMED-CT",
112-
"code": 47318007,
113-
"display": "Neutropenia (disorder)"
112+
"code": "47318007",
113+
"display": "Drug-induced neutropenia (disorder)"
114114
}
115115
],
116116
"direct_transition": "Transfer_to_Stepdown"
@@ -122,7 +122,7 @@
122122
"codes": [
123123
{
124124
"system": "SNOMED-CT",
125-
"code": 5758002,
125+
"code": "5758002",
126126
"display": "Bacteremia (finding)"
127127
}
128128
],
@@ -219,8 +219,8 @@
219219
"codes": [
220220
{
221221
"system": "SNOMED-CT",
222-
"code": 91861009,
223-
"display": "Acute myeloid leukemia, disease (disorder)"
222+
"code": "91861009",
223+
"display": "Acute myeloid leukemia (disorder)"
224224
}
225225
]
226226
},
@@ -315,7 +315,7 @@
315315
"codes": [
316316
{
317317
"system": "SNOMED-CT",
318-
"code": 367336001,
318+
"code": "367336001",
319319
"display": "Chemotherapy (procedure)"
320320
}
321321
],
@@ -332,7 +332,7 @@
332332
"codes": [
333333
{
334334
"system": "SNOMED-CT",
335-
"code": 305351004,
335+
"code": "305351004",
336336
"display": "Admission to intensive care unit (procedure)"
337337
}
338338
],
@@ -348,7 +348,7 @@
348348
"codes": [
349349
{
350350
"system": "SNOMED-CT",
351-
"code": 5758002,
351+
"code": "5758002",
352352
"display": "Bacteremia (finding)"
353353
}
354354
]
@@ -386,7 +386,7 @@
386386
"codes": [
387387
{
388388
"system": "SNOMED-CT",
389-
"code": 185347001,
389+
"code": "185347001",
390390
"display": "Encounter for problem (procedure)"
391391
}
392392
],
@@ -397,7 +397,7 @@
397397
"codes": [
398398
{
399399
"system": "SNOMED-CT",
400-
"code": 16983000,
400+
"code": "16983000",
401401
"display": "Death in hospital (event)"
402402
}
403403
],
@@ -446,8 +446,8 @@
446446
"codes": [
447447
{
448448
"system": "SNOMED-CT",
449-
"code": 449214001,
450-
"display": "Transfer to stepdown"
449+
"code": "449214001",
450+
"display": "Transfer to stepdown unit (procedure)"
451451
}
452452
],
453453
"duration": {
@@ -706,8 +706,8 @@
706706
"codes": [
707707
{
708708
"system": "SNOMED-CT",
709-
"code": 91861009,
710-
"display": "Acute myeloid leukemia, disease (disorder)"
709+
"code": "91861009",
710+
"display": "Acute myeloid leukemia (disorder)"
711711
}
712712
],
713713
"direct_transition": "Chemotherapy_Inpatient_Encounter"

src/main/resources/modules/allergic_rhinitis.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
{
119119
"system": "SNOMED-CT",
120120
"code": "367498001",
121-
"display": "Seasonal allergic rhinitis"
121+
"display": "Seasonal allergic rhinitis (disorder)"
122122
}
123123
],
124124
"direct_transition": "Allergic_Rhinitis_Symptom1"
@@ -131,7 +131,7 @@
131131
{
132132
"system": "SNOMED-CT",
133133
"code": "446096008",
134-
"display": "Perennial allergic rhinitis"
134+
"display": "Perennial allergic rhinitis (disorder)"
135135
}
136136
],
137137
"direct_transition": "Allergic_Rhinitis_Symptom1"
@@ -144,7 +144,7 @@
144144
{
145145
"system": "SNOMED-CT",
146146
"code": "232353008",
147-
"display": "Perennial allergic rhinitis with seasonal variation"
147+
"display": "Perennial allergic rhinitis with seasonal variation (disorder)"
148148
}
149149
],
150150
"direct_transition": "Allergic_Rhinitis_Symptom1"
@@ -158,7 +158,7 @@
158158
{
159159
"system": "SNOMED-CT",
160160
"code": "185345009",
161-
"display": "Encounter for symptom"
161+
"display": "Encounter for symptom (procedure)"
162162
}
163163
],
164164
"direct_transition": "Prescribe_OTC_Antihistamine"
@@ -264,7 +264,7 @@
264264
{
265265
"system": "SNOMED-CT",
266266
"code": "419263009",
267-
"display": "Allergy to tree pollen"
267+
"display": "Allergy to tree pollen (finding)"
268268
}
269269
]
270270
},
@@ -274,7 +274,7 @@
274274
{
275275
"system": "SNOMED-CT",
276276
"code": "418689008",
277-
"display": "Allergy to grass pollen"
277+
"display": "Allergy to grass pollen (finding)"
278278
}
279279
]
280280
},
@@ -283,8 +283,8 @@
283283
"codes": [
284284
{
285285
"system": "SNOMED-CT",
286-
"code": "232347008",
287-
"display": "Dander (animal) allergy"
286+
"code": "717234006",
287+
"display": "Allergy to animal protein (finding)"
288288
}
289289
]
290290
},
@@ -294,7 +294,7 @@
294294
{
295295
"system": "SNOMED-CT",
296296
"code": "232350006",
297-
"display": "House dust mite allergy"
297+
"display": "Allergy to dust mite protein (finding)"
298298
}
299299
]
300300
},
@@ -304,7 +304,7 @@
304304
{
305305
"system": "SNOMED-CT",
306306
"code": "419474003",
307-
"display": "Allergy to mould"
307+
"display": "Allergy to mold (finding)"
308308
}
309309
]
310310
}

src/main/resources/modules/allergies.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
{
103103
"system": "SNOMED-CT",
104104
"code": "185347001",
105-
"display": "Encounter for problem"
105+
"display": "Encounter for problem (procedure)"
106106
}
107107
],
108108
"conditional_transition": [
@@ -131,7 +131,7 @@
131131
{
132132
"system": "SNOMED-CT",
133133
"code": "395142003",
134-
"display": "Allergy screening test"
134+
"display": "Allergy screening test (procedure)"
135135
}
136136
],
137137
"direct_transition": "Allergy_Panel"
@@ -166,7 +166,7 @@
166166
{
167167
"system": "SNOMED-CT",
168168
"code": "58332002",
169-
"display": "Allergy education"
169+
"display": "Allergy education (procedure)"
170170
}
171171
],
172172
"conditional_transition": [

0 commit comments

Comments
 (0)