Skip to content

Commit

Permalink
Resolve merge conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawalonoski committed Oct 31, 2024
2 parents b6ea32b + e2ca05d commit 364198f
Show file tree
Hide file tree
Showing 174 changed files with 3,842 additions and 2,876 deletions.
58 changes: 41 additions & 17 deletions src/main/java/org/mitre/synthea/export/flexporter/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ private static Map<String, Object> createFhirPathMapping(List<Map<String, Object
String location = (String)field.get("location");
Object valueDef = field.get("value");
String transform = (String)field.get("transform");
String ifDef = (String)field.get("if");

if (ifDef != null && !FhirPathUtils.appliesToResource(sourceResource, ifDef)) {
// The "if" condition returned falsy, so don't evaluate this value/set this field
continue;
}

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

populateFhirPathMapping(fhirPathMapping, location, valueMap);
populateFhirPathMapping(fhirPathMapping, location, valueMap, sourceBundle, sourceResource,
person, fjContext);

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

populateFhirPathMapping(fhirPathMapping, location, valueList);
populateFhirPathMapping(fhirPathMapping, location, valueList, sourceBundle, sourceResource,
person, fjContext);

} else {
// unexpected type here - is it even possible to get anything else?
String type = valueDef == null ? "null" : valueDef.getClass().toGenericString();
Expand All @@ -474,21 +483,32 @@ private static Map<String, Object> createFhirPathMapping(List<Map<String, Object
}

private static void populateFhirPathMapping(Map<String, Object> fhirPathMapping, String basePath,
Map<String, Object> valueMap) {
Map<String, Object> valueMap, Bundle sourceBundle, Resource sourceResource, Person person,
FlexporterJavascriptContext fjContext) {
for (Map.Entry<String,Object> entry : valueMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();

String path = basePath + "." + key;

if (value instanceof String) {
String valueString = (String)value;

if (valueString.startsWith("$")) {
value = getValue(sourceBundle, valueString, sourceResource, person, fjContext);
}
}

if (value instanceof String || value instanceof Base) {
fhirPathMapping.put(path, value);
} else if (value instanceof Number) {
fhirPathMapping.put(path, value.toString());
} else if (value instanceof Map<?,?>) {
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value);
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value, sourceBundle,
sourceResource, person, fjContext);
} else if (value instanceof List<?>) {
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value);
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value, sourceBundle,
sourceResource, person, fjContext);
} else if (value != null) {
System.err
.println("Unexpected class found in populateFhirPathMapping[map]: " + value.getClass());
Expand All @@ -497,20 +517,23 @@ private static void populateFhirPathMapping(Map<String, Object> fhirPathMapping,
}

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

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

if (value instanceof String) {
if (value instanceof String || value instanceof Base) {
fhirPathMapping.put(path, value);
} else if (value instanceof Number) {
fhirPathMapping.put(path, value.toString());
} else if (value instanceof Map<?,?>) {
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value);
populateFhirPathMapping(fhirPathMapping, path, (Map<String, Object>) value, sourceBundle,
sourceResource, person, fjContext);
} else if (value instanceof List<?>) {
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value);
populateFhirPathMapping(fhirPathMapping, path, (List<Object>) value, sourceBundle,
sourceResource, person, fjContext);
} else if (value != null) {
System.err
.println("Unexpected class found in populateFhirPathMapping[list]:" + value.getClass());
Expand Down Expand Up @@ -649,13 +672,9 @@ private static void dateFilter(Bundle bundle, String minDateStr, String maxDateS
* Cascade (current), Delete reference field but leave object, Do nothing
*
* @param bundle FHIR Bundle to filter
* @param list List of resource types to delete, other types not listed will be kept
* @param list List of resource types or FHIRPath to delete, other types not listed will be kept
*/
public static void deleteResources(Bundle bundle, List<String> list) {
// TODO: make this FHIRPath instead of just straight resource types

Set<String> resourceTypesToDelete = new HashSet<>(list);

Set<String> deletedResourceIDs = new HashSet<>();

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

Resource resource = entry.getResource();
String resourceType = resource.getResourceType().toString();
if (resourceTypesToDelete.contains(resourceType)) {
deletedResourceIDs.add(resource.getId());
itr.remove();

for (String applicability : list) {
if (applicability.equals(resourceType)
|| FhirPathUtils.appliesToResource(resource, applicability)) {
deletedResourceIDs.add(resource.getId());
itr.remove();
break;
}
}
}

Expand Down
30 changes: 15 additions & 15 deletions src/main/resources/modules/acute_myeloid_leukemia.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 409089005,
"code": "409089005",
"display": "Febrile neutropenia (disorder)"
}
],
Expand All @@ -109,8 +109,8 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 47318007,
"display": "Neutropenia (disorder)"
"code": "47318007",
"display": "Drug-induced neutropenia (disorder)"
}
],
"direct_transition": "Transfer_to_Stepdown"
Expand All @@ -122,7 +122,7 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 5758002,
"code": "5758002",
"display": "Bacteremia (finding)"
}
],
Expand Down Expand Up @@ -219,8 +219,8 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 91861009,
"display": "Acute myeloid leukemia, disease (disorder)"
"code": "91861009",
"display": "Acute myeloid leukemia (disorder)"
}
]
},
Expand Down Expand Up @@ -315,7 +315,7 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 367336001,
"code": "367336001",
"display": "Chemotherapy (procedure)"
}
],
Expand All @@ -332,7 +332,7 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 305351004,
"code": "305351004",
"display": "Admission to intensive care unit (procedure)"
}
],
Expand All @@ -348,7 +348,7 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 5758002,
"code": "5758002",
"display": "Bacteremia (finding)"
}
]
Expand Down Expand Up @@ -386,7 +386,7 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 185347001,
"code": "185347001",
"display": "Encounter for problem (procedure)"
}
],
Expand All @@ -397,7 +397,7 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 16983000,
"code": "16983000",
"display": "Death in hospital (event)"
}
],
Expand Down Expand Up @@ -446,8 +446,8 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 449214001,
"display": "Transfer to stepdown"
"code": "449214001",
"display": "Transfer to stepdown unit (procedure)"
}
],
"duration": {
Expand Down Expand Up @@ -706,8 +706,8 @@
"codes": [
{
"system": "SNOMED-CT",
"code": 91861009,
"display": "Acute myeloid leukemia, disease (disorder)"
"code": "91861009",
"display": "Acute myeloid leukemia (disorder)"
}
],
"direct_transition": "Chemotherapy_Inpatient_Encounter"
Expand Down
20 changes: 10 additions & 10 deletions src/main/resources/modules/allergic_rhinitis.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
{
"system": "SNOMED-CT",
"code": "367498001",
"display": "Seasonal allergic rhinitis"
"display": "Seasonal allergic rhinitis (disorder)"
}
],
"direct_transition": "Allergic_Rhinitis_Symptom1"
Expand All @@ -131,7 +131,7 @@
{
"system": "SNOMED-CT",
"code": "446096008",
"display": "Perennial allergic rhinitis"
"display": "Perennial allergic rhinitis (disorder)"
}
],
"direct_transition": "Allergic_Rhinitis_Symptom1"
Expand All @@ -144,7 +144,7 @@
{
"system": "SNOMED-CT",
"code": "232353008",
"display": "Perennial allergic rhinitis with seasonal variation"
"display": "Perennial allergic rhinitis with seasonal variation (disorder)"
}
],
"direct_transition": "Allergic_Rhinitis_Symptom1"
Expand All @@ -158,7 +158,7 @@
{
"system": "SNOMED-CT",
"code": "185345009",
"display": "Encounter for symptom"
"display": "Encounter for symptom (procedure)"
}
],
"direct_transition": "Prescribe_OTC_Antihistamine"
Expand Down Expand Up @@ -264,7 +264,7 @@
{
"system": "SNOMED-CT",
"code": "419263009",
"display": "Allergy to tree pollen"
"display": "Allergy to tree pollen (finding)"
}
]
},
Expand All @@ -274,7 +274,7 @@
{
"system": "SNOMED-CT",
"code": "418689008",
"display": "Allergy to grass pollen"
"display": "Allergy to grass pollen (finding)"
}
]
},
Expand All @@ -283,8 +283,8 @@
"codes": [
{
"system": "SNOMED-CT",
"code": "232347008",
"display": "Dander (animal) allergy"
"code": "717234006",
"display": "Allergy to animal protein (finding)"
}
]
},
Expand All @@ -294,7 +294,7 @@
{
"system": "SNOMED-CT",
"code": "232350006",
"display": "House dust mite allergy"
"display": "Allergy to dust mite protein (finding)"
}
]
},
Expand All @@ -304,7 +304,7 @@
{
"system": "SNOMED-CT",
"code": "419474003",
"display": "Allergy to mould"
"display": "Allergy to mold (finding)"
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/modules/allergies.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
{
"system": "SNOMED-CT",
"code": "185347001",
"display": "Encounter for problem"
"display": "Encounter for problem (procedure)"
}
],
"conditional_transition": [
Expand Down Expand Up @@ -131,7 +131,7 @@
{
"system": "SNOMED-CT",
"code": "395142003",
"display": "Allergy screening test"
"display": "Allergy screening test (procedure)"
}
],
"direct_transition": "Allergy_Panel"
Expand Down Expand Up @@ -166,7 +166,7 @@
{
"system": "SNOMED-CT",
"code": "58332002",
"display": "Allergy education"
"display": "Allergy education (procedure)"
}
],
"conditional_transition": [
Expand Down
Loading

0 comments on commit 364198f

Please sign in to comment.