Skip to content

Commit

Permalink
Merge pull request #47 from icanbwell/HHRE-919-remove-print-patient-b…
Browse files Browse the repository at this point in the history
…undle

HHRE-919 removed logging the Patient PHI data, updated for minor changes
  • Loading branch information
changsu-bWell authored Sep 2, 2022
2 parents 815d4f5 + 630e52f commit 105237a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ COPY ./src/ /bsights-engine-spark/src/

## skip running tests since it requires a fhir server
RUN mvn -Dmaven.test.skip package -s ./settings.xml && \
cp ./target/bsights-engine-spark-1.0.10.jar /opt/spark/jars/
cp ./target/bsights-engine-spark-1.0.11.jar /opt/spark/jars/

# USER 1001
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.bwell</groupId>
<artifactId>bsights-engine-spark</artifactId>
<version>1.0.10</version>
<version>1.0.11</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/bwell/infrastructure/FhirJsonExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ public static String getMapSetAsJson(String fhirVersion, Set<Map.Entry<String, O
for (Map.Entry<String, Object> libraryEntry : entrySet) {
String key = libraryEntry.getKey();
Object value = libraryEntry.getValue();

// IF the value is FHIR resource, just get the Id of this resource object
if (value instanceof IBaseResource) {
jsonMap.put(key, getResourceAsJson(fhirVersion, (IBaseResource) value));
jsonMap.put(key + "Id", ((IBaseResource) value).getIdElement().getIdPart());
} else {
jsonMap.put(key, value != null ? value.toString(): null);
jsonMap.put(key, value != null ? value.toString() : null);
}
}
return getMapAsJson(jsonMap);
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/com/bwell/services/application/MeasureService.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public Map<String, String> runCqlLibrary(
libraryParameter.context.contextValue = contextValue;
}

myLogger.info("Running with libraryUrl={}, terminologyUrl={}, fhir={}", libraryUrl, terminologyUrl, fhirBundle);
myLogger.info("Running with libraryName={}, libraryVersion={}, libraryUrl={}, terminologyUrl={}",
libraryName, libraryVersion, libraryUrl, terminologyUrl);

if(authUrl != null){
List<String> headers = headers(authUrl, authId, authSecret, authScope);
Expand All @@ -92,31 +93,32 @@ public Map<String, String> runCqlLibrary(

Set<Map.Entry<String, Object>> entrySet = result.expressionResults.entrySet();

myLogger.info("Received result from CQL Engine={} for bundle={}",
FhirJsonExporter.getMapSetAsJson(fhirVersion, entrySet),
fhirBundle);
myLogger.info("Received result from CQL Engine={}",
FhirJsonExporter.getMapSetAsJson(fhirVersion, entrySet));

for (Map.Entry<String, Object> libraryEntry : entrySet) {
String key = libraryEntry.getKey();
Object value = libraryEntry.getValue();

if ("Patient".equals(key)) {
Patient patient = (Patient) value;
myLogger.info("Received Patient in CQL result={}",
patient != null ? FhirJsonExporter.getResourceAsJson(fhirVersion, patient) : null);
newMap.put("PatientId", (patient != null) ? patient.getIdElement().getIdPart() : null);

String patientId = (patient != null) ? patient.getIdElement().getIdPart() : null;
myLogger.info("Received Patient in CQL result, Patient Id={}", patientId);

newMap.put("PatientId", patientId);
} else {
if (cqlVariables.contains(key)) {
newMap.put(key, value != null ? value.toString() : null);
}
}
}
} catch (Exception ex) {
myLogger.error("Error={} for bundle={}", ex, fhirBundle);
myLogger.error("Error={}", ex);
throw ex;
}

myLogger.info("Calculated CQL variables={} for bundle={}", FhirJsonExporter.getMapAsJson(newMap), fhirBundle);
myLogger.info("Calculated CQL variables={}", FhirJsonExporter.getMapAsJson(newMap));

return newMap;
}
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/bwell/services/domain/ResourceLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,18 @@ public IBaseBundle loadResourceFromString(String fhirVersion, String resourceJso
bundle = (Bundle) baseResource;
}

myLogger.info("Read resources from {}: {}", resourceJson, FhirJsonExporter.getResourceAsJson(fhirVersion, bundle));
String resourceId = null;
List<Bundle.BundleEntryComponent> entries = ((Bundle)bundle).getEntry();
if (entries.size() > 0) {
resourceId = entries.get(0).getResource().getIdElement().getIdPart();
}

myLogger.info("Read resources for resource Id: {}", resourceId);
bundle = moveContainedResourcesToTopLevel(bundle);

//noinspection ConstantConditions
bundle = clean_and_fix_bundle(bundle);
myLogger.info("Cleaned resources from {}: {}", resourceJson, FhirJsonExporter.getResourceAsJson(fhirVersion, bundle));
bundle = cleanFixBundle(bundle);
myLogger.info("Cleaned resources for resource Id: {}", resourceId);

return bundle;
} catch (FHIRFormatError | FhirException ex) {
Expand Down Expand Up @@ -139,7 +145,7 @@ private IBaseBundle moveContainedResourcesToTopLevel(IBaseBundle bundle) {
return bundle;
}

private IBaseBundle clean_and_fix_bundle(IBaseBundle bundle) {
private IBaseBundle cleanFixBundle(IBaseBundle bundle) {
// some data we get is bad FHIR ,so we have to fix it
return bundle;
}
Expand Down

0 comments on commit 105237a

Please sign in to comment.