Skip to content

Commit

Permalink
BFD-3415: Replaces Code System on FHIR Mapping for rev_cntr_ndc_qty_q…
Browse files Browse the repository at this point in the history
…lfr_cd (#2356)
  • Loading branch information
meliGuzman authored Jul 9, 2024
1 parent 0d0dea9 commit ea434ce
Show file tree
Hide file tree
Showing 35 changed files with 186 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"version": "R4",
"resource": "ExplanationOfBenefit",
"element": "item[N].modifier[N].coding[N].code",
"fhirPath": "item[%n].modifier.coding.where(system='https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd').code",
"fhirPath": "item[%n].modifier.coding.where(system='http://unitsofmeasure.org').code",
"discriminator": [
"item[N].modifier[N].coding[N].system = 'https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd'"
"item[N].modifier[N].coding[N].system = 'http://unitsofmeasure.org'"
],
"additional": [],
"derived": "",
"note": "",
"example": "[\\n {\\n \"system\": \"https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd\",\\n \"code\": \"GG\"\\n }\\n]"
"example": "[\\n {\\n \"system\": \"http://unitsofmeasure.org\",\\n \"code\": \"GG\"\\n }\\n]"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,48 @@ public final class TransformerConstants {
/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} for "International Unit". */
public static final String CODING_SYSTEM_UCUM_F2_CODE = "[IU]";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode() constant} for "International Unit". */
public static final String CODING_SYSTEM_UCUM_F2 = "F2";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getDisplay()} for "International Unit". */
public static final String CODING_SYSTEM_UCUM_F2_DISPLAY = "International Unit";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} for "Gram". */
public static final String CODING_SYSTEM_UCUM_GR_CODE = "g";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getDisplay()} for "Gram". */
public static final String CODING_SYSTEM_UCUM_GR_DISPLAY = "Gram";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} constant for "Gram". */
public static final String CODING_SYSTEM_UCUM_GR = "GR";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} for "Milliliter". */
public static final String CODING_SYSTEM_UCUM_ML_CODE = "mL";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getDisplay()} for "Milliliter". */
public static final String CODING_SYSTEM_UCUM_ML_DISPLAY = "Milliliter";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} constant for "Milliliter". */
public static final String CODING_SYSTEM_UCUM_ML = "ML";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} for "Milligram". */
public static final String CODING_SYSTEM_UCUM_ME_CODE = "mg";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getDisplay()} for "Milligram". */
public static final String CODING_SYSTEM_UCUM_ME_DISPLAY = "Milligram";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} constant for "Milligram". */
public static final String CODING_SYSTEM_UCUM_ME = "ME";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} for "Unit". */
public static final String CODING_SYSTEM_UCUM_UN_CODE = "[arb'U]";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getDisplay()} for "Unit". */
public static final String CODING_SYSTEM_UCUM_UN_DISPLAY = "Unit";

/** The {@link #CODING_SYSTEM_UCUM} {@link Coding#getCode()} constant for "Unit". */
public static final String CODING_SYSTEM_UCUM_UN = "UN";

/**
* Code System URL for Data Absent <a
* href="http://hl7.org/fhir/StructureDefinition/data-absent-reason">Extension: Data Absent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,27 @@ static CodeableConcept createCodeableConcept(
return concept;
}

/**
* Creates a {@link CodeableConcept} from the specified system and code.
*
* @param rootResource the root FHIR {@link IAnyResource} that the resultant {@link
* CodeableConcept} will be contained in
* @param codingSystem the {@link Coding#getSystem()} to use
* @param codingCode the {@link Coding#getCode()} to use
* @return a {@link CodeableConcept} with the specified {@link Coding}
*/
static CodeableConcept createCodeableConceptForUnitOfMeasure(
IAnyResource rootResource, String codingSystem, Optional<String> codingCode) {
if (rootResource == null || codingCode.isEmpty()) {
throw new IllegalArgumentException();
}
Coding coding = createUnitOfMeasureCoding(codingSystem, codingCode.get());
CodeableConcept concept = new CodeableConcept();
concept.addCoding(coding);

return concept;
}

