Skip to content

Commit

Permalink
Merge branch 'develop' into feature/MAT-7030-use-cqm-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
chubert-sb committed Jun 5, 2024
2 parents 64c83a5 + c34628a commit ebe95fd
Show file tree
Hide file tree
Showing 24 changed files with 411 additions and 68 deletions.
17 changes: 17 additions & 0 deletions src/main/java/gov/cms/madie/dto/qrda/PopulationDTO.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,11 +13,12 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class QRDADto {
public class QrdaDTO {

String measure;
List<TestCase> testCases;
// TODO waiting for SME feedback
List<SourceDataCriteria> sourceDataCriteria;
Object options;
QrdaGroupDTO[] groupDTOs;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gov.cms.madie.dto;
package gov.cms.madie.dto.qrda;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -13,5 +13,5 @@
@AllArgsConstructor
public class QrdaExportResponseDto {
String summaryReport;
List<QrdaReportDto> individualReports;
List<QrdaReportDTO> individualReports;
}
17 changes: 17 additions & 0 deletions src/main/java/gov/cms/madie/dto/qrda/QrdaGroupDTO.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gov.cms.madie.dto;
package gov.cms.madie.dto.qrda;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -9,7 +9,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class QrdaReportDto {
public class QrdaReportDTO {
String qrda;
String report;
String filename;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/gov/cms/madie/dto/qrda/QrdaRequestDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package gov.cms.madie.dto.qrda;

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;
Object options;
QrdaGroupDTO[] groupDTOs;
}
18 changes: 18 additions & 0 deletions src/main/java/gov/cms/madie/dto/qrda/QrdaTestCaseDTO.java
Original file line number Diff line number Diff line change
@@ -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;
}
18 changes: 18 additions & 0 deletions src/main/java/gov/cms/madie/dto/qrda/StratificationDTO.java
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 4 additions & 2 deletions src/main/java/gov/cms/madie/resources/PackageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gov.cms.madie.Exceptions.UnsupportedModelException;
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;
Expand Down Expand Up @@ -103,12 +104,13 @@ public ResponseEntity<String> 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());
}
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/gov/cms/madie/services/HumanReadableService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -230,7 +232,7 @@ List<HumanReadablePopulationModel> 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))
Expand All @@ -244,7 +246,17 @@ List<HumanReadablePopulationModel> buildPopulations(
List<HumanReadablePopulationModel> buildStratification(
Group group, Set<CQLDefinition> allDefinitions) {
if (CollectionUtils.isEmpty(group.getStratifications())) {
return Collections.emptyList();
HumanReadablePopulationModel emptyStrat =
HumanReadablePopulationModel.builder()
.name("Stratification")
.display("Stratification")
.logic("None")
.id("None")
.inGroup(false)
.expressionName("None")
.build();

return new ArrayList<HumanReadablePopulationModel>(Arrays.asList(emptyStrat));
}
List<HumanReadablePopulationModel> model = new ArrayList<>(group.getStratifications().size());
for (int i = 0; i < group.getStratifications().size(); i++) {
Expand Down Expand Up @@ -456,4 +468,11 @@ List<HumanReadableExpressionModel> buildRiskAdjustmentVariables(
.build())
.collect(Collectors.toList());
}

String exclusionDisplayPluralizor(String display) {
if (display.endsWith("Exclusion") || display.endsWith("Exception")) {
return display + "s";
}
return display;
}
}
20 changes: 11 additions & 9 deletions src/main/java/gov/cms/madie/services/PackagingService.java
Original file line number Diff line number Diff line change
@@ -1,8 +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.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;
Expand Down Expand Up @@ -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];
}
Expand All @@ -81,11 +84,10 @@ public byte[] createQRDA(Measure measure, String accessToken) {
String htmlDir = "/html/";
String qrdaDir = "/qrda/";
Map<String, byte[]> 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());
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/gov/cms/madie/services/QrdaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/gov/cms/madie/services/QrdaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.QrdaExportResponseDto;
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;
Expand All @@ -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<TranslatedLibrary> translatedLibraries =
translationServiceClient.getTranslatedLibraries(measure.getCql(), accessToken);
Expand All @@ -42,16 +44,16 @@ public QrdaExportResponseDto generateQrda(QdmMeasure measure, String accessToken
List<SourceDataCriteria> 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)
.options(buildOptions(measure))
.groupDTOs(request.getGroupDTOs())
.build();
} catch (JsonProcessingException e) {
throw new QrdaServiceException("Problem mapping the measure for QRDA generation", e);
Expand Down
Loading

0 comments on commit ebe95fd

Please sign in to comment.