From d780ca33a6a19964f0b21d744045d5c5d6a61e34 Mon Sep 17 00:00:00 2001 From: jewelbonnie Date: Thu, 19 Dec 2024 21:15:10 +0530 Subject: [PATCH 1/4] fix: handle Encounter resource type data mapping issues in CSV bundile validate api --- .../converters/shinny/EncounterConverter.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hub-prime/src/main/java/org/techbd/service/converters/shinny/EncounterConverter.java b/hub-prime/src/main/java/org/techbd/service/converters/shinny/EncounterConverter.java index 498905a2a4f..bf441ad0163 100644 --- a/hub-prime/src/main/java/org/techbd/service/converters/shinny/EncounterConverter.java +++ b/hub-prime/src/main/java/org/techbd/service/converters/shinny/EncounterConverter.java @@ -26,6 +26,8 @@ import org.techbd.util.CsvConversionUtil; import org.techbd.util.DateUtil; +import ca.uhn.fhir.context.FhirContext; + /** * Converts data into a FHIR Encounter resource. */ @@ -90,11 +92,12 @@ public List convert(Bundle bundle, DemographicData demogra Narrative text = new Narrative(); text.setStatus(NarrativeStatus.GENERATED); encounter.setText(text); - BundleEntryComponent bundleEntryComponent = new BundleEntryComponent(); bundleEntryComponent.setFullUrl(fullUrl); - bundleEntryComponent.setRequest(new Bundle.BundleEntryRequestComponent().setMethod(HTTPVerb.POST).setUrl("http://shinny.org/us/ny/hrsn/Encounter/" + encounter.getId())); + bundleEntryComponent.setRequest(new Bundle.BundleEntryRequestComponent().setMethod(HTTPVerb.POST) + .setUrl("http://shinny.org/us/ny/hrsn/Encounter/" + encounter.getId())); bundleEntryComponent.setResource(encounter); + return List.of(bundleEntryComponent); } @@ -117,7 +120,7 @@ private static void populateEncounterType(Encounter encounter, ScreeningProfileD if (data.getEncounterTypeCode() != null) { Coding coding = new Coding(); - coding.setCode(data.getEncounterClassCode()); + coding.setCode(data.getEncounterTypeCode()); coding.setSystem(data.getEncounterTypeCodeSystem()); coding.setDisplay(data.getEncounterTypeCodeDescription()); encounterType.addCoding(coding); @@ -154,7 +157,8 @@ private void populateEncounterPeriod(Encounter encounter, ScreeningProfileData s } } - private void populateLocationReference(Encounter encounter, ScreeningProfileData screeningResourceData, Map idsGenerated) { + private void populateLocationReference(Encounter encounter, ScreeningProfileData screeningResourceData, + Map idsGenerated) { if (screeningResourceData != null) { encounter.addLocation(new Encounter.EncounterLocationComponent() .setLocation(new Reference("Location/" + idsGenerated.get(CsvConstants.PATIENT_ID)))); From 10b5385acf1ef0048353373e009759b7456474ca Mon Sep 17 00:00:00 2001 From: jewelbonnie Date: Thu, 19 Dec 2024 21:47:37 +0530 Subject: [PATCH 2/4] fix: Implement Encounter resource failing test case in CSV bundile validate api --- .../service/csv/EncounterConverterTest.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/hub-prime/src/test/java/org/techbd/service/csv/EncounterConverterTest.java b/hub-prime/src/test/java/org/techbd/service/csv/EncounterConverterTest.java index 6078b05a3dd..415d4d9bce5 100644 --- a/hub-prime/src/test/java/org/techbd/service/csv/EncounterConverterTest.java +++ b/hub-prime/src/test/java/org/techbd/service/csv/EncounterConverterTest.java @@ -35,7 +35,7 @@ class EncounterConverterTest { private EncounterConverter encounterConverter; @Test - @Disabled + // @Disabled void testConvert() throws Exception { // Create necessary data objects for the test final Bundle bundle = new Bundle(); @@ -44,44 +44,46 @@ void testConvert() throws Exception { final QeAdminData qrAdminData = CsvTestHelper.createQeAdminData(); final ScreeningProfileData screeningResourceData = CsvTestHelper.createScreeningProfileData(); final Map idsGenerated = new HashMap<>(); - + // Instantiate the EncounterConverter EncounterConverter encounterConverter = new EncounterConverter(); - + // Call the convert method of the encounter converter - final BundleEntryComponent result = encounterConverter.convert(bundle, demographicData, qrAdminData, screeningResourceData, - screeningDataList, "interactionId", idsGenerated).get(0);; - + final BundleEntryComponent result = encounterConverter + .convert(bundle, demographicData, qrAdminData, screeningResourceData, + screeningDataList, "interactionId", idsGenerated) + .get(0); + ; + // Create soft assertions to verify the result final SoftAssertions softly = new SoftAssertions(); - + // Assert that the result is not null softly.assertThat(result).isNotNull(); - + // Assert that the result resource is an instance of Encounter softly.assertThat(result.getResource()).isInstanceOf(Encounter.class); - + // Cast the result to Encounter and assert various properties final Encounter encounter = (Encounter) result.getResource(); - + // Assert that the encounter ID is not null or empty and matches expected softly.assertThat(encounter.getId()).isNotEmpty(); - softly.assertThat(encounter.getId()).isEqualTo("Encounter-interactionId"); - + softly.assertThat(encounter.getId()).matches("[a-f0-9]{64}"); + // Assert that the encounter status is active (FINISHED) - //softly.assertThat(encounter.getStatus()).isEqualTo("FINISHED"); - + // softly.assertThat(encounter.getStatus()).isEqualTo("FINISHED"); + // Assert that the encounter has the correct encounter type softly.assertThat(encounter.getType()).hasSize(1); softly.assertThat(encounter.getTypeFirstRep().getCodingFirstRep().getCode()).isEqualTo("405672008"); - + // Assert all soft assertions softly.assertAll(); } - @Test - @Disabled + //@Disabled void testGeneratedJson() throws Exception { final var bundle = new Bundle(); final var demographicData = CsvTestHelper.createDemographicData(); From f6e4231ecf2a490a91d68026acb97ecb75c2e79f Mon Sep 17 00:00:00 2001 From: jewelbonnie Date: Thu, 19 Dec 2024 21:57:36 +0530 Subject: [PATCH 3/4] fix: Implement the removal of number of screenings from validation results in CSV validate api #745 --- .../java/org/techbd/orchestrate/csv/CsvOrchestrationEngine.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hub-prime/src/main/java/org/techbd/orchestrate/csv/CsvOrchestrationEngine.java b/hub-prime/src/main/java/org/techbd/orchestrate/csv/CsvOrchestrationEngine.java index 0431db2070c..44ecbbcc488 100644 --- a/hub-prime/src/main/java/org/techbd/orchestrate/csv/CsvOrchestrationEngine.java +++ b/hub-prime/src/main/java/org/techbd/orchestrate/csv/CsvOrchestrationEngine.java @@ -507,7 +507,6 @@ public Map generateValidationResults(final String masterInteract result.put("validationResults", combinedValidationResult); result.put("requestUri", request.getRequestURI()); result.put("zipFileSize", zipFileSize); - result.put("noOfScreenings", combinedValidationResult.size()); result.put("userAgent", userAgent); result.put("device", Map.of( "deviceId", device.deviceId(), From 0d703af6835691669d260f2ac778c1856c14b679 Mon Sep 17 00:00:00 2001 From: jewelbonnie Date: Fri, 20 Dec 2024 11:57:39 +0530 Subject: [PATCH 4/4] fix: Enable lazy resolution of multipart files in Spring configuration and solve data mapping issues in bundile api --- .../converters/csv/CsvToFhirConverter.java | 31 +++++++++++++------ hub-prime/src/main/resources/application.yml | 1 + .../service/csv/ConsentConverterTest.java | 7 +++-- ...alOrientationObservationConverterTest.java | 4 +-- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/hub-prime/src/main/java/org/techbd/service/converters/csv/CsvToFhirConverter.java b/hub-prime/src/main/java/org/techbd/service/converters/csv/CsvToFhirConverter.java index 8cd7ade69e3..a2b14c9823a 100644 --- a/hub-prime/src/main/java/org/techbd/service/converters/csv/CsvToFhirConverter.java +++ b/hub-prime/src/main/java/org/techbd/service/converters/csv/CsvToFhirConverter.java @@ -35,14 +35,15 @@ public CsvToFhirConverter(AppConfig appConfig, BundleConverter bundleConverter, } public String convert(DemographicData demographicData, - QeAdminData qeAdminData, ScreeningProfileData screeningProfileData, List screeningDataList, String interactionId) { + QeAdminData qeAdminData, ScreeningProfileData screeningProfileData, + List screeningDataList, String interactionId) { Bundle bundle = null; try { LOG.info("CsvToFhirConvereter::convert - BEGIN for interactionId :{}", interactionId); - bundle = bundleConverter.generateEmptyBundle(interactionId, appConfig.getIgVersion(),demographicData); + bundle = bundleConverter.generateEmptyBundle(interactionId, appConfig.getIgVersion(), demographicData); LOG.debug("CsvToFhirConvereter::convert - Bundle entry created :{}", interactionId); LOG.debug("Conversion of resources - BEGIN for interactionId :{}", interactionId); - addEntries(bundle, demographicData, screeningDataList, qeAdminData, screeningProfileData,interactionId); + addEntries(bundle, demographicData, screeningDataList, qeAdminData, screeningProfileData, interactionId); LOG.debug("Conversion of resources - END for interactionId :{}", interactionId); LOG.info("CsvToFhirConvereter::convert - END for interactionId :{}", interactionId); } catch (Exception ex) { @@ -50,14 +51,26 @@ public String convert(DemographicData demographicData, } return FhirContext.forR4().newJsonParser().encodeResourceToString(bundle); } - private void addEntries(Bundle bundle, DemographicData demographicData, List screeningObservationData, - QeAdminData qeAdminData,ScreeningProfileData screeningProfileData, String interactionId) { + + private void addEntries(Bundle bundle, DemographicData demographicData, + List screeningObservationData, + QeAdminData qeAdminData, ScreeningProfileData screeningProfileData, String interactionId) { List entries = new ArrayList<>(); - Map idsGenerated = new HashMap<>(); + Map idsGenerated = new HashMap<>(); + + // Iterate over the converters converters.stream().forEach(converter -> { - entries.addAll(converter.convert(bundle, demographicData, qeAdminData,screeningProfileData,screeningObservationData, interactionId,idsGenerated)); + try { + // Attempt to process using the current converter + entries.addAll(converter.convert(bundle, demographicData, qeAdminData, screeningProfileData, + screeningObservationData, interactionId, idsGenerated)); + } catch (Exception e) { + // Log the error and continue with other converters + LOG.error("Error occurred while processing converter: " + converter.getClass().getName(), e); + } }); + + // Add all successful entries to the bundle bundle.getEntry().addAll(entries); } - -} +} \ No newline at end of file diff --git a/hub-prime/src/main/resources/application.yml b/hub-prime/src/main/resources/application.yml index ed53b8c73d0..c4097877664 100644 --- a/hub-prime/src/main/resources/application.yml +++ b/hub-prime/src/main/resources/application.yml @@ -56,6 +56,7 @@ spring: max-file-size: 10MB max-request-size: 10MB file-size-threshold: 2MB + resolve-lazily: true springdoc: api-docs: path: /docs/api/openapi diff --git a/hub-prime/src/test/java/org/techbd/service/csv/ConsentConverterTest.java b/hub-prime/src/test/java/org/techbd/service/csv/ConsentConverterTest.java index 342096563d4..e8a85982a70 100644 --- a/hub-prime/src/test/java/org/techbd/service/csv/ConsentConverterTest.java +++ b/hub-prime/src/test/java/org/techbd/service/csv/ConsentConverterTest.java @@ -35,7 +35,7 @@ class ConsentConverterTest { private ConsentConverter consentConverter; @Test - @Disabled + //@Disabled void testConvert() throws Exception { // Create the necessary data objects for the test final Bundle bundle = new Bundle(); @@ -63,7 +63,8 @@ void testConvert() throws Exception { // Assert that the consent ID is not null or empty and matches expected softly.assertThat(consent.getId()).isNotEmpty(); - softly.assertThat(consent.getId()).isEqualTo("Consent-interactionId"); + softly.assertThat(consent.getId()).matches("[a-f0-9]{64}"); + // softly.assertThat(consent.getId()).isEqualTo("Consent-interactionId"); // Assert that the consent status is active softly.assertThat(consent.getStatus()).isEqualTo(Consent.ConsentState.ACTIVE); @@ -77,7 +78,7 @@ void testConvert() throws Exception { } @Test - @Disabled + // @Disabled void testGeneratedJson() throws Exception { final var bundle = new Bundle(); final var demographicData = CsvTestHelper.createDemographicData(); diff --git a/hub-prime/src/test/java/org/techbd/service/csv/SexualOrientationObservationConverterTest.java b/hub-prime/src/test/java/org/techbd/service/csv/SexualOrientationObservationConverterTest.java index 78cfe0c1759..95bcaa146e4 100644 --- a/hub-prime/src/test/java/org/techbd/service/csv/SexualOrientationObservationConverterTest.java +++ b/hub-prime/src/test/java/org/techbd/service/csv/SexualOrientationObservationConverterTest.java @@ -30,7 +30,7 @@ class SexualOrientationObservationConverterTest { private SexualOrientationObservationConverter sexualOrientationObservationConverter; @Test - @Disabled + //@Disabled void testConvert() throws Exception { final Bundle bundle = new Bundle(); final List screeningDataList = CsvTestHelper.createScreeningObservationData(); @@ -69,7 +69,7 @@ void testConvert() throws Exception { } @Test - @Disabled + //@Disabled void testGeneratedJson() throws Exception { final var bundle = new Bundle(); final var demographicData = CsvTestHelper.createDemographicData();