From 074d973f22b1396345c2825b22361898c30076e3 Mon Sep 17 00:00:00 2001 From: Christopher Hubert Date: Thu, 6 Jun 2024 11:46:22 -0400 Subject: [PATCH] MAT-7030: overwrite population sets for qrda generation --- .../gov/cms/madie/services/CqmMeasureMapper.java | 12 ++++++++++-- .../java/gov/cms/madie/services/QrdaService.java | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/gov/cms/madie/services/CqmMeasureMapper.java b/src/main/java/gov/cms/madie/services/CqmMeasureMapper.java index 8097b11..e3ca6fb 100644 --- a/src/main/java/gov/cms/madie/services/CqmMeasureMapper.java +++ b/src/main/java/gov/cms/madie/services/CqmMeasureMapper.java @@ -10,6 +10,7 @@ import gov.cms.madie.models.cqm.datacriteria.*; import gov.cms.madie.models.measure.*; import gov.cms.madie.util.ElmDependencyUtil; +import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -268,7 +269,10 @@ default List getPopulationSets(QdmMeasure measure) { return null; } - String measureScoring = measure.getScoring().replaceAll(" +", ""); + String measureScoring = null; + if (!StringUtils.isEmpty(measure.getScoring())) { + measureScoring = measure.getScoring().replaceAll(" +", ""); + } List populationSets = new ArrayList<>(); for (int i = 0; i < measure.getGroups().size(); i++) { String groupId = measure.getGroups().get(i).getId(); @@ -291,7 +295,8 @@ default List getPopulationSets(QdmMeasure measure) { generateCqmSupplementalDataElements( measure.getSupplementalData(), measure.getCqlLibraryName())) .build(); - if (measureScoring.equals("ContinuousVariable") || measureScoring.equals("Ratio")) { + if (!StringUtils.isEmpty(measureScoring) + && (measureScoring.equals("ContinuousVariable") || measureScoring.equals("Ratio"))) { populationSet.setObservations(generateCqmObservations(measure)); } populationSets.add(populationSet); @@ -351,6 +356,9 @@ default PopulationMap determinePopulationType(Map acc, String me default PopulationMap generateCqmPopulations( List populations, String cqlLibraryName, String measureScoring) { + if (StringUtils.isEmpty(measureScoring)) { + return null; + } ObjectMapper mapper = new ObjectMapper(); Map acc = new HashMap<>(); for (Population population : populations) { diff --git a/src/main/java/gov/cms/madie/services/QrdaService.java b/src/main/java/gov/cms/madie/services/QrdaService.java index 13ac10e..904022d 100644 --- a/src/main/java/gov/cms/madie/services/QrdaService.java +++ b/src/main/java/gov/cms/madie/services/QrdaService.java @@ -7,6 +7,7 @@ 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.cqm.CqmMeasure; import gov.cms.madie.models.dto.TranslatedLibrary; import gov.cms.madie.models.measure.QdmMeasure; import lombok.AllArgsConstructor; @@ -16,6 +17,7 @@ import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -46,10 +48,11 @@ public QrdaExportResponseDto generateQrda(QrdaRequestDTO request, String accessT QrdaDTO dto = null; try { + CqmMeasure cqmMeasure = mapper.measureToCqmMeasure(measure, elms, null); + cqmMeasure.setPopulation_sets(new ArrayList<>()); dto = QrdaDTO.builder() - .measure( - objectMapper.writeValueAsString(mapper.measureToCqmMeasure(measure, elms, null))) + .measure(objectMapper.writeValueAsString(cqmMeasure)) .testCases(measure.getTestCases()) .sourceDataCriteria(dataCriteria) .options(buildOptions(measure))