From e2eeabbe48c0e22fafe76ecf1414bed0e232a556 Mon Sep 17 00:00:00 2001 From: Ethan Kaplan Date: Fri, 17 May 2024 08:56:17 -0700 Subject: [PATCH 01/11] MAT-7209 change empty stratification behavior to display none instead of nothing --- .../gov/cms/madie/services/HumanReadableService.java | 12 +++++++++++- .../cms/madie/services/HumanReadableServiceTest.java | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/cms/madie/services/HumanReadableService.java b/src/main/java/gov/cms/madie/services/HumanReadableService.java index 3f2624c..a180015 100644 --- a/src/main/java/gov/cms/madie/services/HumanReadableService.java +++ b/src/main/java/gov/cms/madie/services/HumanReadableService.java @@ -244,7 +244,17 @@ List buildPopulations( List buildStratification( Group group, Set allDefinitions) { if (CollectionUtils.isEmpty(group.getStratifications())) { - return Collections.emptyList(); + HumanReadablePopulationModel E = + HumanReadablePopulationModel.builder() + .name("Stratification") + .display("Stratification") + .logic("None") + .id("None") + .inGroup(false) + .expressionName("None") + .build(); + + return new ArrayList(Arrays.asList(E)); } return group.getStratifications().stream() diff --git a/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java b/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java index 9fa4ff6..d281d95 100644 --- a/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java +++ b/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java @@ -561,7 +561,8 @@ public void testbuildStratificationWithNoStratifications() { group.setStratifications(null); List model = humanReadableService.buildStratification(group, allDefinitions); - assertThat(CollectionUtils.isEmpty(model), is(true)); + assertThat(CollectionUtils.isEmpty(model), is(false)); + assertThat(model.get(0).getLogic(), is("None")); } @Test From 14ef06cf69b96f5ca07f5247d9e279b03534c9a2 Mon Sep 17 00:00:00 2001 From: Ethan Kaplan Date: Fri, 17 May 2024 09:10:59 -0700 Subject: [PATCH 02/11] MAT-7209 better variable name --- .../java/gov/cms/madie/services/HumanReadableService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/cms/madie/services/HumanReadableService.java b/src/main/java/gov/cms/madie/services/HumanReadableService.java index a180015..9fc6275 100644 --- a/src/main/java/gov/cms/madie/services/HumanReadableService.java +++ b/src/main/java/gov/cms/madie/services/HumanReadableService.java @@ -244,7 +244,7 @@ List buildPopulations( List buildStratification( Group group, Set allDefinitions) { if (CollectionUtils.isEmpty(group.getStratifications())) { - HumanReadablePopulationModel E = + HumanReadablePopulationModel emptyStrat = HumanReadablePopulationModel.builder() .name("Stratification") .display("Stratification") @@ -254,7 +254,7 @@ List buildStratification( .expressionName("None") .build(); - return new ArrayList(Arrays.asList(E)); + return new ArrayList(Arrays.asList(emptyStrat)); } return group.getStratifications().stream() From 130b48e03389e3f1e87fb3083c46c58383101777 Mon Sep 17 00:00:00 2001 From: Ethan Kaplan Date: Fri, 24 May 2024 11:05:25 -0700 Subject: [PATCH 03/11] MAT-7199 Add a pluralizor to exclusions and exceptions in human readable --- .../gov/cms/madie/services/HumanReadableService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/gov/cms/madie/services/HumanReadableService.java b/src/main/java/gov/cms/madie/services/HumanReadableService.java index 9cee627..03a0860 100644 --- a/src/main/java/gov/cms/madie/services/HumanReadableService.java +++ b/src/main/java/gov/cms/madie/services/HumanReadableService.java @@ -230,7 +230,7 @@ List buildPopulations( HumanReadablePopulationModel.builder() .name(population.getName().name()) .id(population.getId()) - .display(population.getName().getDisplay()) + .display(exclusionDisplayPluralizor(population.getName().getDisplay())) .logic( HumanReadableUtil.getCQLDefinitionLogic( population.getDefinition(), allDefinitions)) @@ -456,4 +456,11 @@ List buildRiskAdjustmentVariables( .build()) .collect(Collectors.toList()); } + + String exclusionDisplayPluralizor(String display) { + if (display.endsWith("Exclusion") || display.endsWith("Exception")) { + return display + "s"; + } + return display; + } } From 440e213fbd7f0152651c5d62fb977d951adb4742 Mon Sep 17 00:00:00 2001 From: Rohit Kandimalla Date: Wed, 29 May 2024 07:12:43 -0400 Subject: [PATCH 04/11] MAT-7055 Routing elm translation calls to QDM specific service --- src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2878146..00fc558 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,7 +7,7 @@ madie: allowedApi: http://localhost:9000 cql-elm: service: - base-url: ${ELM_TRANSLATOR_SERVICE_URL:http://localhost:8084/api} + base-url: ${ELM_TRANSLATOR_SERVICE_URL:http://localhost:8084/api/qdm} cql-elm-urn: /cql/elm cql-lookups: /cql/lookups relevant-data-elements: /cql/relevant-elements @@ -30,4 +30,4 @@ logging: okta: oauth2: issuer: ${OKTA_ISSUER:https://dev-18092578.okta.com/oauth2/default} - audience: ${OKTA_AUDIENCE:api://default} \ No newline at end of file + audience: ${OKTA_AUDIENCE:api://default} From a625f72a8d4a4aa01bda8425347d55c4761648cf Mon Sep 17 00:00:00 2001 From: Joseph Kotanchik Date: Tue, 14 May 2024 10:21:58 -0400 Subject: [PATCH 05/11] MAT-6835: Pass DTO with test case stats to QRDA service for top level summary file. Rename ...Dto to ...DTO to be consistent. --- .../madie/dto/{QRDADto.java => QrdaDTO.java} | 6 +++++- .../cms/madie/dto/QrdaExportResponseDto.java | 2 +- ...{QrdaReportDto.java => QrdaReportDTO.java} | 2 +- .../gov/cms/madie/dto/QrdaRequestDTO.java | 20 +++++++++++++++++++ .../madie/resources/PackageController.java | 6 ++++-- .../cms/madie/services/PackagingService.java | 18 +++++++++-------- .../gov/cms/madie/services/QrdaClient.java | 4 ++-- .../gov/cms/madie/services/QrdaService.java | 15 +++++++++----- .../resources/PackageControllerTest.java | 13 ++++++++---- .../services/CqmConversionServiceTest.java | 6 +++--- .../madie/services/PackagingServiceTest.java | 10 ++++++---- .../cms/madie/services/QrdaServiceTest.java | 14 +++++++------ 12 files changed, 79 insertions(+), 37 deletions(-) rename src/main/java/gov/cms/madie/dto/{QRDADto.java => QrdaDTO.java} (76%) rename src/main/java/gov/cms/madie/dto/{QrdaReportDto.java => QrdaReportDTO.java} (89%) create mode 100644 src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java diff --git a/src/main/java/gov/cms/madie/dto/QRDADto.java b/src/main/java/gov/cms/madie/dto/QrdaDTO.java similarity index 76% rename from src/main/java/gov/cms/madie/dto/QRDADto.java rename to src/main/java/gov/cms/madie/dto/QrdaDTO.java index 741397e..5b6f51a 100644 --- a/src/main/java/gov/cms/madie/dto/QRDADto.java +++ b/src/main/java/gov/cms/madie/dto/QrdaDTO.java @@ -12,11 +12,15 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class QRDADto { +public class QrdaDTO { String measure; List testCases; // TODO waiting for SME feedback List sourceDataCriteria; + String coveragePercentage; + Integer passPercentage; + String passFailRatio; Object options; + Object[] testCaseDtos; } diff --git a/src/main/java/gov/cms/madie/dto/QrdaExportResponseDto.java b/src/main/java/gov/cms/madie/dto/QrdaExportResponseDto.java index 72cb0ba..e51f8e4 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaExportResponseDto.java +++ b/src/main/java/gov/cms/madie/dto/QrdaExportResponseDto.java @@ -13,5 +13,5 @@ @AllArgsConstructor public class QrdaExportResponseDto { String summaryReport; - List individualReports; + List individualReports; } diff --git a/src/main/java/gov/cms/madie/dto/QrdaReportDto.java b/src/main/java/gov/cms/madie/dto/QrdaReportDTO.java similarity index 89% rename from src/main/java/gov/cms/madie/dto/QrdaReportDto.java rename to src/main/java/gov/cms/madie/dto/QrdaReportDTO.java index 5b2e9f9..b41fb11 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaReportDto.java +++ b/src/main/java/gov/cms/madie/dto/QrdaReportDTO.java @@ -9,7 +9,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class QrdaReportDto { +public class QrdaReportDTO { String qrda; String report; String filename; diff --git a/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java b/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java new file mode 100644 index 0000000..5d80343 --- /dev/null +++ b/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java @@ -0,0 +1,20 @@ +package gov.cms.madie.dto; + +import gov.cms.madie.models.measure.Measure; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class QrdaRequestDTO { + Measure measure; + String coveragePercentage; + Integer passPercentage; + String passFailRatio; + Object options; + Object[] testCaseDtos; +} diff --git a/src/main/java/gov/cms/madie/resources/PackageController.java b/src/main/java/gov/cms/madie/resources/PackageController.java index b11b4c8..58af6f1 100644 --- a/src/main/java/gov/cms/madie/resources/PackageController.java +++ b/src/main/java/gov/cms/madie/resources/PackageController.java @@ -2,6 +2,7 @@ import gov.cms.madie.Exceptions.UnsupportedModelException; import gov.cms.madie.dto.CqlLookups; +import gov.cms.madie.dto.QrdaRequestDTO; import gov.cms.madie.models.measure.QdmMeasure; import gov.cms.madie.services.*; import gov.cms.madie.models.measure.Measure; @@ -103,12 +104,13 @@ public ResponseEntity generateHqmf( }, consumes = {MediaType.APPLICATION_JSON_VALUE}) public byte[] getQRDA( - @RequestBody @Validated(Measure.ValidationSequence.class) Measure measure, + @RequestBody QrdaRequestDTO qrdaRequestDTO, @RequestHeader("Authorization") String accessToken) { + Measure measure = qrdaRequestDTO.getMeasure(); log.info("export QRDA for measure [{}] ", measure.getId()); // generate QRDA if the model type is QDM if (measure.getModel() != null && measure.getModel().contains("QDM")) { - return packagingService.createQRDA(measure, accessToken); + return packagingService.createQRDA(qrdaRequestDTO, accessToken); } throw new UnsupportedModelException("Unsupported model type: " + measure.getModel()); } diff --git a/src/main/java/gov/cms/madie/services/PackagingService.java b/src/main/java/gov/cms/madie/services/PackagingService.java index 39a73f7..6301059 100644 --- a/src/main/java/gov/cms/madie/services/PackagingService.java +++ b/src/main/java/gov/cms/madie/services/PackagingService.java @@ -2,7 +2,8 @@ import gov.cms.madie.dto.CqlLookups; import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDto; +import gov.cms.madie.dto.QrdaReportDTO; +import gov.cms.madie.dto.QrdaRequestDTO; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.Measure; import gov.cms.madie.models.measure.QdmMeasure; @@ -68,10 +69,12 @@ public byte[] createMeasurePackage(Measure measure, String accessToken) { return new ZipUtility().zipEntries(entries, outputStream); } - public byte[] createQRDA(Measure measure, String accessToken) { + public byte[] createQRDA(QrdaRequestDTO qrdaRequestDTO, String accessToken) { + QdmMeasure measure = (QdmMeasure) qrdaRequestDTO.getMeasure(); log.info("Creating QRDA for measure [{}]", measure.getId()); - QrdaExportResponseDto qrdaExport = qrdaService.generateQrda((QdmMeasure) measure, accessToken); + QrdaExportResponseDto qrdaExport = qrdaService.generateQrda(qrdaRequestDTO, accessToken); + if (CollectionUtils.isEmpty(qrdaExport.getIndividualReports())) { return new byte[0]; } @@ -81,11 +84,10 @@ public byte[] createQRDA(Measure measure, String accessToken) { String htmlDir = "/html/"; String qrdaDir = "/qrda/"; Map entries = new HashMap<>(); - // TODO MAT-6835: Exclude top level summary until completion of this story. - // entries.put( - // "/" + measure.getEcqmTitle() + "_patients_results.html", - // qrdaExport.getSummaryReport().getBytes()); - for (QrdaReportDto qrda : qrdaExport.getIndividualReports()) { + entries.put( + "/" + measure.getEcqmTitle() + "_patients_results.html", + qrdaExport.getSummaryReport().getBytes()); + for (QrdaReportDTO qrda : qrdaExport.getIndividualReports()) { entries.put(qrdaDir + qrda.getFilename() + ".xml", qrda.getQrda().getBytes()); entries.put(htmlDir + qrda.getFilename() + ".html", qrda.getReport().getBytes()); } diff --git a/src/main/java/gov/cms/madie/services/QrdaClient.java b/src/main/java/gov/cms/madie/services/QrdaClient.java index d85f530..ee5a8a3 100644 --- a/src/main/java/gov/cms/madie/services/QrdaClient.java +++ b/src/main/java/gov/cms/madie/services/QrdaClient.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import gov.cms.madie.Exceptions.TranslationServiceException; import gov.cms.madie.config.QrdaClientConfig; -import gov.cms.madie.dto.QRDADto; +import gov.cms.madie.dto.QrdaDTO; import gov.cms.madie.dto.QrdaExportResponseDto; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -27,7 +27,7 @@ public class QrdaClient { @Autowired private ObjectMapper mapper; - public QrdaExportResponseDto getQRDA(QRDADto dto, String accessToken, String measureId) { + public QrdaExportResponseDto getQRDA(QrdaDTO dto, String accessToken, String measureId) { URI uri = URI.create(qrdaClientConfig.getBaseUrl() + qrdaClientConfig.getQrda()); HttpHeaders headers = new HttpHeaders(); headers.set(HttpHeaders.AUTHORIZATION, accessToken); diff --git a/src/main/java/gov/cms/madie/services/QrdaService.java b/src/main/java/gov/cms/madie/services/QrdaService.java index 995573b..e73c99e 100644 --- a/src/main/java/gov/cms/madie/services/QrdaService.java +++ b/src/main/java/gov/cms/madie/services/QrdaService.java @@ -3,8 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import gov.cms.madie.Exceptions.QrdaServiceException; -import gov.cms.madie.dto.QRDADto; +import gov.cms.madie.dto.QrdaDTO; import gov.cms.madie.dto.QrdaExportResponseDto; +import gov.cms.madie.dto.QrdaRequestDTO; import gov.cms.madie.dto.SourceDataCriteria; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.QdmMeasure; @@ -30,7 +31,8 @@ public class QrdaService { private final QrdaClient client; private final ObjectMapper objectMapper; - public QrdaExportResponseDto generateQrda(QdmMeasure measure, String accessToken) { + public QrdaExportResponseDto generateQrda(QrdaRequestDTO request, String accessToken) { + QdmMeasure measure = (QdmMeasure) request.getMeasure(); // get Libraries List translatedLibraries = translationServiceClient.getTranslatedLibraries(measure.getCql(), accessToken); @@ -42,16 +44,19 @@ public QrdaExportResponseDto generateQrda(QdmMeasure measure, String accessToken List dataCriteria = translationServiceClient.getRelevantDataElements(measure, accessToken); - QRDADto dto = null; + QrdaDTO dto = null; try { - dto = - QRDADto.builder() + QrdaDTO.builder() .measure( objectMapper.writeValueAsString(mapper.measureToCqmMeasure(measure, elms, null))) .testCases(measure.getTestCases()) .sourceDataCriteria(dataCriteria) + .coveragePercentage(request.getCoveragePercentage()) + .passPercentage(request.getPassPercentage()) + .passFailRatio(request.getPassFailRatio()) .options(buildOptions(measure)) + .testCaseDtos(request.getTestCaseDtos()) .build(); } catch (JsonProcessingException e) { throw new QrdaServiceException("Problem mapping the measure for QRDA generation", e); diff --git a/src/test/java/gov/cms/madie/resources/PackageControllerTest.java b/src/test/java/gov/cms/madie/resources/PackageControllerTest.java index 03f5506..c6585df 100644 --- a/src/test/java/gov/cms/madie/resources/PackageControllerTest.java +++ b/src/test/java/gov/cms/madie/resources/PackageControllerTest.java @@ -2,6 +2,7 @@ import gov.cms.madie.Exceptions.UnsupportedModelException; import gov.cms.madie.dto.CqlLookups; +import gov.cms.madie.dto.QrdaRequestDTO; import gov.cms.madie.models.measure.FhirMeasure; import gov.cms.madie.models.measure.QdmMeasure; import gov.cms.madie.services.HqmfService; @@ -150,8 +151,10 @@ void testGenerateHqmfReturnsHqmf() throws Exception { @Test void testGetQRDASuccess() { String qrda = "test QRDA"; - when(packagingService.createQRDA(measure, TOKEN)).thenReturn(qrda.getBytes()); - byte[] result = packageController.getQRDA(measure, TOKEN); + when(packagingService.createQRDA(QrdaRequestDTO.builder().measure(measure).build(), TOKEN)) + .thenReturn(qrda.getBytes()); + byte[] result = + packageController.getQRDA(QrdaRequestDTO.builder().measure(measure).build(), TOKEN); assertThat(new String(result), is(equalTo(qrda))); } @@ -162,7 +165,8 @@ void testGetQRDAIfModelIsNull() { Exception ex = Assertions.assertThrows( UnsupportedModelException.class, - () -> packageController.getQRDA(measure, TOKEN), + () -> + packageController.getQRDA(QrdaRequestDTO.builder().measure(measure).build(), TOKEN), errorMessage); assertThat(ex.getMessage(), is(equalTo(errorMessage))); } @@ -174,7 +178,8 @@ void testGetQRDAForUnsupportedModel() { Exception ex = Assertions.assertThrows( UnsupportedModelException.class, - () -> packageController.getQRDA(measure, TOKEN), + () -> + packageController.getQRDA(QrdaRequestDTO.builder().measure(measure).build(), TOKEN), errorMessage); assertThat(ex.getMessage(), is(equalTo(errorMessage))); } diff --git a/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java b/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java index 661dc2b..72a880a 100644 --- a/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java +++ b/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java @@ -2,7 +2,7 @@ import gov.cms.madie.Exceptions.CqmConversionException; import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDto; +import gov.cms.madie.dto.QrdaReportDTO; import gov.cms.madie.dto.SourceDataCriteria; import gov.cms.madie.models.common.ModelType; import gov.cms.madie.models.cqm.CqmMeasure; @@ -68,8 +68,8 @@ void convertMadieMeasureToCqmMeasure() throws Exception { when(mapper.measureToCqmMeasure(any(QdmMeasure.class), any(List.class), any(List.class))) .thenReturn(cqmMeasure); - List qrdaExport = - List.of(QrdaReportDto.builder().qrda("qrda").filename("1_test").report("report").build()); + List qrdaExport = + List.of(QrdaReportDTO.builder().qrda("qrda").filename("1_test").report("report").build()); QrdaExportResponseDto clientResponse = QrdaExportResponseDto.builder() .summaryReport("summaryReport") diff --git a/src/test/java/gov/cms/madie/services/PackagingServiceTest.java b/src/test/java/gov/cms/madie/services/PackagingServiceTest.java index 6c65919..fb5e683 100644 --- a/src/test/java/gov/cms/madie/services/PackagingServiceTest.java +++ b/src/test/java/gov/cms/madie/services/PackagingServiceTest.java @@ -3,7 +3,8 @@ import gov.cms.madie.Exceptions.TranslationServiceException; import gov.cms.madie.dto.CqlLookups; import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDto; +import gov.cms.madie.dto.QrdaReportDTO; +import gov.cms.madie.dto.QrdaRequestDTO; import gov.cms.madie.models.common.ModelType; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.Measure; @@ -154,19 +155,20 @@ void testCreateMeasurePackageWhenHqmfGenerationFailed() { @Test void testCreateQRDA() { - when(qrdaService.generateQrda(any(QdmMeasure.class), any(String.class))) + when(qrdaService.generateQrda(any(QrdaRequestDTO.class), any(String.class))) .thenReturn( QrdaExportResponseDto.builder() .summaryReport("summaryReport") .individualReports( List.of( - QrdaReportDto.builder() + QrdaReportDTO.builder() .qrda("qrda") .filename("1_test") .report("report") .build())) .build()); - byte[] qrda = packagingService.createQRDA(measure, TOKEN); + byte[] qrda = + packagingService.createQRDA(QrdaRequestDTO.builder().measure(measure).build(), TOKEN); assertThat(new String(qrda), containsString("qrda/")); assertThat(new String(qrda), containsString("1_test.xml")); diff --git a/src/test/java/gov/cms/madie/services/QrdaServiceTest.java b/src/test/java/gov/cms/madie/services/QrdaServiceTest.java index 71736f0..3d183e0 100644 --- a/src/test/java/gov/cms/madie/services/QrdaServiceTest.java +++ b/src/test/java/gov/cms/madie/services/QrdaServiceTest.java @@ -3,15 +3,16 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import gov.cms.madie.Exceptions.QrdaServiceException; -import gov.cms.madie.dto.QRDADto; +import gov.cms.madie.dto.QrdaDTO; import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDto; +import gov.cms.madie.dto.QrdaReportDTO; import gov.cms.madie.dto.SourceDataCriteria; import gov.cms.madie.models.common.ModelType; import gov.cms.madie.models.cqm.CqmMeasure; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.*; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; @@ -59,6 +60,7 @@ void setUp() { } @Test + @Disabled //TODO void convertToCqmMeasure() throws Exception { CqmMeasure cqmMeasure = CqmMeasure.builder().id("1").description("test").build(); when(translationServiceClient.getTranslatedLibraries(any(String.class), any(String.class))) @@ -71,9 +73,9 @@ void convertToCqmMeasure() throws Exception { when(objectMapper.writeValueAsString(any(CqmMeasure.class))).thenReturn(cqmMeasure.toString()); - ArgumentCaptor captor = ArgumentCaptor.forClass(QRDADto.class); - List qrdaExport = - List.of(QrdaReportDto.builder().qrda("qrda").filename("1_test").report("report").build()); + ArgumentCaptor captor = ArgumentCaptor.forClass(QrdaDTO.class); + List qrdaExport = + List.of(QrdaReportDTO.builder().qrda("qrda").filename("1_test").report("report").build()); QrdaExportResponseDto clientResponse = QrdaExportResponseDto.builder() .summaryReport("summaryReport") @@ -84,7 +86,7 @@ void convertToCqmMeasure() throws Exception { QrdaExportResponseDto result = qrdaService.generateQrda(qdmMeasure, "testToken"); - QRDADto dto = captor.getValue(); + QrdaDTO dto = captor.getValue(); assertTrue(dto.getMeasure().contains("test")); assertFalse(dto.getTestCases().isEmpty()); assertEquals(1, dto.getTestCases().size()); From a281ee133a23f3c67aa4cf55b673136b4bc5df7f Mon Sep 17 00:00:00 2001 From: Joseph Kotanchik Date: Wed, 29 May 2024 14:53:02 -0400 Subject: [PATCH 06/11] MAT-6835: Reworking QRDA DTOs, removing pass/fail and moving coverage percentage into testCaseDTOs. --- src/main/java/gov/cms/madie/dto/QrdaDTO.java | 3 --- src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java | 3 --- src/main/java/gov/cms/madie/services/QrdaService.java | 3 --- 3 files changed, 9 deletions(-) diff --git a/src/main/java/gov/cms/madie/dto/QrdaDTO.java b/src/main/java/gov/cms/madie/dto/QrdaDTO.java index 5b6f51a..2c9937b 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaDTO.java +++ b/src/main/java/gov/cms/madie/dto/QrdaDTO.java @@ -18,9 +18,6 @@ public class QrdaDTO { List testCases; // TODO waiting for SME feedback List sourceDataCriteria; - String coveragePercentage; - Integer passPercentage; - String passFailRatio; Object options; Object[] testCaseDtos; } diff --git a/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java b/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java index 5d80343..e22a765 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java +++ b/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java @@ -12,9 +12,6 @@ @Builder(toBuilder = true) public class QrdaRequestDTO { Measure measure; - String coveragePercentage; - Integer passPercentage; - String passFailRatio; Object options; Object[] testCaseDtos; } diff --git a/src/main/java/gov/cms/madie/services/QrdaService.java b/src/main/java/gov/cms/madie/services/QrdaService.java index e73c99e..9c6cd3c 100644 --- a/src/main/java/gov/cms/madie/services/QrdaService.java +++ b/src/main/java/gov/cms/madie/services/QrdaService.java @@ -52,9 +52,6 @@ public QrdaExportResponseDto generateQrda(QrdaRequestDTO request, String accessT objectMapper.writeValueAsString(mapper.measureToCqmMeasure(measure, elms, null))) .testCases(measure.getTestCases()) .sourceDataCriteria(dataCriteria) - .coveragePercentage(request.getCoveragePercentage()) - .passPercentage(request.getPassPercentage()) - .passFailRatio(request.getPassFailRatio()) .options(buildOptions(measure)) .testCaseDtos(request.getTestCaseDtos()) .build(); From aaf8b7746a57eb179339002b795b2b04083329a6 Mon Sep 17 00:00:00 2001 From: Joseph Kotanchik Date: Thu, 30 May 2024 14:08:20 -0400 Subject: [PATCH 07/11] MAT-6835: Use DTOs instead of Object[]. --- .../gov/cms/madie/dto/qrda/PopulationDTO.java | 17 +++ .../gov/cms/madie/dto/{ => qrda}/QrdaDTO.java | 5 +- .../dto/{ => qrda}/QrdaExportResponseDto.java | 2 +- .../gov/cms/madie/dto/qrda/QrdaGroupDTO.java | 17 +++ .../dto/qrda/QrdaGroupStratificationDTO.java | 17 +++ .../madie/dto/{ => qrda}/QrdaReportDTO.java | 2 +- .../madie/dto/{ => qrda}/QrdaRequestDTO.java | 4 +- .../cms/madie/dto/qrda/QrdaTestCaseDTO.java | 18 +++ .../cms/madie/dto/qrda/StratificationDTO.java | 18 +++ .../madie/resources/PackageController.java | 2 +- .../cms/madie/services/PackagingService.java | 6 +- .../gov/cms/madie/services/QrdaClient.java | 4 +- .../gov/cms/madie/services/QrdaService.java | 8 +- .../resources/PackageControllerMvcTest.java | 12 +- .../resources/PackageControllerTest.java | 2 +- .../services/CqmConversionServiceTest.java | 8 +- .../madie/services/PackagingServiceTest.java | 6 +- .../cms/madie/services/QrdaServiceTest.java | 16 +-- .../resources/measures/qrda-qdm-test.json | 108 ++++++++++++++++++ .../resources/measures/qrda-qicore-test.json | 71 ++++++++++++ 20 files changed, 306 insertions(+), 37 deletions(-) create mode 100644 src/main/java/gov/cms/madie/dto/qrda/PopulationDTO.java rename src/main/java/gov/cms/madie/dto/{ => qrda}/QrdaDTO.java (79%) rename src/main/java/gov/cms/madie/dto/{ => qrda}/QrdaExportResponseDto.java (90%) create mode 100644 src/main/java/gov/cms/madie/dto/qrda/QrdaGroupDTO.java create mode 100644 src/main/java/gov/cms/madie/dto/qrda/QrdaGroupStratificationDTO.java rename src/main/java/gov/cms/madie/dto/{ => qrda}/QrdaReportDTO.java (88%) rename src/main/java/gov/cms/madie/dto/{ => qrda}/QrdaRequestDTO.java (83%) create mode 100644 src/main/java/gov/cms/madie/dto/qrda/QrdaTestCaseDTO.java create mode 100644 src/main/java/gov/cms/madie/dto/qrda/StratificationDTO.java create mode 100644 src/test/resources/measures/qrda-qdm-test.json create mode 100644 src/test/resources/measures/qrda-qicore-test.json diff --git a/src/main/java/gov/cms/madie/dto/qrda/PopulationDTO.java b/src/main/java/gov/cms/madie/dto/qrda/PopulationDTO.java new file mode 100644 index 0000000..e1a39da --- /dev/null +++ b/src/main/java/gov/cms/madie/dto/qrda/PopulationDTO.java @@ -0,0 +1,17 @@ +package gov.cms.madie.dto.qrda; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class PopulationDTO { + String name; + int expected; + int actual; + boolean pass; +} diff --git a/src/main/java/gov/cms/madie/dto/QrdaDTO.java b/src/main/java/gov/cms/madie/dto/qrda/QrdaDTO.java similarity index 79% rename from src/main/java/gov/cms/madie/dto/QrdaDTO.java rename to src/main/java/gov/cms/madie/dto/qrda/QrdaDTO.java index 2c9937b..851e60f 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaDTO.java +++ b/src/main/java/gov/cms/madie/dto/qrda/QrdaDTO.java @@ -1,5 +1,6 @@ -package gov.cms.madie.dto; +package gov.cms.madie.dto.qrda; +import gov.cms.madie.dto.SourceDataCriteria; import gov.cms.madie.models.measure.TestCase; import lombok.AllArgsConstructor; import lombok.Builder; @@ -19,5 +20,5 @@ public class QrdaDTO { // TODO waiting for SME feedback List sourceDataCriteria; Object options; - Object[] testCaseDtos; + QrdaGroupDTO[] groupDTOs; } diff --git a/src/main/java/gov/cms/madie/dto/QrdaExportResponseDto.java b/src/main/java/gov/cms/madie/dto/qrda/QrdaExportResponseDto.java similarity index 90% rename from src/main/java/gov/cms/madie/dto/QrdaExportResponseDto.java rename to src/main/java/gov/cms/madie/dto/qrda/QrdaExportResponseDto.java index e51f8e4..9b31826 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaExportResponseDto.java +++ b/src/main/java/gov/cms/madie/dto/qrda/QrdaExportResponseDto.java @@ -1,4 +1,4 @@ -package gov.cms.madie.dto; +package gov.cms.madie.dto.qrda; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/gov/cms/madie/dto/qrda/QrdaGroupDTO.java b/src/main/java/gov/cms/madie/dto/qrda/QrdaGroupDTO.java new file mode 100644 index 0000000..bc243c3 --- /dev/null +++ b/src/main/java/gov/cms/madie/dto/qrda/QrdaGroupDTO.java @@ -0,0 +1,17 @@ +package gov.cms.madie.dto.qrda; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class QrdaGroupDTO { + String groupId; + String groupNumber; + String coverage; + QrdaTestCaseDTO[] testCaseDTOs; +} diff --git a/src/main/java/gov/cms/madie/dto/qrda/QrdaGroupStratificationDTO.java b/src/main/java/gov/cms/madie/dto/qrda/QrdaGroupStratificationDTO.java new file mode 100644 index 0000000..929a414 --- /dev/null +++ b/src/main/java/gov/cms/madie/dto/qrda/QrdaGroupStratificationDTO.java @@ -0,0 +1,17 @@ +package gov.cms.madie.dto.qrda; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class QrdaGroupStratificationDTO { + String testCaseId; + String stratId; + String stratName; + StratificationDTO[] stratificationDtos; +} diff --git a/src/main/java/gov/cms/madie/dto/QrdaReportDTO.java b/src/main/java/gov/cms/madie/dto/qrda/QrdaReportDTO.java similarity index 88% rename from src/main/java/gov/cms/madie/dto/QrdaReportDTO.java rename to src/main/java/gov/cms/madie/dto/qrda/QrdaReportDTO.java index b41fb11..edd812d 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaReportDTO.java +++ b/src/main/java/gov/cms/madie/dto/qrda/QrdaReportDTO.java @@ -1,4 +1,4 @@ -package gov.cms.madie.dto; +package gov.cms.madie.dto.qrda; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java b/src/main/java/gov/cms/madie/dto/qrda/QrdaRequestDTO.java similarity index 83% rename from src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java rename to src/main/java/gov/cms/madie/dto/qrda/QrdaRequestDTO.java index e22a765..c160aa1 100644 --- a/src/main/java/gov/cms/madie/dto/QrdaRequestDTO.java +++ b/src/main/java/gov/cms/madie/dto/qrda/QrdaRequestDTO.java @@ -1,4 +1,4 @@ -package gov.cms.madie.dto; +package gov.cms.madie.dto.qrda; import gov.cms.madie.models.measure.Measure; import lombok.AllArgsConstructor; @@ -13,5 +13,5 @@ public class QrdaRequestDTO { Measure measure; Object options; - Object[] testCaseDtos; + QrdaGroupDTO[] groupDTOs; } diff --git a/src/main/java/gov/cms/madie/dto/qrda/QrdaTestCaseDTO.java b/src/main/java/gov/cms/madie/dto/qrda/QrdaTestCaseDTO.java new file mode 100644 index 0000000..4c08373 --- /dev/null +++ b/src/main/java/gov/cms/madie/dto/qrda/QrdaTestCaseDTO.java @@ -0,0 +1,18 @@ +package gov.cms.madie.dto.qrda; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class QrdaTestCaseDTO { + String testCaseId; + String lastName; + String firstName; + PopulationDTO[] populations; + QrdaGroupStratificationDTO[] stratifications; +} diff --git a/src/main/java/gov/cms/madie/dto/qrda/StratificationDTO.java b/src/main/java/gov/cms/madie/dto/qrda/StratificationDTO.java new file mode 100644 index 0000000..b8bdf3a --- /dev/null +++ b/src/main/java/gov/cms/madie/dto/qrda/StratificationDTO.java @@ -0,0 +1,18 @@ +package gov.cms.madie.dto.qrda; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class StratificationDTO { + String id; + String name; + int expected; + int actual; + boolean pass; +} diff --git a/src/main/java/gov/cms/madie/resources/PackageController.java b/src/main/java/gov/cms/madie/resources/PackageController.java index 58af6f1..354b735 100644 --- a/src/main/java/gov/cms/madie/resources/PackageController.java +++ b/src/main/java/gov/cms/madie/resources/PackageController.java @@ -2,7 +2,7 @@ import gov.cms.madie.Exceptions.UnsupportedModelException; import gov.cms.madie.dto.CqlLookups; -import gov.cms.madie.dto.QrdaRequestDTO; +import gov.cms.madie.dto.qrda.QrdaRequestDTO; import gov.cms.madie.models.measure.QdmMeasure; import gov.cms.madie.services.*; import gov.cms.madie.models.measure.Measure; diff --git a/src/main/java/gov/cms/madie/services/PackagingService.java b/src/main/java/gov/cms/madie/services/PackagingService.java index 6301059..e124efe 100644 --- a/src/main/java/gov/cms/madie/services/PackagingService.java +++ b/src/main/java/gov/cms/madie/services/PackagingService.java @@ -1,9 +1,9 @@ package gov.cms.madie.services; import gov.cms.madie.dto.CqlLookups; -import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDTO; -import gov.cms.madie.dto.QrdaRequestDTO; +import gov.cms.madie.dto.qrda.QrdaExportResponseDto; +import gov.cms.madie.dto.qrda.QrdaReportDTO; +import gov.cms.madie.dto.qrda.QrdaRequestDTO; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.Measure; import gov.cms.madie.models.measure.QdmMeasure; diff --git a/src/main/java/gov/cms/madie/services/QrdaClient.java b/src/main/java/gov/cms/madie/services/QrdaClient.java index ee5a8a3..5755c85 100644 --- a/src/main/java/gov/cms/madie/services/QrdaClient.java +++ b/src/main/java/gov/cms/madie/services/QrdaClient.java @@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import gov.cms.madie.Exceptions.TranslationServiceException; import gov.cms.madie.config.QrdaClientConfig; -import gov.cms.madie.dto.QrdaDTO; -import gov.cms.madie.dto.QrdaExportResponseDto; +import gov.cms.madie.dto.qrda.QrdaDTO; +import gov.cms.madie.dto.qrda.QrdaExportResponseDto; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/gov/cms/madie/services/QrdaService.java b/src/main/java/gov/cms/madie/services/QrdaService.java index 9c6cd3c..13ac10e 100644 --- a/src/main/java/gov/cms/madie/services/QrdaService.java +++ b/src/main/java/gov/cms/madie/services/QrdaService.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import gov.cms.madie.Exceptions.QrdaServiceException; -import gov.cms.madie.dto.QrdaDTO; -import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaRequestDTO; +import gov.cms.madie.dto.qrda.QrdaDTO; +import gov.cms.madie.dto.qrda.QrdaExportResponseDto; +import gov.cms.madie.dto.qrda.QrdaRequestDTO; import gov.cms.madie.dto.SourceDataCriteria; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.QdmMeasure; @@ -53,7 +53,7 @@ public QrdaExportResponseDto generateQrda(QrdaRequestDTO request, String accessT .testCases(measure.getTestCases()) .sourceDataCriteria(dataCriteria) .options(buildOptions(measure)) - .testCaseDtos(request.getTestCaseDtos()) + .groupDTOs(request.getGroupDTOs()) .build(); } catch (JsonProcessingException e) { throw new QrdaServiceException("Problem mapping the measure for QRDA generation", e); diff --git a/src/test/java/gov/cms/madie/resources/PackageControllerMvcTest.java b/src/test/java/gov/cms/madie/resources/PackageControllerMvcTest.java index 60c0bd7..bc7d872 100644 --- a/src/test/java/gov/cms/madie/resources/PackageControllerMvcTest.java +++ b/src/test/java/gov/cms/madie/resources/PackageControllerMvcTest.java @@ -1,6 +1,7 @@ package gov.cms.madie.resources; import gov.cms.madie.dto.CqlLookups; +import gov.cms.madie.dto.qrda.QrdaRequestDTO; import gov.cms.madie.models.measure.QdmMeasure; import gov.cms.madie.services.*; import gov.cms.madie.models.measure.Measure; @@ -19,8 +20,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; @@ -164,8 +164,8 @@ void testGetMeasureHqmfForUnsupportedModel() throws Exception { @Test void testGetQRDASuccess() throws Exception { - String measureJson = getStringFromTestResource("/measures/qdm-test-measure.json"); - Mockito.when(packagingService.createQRDA(new Measure(), TOKEN)) + String measureJson = getStringFromTestResource("/measures/qrda-qdm-test.json"); + Mockito.when(packagingService.createQRDA(any(), eq(TOKEN))) .thenReturn("measure package".getBytes()); mockMvc .perform( @@ -178,12 +178,12 @@ void testGetQRDASuccess() throws Exception { .andExpect(status().isOk()) .andReturn(); - verify(packagingService, times(1)).createQRDA(any(Measure.class), anyString()); + verify(packagingService, times(1)).createQRDA(any(QrdaRequestDTO.class), anyString()); } @Test void testGetQRDAUnsupportedModel() throws Exception { - String measureJson = getStringFromTestResource("/measures/qicore-test-measure.json"); + String measureJson = getStringFromTestResource("/measures/qrda-qicore-test.json"); MvcResult mockResult = mockMvc .perform( diff --git a/src/test/java/gov/cms/madie/resources/PackageControllerTest.java b/src/test/java/gov/cms/madie/resources/PackageControllerTest.java index c6585df..f910593 100644 --- a/src/test/java/gov/cms/madie/resources/PackageControllerTest.java +++ b/src/test/java/gov/cms/madie/resources/PackageControllerTest.java @@ -2,7 +2,7 @@ import gov.cms.madie.Exceptions.UnsupportedModelException; import gov.cms.madie.dto.CqlLookups; -import gov.cms.madie.dto.QrdaRequestDTO; +import gov.cms.madie.dto.qrda.QrdaRequestDTO; import gov.cms.madie.models.measure.FhirMeasure; import gov.cms.madie.models.measure.QdmMeasure; import gov.cms.madie.services.HqmfService; diff --git a/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java b/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java index 72a880a..2693332 100644 --- a/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java +++ b/src/test/java/gov/cms/madie/services/CqmConversionServiceTest.java @@ -1,8 +1,8 @@ package gov.cms.madie.services; import gov.cms.madie.Exceptions.CqmConversionException; -import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDTO; +import gov.cms.madie.dto.qrda.QrdaExportResponseDto; +import gov.cms.madie.dto.qrda.QrdaReportDTO; import gov.cms.madie.dto.SourceDataCriteria; import gov.cms.madie.models.common.ModelType; import gov.cms.madie.models.cqm.CqmMeasure; @@ -103,8 +103,8 @@ void convertMadieMeasureToCqmMeasureNoScoring() throws Exception { when(mapper.measureToCqmMeasure(any(QdmMeasure.class), any(List.class), any(List.class))) .thenReturn(cqmMeasure); - List qrdaExport = - List.of(QrdaReportDto.builder().qrda("qrda").filename("1_test").report("report").build()); + List qrdaExport = + List.of(QrdaReportDTO.builder().qrda("qrda").filename("1_test").report("report").build()); QrdaExportResponseDto clientResponse = QrdaExportResponseDto.builder() .summaryReport("summaryReport") diff --git a/src/test/java/gov/cms/madie/services/PackagingServiceTest.java b/src/test/java/gov/cms/madie/services/PackagingServiceTest.java index fb5e683..7389eac 100644 --- a/src/test/java/gov/cms/madie/services/PackagingServiceTest.java +++ b/src/test/java/gov/cms/madie/services/PackagingServiceTest.java @@ -2,9 +2,9 @@ import gov.cms.madie.Exceptions.TranslationServiceException; import gov.cms.madie.dto.CqlLookups; -import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDTO; -import gov.cms.madie.dto.QrdaRequestDTO; +import gov.cms.madie.dto.qrda.QrdaExportResponseDto; +import gov.cms.madie.dto.qrda.QrdaReportDTO; +import gov.cms.madie.dto.qrda.QrdaRequestDTO; import gov.cms.madie.models.common.ModelType; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.Measure; diff --git a/src/test/java/gov/cms/madie/services/QrdaServiceTest.java b/src/test/java/gov/cms/madie/services/QrdaServiceTest.java index 3d183e0..bdcfedd 100644 --- a/src/test/java/gov/cms/madie/services/QrdaServiceTest.java +++ b/src/test/java/gov/cms/madie/services/QrdaServiceTest.java @@ -3,16 +3,16 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import gov.cms.madie.Exceptions.QrdaServiceException; -import gov.cms.madie.dto.QrdaDTO; -import gov.cms.madie.dto.QrdaExportResponseDto; -import gov.cms.madie.dto.QrdaReportDTO; +import gov.cms.madie.dto.qrda.QrdaDTO; +import gov.cms.madie.dto.qrda.QrdaExportResponseDto; +import gov.cms.madie.dto.qrda.QrdaReportDTO; import gov.cms.madie.dto.SourceDataCriteria; +import gov.cms.madie.dto.qrda.QrdaRequestDTO; import gov.cms.madie.models.common.ModelType; import gov.cms.madie.models.cqm.CqmMeasure; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.*; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; @@ -60,7 +60,6 @@ void setUp() { } @Test - @Disabled //TODO void convertToCqmMeasure() throws Exception { CqmMeasure cqmMeasure = CqmMeasure.builder().id("1").description("test").build(); when(translationServiceClient.getTranslatedLibraries(any(String.class), any(String.class))) @@ -84,7 +83,8 @@ void convertToCqmMeasure() throws Exception { when(client.getQRDA(captor.capture(), eq("testToken"), eq("testId"))) .thenReturn(clientResponse); - QrdaExportResponseDto result = qrdaService.generateQrda(qdmMeasure, "testToken"); + QrdaExportResponseDto result = + qrdaService.generateQrda(QrdaRequestDTO.builder().measure(qdmMeasure).build(), "testToken"); QrdaDTO dto = captor.getValue(); assertTrue(dto.getMeasure().contains("test")); @@ -119,7 +119,9 @@ void convertToCqmMeasureThrowsException() throws Exception { Exception ex = assertThrows( QrdaServiceException.class, - () -> qrdaService.generateQrda(qdmMeasure, "testToken"), + () -> + qrdaService.generateQrda( + QrdaRequestDTO.builder().measure(qdmMeasure).build(), "testToken"), "Problem mapping the measure for QRDA generation"); assertThat(ex.getMessage(), containsString("Problem mapping the measure for QRDA generation")); } diff --git a/src/test/resources/measures/qrda-qdm-test.json b/src/test/resources/measures/qrda-qdm-test.json new file mode 100644 index 0000000..eeb5e5a --- /dev/null +++ b/src/test/resources/measures/qrda-qdm-test.json @@ -0,0 +1,108 @@ +{ + "measure": { + "id": "6564ac8a5159a90bd713bea5", + "measureHumanReadableId": null, + "measureSetId": "3abdaa71-3683-4afe-829f-278cadc82950", + "version": "0.0.000", + "revisionNumber": null, + "state": null, + "cqlLibraryName": "QDMTestMeasure", + "ecqmTitle": "QDMTestMeasure", + "measureName": "QDMTestMeausre", + "active": true, + "cqlErrors": false, + "errors": [], + "cql": "library QDMTestMeasure version '0.0.000'\n\nusing QDM version '5.6'\n\ninclude TestMATGlobal version '1.0.000' called Global\n\ncodesystem \"SNOMEDCT\": 'urn:oid:2.16.840.1.113883.6.96' \n\nvalueset \"Encounter Inpatient\": 'urn:oid:2.16.840.1.113883.3.666.5.307'\n\ncode \"Dead (finding)\": '419099009' from \"SNOMEDCT\" display 'Dead (finding)'\n\nparameter \"Measurement Period\" Interval\n\ncontext Patient\n\n \ndefine \"Initial Population\":\n \"Qualifying Encounters\"\n\ndefine \"Qualifying Encounters\":\n [\"Encounter, Performed\": \"Encounter Inpatient\"] Encounter\n where Encounter.relevantPeriod ends during \"Measurement Period\"\n ", + "elmJson": "{\n \"library\" : {\n \"annotation\" : [ ],\n \"identifier\" : {\n \"id\" : \"QDMTestMeasure\",\n \"version\" : \"0.0.000\"\n },\n \"schemaIdentifier\" : {\n \"id\" : \"urn:hl7-org:elm\",\n \"version\" : \"r1\"\n },\n \"usings\" : {\n \"def\" : [ {\n \"localIdentifier\" : \"System\",\n \"uri\" : \"urn:hl7-org:elm-types:r1\"\n }, {\n \"localId\" : \"1\",\n \"locator\" : \"3:1-3:23\",\n \"localIdentifier\" : \"QDM\",\n \"uri\" : \"urn:healthit-gov:qdm:v5_6\",\n \"version\" : \"5.6\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"1\",\n \"s\" : [ {\n \"value\" : [ \"\", \"using \" ]\n }, {\n \"s\" : [ {\n \"value\" : [ \"QDM\" ]\n } ]\n }, {\n \"value\" : [ \" version '5.6'\" ]\n } ]\n }\n } ]\n } ]\n },\n \"includes\" : {\n \"def\" : [ {\n \"localId\" : \"2\",\n \"locator\" : \"5:1-5:53\",\n \"localIdentifier\" : \"Global\",\n \"path\" : \"TestMATGlobal\",\n \"version\" : \"1.0.000\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"2\",\n \"s\" : [ {\n \"value\" : [ \"\", \"include \" ]\n }, {\n \"s\" : [ {\n \"value\" : [ \"TestMATGlobal\" ]\n } ]\n }, {\n \"value\" : [ \" version \", \"'1.0.000'\", \" called \", \"Global\" ]\n } ]\n }\n } ]\n } ]\n },\n \"parameters\" : {\n \"def\" : [ {\n \"localId\" : \"9\",\n \"locator\" : \"13:1-13:49\",\n \"name\" : \"Measurement Period\",\n \"accessLevel\" : \"Public\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"9\",\n \"s\" : [ {\n \"value\" : [ \"\", \"parameter \", \"\\\"Measurement Period\\\"\", \" \" ]\n }, {\n \"r\" : \"8\",\n \"s\" : [ {\n \"value\" : [ \"Interval<\" ]\n }, {\n \"r\" : \"7\",\n \"s\" : [ {\n \"value\" : [ \"DateTime\" ]\n } ]\n }, {\n \"value\" : [ \">\" ]\n } ]\n } ]\n }\n } ],\n \"resultTypeSpecifier\" : {\n \"type\" : \"IntervalTypeSpecifier\",\n \"pointType\" : {\n \"name\" : \"{urn:hl7-org:elm-types:r1}DateTime\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n },\n \"parameterTypeSpecifier\" : {\n \"localId\" : \"8\",\n \"locator\" : \"13:32-13:49\",\n \"type\" : \"IntervalTypeSpecifier\",\n \"resultTypeSpecifier\" : {\n \"type\" : \"IntervalTypeSpecifier\",\n \"pointType\" : {\n \"name\" : \"{urn:hl7-org:elm-types:r1}DateTime\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n },\n \"pointType\" : {\n \"localId\" : \"7\",\n \"locator\" : \"13:41-13:48\",\n \"resultTypeName\" : \"{urn:hl7-org:elm-types:r1}DateTime\",\n \"name\" : \"{urn:hl7-org:elm-types:r1}DateTime\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n }\n } ]\n },\n \"codeSystems\" : {\n \"def\" : [ {\n \"localId\" : \"3\",\n \"locator\" : \"7:1-7:55\",\n \"resultTypeName\" : \"{urn:hl7-org:elm-types:r1}CodeSystem\",\n \"name\" : \"SNOMEDCT\",\n \"id\" : \"urn:oid:2.16.840.1.113883.6.96\",\n \"accessLevel\" : \"Public\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"3\",\n \"s\" : [ {\n \"value\" : [ \"\", \"codesystem \", \"\\\"SNOMEDCT\\\"\", \": \", \"'urn:oid:2.16.840.1.113883.6.96'\" ]\n } ]\n }\n } ]\n } ]\n },\n \"valueSets\" : {\n \"def\" : [ {\n \"localId\" : \"4\",\n \"locator\" : \"9:1-9:71\",\n \"resultTypeName\" : \"{urn:hl7-org:elm-types:r1}ValueSet\",\n \"name\" : \"Encounter Inpatient\",\n \"id\" : \"urn:oid:2.16.840.1.113883.3.666.5.307\",\n \"accessLevel\" : \"Public\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"4\",\n \"s\" : [ {\n \"value\" : [ \"\", \"valueset \", \"\\\"Encounter Inpatient\\\"\", \": \", \"'urn:oid:2.16.840.1.113883.3.666.5.307'\" ]\n } ]\n }\n } ]\n } ]\n },\n \"codes\" : {\n \"def\" : [ {\n \"localId\" : \"6\",\n \"locator\" : \"11:1-11:75\",\n \"resultTypeName\" : \"{urn:hl7-org:elm-types:r1}Code\",\n \"name\" : \"Dead (finding)\",\n \"id\" : \"419099009\",\n \"display\" : \"Dead (finding)\",\n \"accessLevel\" : \"Public\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"6\",\n \"s\" : [ {\n \"value\" : [ \"\", \"code \", \"\\\"Dead (finding)\\\"\", \": \", \"'419099009'\", \" from \" ]\n }, {\n \"r\" : \"5\",\n \"s\" : [ {\n \"value\" : [ \"\\\"SNOMEDCT\\\"\" ]\n } ]\n }, {\n \"value\" : [ \" display \", \"'Dead (finding)'\" ]\n } ]\n }\n } ],\n \"codeSystem\" : {\n \"localId\" : \"5\",\n \"locator\" : \"11:41-11:50\",\n \"resultTypeName\" : \"{urn:hl7-org:elm-types:r1}CodeSystem\",\n \"name\" : \"SNOMEDCT\"\n }\n } ]\n },\n \"contexts\" : {\n \"def\" : [ {\n \"locator\" : \"15:1-15:15\",\n \"name\" : \"Patient\"\n } ]\n },\n \"statements\" : {\n \"def\" : [ {\n \"locator\" : \"15:1-15:15\",\n \"name\" : \"Patient\",\n \"context\" : \"Patient\",\n \"expression\" : {\n \"type\" : \"SingletonFrom\",\n \"operand\" : {\n \"locator\" : \"15:1-15:15\",\n \"dataType\" : \"{urn:healthit-gov:qdm:v5_6}Patient\",\n \"templateId\" : \"Patient\",\n \"type\" : \"Retrieve\"\n }\n }\n }, {\n \"localId\" : \"17\",\n \"locator\" : \"21:1-23:67\",\n \"name\" : \"Qualifying Encounters\",\n \"context\" : \"Patient\",\n \"accessLevel\" : \"Public\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"17\",\n \"s\" : [ {\n \"value\" : [ \"\", \"define \", \"\\\"Qualifying Encounters\\\"\", \":\\n \" ]\n }, {\n \"r\" : \"16\",\n \"s\" : [ {\n \"s\" : [ {\n \"r\" : \"11\",\n \"s\" : [ {\n \"r\" : \"10\",\n \"s\" : [ {\n \"r\" : \"10\",\n \"s\" : [ {\n \"value\" : [ \"[\", \"\\\"Encounter, Performed\\\"\", \": \" ]\n }, {\n \"s\" : [ {\n \"value\" : [ \"\\\"Encounter Inpatient\\\"\" ]\n } ]\n }, {\n \"value\" : [ \"]\" ]\n } ]\n } ]\n }, {\n \"value\" : [ \" \", \"Encounter\" ]\n } ]\n } ]\n }, {\n \"value\" : [ \"\\n \" ]\n }, {\n \"r\" : \"15\",\n \"s\" : [ {\n \"value\" : [ \"where \" ]\n }, {\n \"r\" : \"15\",\n \"s\" : [ {\n \"r\" : \"13\",\n \"s\" : [ {\n \"r\" : \"12\",\n \"s\" : [ {\n \"value\" : [ \"Encounter\" ]\n } ]\n }, {\n \"value\" : [ \".\" ]\n }, {\n \"r\" : \"13\",\n \"s\" : [ {\n \"value\" : [ \"relevantPeriod\" ]\n } ]\n } ]\n }, {\n \"r\" : \"15\",\n \"value\" : [ \" \", \"ends during\", \" \" ]\n }, {\n \"r\" : \"14\",\n \"s\" : [ {\n \"value\" : [ \"\\\"Measurement Period\\\"\" ]\n } ]\n } ]\n } ]\n } ]\n } ]\n }\n } ],\n \"resultTypeSpecifier\" : {\n \"type\" : \"ListTypeSpecifier\",\n \"elementType\" : {\n \"name\" : \"{urn:healthit-gov:qdm:v5_6}PositiveEncounterPerformed\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n },\n \"expression\" : {\n \"localId\" : \"16\",\n \"locator\" : \"22:3-23:67\",\n \"type\" : \"Query\",\n \"resultTypeSpecifier\" : {\n \"type\" : \"ListTypeSpecifier\",\n \"elementType\" : {\n \"name\" : \"{urn:healthit-gov:qdm:v5_6}PositiveEncounterPerformed\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n },\n \"source\" : [ {\n \"localId\" : \"11\",\n \"locator\" : \"22:3-22:59\",\n \"alias\" : \"Encounter\",\n \"resultTypeSpecifier\" : {\n \"type\" : \"ListTypeSpecifier\",\n \"elementType\" : {\n \"name\" : \"{urn:healthit-gov:qdm:v5_6}PositiveEncounterPerformed\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n },\n \"expression\" : {\n \"localId\" : \"10\",\n \"locator\" : \"22:3-22:49\",\n \"dataType\" : \"{urn:healthit-gov:qdm:v5_6}PositiveEncounterPerformed\",\n \"templateId\" : \"PositiveEncounterPerformed\",\n \"codeProperty\" : \"code\",\n \"codeComparator\" : \"in\",\n \"type\" : \"Retrieve\",\n \"resultTypeSpecifier\" : {\n \"type\" : \"ListTypeSpecifier\",\n \"elementType\" : {\n \"name\" : \"{urn:healthit-gov:qdm:v5_6}PositiveEncounterPerformed\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n },\n \"codes\" : {\n \"locator\" : \"22:28-22:48\",\n \"resultTypeName\" : \"{urn:hl7-org:elm-types:r1}ValueSet\",\n \"name\" : \"Encounter Inpatient\",\n \"preserve\" : true,\n \"type\" : \"ValueSetRef\"\n }\n }\n } ],\n \"relationship\" : [ ],\n \"where\" : {\n \"localId\" : \"15\",\n \"locator\" : \"23:5-23:67\",\n \"resultTypeName\" : \"{urn:hl7-org:elm-types:r1}Boolean\",\n \"type\" : \"In\",\n \"operand\" : [ {\n \"locator\" : \"23:36-23:39\",\n \"type\" : \"End\",\n \"operand\" : {\n \"localId\" : \"13\",\n \"locator\" : \"23:11-23:34\",\n \"path\" : \"relevantPeriod\",\n \"scope\" : \"Encounter\",\n \"type\" : \"Property\",\n \"resultTypeSpecifier\" : {\n \"type\" : \"IntervalTypeSpecifier\",\n \"pointType\" : {\n \"name\" : \"{urn:hl7-org:elm-types:r1}DateTime\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n }\n }\n }, {\n \"localId\" : \"14\",\n \"locator\" : \"23:48-23:67\",\n \"name\" : \"Measurement Period\",\n \"type\" : \"ParameterRef\",\n \"resultTypeSpecifier\" : {\n \"type\" : \"IntervalTypeSpecifier\",\n \"pointType\" : {\n \"name\" : \"{urn:hl7-org:elm-types:r1}DateTime\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n }\n } ]\n }\n }\n }, {\n \"localId\" : \"19\",\n \"locator\" : \"18:1-19:25\",\n \"name\" : \"Initial Population\",\n \"context\" : \"Patient\",\n \"accessLevel\" : \"Public\",\n \"annotation\" : [ {\n \"type\" : \"Annotation\",\n \"s\" : {\n \"r\" : \"19\",\n \"s\" : [ {\n \"value\" : [ \"\", \"define \", \"\\\"Initial Population\\\"\", \":\\n \" ]\n }, {\n \"r\" : \"18\",\n \"s\" : [ {\n \"value\" : [ \"\\\"Qualifying Encounters\\\"\" ]\n } ]\n } ]\n }\n } ],\n \"resultTypeSpecifier\" : {\n \"type\" : \"ListTypeSpecifier\",\n \"elementType\" : {\n \"name\" : \"{urn:healthit-gov:qdm:v5_6}PositiveEncounterPerformed\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n },\n \"expression\" : {\n \"localId\" : \"18\",\n \"locator\" : \"19:3-19:25\",\n \"name\" : \"Qualifying Encounters\",\n \"type\" : \"ExpressionRef\",\n \"resultTypeSpecifier\" : {\n \"type\" : \"ListTypeSpecifier\",\n \"elementType\" : {\n \"name\" : \"{urn:healthit-gov:qdm:v5_6}PositiveEncounterPerformed\",\n \"type\" : \"NamedTypeSpecifier\"\n }\n }\n }\n } ]\n }\n },\n \"externalErrors\" : [ ]\n}", + "elmXml": null, + "testCases": [ + { + "id": "6564acb75159a90bd713bea8", + "name": null, + "title": "Test", + "series": "", + "description": "", + "createdAt": "2023-11-27T14:50:31.284Z", + "createdBy": "john doe", + "lastModifiedAt": "2023-12-19T23:08:44.365Z", + "lastModifiedBy": "John doe", + "validResource": true, + "json": "{\"qdmVersion\":\"5.6\",\"dataElements\":[{\"dataElementCodes\":[],\"_id\":\"658222799d67250000a656eb\",\"participant\":[],\"relatedTo\":[],\"qdmTitle\":\"Encounter, Performed\",\"hqmfOid\":\"2.16.840.1.113883.10.20.28.4.5\",\"qdmCategory\":\"encounter\",\"qdmStatus\":\"performed\",\"qdmVersion\":\"5.6\",\"_type\":\"QDM::EncounterPerformed\",\"description\":\"Encounter, Performed: Encounter Inpatient\",\"codeListId\":\"2.16.840.1.113883.3.666.5.307\",\"id\":\"658222799d67250000a656ea\",\"facilityLocations\":[],\"diagnoses\":[]}],\"_id\":\"658222789d67250000a656cd\"}", + "patientId": "41dd75cc-57fb-456a-9eb9-598798db7817", + "hapiOperationOutcome": null, + "groupPopulations": [] + } + ], + "groups": [ + { + "id": "6564acab5159a90bd713bea7", + "scoring": "Cohort", + "populations": [ + { + "id": "f341c318-9b30-4b7c-b642-d29d5980ea6d", + "name": "initialPopulation", + "definition": "Initial Population", + "associationType": null, + "description": "" + } + ], + "measureObservations": null, + "groupDescription": "", + "improvementNotation": "", + "rateAggregation": "", + "measureGroupTypes": null, + "scoringUnit": "", + "stratifications": [], + "populationBasis": "false" + } + ], + "createdAt": "2023-11-27T14:49:46.742Z", + "createdBy": "John doe", + "lastModifiedAt": "2023-12-18T16:38:12.125Z", + "lastModifiedBy": "John doe", + "measurementPeriodStart": "2020-01-01T00:00:00.000+00:00", + "measurementPeriodEnd": "2020-12-31T23:59:59.999+00:00", + "supplementalData": [], + "supplementalDataDescription": null, + "riskAdjustments": [], + "riskAdjustmentDescription": null, + "model": "QDM v5.6", + "measureMetaData": { + "steward": null, + "developers": null, + "description": null, + "copyright": null, + "disclaimer": null, + "rationale": null, + "guidance": null, + "clinicalRecommendation": null, + "draft": true, + "references": null, + "endorsements": null, + "riskAdjustment": null, + "definition": null, + "experimental": true, + "transmissionFormat": null, + "supplementalDataElements": null + }, + "versionId": "b84bf535-e179-49d1-8871-c08056358275", + "reviewMetaData": { + "approvalDate": null, + "lastReviewDate": null + }, + "measureSet": { + "id": "6564ac8a5159a90bd713bea6", + "measureSetId": "3abdaa71-3683-4afe-829f-278cadc82950", + "owner": "john_doe", + "acls": null + }, + "scoring": "Cohort", + "baseConfigurationTypes": [ + "Efficiency" + ], + "patientBasis": false, + "rateAggregation": null, + "improvementNotation": null + }, + "groupDTOs": [] +} \ No newline at end of file diff --git a/src/test/resources/measures/qrda-qicore-test.json b/src/test/resources/measures/qrda-qicore-test.json new file mode 100644 index 0000000..5478c34 --- /dev/null +++ b/src/test/resources/measures/qrda-qicore-test.json @@ -0,0 +1,71 @@ +{ + "measure": { + "id": "6564ac8a5159a90bd713bea5", + "measureHumanReadableId": null, + "measureSetId": "3abdaa71-3683-4afe-829f-278cadc82950", + "version": "0.0.000", + "revisionNumber": null, + "state": null, + "cqlLibraryName": "QICoreTestMeasure", + "ecqmTitle": "QICoreTestMeasure", + "measureName": "QICoreTestMeasure", + "active": true, + "cqlErrors": false, + "errors": [], + "cql": "fake cql", + "elmJson": null, + "elmXml": null, + "testCases": [], + "groups": [ + ], + "createdAt": "2023-11-27T14:49:46.742Z", + "createdBy": "john doe", + "lastModifiedAt": "2023-12-18T16:38:12.125Z", + "lastModifiedBy": "John doe", + "measurementPeriodStart": "2020-01-01T00:00:00.000+00:00", + "measurementPeriodEnd": "2020-12-31T23:59:59.999+00:00", + "supplementalData": [], + "supplementalDataDescription": null, + "riskAdjustments": [], + "riskAdjustmentDescription": null, + "model": "QI-Core v4.1.1", + "measureMetaData": { + "steward": null, + "developers": null, + "description": null, + "copyright": null, + "disclaimer": null, + "rationale": null, + "guidance": null, + "clinicalRecommendation": null, + "draft": true, + "references": null, + "endorsements": null, + "riskAdjustment": null, + "definition": null, + "experimental": true, + "transmissionFormat": null, + "supplementalDataElements": null + }, + "versionId": "b84bf535-e179-49d1-8871-c08056358275", + "cmsId": null, + "reviewMetaData": { + "approvalDate": null, + "lastReviewDate": null + }, + "measureSet": { + "id": "6564ac8a5159a90bd713bea6", + "measureSetId": "3abdaa71-3683-4afe-829f-278cadc82950", + "owner": "john_doe", + "acls": null + }, + "scoring": "Cohort", + "baseConfigurationTypes": [ + "Efficiency" + ], + "patientBasis": false, + "rateAggregation": null, + "improvementNotation": null + }, + "groupDTOs": [] +} \ No newline at end of file From bbb76f848ffd9789cf616af66981d2cb17f49f6a Mon Sep 17 00:00:00 2001 From: Ethan Kaplan Date: Thu, 30 May 2024 12:54:39 -0700 Subject: [PATCH 08/11] MAT-7197 add longer date to format checker --- .../madie/services/HumanReadableService.java | 6 +++-- .../cms/madie/util/HumanReadableDateUtil.java | 22 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/gov/cms/madie/services/HumanReadableService.java b/src/main/java/gov/cms/madie/services/HumanReadableService.java index 9652e7a..8494747 100644 --- a/src/main/java/gov/cms/madie/services/HumanReadableService.java +++ b/src/main/java/gov/cms/madie/services/HumanReadableService.java @@ -141,9 +141,11 @@ HumanReadableMeasureInformationModel buildMeasureInfo(Measure measure) { // TODO needs safety check .patientBased(patientBased) .measurementPeriodStartDate( - DateFormat.getDateInstance().format(measure.getMeasurementPeriodStart())) + DateFormat.getDateInstance(DateFormat.LONG, Locale.US) + .format(measure.getMeasurementPeriodStart())) .measurementPeriodEndDate( - DateFormat.getDateInstance().format(measure.getMeasurementPeriodEnd())) + DateFormat.getDateInstance(DateFormat.LONG, Locale.US) + .format(measure.getMeasurementPeriodEnd())) .measureScoring(measureScoring) // All groups expected to have same scoring .description(measure.getMeasureMetaData().getDescription()) .copyright(measure.getMeasureMetaData().getCopyright()) diff --git a/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java b/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java index 788eff9..2c39f86 100644 --- a/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java +++ b/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java @@ -1,5 +1,8 @@ package gov.cms.madie.util; +import java.text.ParseException; +import java.text.SimpleDateFormat; + public class HumanReadableDateUtil { public static String getFormattedMeasurementPeriod( @@ -27,21 +30,21 @@ public static String getFormattedMeasurementPeriod( if (" ".equals(formattedEndDate)) { through = ""; } - return formattedStartDate + through + formattedEndDate; } private static String formatDate(String date) { String returnDate = " "; // The string should be 8 characters long if not return " " - if (date.length() == 8) { + if (isValidLongDate(date)) { + returnDate = date; + } else if (date.length() == 8) { // Separate the string into year, month, and dat String year = date.substring(0, 4); String month = date.substring(4, 6); String day = date.substring(6, 8); // Get the string version of the month month = getMonth(month); - // if the day starts with a zero only display the second digit if (day.charAt(0) == '0') { day = day.substring(1, 2); @@ -51,6 +54,7 @@ private static String formatDate(String date) { else if (date.length() == 11 || date.length() == 12) { returnDate = date; } + return returnDate; } @@ -95,4 +99,16 @@ public static String getFormattedMeasurementPeriodForFhir(String startDate, Stri return formattedStartDate + " through " + formattedEndDate; } + + public static boolean isValidLongDate(String dateString) { + SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy"); + dateFormat.setLenient(false); // Strict date parsing + + try { + dateFormat.parse(dateString); + return true; + } catch (ParseException e) { + return false; + } + } } From f947b4b63faedb14cec3c7b81d6578aba3420904 Mon Sep 17 00:00:00 2001 From: Ethan Kaplan Date: Thu, 30 May 2024 12:57:43 -0700 Subject: [PATCH 09/11] MAT-7197: better method name --- src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java b/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java index 2c39f86..5221868 100644 --- a/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java +++ b/src/main/java/gov/cms/madie/util/HumanReadableDateUtil.java @@ -36,7 +36,7 @@ public static String getFormattedMeasurementPeriod( private static String formatDate(String date) { String returnDate = " "; // The string should be 8 characters long if not return " " - if (isValidLongDate(date)) { + if (isValidDateWithFullMonth(date)) { returnDate = date; } else if (date.length() == 8) { // Separate the string into year, month, and dat @@ -100,7 +100,7 @@ public static String getFormattedMeasurementPeriodForFhir(String startDate, Stri return formattedStartDate + " through " + formattedEndDate; } - public static boolean isValidLongDate(String dateString) { + public static boolean isValidDateWithFullMonth(String dateString) { SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy"); dateFormat.setLenient(false); // Strict date parsing From e28b440edc64ef4e086ec58e25e58f194a030386 Mon Sep 17 00:00:00 2001 From: Ethan Kaplan Date: Tue, 4 Jun 2024 11:06:57 -0700 Subject: [PATCH 10/11] MAT-7197 testcase fix --- .../gov/cms/madie/services/HumanReadableServiceTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java b/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java index c3b0850..11ef727 100644 --- a/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java +++ b/src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java @@ -33,6 +33,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import static org.hamcrest.CoreMatchers.is; @@ -322,10 +323,14 @@ public void canBuildMeasureInfoFromMeasure() { equalTo(measure.getGroups().get(0).getPopulationBasis().equals("boolean"))); assertThat( measureInfoModel.getMeasurementPeriodStartDate(), - equalTo(DateFormat.getDateInstance().format(measure.getMeasurementPeriodStart()))); + equalTo( + DateFormat.getDateInstance(DateFormat.LONG, Locale.US) + .format(measure.getMeasurementPeriodStart()))); assertThat( measureInfoModel.getMeasurementPeriodEndDate(), - equalTo(DateFormat.getDateInstance().format(measure.getMeasurementPeriodEnd()))); + equalTo( + DateFormat.getDateInstance(DateFormat.LONG, Locale.US) + .format(measure.getMeasurementPeriodEnd()))); assertThat( measureInfoModel.getMeasureScoring(), equalTo( From 5711ea42e90d6e29fe828513c100011b08a3233b Mon Sep 17 00:00:00 2001 From: Rohit Kandimalla Date: Tue, 4 Jun 2024 16:46:00 -0400 Subject: [PATCH 11/11] MAT-7054 Updating env variables to keep it consistent --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 00fc558..62eac29 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,7 +7,7 @@ madie: allowedApi: http://localhost:9000 cql-elm: service: - base-url: ${ELM_TRANSLATOR_SERVICE_URL:http://localhost:8084/api/qdm} + base-url: ${QDM_ELM_TRANSLATOR_SERVICE_URL:http://localhost:8084/api/qdm} cql-elm-urn: /cql/elm cql-lookups: /cql/lookups relevant-data-elements: /cql/relevant-elements