/**
* Adds a qualification {@link CodeableConcept} to the given careTeam component, if the input code
* optional is not empty. If the code is empty, returns with no effect. Can safely be called to
Expand Down Expand Up @@ -892,6 +913,32 @@ public static Coding createCoding(
return new Coding(system, codeString, display);
}

/**
* Creates a unit of measure coding.
*
* @param codingSystem the {@link Coding#getSystem()} to use
* @param codingCode the {@link Coding#getCode()} to use
* @return the output {@link Coding} for the specified input values
*/
public static Coding createUnitOfMeasureCoding(String codingSystem, String codingCode) {
String display =
switch (codingCode) {
case TransformerConstants.CODING_SYSTEM_UCUM_F2 -> TransformerConstants
.CODING_SYSTEM_UCUM_F2_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_GR -> TransformerConstants
.CODING_SYSTEM_UCUM_GR_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_ML -> TransformerConstants
.CODING_SYSTEM_UCUM_ML_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_ME -> TransformerConstants
.CODING_SYSTEM_UCUM_ME_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_UN -> TransformerConstants
.CODING_SYSTEM_UCUM_UN_DISPLAY;
default -> null;
};

return new Coding(codingSystem, codingCode, display);
}

/**
* Creates a coding.
*
Expand Down Expand Up @@ -3797,10 +3844,8 @@ static ItemComponent mapEobCommonItemRevenue(
if (nationalDrugCodeQualifierCode.isPresent()) {
item.getModifier()
.add(
TransformerUtilsV2.createCodeableConcept(
eob,
CcwCodebookVariable.REV_CNTR_NDC_QTY_QLFR_CD,
nationalDrugCodeQualifierCode));
TransformerUtilsV2.createCodeableConceptForUnitOfMeasure(
eob, TransformerConstants.CODING_SYSTEM_UCUM, nationalDrugCodeQualifierCode));
}

// REV_CNTR_NDC_QTY => ExplanationOfBenefit.item.quantity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,16 @@ private List<Claim.ItemComponent> getClaimItems(RdaFissClaim claimGroup) {
quantity.setSystem(TransformerConstants.CODING_SYSTEM_UCUM);

switch (revenueLine.getNdcQtyQual()) {
case "F2" -> quantity.setCode(TransformerConstants.CODING_SYSTEM_UCUM_F2_CODE);
case "GR" -> quantity.setCode(TransformerConstants.CODING_SYSTEM_UCUM_GR_CODE);
case "ML" -> quantity.setCode(TransformerConstants.CODING_SYSTEM_UCUM_ML_CODE);
case "ME" -> quantity.setCode(TransformerConstants.CODING_SYSTEM_UCUM_ME_CODE);
case "UN" -> quantity.setCode(TransformerConstants.CODING_SYSTEM_UCUM_UN_CODE);
case TransformerConstants.CODING_SYSTEM_UCUM_F2 -> quantity.setCode(
TransformerConstants.CODING_SYSTEM_UCUM_F2_CODE);
case TransformerConstants.CODING_SYSTEM_UCUM_GR -> quantity.setCode(
TransformerConstants.CODING_SYSTEM_UCUM_GR_CODE);
case TransformerConstants.CODING_SYSTEM_UCUM_ML -> quantity.setCode(
TransformerConstants.CODING_SYSTEM_UCUM_ML_CODE);
case TransformerConstants.CODING_SYSTEM_UCUM_ME -> quantity.setCode(
TransformerConstants.CODING_SYSTEM_UCUM_ME_CODE);
case TransformerConstants.CODING_SYSTEM_UCUM_UN -> quantity.setCode(
TransformerConstants.CODING_SYSTEM_UCUM_UN_CODE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,44 @@ static void setQuantityUnitInfo(
}
}

/**
* Sets the {@link Quantity} fields related to the unit for the amount: {@link
* Quantity#getSystem()}, {@link Quantity#getCode()}, and {@link Quantity#getUnit()}.
*
* @param codingSystem the {@link org.hl7.fhir.r4.model.Coding#getSystem()} to use
* @param unitCode the value to use for {@link Quantity#getCode()}
* @param quantity the {@link Quantity} to modify
*/
static void setNdcQuantityUnitInfo(
String codingSystem, Optional<String> unitCode, Quantity quantity) {
if (!unitCode.isPresent()) {
return;
}
quantity.setSystem(codingSystem);
quantity.setCode(unitCode.get());

String display =
switch (unitCode.get()) {
case TransformerConstants.CODING_SYSTEM_UCUM_F2 -> TransformerConstants
.CODING_SYSTEM_UCUM_F2_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_GR -> TransformerConstants
.CODING_SYSTEM_UCUM_GR_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_ML -> TransformerConstants
.CODING_SYSTEM_UCUM_ML_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_ME -> TransformerConstants
.CODING_SYSTEM_UCUM_ME_DISPLAY;
case TransformerConstants.CODING_SYSTEM_UCUM_UN -> TransformerConstants
.CODING_SYSTEM_UCUM_UN_DISPLAY;
default -> null;
};

Optional<String> unit = Optional.ofNullable(display);

if (unit.isPresent()) {
quantity.setUnit(unit.get());
}
}

