Search in sources :

Example 56 with AdjudicationComponent

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 method mapEobCommonItemCarrierDME.

/**
 * Transforms the common item level data elements between the {@link CarrierClaimLine} and {@link
 * DMEClaimLine} claim types to FHIR. The method parameter fields from {@link CarrierClaimLine}
 * and {@link DMEClaimLine} are listed below and their corresponding RIF CCW fields (denoted in
 * all CAPS below from {@link CarrierClaimColumn} and {@link DMEClaimColumn}).
 *
 * @param item the {@ ItemComponent} to modify
 * @param eob the {@ ExplanationOfBenefit} to modify
 * @param claimId CLM_ID,
 * @param serviceCount LINE_SRVC_CNT,
 * @param placeOfServiceCode LINE_PLACE_OF_SRVC_CD,
 * @param firstExpenseDate LINE_1ST_EXPNS_DT,
 * @param lastExpenseDate LINE_LAST_EXPNS_DT,
 * @param beneficiaryPaymentAmount LINE_BENE_PMT_AMT,
 * @param providerPaymentAmount LINE_PRVDR_PMT_AMT,
 * @param beneficiaryPartBDeductAmount LINE_BENE_PTB_DDCTBL_AMT,
 * @param primaryPayerCode LINE_BENE_PRMRY_PYR_CD,
 * @param primaryPayerPaidAmount LINE_BENE_PRMRY_PYR_PD_AMT,
 * @param betosCode BETOS_CD,
 * @param paymentAmount LINE_NCH_PMT_AMT,
 * @param paymentCode LINE_PMT_80_100_CD,
 * @param coinsuranceAmount LINE_COINSRNC_AMT,
 * @param submittedChargeAmount LINE_SBMTD_CHRG_AMT,
 * @param allowedChargeAmount LINE_ALOWD_CHRG_AMT,
 * @param processingIndicatorCode LINE_PRCSG_IND_CD,
 * @param serviceDeductibleCode LINE_SERVICE_DEDUCTIBLE,
 * @param hctHgbTestTypeCode LINE_HCT_HGB_TYPE_CD
 * @param hctHgbTestResult LINE_HCT_HGB_RSLT_NUM,
 * @param cmsServiceTypeCode LINE_CMS_TYPE_SRVC_CD,
 * @param nationalDrugCode LINE_NDC_CD,
 * @param beneficiaryId BENE_ID,
 * @param referringPhysicianNpi RFR_PHYSN_NPI
 * @return the {@link ItemComponent}
 */
