Skip to content

Commit

Permalink
Fix problems from merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukedegruchy committed Nov 26, 2024
1 parent fb9a09b commit 7a6cb14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public MeasureDef build(Measure measure) {
// between versions
if (measureScoring == null && measure.hasGroup()) {
throw new InvalidRequestException(
String.format("MeasureScoring must be specified on Measure: %s", measure.getUrl()));
throw new IllegalArgumentException("MeasureScoring must be specified on Measure");
String.format("MeasureScoring must be specified on Measure: %s", measure.getUrl()));
}
List<GroupDef> groups = new ArrayList<>();
for (MeasureGroupComponent group : measure.getGroup()) {
Expand Down Expand Up @@ -163,14 +162,15 @@ private void checkId(Resource r) {
}
}

private void validateImprovementNotationCode(CodeDef improvementNotation) {
private void validateImprovementNotationCode(Measure measure, CodeDef improvementNotation) {
if (improvementNotation != null) {
var code = improvementNotation.code();
boolean hasValidCode = IMPROVEMENT_NOTATION_SYSTEM_INCREASE.equals(code)
|| IMPROVEMENT_NOTATION_SYSTEM_DECREASE.equals(code);
if (!hasValidCode) {
throw new IllegalArgumentException(String.format(
"ImprovementNotation Coding has invalid code: %s, combination for Measure: %s", code, measure.getUrl()));
"ImprovementNotation Coding has invalid code: %s, combination for Measure: %s",
code, measure.getUrl()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import static org.opencds.cqf.fhir.cr.measure.constant.MeasureReportConstants.MEASUREREPORT_IMPROVEMENT_NOTATION_SYSTEM;
import static org.opencds.cqf.fhir.cr.measure.constant.MeasureReportConstants.SDE_USAGE_CODE;

import jakarta.annotation.Nullable;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import jakarta.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -70,11 +70,11 @@ public MeasureDef build(Measure measure) {
List<GroupDef> groups = new ArrayList<>();
for (MeasureGroupComponent group : measure.getGroup()) {
// group Measure Scoring
var groupScoring = getGroupMeasureScoring(group);
var groupScoring = getGroupMeasureScoring(measure, group);
// populationBasis
var groupBasis = getGroupPopulationBasis(group);
// improvement Notation
var groupImpNotation = getGroupImpNotation(group);
var groupImpNotation = getGroupImpNotation(measure, group);
var hasGroupImpNotation = groupImpNotation != null;

// Populations
Expand Down Expand Up @@ -212,7 +212,7 @@ private void checkId(Resource r) {
}
}

private MeasureScoring getMeasureScoring(@Nullable String scoringCode) {
private MeasureScoring getMeasureScoring(Measure measure, @Nullable String scoringCode) {
if (scoringCode != null) {
var code = MeasureScoring.fromCode(scoringCode);
if (code == null) {
Expand All @@ -228,10 +228,10 @@ private MeasureScoring getMeasureScoring(@Nullable String scoringCode) {

private MeasureScoring getMeasureScoring(Measure measure) {
var scoringCode = measure.getScoring().getCodingFirstRep().getCode();
return getMeasureScoring(scoringCode);
return getMeasureScoring(measure, scoringCode);
}

private void validateImprovementNotationCode(CodeDef improvementNotation) {
private void validateImprovementNotationCode(Measure measure, CodeDef improvementNotation) {
var code = improvementNotation.code();
var system = improvementNotation.system();
boolean hasValidSystem = system.equals(MEASUREREPORT_IMPROVEMENT_NOTATION_SYSTEM);
Expand Down Expand Up @@ -267,13 +267,13 @@ public CodeDef getMeasureImprovementNotation(Measure measure) {
var codeDef = new CodeDef(
improvementNotationValue.getCodingFirstRep().getSystem(),
improvementNotationValue.getCodingFirstRep().getCode());
validateImprovementNotationCode(codeDef);
validateImprovementNotationCode(measure, codeDef);
return codeDef;
}
return null;
}

public CodeDef getGroupImpNotation(MeasureGroupComponent group) {
public CodeDef getGroupImpNotation(Measure measure, MeasureGroupComponent group) {
var ext = group.getExtensionByUrl(MEASUREREPORT_IMPROVEMENT_NOTATION_EXTENSION);
if (ext != null) {
var value = ext.getValue();
Expand All @@ -282,20 +282,20 @@ public CodeDef getGroupImpNotation(MeasureGroupComponent group) {
var codeDef = new CodeDef(
coding.getCodingFirstRep().getSystem(),
coding.getCodingFirstRep().getCode());
validateImprovementNotationCode(codeDef);
validateImprovementNotationCode(measure, codeDef);
return codeDef;
}
}
return null;
}

public MeasureScoring getGroupMeasureScoring(MeasureGroupComponent group) {
public MeasureScoring getGroupMeasureScoring(Measure measure, MeasureGroupComponent group) {
var ext = group.getExtensionByUrl(CQFM_SCORING_EXT_URL);
if (ext != null) {
var extVal = ext.getValue();
assert extVal instanceof CodeableConcept;
CodeableConcept coding = (CodeableConcept) extVal;
return getMeasureScoring(coding.getCodingFirstRep().getCode());
return getMeasureScoring(measure, coding.getCodingFirstRep().getCode());
}
return null;
}
Expand All @@ -311,7 +311,7 @@ public CodeDef getGroupPopulationBasis(MeasureGroupComponent group) {

private MeasureScoring getScoringDef(MeasureScoring measureScoring, MeasureScoring groupScoring) {
if (groupScoring == null && measureScoring == null) {
throw new IllegalArgumentException("MeasureScoring must be specified on Group or Measure");
throw new InvalidRequestException("MeasureScoring must be specified on Group or Measure");
}
if (groupScoring != null) {
return groupScoring;
Expand Down

0 comments on commit 7a6cb14

Please sign in to comment.