From 3f5276eb0ad6ed59b78598153c8db0e2dc72d4ac Mon Sep 17 00:00:00 2001 From: adongare Date: Fri, 1 Sep 2023 14:56:45 -0400 Subject: [PATCH 1/3] MAT-6093 MADiE measure exports - updates to IDs for measure and library resources MAT-6107 MADiE Measure exports - add fullURL and "PUT" request to every resource in bundle entry --- .../services/LibraryTranslatorService.java | 5 +---- .../madiefhirservice/services/MeasureBundleService.java | 6 +++++- .../services/MeasureTranslatorService.java | 7 ++++++- src/main/resources/application.yml | 2 ++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/gov/cms/madie/madiefhirservice/services/LibraryTranslatorService.java b/src/main/java/gov/cms/madie/madiefhirservice/services/LibraryTranslatorService.java index 2d1ed1c2..f59b1fc4 100644 --- a/src/main/java/gov/cms/madie/madiefhirservice/services/LibraryTranslatorService.java +++ b/src/main/java/gov/cms/madie/madiefhirservice/services/LibraryTranslatorService.java @@ -49,7 +49,7 @@ public LibraryTranslatorService(LibraryCqlVisitorFactory libCqlVisitorFactory) { public Library convertToFhirLibrary(CqlLibrary cqlLibrary) { var visitor = libCqlVisitorFactory.visit(cqlLibrary.getCql()); Library library = new Library(); - library.setId(cqlLibrary.getId()); + library.setId(cqlLibrary.getCqlLibraryName()); library.setLanguage("en"); library.setName(cqlLibrary.getCqlLibraryName()); library.setVersion(cqlLibrary.getVersion().toString()); @@ -75,9 +75,6 @@ public Library convertToFhirLibrary(CqlLibrary cqlLibrary) { identifier.setSystem("https://madie.cms.gov/login"); identifier.setValue(cqlLibrary.getId()); library.setIdentifier(List.of(identifier)); - - // TODO: probably have to revisit this. Human Readable feature is not yet ready - // result.setText(findHumanReadable(lib.getMeasureId())); return library; } diff --git a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java index e479f979..d19a6781 100644 --- a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java +++ b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java @@ -108,7 +108,11 @@ public List createBundleComponentsForLibrariesOfMad /** Creates BundleEntryComponent for given resource */ public Bundle.BundleEntryComponent getBundleEntryComponent(Resource resource) { - return new Bundle.BundleEntryComponent().setResource(resource); + Bundle.HTTPVerb bundleVerb = Bundle.HTTPVerb.fromCode("PUT"); + String url = resource.getResourceType() + "/" + resource.getId(); + Bundle.BundleEntryRequestComponent requestComponent = + new Bundle.BundleEntryRequestComponent().setMethod(bundleVerb).setUrl(url); + return new Bundle.BundleEntryComponent().setResource(resource).setRequest(requestComponent); } /** diff --git a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java index a36700f0..748fed3c 100644 --- a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java +++ b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java @@ -33,6 +33,7 @@ import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.*; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import gov.cms.madie.madiefhirservice.constants.UriConstants; @@ -45,6 +46,9 @@ public class MeasureTranslatorService { public static final String UNKNOWN = "UNKNOWN"; + @Value("${madie.url}") + private String madieUrl; + public org.hl7.fhir.r4.model.Measure createFhirMeasureForMadieMeasure(Measure madieMeasure) { Organization steward = madieMeasure.getMeasureMetaData().getSteward(); String copyright = madieMeasure.getMeasureMetaData().getCopyright(); @@ -91,7 +95,8 @@ public org.hl7.fhir.r4.model.Measure createFhirMeasureForMadieMeasure(Measure ma madieMeasure.getMeasureMetaData().getClinicalRecommendation()) .setDate(Date.from(madieMeasure.getLastModifiedAt())) .setMeta(buildMeasureMeta()); - + measure.setId(madieMeasure.getCqlLibraryName()); + measure.setUrl(madieUrl + "/Measure/" + madieMeasure.getCqlLibraryName()); for (Extension ext : buildExtensions(madieMeasure)) { measure.addExtension(ext); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d9b7ae4f..38895971 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -19,6 +19,8 @@ madie: baseUrl: ${CQL_LIBRARY_SERVICE_URL:http://localhost:8082/api} versioned: uri: /cql-libraries/versioned + url: ${MADIE_URL:https://madie.cms.gov} + #springdoc: # swagger-ui: # path: ${SWAGGER_PATH:/swagger} From 452a0fc7fdec306d5302c688e2ff1b87257f5360 Mon Sep 17 00:00:00 2001 From: adongare Date: Wed, 6 Sep 2023 11:21:24 -0400 Subject: [PATCH 2/3] MAT-6093, MAT-6107 and MAT-6147 --- .../services/MeasureBundleService.java | 12 ++++++--- .../services/MeasureTranslatorService.java | 10 +++---- .../services/TestCaseBundleService.java | 7 ++--- .../utils/FhirResourceHelpers.java | 26 +++++++++++++++---- .../LibraryTranslatorServiceTest.java | 3 ++- .../services/MeasureBundleServiceTest.java | 10 ++++++- .../MeasureTranslatorServiceTest.java | 12 ++++++--- .../services/TestCaseBundleServiceTest.java | 11 ++++---- .../SimpleFhirMeasureLib/fhir_measure.json | 1 + 9 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java index d19a6781..e6b617f7 100644 --- a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java +++ b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureBundleService.java @@ -3,6 +3,7 @@ import gov.cms.madie.madiefhirservice.constants.UriConstants; import gov.cms.madie.madiefhirservice.hapi.HapiFhirServer; import gov.cms.madie.madiefhirservice.utils.BundleUtil; +import gov.cms.madie.madiefhirservice.utils.FhirResourceHelpers; import gov.cms.madie.madiefhirservice.utils.ResourceUtils; import gov.cms.madie.models.library.CqlLibrary; import gov.cms.madie.models.measure.Measure; @@ -108,11 +109,14 @@ public List createBundleComponentsForLibrariesOfMad /** Creates BundleEntryComponent for given resource */ public Bundle.BundleEntryComponent getBundleEntryComponent(Resource resource) { - Bundle.HTTPVerb bundleVerb = Bundle.HTTPVerb.fromCode("PUT"); - String url = resource.getResourceType() + "/" + resource.getId(); Bundle.BundleEntryRequestComponent requestComponent = - new Bundle.BundleEntryRequestComponent().setMethod(bundleVerb).setUrl(url); - return new Bundle.BundleEntryComponent().setResource(resource).setRequest(requestComponent); + new Bundle.BundleEntryRequestComponent() + .setMethod(Bundle.HTTPVerb.PUT) + .setUrl(resource.getResourceType() + "/" + resource.getIdPart()); + return new Bundle.BundleEntryComponent() + .setFullUrl(FhirResourceHelpers.getFullUrl(resource)) + .setResource(resource) + .setRequest(requestComponent); } /** diff --git a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java index 748fed3c..73a2d8fc 100644 --- a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java +++ b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java @@ -33,7 +33,6 @@ import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.*; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import gov.cms.madie.madiefhirservice.constants.UriConstants; @@ -46,9 +45,6 @@ public class MeasureTranslatorService { public static final String UNKNOWN = "UNKNOWN"; - @Value("${madie.url}") - private String madieUrl; - public org.hl7.fhir.r4.model.Measure createFhirMeasureForMadieMeasure(Measure madieMeasure) { Organization steward = madieMeasure.getMeasureMetaData().getSteward(); String copyright = madieMeasure.getMeasureMetaData().getCopyright(); @@ -63,7 +59,7 @@ public org.hl7.fhir.r4.model.Measure createFhirMeasureForMadieMeasure(Measure ma .setTitle(madieMeasure.getMeasureName()) .setIdentifier(buildMeasureIdentifiers(madieMeasure)) .setExperimental(madieMeasure.getMeasureMetaData().isExperimental()) - .setUrl(FhirResourceHelpers.buildMeasureUrl(madieMeasure)) + .setUrl(FhirResourceHelpers.buildMeasureUrl(madieMeasure.getCqlLibraryName())) .setVersion(madieMeasure.getVersion().toString()) .setEffectivePeriod( getPeriodFromDates( @@ -79,7 +75,8 @@ public org.hl7.fhir.r4.model.Measure createFhirMeasureForMadieMeasure(Measure ma .setRationale(rationale) .setLibrary( Collections.singletonList( - new CanonicalType(FhirResourceHelpers.buildLibraryUrl(madieMeasure)))) + new CanonicalType( + FhirResourceHelpers.buildLibraryUrl(madieMeasure.getCqlLibraryName())))) .setPurpose(UNKNOWN) .setContact(buildContactDetail(madieMeasure.getMeasureMetaData().getSteward(), false)) .setGroup(buildGroups(madieMeasure.getGroups())) @@ -96,7 +93,6 @@ public org.hl7.fhir.r4.model.Measure createFhirMeasureForMadieMeasure(Measure ma .setDate(Date.from(madieMeasure.getLastModifiedAt())) .setMeta(buildMeasureMeta()); measure.setId(madieMeasure.getCqlLibraryName()); - measure.setUrl(madieUrl + "/Measure/" + madieMeasure.getCqlLibraryName()); for (Extension ext : buildExtensions(madieMeasure)) { measure.addExtension(ext); } diff --git a/src/main/java/gov/cms/madie/madiefhirservice/services/TestCaseBundleService.java b/src/main/java/gov/cms/madie/madiefhirservice/services/TestCaseBundleService.java index 543ad0bb..c9099132 100644 --- a/src/main/java/gov/cms/madie/madiefhirservice/services/TestCaseBundleService.java +++ b/src/main/java/gov/cms/madie/madiefhirservice/services/TestCaseBundleService.java @@ -73,10 +73,7 @@ public Map getTestCaseExportBundle(Measure measure, List Date: Wed, 6 Sep 2023 11:45:34 -0400 Subject: [PATCH 3/3] MAT-6093 fixing tests --- .../services/MeasureTranslatorService.java | 5 +++-- .../services/MeasureTranslatorServiceTest.java | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java index 73a2d8fc..33a29a15 100644 --- a/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java +++ b/src/main/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorService.java @@ -91,8 +91,9 @@ public org.hl7.fhir.r4.model.Measure createFhirMeasureForMadieMeasure(Measure ma .setClinicalRecommendationStatement( madieMeasure.getMeasureMetaData().getClinicalRecommendation()) .setDate(Date.from(madieMeasure.getLastModifiedAt())) - .setMeta(buildMeasureMeta()); - measure.setId(madieMeasure.getCqlLibraryName()); + .setMeta(buildMeasureMeta()) + .setId(madieMeasure.getCqlLibraryName()); + for (Extension ext : buildExtensions(madieMeasure)) { measure.addExtension(ext); } diff --git a/src/test/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorServiceTest.java b/src/test/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorServiceTest.java index dd519e0b..3ac58654 100644 --- a/src/test/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorServiceTest.java +++ b/src/test/java/gov/cms/madie/madiefhirservice/services/MeasureTranslatorServiceTest.java @@ -82,8 +82,7 @@ public void setUp() throws JsonProcessingException { getStringFromTestResource("/measures/SimpleFhirMeasureLib/madie_cv_measure.json"); madieCVMeasure = MeasureTestHelper.createMadieMeasureFromJson(cvMeasureJson); ReflectionTestUtils.setField(fhirResourceHelpers, "fhirBaseUrl", "cms.gov"); - ReflectionTestUtils.setField(fhirResourceHelpers, "fhirBaseUrl", "cms.gov"); - ReflectionTestUtils.setField(fhirResourceHelpers, "madieUrl", "https://madie.cms.gov"); + ReflectionTestUtils.setField(fhirResourceHelpers, "madieUrl", "madie.cms.gov"); } @Test @@ -97,8 +96,7 @@ public void testCreateFhirMeasureForMadieMeasure() { measure.getRationale(), is(equalTo(madieMeasure.getMeasureMetaData().getRationale()))); assertThat(measure.getPublisher(), is(equalTo("UNKNOWN"))); assertThat( - measure.getUrl(), - is(equalTo("https://madie.cms.gov/Measure/" + madieMeasure.getCqlLibraryName()))); + measure.getUrl(), is(equalTo("madie.cms.gov/Measure/" + madieMeasure.getCqlLibraryName()))); assertThat( DateFormatUtils.format(measure.getEffectivePeriod().getStart(), "MM/dd/yyyy"), is(equalTo("01/01/2023"))); @@ -285,7 +283,7 @@ public void testCreateFhirMeasureForMadieRatioMeasure() { assertThat(measure.getDisclaimer(), is(equalTo("testDisclaimer"))); assertThat( measure.getUrl(), - is(equalTo("https://madie.cms.gov/Measure/" + madieRatioMeasure.getCqlLibraryName()))); + is(equalTo("madie.cms.gov/Measure/" + madieRatioMeasure.getCqlLibraryName()))); assertThat( DateFormatUtils.format(measure.getEffectivePeriod().getStart(), "MM/dd/yyyy"), is(equalTo("01/01/2023"))); @@ -412,7 +410,7 @@ public void testCreateFhirMeasureForMadieCVMeasure() { measure.getRationale(), is(equalTo(madieCVMeasure.getMeasureMetaData().getRationale()))); assertThat( measure.getUrl(), - is(equalTo("https://madie.cms.gov/Measure/" + madieCVMeasure.getCqlLibraryName()))); + is(equalTo("madie.cms.gov/Measure/" + madieCVMeasure.getCqlLibraryName()))); assertThat( DateFormatUtils.format(measure.getEffectivePeriod().getStart(), "MM/dd/yyyy"), is(equalTo("01/01/2022")));