diff --git a/src/main/java/cms/gov/madie/measure/services/VersionService.java b/src/main/java/cms/gov/madie/measure/services/VersionService.java index a7ea0539d..2cc5595f9 100644 --- a/src/main/java/cms/gov/madie/measure/services/VersionService.java +++ b/src/main/java/cms/gov/madie/measure/services/VersionService.java @@ -1,9 +1,6 @@ package cms.gov.madie.measure.services; -import cms.gov.madie.measure.exceptions.BadVersionRequestException; -import cms.gov.madie.measure.exceptions.CqlElmTranslationErrorException; -import cms.gov.madie.measure.exceptions.MeasureNotDraftableException; -import cms.gov.madie.measure.exceptions.ResourceNotFoundException; +import cms.gov.madie.measure.exceptions.*; import cms.gov.madie.measure.repositories.CqmMeasureRepository; import cms.gov.madie.measure.repositories.ExportRepository; import cms.gov.madie.measure.repositories.MeasureRepository; @@ -12,6 +9,8 @@ import gov.cms.madie.models.common.Version; import gov.cms.madie.models.cqm.CqmMeasure; import gov.cms.madie.models.measure.*; +import gov.cms.madie.packaging.utils.PackagingUtility; +import gov.cms.madie.packaging.utils.PackagingUtilityFactory; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -19,6 +18,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.lang.reflect.InvocationTargetException; import java.time.Instant; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -366,8 +366,23 @@ public String generateLibraryContentLine(String cqlLibraryName, Version version) } private void saveMeasureBundle(Measure savedMeasure, String measureBundle, String username) { + String humanReadableWithCss; + try { + PackagingUtility utility = PackagingUtilityFactory.getInstance(savedMeasure.getModel()); + humanReadableWithCss = utility.getHumanReadableWithCSS(measureBundle); + } catch (InstantiationException + | IllegalAccessException + | InvocationTargetException + | NoSuchMethodException + | ClassNotFoundException e) { + throw new BundleOperationException("Measure", savedMeasure.getId(), e); + } Export export = - Export.builder().measureId(savedMeasure.getId()).measureBundleJson(measureBundle).build(); + Export.builder() + .measureId(savedMeasure.getId()) + .measureBundleJson(measureBundle) + .humanReadable(humanReadableWithCss) + .build(); Export savedExport = exportRepository.save(export); log.info( "User [{}] successfully saved versioned measure's export data with ID [{}]", diff --git a/src/main/resources/templates/HumanReadable.liquid b/src/main/resources/templates/HumanReadable.liquid index d2f034c9e..6909a1eef 100644 --- a/src/main/resources/templates/HumanReadable.liquid +++ b/src/main/resources/templates/HumanReadable.liquid @@ -2,337 +2,420 @@
- human_readable_content_holder +human_readable_content_holder \ No newline at end of file diff --git a/src/test/java/cms/gov/madie/measure/services/VersionServiceTest.java b/src/test/java/cms/gov/madie/measure/services/VersionServiceTest.java index 4323a65fc..e9ccb270c 100644 --- a/src/test/java/cms/gov/madie/measure/services/VersionServiceTest.java +++ b/src/test/java/cms/gov/madie/measure/services/VersionServiceTest.java @@ -50,33 +50,25 @@ public class VersionServiceTest { @Mock private MeasureRepository measureRepository; @Mock private CqmMeasureRepository cqmMeasureRepository; + @Mock private ExportRepository exportRepository; @Mock ActionLogService actionLogService; - - @Mock ElmTranslatorClient elmTranslatorClient; - - @Mock FhirServicesClient fhirServicesClient; - - @Mock ExportRepository exportRepository; - @Mock MeasureService measureService; - - @Mock QdmPackageService qdmPackageService; - @Mock ExportService exportService; - @Mock TestCaseSequenceService sequenceService; + @Mock QdmPackageService qdmPackageService; @Mock AppConfigService appConfigService; - @Mock ElmToJsonService elmToJsonService; - @InjectMocks VersionService versionService; + @Mock ElmTranslatorClient elmTranslatorClient; + @Mock FhirServicesClient fhirServicesClient; @Captor private ArgumentCaptor