Skip to content

Commit

Permalink
MAT-7243: When versioning FHIR based measures, save the Human Readabl…
Browse files Browse the repository at this point in the history
…e separately so that it can be retrieved independently of the Bundle and not subject to Template changes.

Signed-off-by: Joseph Kotanchik <[email protected]>
  • Loading branch information
jkotanchik-SB committed Jan 14, 2025
1 parent 42c8ace commit ac4f4e7
Show file tree
Hide file tree
Showing 3 changed files with 450 additions and 358 deletions.
25 changes: 20 additions & 5 deletions src/main/java/cms/gov/madie/measure/services/VersionService.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,13 +9,16 @@
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;
import org.bson.types.ObjectId;
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;
Expand Down Expand Up @@ -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 [{}]",
Expand Down
Loading

0 comments on commit ac4f4e7

Please sign in to comment.