Skip to content

Commit

Permalink
Merge pull request #327 from echicoine-esac/319-update-measure-refresh
Browse files Browse the repository at this point in the history
319: Update Measure Refresh to use QM IG 3.0.0 approach
  • Loading branch information
bryantaustin13 authored Dec 15, 2021
2 parents 1a4ecd3 + de537f2 commit 61295d7
Showing 1 changed file with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

public class MeasureRefreshProcessor {
public Measure refreshMeasure(Measure measureToUse, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) {
Library moduleDefinitionLibrary = getModuleDefinitionLibrary(measureToUse, libraryManager, translatedLibrary, options);

Library moduleDefinitionLibrary = getModuleDefinitionLibrary(measureToUse, libraryManager, translatedLibrary, options);

measureToUse.setDate(new Date());
// http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/measure-cqfm
setMeta(measureToUse, moduleDefinitionLibrary);
Expand All @@ -27,11 +29,11 @@ public Measure refreshMeasure(Measure measureToUse, LibraryManager libraryManage
clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement");
clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode");
clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition");
clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-effectiveDataRequirements");
clearRelatedArtifacts(measureToUse);
setParameters(measureToUse, moduleDefinitionLibrary);
setDataRequirements(measureToUse, moduleDefinitionLibrary);
setDirectReferenceCode(measureToUse, moduleDefinitionLibrary);
setLogicDefinition(measureToUse, moduleDefinitionLibrary);

setEffectiveDataRequirements(measureToUse, moduleDefinitionLibrary);

measureToUse.setRelatedArtifact(moduleDefinitionLibrary.getRelatedArtifact());

return measureToUse;
Expand Down Expand Up @@ -68,29 +70,29 @@ private void clearRelatedArtifacts(Measure measure) {
measure.getRelatedArtifact().removeIf(r -> r.getType() == RelatedArtifact.RelatedArtifactType.DEPENDSON);
}

private void setLogicDefinition(Measure measureToUse, Library moduleDefinitionLibrary) {
moduleDefinitionLibrary.getExtension().forEach(extension -> {
if (extension.getUrl().equalsIgnoreCase("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition")) {
measureToUse.addExtension(extension);
}
});
}

private void setDirectReferenceCode(Measure measureToUse, Library moduleDefinitionLibrary) {
moduleDefinitionLibrary.getExtension().forEach(extension -> {
if(extension.getUrl().equalsIgnoreCase("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode")) {
measureToUse.addExtension(extension);
}
});
}

private void setDataRequirements(Measure measureToUse, Library moduleDefinitionLibrary) {
moduleDefinitionLibrary.getDataRequirement().forEach(dataRequirement -> {
Extension dataReqExtension = new Extension();
dataReqExtension.setUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement");
dataReqExtension.setValue(dataRequirement);
measureToUse.addExtension(dataReqExtension);
});
private void setEffectiveDataRequirements(Measure measureToUse, Library moduleDefinitionLibrary) {
moduleDefinitionLibrary.setId("effective-data-requirements");
int delIndex = -1;
for (Resource res : measureToUse.getContained()) {
if (res instanceof Library && ((Library)res).getId().equalsIgnoreCase("effective-data-requirements")) {
delIndex = measureToUse.getContained().indexOf(res);
break;
}
}
if (delIndex >= 0) {
measureToUse.getContained().remove(delIndex);
}
measureToUse.getContained().add(moduleDefinitionLibrary);
Extension effDataReqExtension = new Extension();
effDataReqExtension.setUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-effectiveDataRequirements");
effDataReqExtension.setId("effective-data-requirements");
effDataReqExtension.setValue(new Reference().setReference("#effective-data-requirements"));
measureToUse.addExtension(effDataReqExtension);
}

private void setParameters(Measure measureToUse, Library moduleDefinitionLibrary) {
Expand Down Expand Up @@ -120,4 +122,6 @@ private void setMeta(Measure measureToUse, Library moduleDefinitionLibrary){
measureToUse.getMeta().addProfile("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm");
}
}


}

0 comments on commit 61295d7

Please sign in to comment.