/**
* Creates an extension coding for the specified ccw variable and code.
*
Expand Down Expand Up @@ -1942,11 +1980,8 @@ static ItemComponent mapEobCommonItemRevenue(
Extension drugQuantityExtension =
createExtensionQuantity(CcwCodebookVariable.REV_CNTR_NDC_QTY, nationalDrugCodeQuantity);
Quantity drugQuantity = (Quantity) drugQuantityExtension.getValue();
TransformerUtils.setQuantityUnitInfo(
CcwCodebookVariable.REV_CNTR_NDC_QTY_QLFR_CD,
nationalDrugCodeQualifierCode,
eob,
drugQuantity);
TransformerUtils.setNdcQuantityUnitInfo(
TransformerConstants.CODING_SYSTEM_UCUM, nationalDrugCodeQualifierCode, drugQuantity);

item.addExtension(drugQuantityExtension);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,12 +1222,7 @@ public void shouldHaveLineItemModifier() {

CodeableConcept compare =
new CodeableConcept()
.setCoding(
Arrays.asList(
new Coding(
"https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"GG",
null)));
.setCoding(Arrays.asList(new Coding("http://unitsofmeasure.org", "GG", null)));

assertTrue(compare.equalsDeep(modifier));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"total" : 4,
"link" : [ {
"relation" : "self",
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/Coverage?_format=json&beneficiary=Patient%2F567834"
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/Coverage/?beneficiary=567834"
} ],
"entry" : [ {
"resource" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"total" : 8,
"link" : [ {
"relation" : "self",
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit?_format=json&patient=Patient%2F567834"
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit/?patient=567834"
} ],
"entry" : [ {
"resource" : {
Expand Down Expand Up @@ -394,7 +394,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 77,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "GG"
}
} ],
Expand Down Expand Up @@ -1455,7 +1455,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 666,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "DD"
}
} ],
Expand Down Expand Up @@ -2313,7 +2313,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 77,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "GG"
}
} ],
Expand Down Expand Up @@ -2965,7 +2965,7 @@
"valueQuantity" : {
"value" : 234.567,
"unit" : "Milliliter",
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "ML"
}
} ],
Expand Down Expand Up @@ -4370,7 +4370,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 5454,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "B"
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"total" : 8,
"link" : [ {
"relation" : "first",
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit?_format=json&startIndex=0&_count=8&patient=Patient%2F567834"
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit?patient=567834&startIndex=0&_count=8"
}, {
"relation" : "last",
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit?_format=json&startIndex=0&_count=8&patient=Patient%2F567834"
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit?patient=567834&startIndex=0&_count=8"
}, {
"relation" : "self",
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit?_count=8&_format=json&patient=Patient%2F567834"
"url" : "https://localhost:IGNORED_FIELD/v1/fhir/ExplanationOfBenefit/?_count=8&patient=567834"
} ],
"entry" : [ {
"resource" : {
Expand Down Expand Up @@ -400,7 +400,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 77,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "GG"
}
} ],
Expand Down Expand Up @@ -1461,7 +1461,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 666,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "DD"
}
} ],
Expand Down Expand Up @@ -2319,7 +2319,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 77,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "GG"
}
} ],
Expand Down Expand Up @@ -2971,7 +2971,7 @@
"valueQuantity" : {
"value" : 234.567,
"unit" : "Milliliter",
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "ML"
}
} ],
Expand Down Expand Up @@ -4376,7 +4376,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 5454,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "B"
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 666,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "DD"
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 5454,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "B"
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 77,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "GG"
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
"url" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty",
"valueQuantity" : {
"value" : 77,
"system" : "https://bluebutton.cms.gov/resources/variables/rev_cntr_ndc_qty_qlfr_cd",
"system" : "http://unitsofmeasure.org",
"code" : "GG"
}
} ],
Expand Down
Loading

0 comments on commit ea434ce

Please sign in to comment.