static ItemComponent mapEobCommonItemCarrierDME(ItemComponent item, ExplanationOfBenefit eob, String claimId, int sequence, BigDecimal serviceCount, String placeOfServiceCode, Optional<LocalDate> firstExpenseDate, Optional<LocalDate> lastExpenseDate, BigDecimal beneficiaryPaymentAmount, BigDecimal providerPaymentAmount, BigDecimal beneficiaryPartBDeductAmount, Optional<Character> primaryPayerCode, BigDecimal primaryPayerPaidAmount, Optional<String> betosCode, BigDecimal paymentAmount, Optional<Character> paymentCode, BigDecimal coinsuranceAmount, BigDecimal submittedChargeAmount, BigDecimal allowedChargeAmount, Optional<String> processingIndicatorCode, Optional<Character> serviceDeductibleCode, Optional<String> hctHgbTestTypeCode, BigDecimal hctHgbTestResult, char cmsServiceTypeCode, Optional<String> nationalDrugCode) {
    // LINE_SRVC_CNT => ExplanationOfBenefit.item.quantity
    item.setQuantity(new SimpleQuantity().setValue(serviceCount));
    // LINE_CMS_TYPE_SRVC_CD => ExplanationOfBenefit.item.category
    item.setCategory(createCodeableConcept(eob, CcwCodebookVariable.LINE_CMS_TYPE_SRVC_CD, cmsServiceTypeCode));
    // LINE_PLACE_OF_SRVC_CD => ExplanationOfBenefit.item.location
    item.setLocation(createCodeableConcept(eob, CcwCodebookVariable.LINE_PLACE_OF_SRVC_CD, placeOfServiceCode));
    // BETOS_CD => ExplanationOfBenefit.item.extension
    betosCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.BETOS_CD, code)));
    // LINE_LAST_EXPNS_DT => ExplanationOfBenefit.item.servicedPeriod
    if (firstExpenseDate.isPresent() && lastExpenseDate.isPresent()) {
        validatePeriodDates(firstExpenseDate, lastExpenseDate);
        item.setServiced(new Period().setStart((convertToDate(firstExpenseDate.get())), TemporalPrecisionEnum.DAY).setEnd((convertToDate(lastExpenseDate.get())), TemporalPrecisionEnum.DAY));
    } else // LINE_1ST_EXPNS_DT => ExplanationOfBenefit.item.servicedDate
    if (firstExpenseDate.isPresent()) {
        item.setServiced(new DateType(convertToDate(firstExpenseDate.get())));
    }
    // LINE_NCH_PMT_AMT => ExplanationOfBenefit.item.adjudication
    Optional<AdjudicationComponent> nchPmtAmtAdjudication = createAdjudicationAmtSlice(CcwCodebookVariable.LINE_NCH_PMT_AMT, C4BBAdjudication.BENEFIT, paymentAmount);
    addAdjudication(item, nchPmtAmtAdjudication);
    // LINE_PMT_80_100_CD => ExplanationOfBenefit.item.adjudication.extension
    if (paymentCode.isPresent() && nchPmtAmtAdjudication.isPresent()) {
        nchPmtAmtAdjudication.get().addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_PMT_80_100_CD, paymentCode));
    }
    // PAID_TO_PATIENT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_BENE_PMT_AMT, C4BBAdjudication.PAID_TO_PATIENT, beneficiaryPaymentAmount));
    // LINE_PRVDR_PMT_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_PRVDR_PMT_AMT, C4BBAdjudication.PAID_TO_PROVIDER, providerPaymentAmount));
    // LINE_BENE_PTB_DDCTBL_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_BENE_PTB_DDCTBL_AMT, C4BBAdjudication.DEDUCTIBLE, beneficiaryPartBDeductAmount));
    // LINE_BENE_PRMRY_PYR_CD => ExplanationOfBenefit.item.extension
    primaryPayerCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_BENE_PRMRY_PYR_CD, code)));
    // LINE_BENE_PRMRY_PYR_PD_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_BENE_PRMRY_PYR_PD_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, primaryPayerPaidAmount));
    // LINE_COINSRNC_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_COINSRNC_AMT, C4BBAdjudication.COINSURANCE, coinsuranceAmount));
    // LINE_SBMTD_CHRG_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_SBMTD_CHRG_AMT, C4BBAdjudication.SUBMITTED, submittedChargeAmount));
    // LINE_ALOWD_CHRG_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_ALOWD_CHRG_AMT, C4BBAdjudication.ELIGIBLE, submittedChargeAmount));
    // LINE_BENE_PRMRY_PYR_CD => ExplanationOfBenefit.item.extension
    processingIndicatorCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_PRCSG_IND_CD, code)));
    // LINE_SERVICE_DEDUCTIBLE => ExplanationOfBenefit.item.extension
    serviceDeductibleCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_SERVICE_DEDUCTIBLE, code)));
    // LINE_HCT_HGB_RSLT_NUM => Observation.value
    if (hctHgbTestTypeCode.isPresent()) {
        String observationId = "line-observation-" + sequence;
        String observationRef = "#" + observationId;
        // The `item` will link to a `supportingInfo` that references the embedded Observation
        SupportingInformationComponent comp = addInformation(eob, CcwCodebookVariable.LINE_HCT_HGB_RSLT_NUM);
        comp.setValue(new Reference(observationRef));
        // Create embedded Observation in ExplanationOfBenefit.contained
        Observation hctHgbObservation = findOrCreateContainedObservation(eob, observationId);
        hctHgbObservation.setStatus(ObservationStatus.UNKNOWN);
        hctHgbObservation.setCode(createCodeableConcept(eob, CcwCodebookVariable.LINE_HCT_HGB_TYPE_CD, hctHgbTestTypeCode));
        hctHgbObservation.setValue(new Quantity().setValue(hctHgbTestResult));
        // Link item.informationSequence to the new `supportingInfo` entry
        item.addInformationSequence(comp.getSequence());
    }
    // LINE_NDC_CD => ExplanationOfBenefit.item.productOrService.extension
    addNationalDrugCode(item, nationalDrugCode);
    return item;
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) Reference(org.hl7.fhir.r4.model.Reference) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Observation(org.hl7.fhir.r4.model.Observation) Period(org.hl7.fhir.r4.model.Period) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Quantity(org.hl7.fhir.r4.model.Quantity) DateType(org.hl7.fhir.r4.model.DateType)

Example 57 with AdjudicationComponent

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 method createAdjudicationCategory.

/**
 * @param ccwVariable the {@link CcwCodebookInterface} being mapped
 * @return the {@link AdjudicationComponent#getCategory()} {@link CodeableConcept} to use for the
 *     specified {@link CcwCodebookInterface}
 */
static CodeableConcept createAdjudicationCategory(CcwCodebookInterface ccwVariable) {
    /*
     * Adjudication.category is mapped a bit differently than other Codings/CodeableConcepts: they
     * all share the same Coding.system and use the CcwCodebookInterface reference URL as their
     * Coding.code. This looks weird, but makes it easy for API developers to find more information
     * about what the specific adjudication they're looking at means.
     */
    String conceptCode = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
    CodeableConcept categoryConcept = createCodeableConcept(TransformerConstants.CODING_CCW_ADJUDICATION_CATEGORY, conceptCode);
    categoryConcept.getCodingFirstRep().setDisplay(ccwVariable.getVariable().getLabel());
    return categoryConcept;
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 58 with AdjudicationComponent

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent in project beneficiary-fhir-data by CMSgov.

the class PartDEventTransformerV2Test method shouldHaveLineItemAdjudicationPtntPayAmt.

@Test
public void shouldHaveLineItemAdjudicationPtntPayAmt() {
    AdjudicationComponent adjudication = TransformerTestUtilsV2.findAdjudicationByCategory("https://bluebutton.cms.gov/resources/variables/ptnt_pay_amt", eob.getItemFirstRep().getAdjudication());
    AdjudicationComponent compare = new AdjudicationComponent().setCategory(new CodeableConcept().setCoding(Arrays.asList(new Coding("http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBAdjudication", "paidbypatient", "Paid by patient"), new Coding("https://bluebutton.cms.gov/resources/codesystem/adjudication", "https://bluebutton.cms.gov/resources/variables/ptnt_pay_amt", "Amount Paid by Patient")))).setAmount(new Money().setValue(235.85).setCurrency(TransformerConstants.CODED_MONEY_USD));
    assertTrue(compare.equalsDeep(adjudication));
}
Also used : Money(org.hl7.fhir.r4.model.Money) Coding(org.hl7.fhir.r4.model.Coding) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 59 with AdjudicationComponent

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent in project beneficiary-fhir-data by CMSgov.

the class PartDEventTransformerV2Test method shouldHaveLineItemAdjudicationCvrdDPlanPdAmt.

@Test
public void shouldHaveLineItemAdjudicationCvrdDPlanPdAmt() {
    AdjudicationComponent adjudication = TransformerTestUtilsV2.findAdjudicationByCategory("https://bluebutton.cms.gov/resources/variables/cvrd_d_plan_pd_amt", eob.getItemFirstRep().getAdjudication());
    AdjudicationComponent compare = new AdjudicationComponent().setCategory(new CodeableConcept().setCoding(Arrays.asList(new Coding("http://terminology.hl7.org/CodeSystem/adjudication", "benefit", "Benefit Amount"), new Coding("https://bluebutton.cms.gov/resources/codesystem/adjudication", "https://bluebutton.cms.gov/resources/variables/cvrd_d_plan_pd_amt", "Amount paid by Part D plan for the PDE (drug is covered by Part D)")))).setAmount(new Money().setValue(126.99).setCurrency(TransformerConstants.CODED_MONEY_USD));
    assertTrue(compare.equalsDeep(adjudication));
}
Also used : Money(org.hl7.fhir.r4.model.Money) Coding(org.hl7.fhir.r4.model.Coding) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 60 with AdjudicationComponent

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent in project beneficiary-fhir-data by CMSgov.

the class HospiceClaimTransformerV2Test method shouldHaveLineItemRevCenterNonRecoverdChargeAmtAdjudication.

@Test
public void shouldHaveLineItemRevCenterNonRecoverdChargeAmtAdjudication() {
    AdjudicationComponent adjudication = TransformerTestUtilsV2.findAdjudicationByCategory("https://bluebutton.cms.gov/resources/variables/rev_cntr_ncvrd_chrg_amt", eob.getItemFirstRep().getAdjudication());
    assertNotNull(adjudication);
    AdjudicationComponent compare = new AdjudicationComponent().setCategory(new CodeableConcept().setCoding(Arrays.asList(new Coding("http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBAdjudication", "noncovered", "Noncovered"), new Coding("https://bluebutton.cms.gov/resources/codesystem/adjudication", "https://bluebutton.cms.gov/resources/variables/rev_cntr_ncvrd_chrg_amt", "Revenue Center Non-Covered Charge Amount")))).setAmount(new Money().setValueElement(new DecimalType("300.00")).setCurrency(TransformerConstants.CODED_MONEY_USD));
    assertTrue(compare.equalsDeep(adjudication));
}
Also used : Money(org.hl7.fhir.r4.model.Money) Coding(org.hl7.fhir.r4.model.Coding) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) DecimalType(org.hl7.fhir.r4.model.DecimalType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Aggregations

CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)67 AdjudicationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent)67 Coding (org.hl7.fhir.r4.model.Coding)65 Test (org.junit.jupiter.api.Test)64 Money (org.hl7.fhir.r4.model.Money)62 BigDecimal (java.math.BigDecimal)18 DecimalType (org.hl7.fhir.r4.model.DecimalType)8 AdjudicationComponent (org.hl7.fhir.dstu3.model.ExplanationOfBenefit.AdjudicationComponent)5 IBaseExtension (org.hl7.fhir.instance.model.api.IBaseExtension)5 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)4 Extension (org.hl7.fhir.dstu3.model.Extension)4 Observation (org.hl7.fhir.dstu3.model.Observation)4 Reference (org.hl7.fhir.dstu3.model.Reference)4 FhirContext (ca.uhn.fhir.context.FhirContext)3 TemporalPrecisionEnum (ca.uhn.fhir.model.api.TemporalPrecisionEnum)3 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)3 CcwCodebookInterface (gov.cms.bfd.model.codebook.model.CcwCodebookInterface)3 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)3 Period (org.hl7.fhir.dstu3.model.Period)3 Quantity (org.hl7.fhir.dstu3.model.Quantity)3