Search in sources :

Example 26 with ItemComponent

use of org.hl7.fhir.r4.model.Claim.ItemComponent in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method mapEobCommonItemRevenue.

/**
 * Transforms the common item level data elements between the {@link InpatientClaimLine} {@link
 * OutpatientClaimLine} {@link HospiceClaimLine} {@link HHAClaimLine}and {@link SNFClaimLine}
 * claim types to FHIR. The method parameter fields from {@link InpatientClaimLine} {@link
 * OutpatientClaimLine} {@link HospiceClaimLine} {@link HHAClaimLine}and {@link SNFClaimLine} are
 * listed below and their corresponding RIF CCW fields (denoted in all CAPS below from {@link
 * InpatientClaimColumn} {@link OutpatientClaimColumn} {@link HopsiceClaimColumn} {@link
 * HHAClaimColumn} and {@link SNFClaimColumn}).
 *
 * @param item the {@ ItemComponent} to modify
 * @param eob the {@ ExplanationOfBenefit} to modify
 * @param revenueCenterCode REV_CNTR,
 * @param rateAmount REV_CNTR_RATE_AMT,
 * @param totalChargeAmount REV_CNTR_TOT_CHRG_AMT,
 * @param nonCoveredChargeAmount REV_CNTR_NCVRD_CHRG_AMT,
 * @param unitCount REV_CNTR_UNIT_CNT,
 * @param nationalDrugCodeQuantity REV_CNTR_NDC_QTY,
 * @param nationalDrugCodeQualifierCode REV_CNTR_NDC_QTY_QLFR_CD,
 * @param revenueCenterRenderingPhysicianNPI RNDRNG_PHYSN_NPI
 * @return the {@link ItemComponent}
 */
static ItemComponent mapEobCommonItemRevenue(ItemComponent item, ExplanationOfBenefit eob, String revenueCenterCode, BigDecimal rateAmount, BigDecimal totalChargeAmount, BigDecimal nonCoveredChargeAmount, BigDecimal unitCount, Optional<BigDecimal> nationalDrugCodeQuantity, Optional<String> nationalDrugCodeQualifierCode, Optional<String> revenueCenterRenderingPhysicianNPI) {
    item.setRevenue(createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR, revenueCenterCode));
    item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_RATE_AMT)).setAmount(createMoney(rateAmount));
    item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_TOT_CHRG_AMT)).setAmount(createMoney(totalChargeAmount));
    item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_NCVRD_CHRG_AMT)).setAmount(createMoney(nonCoveredChargeAmount));
    SimpleQuantity qty = new SimpleQuantity();
    qty.setValue(unitCount);
    item.setQuantity(qty);
    if (nationalDrugCodeQualifierCode.isPresent()) {
        /*
       * TODO: Is NDC count only ever present when line quantity isn't set? Depending on that, it
       * may be that we should stop using this as an extension and instead set the code & system on
       * the FHIR quantity field.
       */
        // TODO Shouldn't this be part of the same Extension with the NDC code itself?
        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);
        item.addExtension(drugQuantityExtension);
    }
    if (revenueCenterRenderingPhysicianNPI.isPresent()) {
        TransformerUtils.addCareTeamPractitioner(eob, item, TransformerConstants.CODING_NPI_US, revenueCenterRenderingPhysicianNPI.get(), ClaimCareteamrole.PRIMARY);
    }
    return item;
}
Also used : IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) Extension(org.hl7.fhir.dstu3.model.Extension) SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) Quantity(org.hl7.fhir.dstu3.model.Quantity)

Example 27 with ItemComponent

use of org.hl7.fhir.r4.model.Claim.ItemComponent in project beneficiary-fhir-data by CMSgov.

the class HHAClaimTransformerTest method assertMatches.

/**
 * Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
 * the specified {@link HHAClaim}.
 *
 * @param claim the {@link HHAClaim} that the {@link ExplanationOfBenefit} was generated from
 * @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
 *     HHAClaim}
 * @throws FHIRException (indicates test failure)
 */
static void assertMatches(HHAClaim claim, ExplanationOfBenefit eob) throws FHIRException {
    // Test to ensure group level fields between all claim types match
    TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.HHA, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
    // test the common field provider number is set as expected in the EOB
    TransformerTestUtils.assertProviderNumber(eob, claim.getProviderNumber());
    // Test to ensure common group fields between Inpatient, Outpatient HHA, Hospice
    // and SNF match
    TransformerTestUtils.assertEobCommonGroupInpOutHHAHospiceSNFEquals(eob, claim.getOrganizationNpi(), claim.getClaimFacilityTypeCode(), claim.getClaimFrequencyCode(), claim.getClaimNonPaymentReasonCode(), claim.getPatientDischargeStatusCode(), claim.getClaimServiceClassificationTypeCode(), claim.getClaimPrimaryPayerCode(), claim.getAttendingPhysicianNpi(), claim.getTotalChargeAmount(), claim.getPrimaryPayerPaidAmount(), claim.getFiscalIntermediaryNumber(), claim.getFiDocumentClaimControlNumber(), claim.getFiOriginalClaimControlNumber());
    assertEquals(4, eob.getDiagnosis().size());
    if (claim.getClaimLUPACode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.CLM_HHA_LUPA_IND_CD, CcwCodebookVariable.CLM_HHA_LUPA_IND_CD, claim.getClaimLUPACode(), eob);
    if (claim.getClaimReferralCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.CLM_HHA_RFRL_CD, CcwCodebookVariable.CLM_HHA_RFRL_CD, claim.getClaimReferralCode(), eob);
    TransformerTestUtils.assertBenefitBalanceUsedIntEquals(BenefitCategory.MEDICAL, CcwCodebookVariable.CLM_HHA_TOT_VISIT_CNT, claim.getTotalVisitCount().intValue(), eob);
    assertEquals(1, eob.getItem().size());
    ItemComponent eobItem0 = eob.getItem().get(0);
    HHAClaimLine claimLine1 = claim.getLines().get(0);
    assertEquals(claimLine1.getLineNumber(), new BigDecimal(eobItem0.getSequence()));
    assertEquals(claim.getProviderStateCode(), eobItem0.getLocationAddress().getState());
    TransformerTestUtils.assertAdjudicationReasonEquals(CcwCodebookVariable.REV_CNTR_1ST_ANSI_CD, claimLine1.getRevCntr1stAnsiCd(), eobItem0.getAdjudication());
    TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), claimLine1.getHcpcsInitialModifierCode(), claimLine1.getHcpcsSecondModifierCode(), Optional.empty(), 0);
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.REV_CNTR_STUS_IND_CD, claimLine1.getStatusCode().get(), eobItem0.getRevenue());
    // test common eob information between Inpatient, HHA, Hospice and SNF claims are set as
    // expected
    TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFEquals(eob, claim.getCareStartDate(), Optional.empty(), Optional.empty());
    // Test to ensure common group field coinsurance between Inpatient, HHA, Hospice and SNF match
    TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFCoinsuranceEquals(eobItem0, claimLine1.getDeductibleCoinsuranceCd());
    String claimControlNumber = "0000000000";
    // Test to ensure item level fields between Inpatient, Outpatient, HHA, Hopsice
    // and SNF match
    TransformerTestUtils.assertEobCommonItemRevenueEquals(eobItem0, eob, claimLine1.getRevenueCenterCode(), claimLine1.getRateAmount(), claimLine1.getTotalChargeAmount(), claimLine1.getNonCoveredChargeAmount(), claimLine1.getUnitCount(), claimControlNumber, claimLine1.getNationalDrugCodeQuantity(), claimLine1.getNationalDrugCodeQualifierCode(), claimLine1.getRevenueCenterRenderingPhysicianNPI(), 1);
    // Test to ensure item level fields between Outpatient, HHA and Hospice match
    TransformerTestUtils.assertEobCommonItemRevenueOutHHAHospice(eobItem0, claimLine1.getRevenueCenterDate(), claimLine1.getPaymentAmount());
    // verify {@link
    // TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
    // method worked as expected for this claim type
    TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.HHA, // be updated to match expected result.
    Optional.empty(), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
    // Test lastUpdated
    TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
Also used : ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) HHAClaimLine(gov.cms.bfd.model.rif.HHAClaimLine) BigDecimal(java.math.BigDecimal)

Example 28 with ItemComponent

use of org.hl7.fhir.r4.model.Claim.ItemComponent in project beneficiary-fhir-data by CMSgov.

the class HospiceClaimTransformerTest method assertMatches.

/**
 * Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
 * the specified {@link HospiceClaim}.
 *
 * @param claim the {@link HospiceClaim} that the {@link ExplanationOfBenefit} was generated from
 * @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
 *     HospiceClaim}
 * @throws FHIRException (indicates test failure)
 */
static void assertMatches(HospiceClaim claim, ExplanationOfBenefit eob) throws FHIRException {
    // Test to ensure group level fields between all claim types match
    TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.HOSPICE, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
    // test the common field provider number is set as expected in the EOB
    TransformerTestUtils.assertProviderNumber(eob, claim.getProviderNumber());
    TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, claim.getPatientStatusCd(), eob);
    TransformerTestUtils.assertDateEquals(claim.getClaimHospiceStartDate().get(), eob.getHospitalization().getStartElement());
    TransformerTestUtils.assertDateEquals(claim.getBeneficiaryDischargeDate().get(), eob.getHospitalization().getEndElement());
    // Test to ensure common group fields between Inpatient, Outpatient HHA, Hospice
    // and SNF match
    TransformerTestUtils.assertEobCommonGroupInpOutHHAHospiceSNFEquals(eob, claim.getOrganizationNpi(), claim.getClaimFacilityTypeCode(), claim.getClaimFrequencyCode(), claim.getClaimNonPaymentReasonCode(), claim.getPatientDischargeStatusCode(), claim.getClaimServiceClassificationTypeCode(), claim.getClaimPrimaryPayerCode(), claim.getAttendingPhysicianNpi(), claim.getTotalChargeAmount(), claim.getPrimaryPayerPaidAmount(), claim.getFiscalIntermediaryNumber(), claim.getFiDocumentClaimControlNumber(), claim.getFiOriginalClaimControlNumber());
    // test common eob information between Inpatient, HHA, Hospice and SNF claims are set as
    // expected
    TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFEquals(eob, claim.getClaimHospiceStartDate(), claim.getBeneficiaryDischargeDate(), Optional.of(claim.getUtilizationDayCount()));
    assertEquals(4, eob.getDiagnosis().size());
    assertEquals(1, eob.getItem().size());
    ItemComponent eobItem0 = eob.getItem().get(0);
    HospiceClaimLine claimLine1 = claim.getLines().get(0);
    assertEquals(claimLine1.getLineNumber(), new BigDecimal(eobItem0.getSequence()));
    TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.BENE_HOSPC_PRD_CNT, claim.getHospicePeriodCount(), eob.getHospitalization());
    assertEquals(claim.getProviderStateCode(), eobItem0.getLocationAddress().getState());
    TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), claimLine1.getHcpcsInitialModifierCode(), claimLine1.getHcpcsSecondModifierCode(), Optional.empty(), 0);
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_PRVDR_PMT_AMT, claimLine1.getProviderPaymentAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_BENE_PMT_AMT, claimLine1.getBenficiaryPaymentAmount(), eobItem0.getAdjudication());
    // Test to ensure common group field coinsurance between Inpatient, HHA, Hospice and SNF match
    TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFCoinsuranceEquals(eobItem0, claimLine1.getDeductibleCoinsuranceCd());
    String claimControlNumber = "0000000000";
    // Test to ensure item level fields between Inpatient, Outpatient, HHA, Hopsice
    // and SNF match
    TransformerTestUtils.assertEobCommonItemRevenueEquals(eobItem0, eob, claimLine1.getRevenueCenterCode(), claimLine1.getRateAmount(), claimLine1.getTotalChargeAmount(), claimLine1.getNonCoveredChargeAmount().get(), claimLine1.getUnitCount(), claimControlNumber, claimLine1.getNationalDrugCodeQuantity(), claimLine1.getNationalDrugCodeQualifierCode(), claimLine1.getRevenueCenterRenderingPhysicianNPI(), 1);
    TransformerTestUtils.assertCareTeamEquals(claimLine1.getRevenueCenterRenderingPhysicianNPI().get(), ClaimCareteamrole.PRIMARY, eob);
    // Test to ensure item level fields between Outpatient, HHA and Hospice match
    TransformerTestUtils.assertEobCommonItemRevenueOutHHAHospice(eobItem0, claimLine1.getRevenueCenterDate(), claimLine1.getPaymentAmount());
    // verify {@link
    // TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
    // method worked as expected for this claim type
    TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.HOSPICE, Optional.of(org.hl7.fhir.dstu3.model.codesystems.ClaimType.INSTITUTIONAL), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
    // Test lastUpdated
    TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
Also used : HospiceClaimLine(gov.cms.bfd.model.rif.HospiceClaimLine) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) BigDecimal(java.math.BigDecimal)

Example 29 with ItemComponent

use of org.hl7.fhir.r4.model.Claim.ItemComponent in project beneficiary-fhir-data by CMSgov.

the class DMEClaimTransformerTest method assertMatches.

/**
 * Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
 * the specified {@link DMEClaim}.
 *
 * @param claim the {@link DMEClaim} that the {@link ExplanationOfBenefit} was generated from
 * @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
 *     DMEClaim}@param includedTaxNumbers whether or not to include tax numbers are expected to be
 *     included in the result (see {@link
 *     ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
 *     false</code>)
 * @throws FHIRException (indicates test failure)
 */
static void assertMatches(DMEClaim claim, ExplanationOfBenefit eob, Optional<Boolean> includedTaxNumbers) throws FHIRException {
    // Test to ensure group level fields between all claim types match
    TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.DME, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
    // Test to ensure common group fields between Carrier and DME match
    TransformerTestUtils.assertEobCommonGroupCarrierDMEEquals(eob, claim.getBeneficiaryId(), claim.getCarrierNumber(), claim.getClinicalTrialNumber(), claim.getBeneficiaryPartBDeductAmount(), claim.getPaymentDenialCode(), claim.getReferringPhysicianNpi(), Optional.of(claim.getProviderAssignmentIndicator()), claim.getProviderPaymentAmount(), claim.getBeneficiaryPaymentAmount(), claim.getSubmittedChargeAmount(), claim.getAllowedChargeAmount());
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.PRPAYAMT, claim.getPrimaryPayerPaidAmount(), eob);
    assertEquals(3, eob.getDiagnosis().size());
    assertEquals(1, eob.getItem().size());
    ItemComponent eobItem0 = eob.getItem().get(0);
    DMEClaimLine claimLine1 = claim.getLines().get(0);
    assertEquals(claimLine1.getLineNumber(), new BigDecimal(eobItem0.getSequence()));
    TransformerTestUtils.assertExtensionIdentifierEquals(CcwCodebookVariable.SUPLRNUM, claimLine1.getProviderBillingNumber(), eobItem0);
    TransformerTestUtils.assertCareTeamEquals(claimLine1.getProviderNPI().get(), ClaimCareteamrole.PRIMARY, eob);
    CareTeamComponent performingCareTeamEntry = TransformerTestUtils.findCareTeamEntryForProviderNpi(claimLine1.getProviderNPI().get(), eob.getCareTeam());
    TransformerTestUtils.assertHasCoding(CcwCodebookVariable.PRVDR_SPCLTY, claimLine1.getProviderSpecialityCode(), performingCareTeamEntry.getQualification());
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRTCPTNG_IND_CD, claimLine1.getProviderParticipatingIndCode(), performingCareTeamEntry);
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRVDR_STATE_CD, claimLine1.getProviderStateCode(), eobItem0.getLocation());
    CareTeamComponent taxNumberCareTeamEntry = TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(claimLine1.getProviderTaxNumber(), eob.getCareTeam());
    if (includedTaxNumbers.orElse(false)) {
        assertNotNull(taxNumberCareTeamEntry);
    } else {
        assertNull(taxNumberCareTeamEntry);
    }
    TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), claimLine1.getHcpcsInitialModifierCode(), claimLine1.getHcpcsSecondModifierCode(), claim.getHcpcsYearCode(), 0);
    TransformerTestUtils.assertHasCoding(TransformerConstants.CODING_SYSTEM_HCPCS, "" + claim.getHcpcsYearCode().get(), null, claimLine1.getHcpcsCode().get(), eobItem0.getService().getCoding());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_PRMRY_ALOWD_CHRG_AMT, claimLine1.getPrimaryPayerAllowedChargeAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_DME_PRCHS_PRICE_AMT, claimLine1.getPurchasePriceAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.DMERC_LINE_PRCNG_STATE_CD, claimLine1.getPricingStateCode(), eobItem0.getLocation());
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.DMERC_LINE_SUPPLR_TYPE_CD, claimLine1.getSupplierTypeCode(), eobItem0.getLocation());
    TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.DMERC_LINE_SCRN_SVGS_AMT, claimLine1.getScreenSavingsAmount(), eobItem0);
    TransformerTestUtils.assertQuantityUnitInfoEquals(CcwCodebookVariable.DMERC_LINE_MTUS_CNT, CcwCodebookVariable.DMERC_LINE_MTUS_CD, claimLine1.getMtusCode(), eobItem0);
    TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.DMERC_LINE_MTUS_CNT, claimLine1.getMtusCount(), eobItem0);
    TransformerTestUtils.assertExtensionCodingEquals(eobItem0, TransformerConstants.CODING_NDC, TransformerConstants.CODING_NDC, claimLine1.getNationalDrugCode().get());
    // verify {@link
    // TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
    // method worked as expected for this claim type
    TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.DME, // be updated to match expected result.
    Optional.empty(), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
    // Test to ensure common item fields between Carrier and DME match
    TransformerTestUtils.assertEobCommonItemCarrierDMEEquals(eobItem0, eob, claimLine1.getServiceCount(), claimLine1.getPlaceOfServiceCode(), claimLine1.getFirstExpenseDate(), claimLine1.getLastExpenseDate(), claimLine1.getBeneficiaryPaymentAmount(), claimLine1.getProviderPaymentAmount(), claimLine1.getBeneficiaryPartBDeductAmount(), claimLine1.getPrimaryPayerCode(), claimLine1.getPrimaryPayerPaidAmount(), claimLine1.getBetosCode(), claimLine1.getPaymentAmount(), claimLine1.getPaymentCode(), claimLine1.getCoinsuranceAmount(), claimLine1.getSubmittedChargeAmount(), claimLine1.getAllowedChargeAmount(), claimLine1.getProcessingIndicatorCode(), claimLine1.getServiceDeductibleCode(), claimLine1.getDiagnosisCode(), claimLine1.getDiagnosisCodeVersion(), claimLine1.getHctHgbTestTypeCode(), claimLine1.getHctHgbTestResult(), claimLine1.getCmsServiceTypeCode(), claimLine1.getNationalDrugCode());
    // Test lastUpdated
    TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
Also used : ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) CareTeamComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.CareTeamComponent) DMEClaimLine(gov.cms.bfd.model.rif.DMEClaimLine) BigDecimal(java.math.BigDecimal)

Example 30 with ItemComponent

use of org.hl7.fhir.r4.model.Claim.ItemComponent in project beneficiary-fhir-data by CMSgov.

the class InpatientClaimTransformerTest method assertMatches.

/**
 * Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
 * the specified {@link InpatientClaim}.
 *
 * @param claim the {@link InpatientClaim} that the {@link ExplanationOfBenefit} was generated
 *     from
 * @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
 *     InpatientClaim}
 * @throws FHIRException (indicates test failure)
 */
static void assertMatches(InpatientClaim claim, ExplanationOfBenefit eob) throws FHIRException {
    // Test to ensure group level fields between all claim types match
    TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.INPATIENT, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
    // test the common field provider number is set as expected in the EOB
    TransformerTestUtils.assertProviderNumber(eob, claim.getProviderNumber());
    if (claim.getPatientStatusCd().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, claim.getPatientStatusCd(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.CLM_PASS_THRU_PER_DIEM_AMT, claim.getPassThruPerDiemAmount(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.NCH_PROFNL_CMPNT_CHRG_AMT, claim.getProfessionalComponentCharge(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.CLM_TOT_PPS_CPTL_AMT, claim.getClaimTotalPPSCapitalAmount(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.IME_OP_CLM_VAL_AMT, claim.getIndirectMedicalEducationAmount(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.DSH_OP_CLM_VAL_AMT, claim.getDisproportionateShareAmount(), eob);
    // test common eob information between Inpatient, HHA, Hospice and SNF claims are set as
    // expected
    TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFEquals(eob, claim.getClaimAdmissionDate(), claim.getBeneficiaryDischargeDate(), Optional.of(claim.getUtilizationDayCount()));
    // test common benefit components between SNF and Inpatient claims are set as expected
    TransformerTestUtils.assertCommonGroupInpatientSNF(eob, claim.getCoinsuranceDayCount(), claim.getNonUtilizationDayCount(), claim.getDeductibleAmount(), claim.getPartACoinsuranceLiabilityAmount(), claim.getBloodPintsFurnishedQty(), claim.getNoncoveredCharge(), claim.getTotalDeductionAmount(), claim.getClaimPPSCapitalDisproportionateShareAmt(), claim.getClaimPPSCapitalExceptionAmount(), claim.getClaimPPSCapitalFSPAmount(), claim.getClaimPPSCapitalIMEAmount(), claim.getClaimPPSCapitalOutlierAmount(), claim.getClaimPPSOldCapitalHoldHarmlessAmount());
    // test common eob information between SNF and Inpatient claims are set as expected
    TransformerTestUtils.assertCommonEobInformationInpatientSNF(eob, claim.getNoncoveredStayFromDate(), claim.getNoncoveredStayThroughDate(), claim.getCoveredCareThoughDate(), claim.getMedicareBenefitsExhaustedDate(), claim.getDiagnosisRelatedGroupCd());
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.NCH_DRG_OUTLIER_APRVD_PMT_AMT, claim.getDrgOutlierApprovedPaymentAmount(), eob);
    // Test to ensure common group fields between Inpatient, Outpatient and SNF
    // match
    TransformerTestUtils.assertEobCommonGroupInpOutSNFEquals(eob, claim.getBloodDeductibleLiabilityAmount(), claim.getOperatingPhysicianNpi(), claim.getOtherPhysicianNpi(), claim.getClaimQueryCode(), claim.getMcoPaidSw());
    // Test to ensure common group fields between Inpatient, Outpatient HHA, Hospice
    // and SNF match
    TransformerTestUtils.assertEobCommonGroupInpOutHHAHospiceSNFEquals(eob, claim.getOrganizationNpi(), claim.getClaimFacilityTypeCode(), claim.getClaimFrequencyCode(), claim.getClaimNonPaymentReasonCode(), claim.getPatientDischargeStatusCode(), claim.getClaimServiceClassificationTypeCode(), claim.getClaimPrimaryPayerCode(), claim.getAttendingPhysicianNpi(), claim.getTotalChargeAmount(), claim.getPrimaryPayerPaidAmount(), claim.getFiscalIntermediaryNumber(), claim.getFiDocumentClaimControlNumber(), claim.getFiOriginalClaimControlNumber());
    assertEquals(9, eob.getDiagnosis().size());
    // test to ensure the diagnosis code display lookup table process works
    Optional<Diagnosis> diagnosis = Diagnosis.from(claim.getDiagnosis5Code(), claim.getDiagnosis5CodeVersion());
    TransformerTestUtils.assertHasCoding(diagnosis.get().getFhirSystem(), null, TransformerUtils.retrieveIcdCodeDisplay(diagnosis.get().getCode()), diagnosis.get().getCode(), eob.getDiagnosis().get(6).getDiagnosisCodeableConcept().getCoding());
    CCWProcedure ccwProcedure = new CCWProcedure(claim.getProcedure1Code(), claim.getProcedure1CodeVersion(), claim.getProcedure1Date());
    TransformerTestUtils.assertHasCoding(ccwProcedure.getFhirSystem().toString(), claim.getProcedure1Code().get(), eob.getProcedure().get(0).getProcedureCodeableConcept().getCoding());
    assertEquals(TransformerUtils.convertToDate(claim.getProcedure1Date().get()), eob.getProcedure().get(0).getDate());
    // test to ensure the procedure code display lookup table process works
    CCWProcedure ccwProcedureDisplay = new CCWProcedure(claim.getProcedure6Code(), claim.getProcedure6CodeVersion(), claim.getProcedure6Date());
    TransformerTestUtils.assertHasCoding(ccwProcedureDisplay.getFhirSystem().toString(), null, TransformerUtils.retrieveProcedureCodeDisplay(claim.getProcedure6Code().get()), claim.getProcedure6Code().get(), eob.getProcedure().get(5).getProcedureCodeableConcept().getCoding());
    assertEquals(1, eob.getItem().size());
    ItemComponent eobItem0 = eob.getItem().get(0);
    InpatientClaimLine claimLine1 = claim.getLines().get(0);
    assertEquals(claimLine1.getLineNumber(), new BigDecimal(eobItem0.getSequence()));
    assertEquals(claim.getProviderStateCode(), eobItem0.getLocationAddress().getState());
    TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), Optional.empty(), Optional.empty(), Optional.empty(), 0);
    // Test to ensure common group field coinsurance between Inpatient, HHA, Hospice and SNF match
    TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFCoinsuranceEquals(eobItem0, claimLine1.getDeductibleCoinsuranceCd());
    String claimControlNumber = "0000000000";
    // Test to ensure item level fields between Inpatient, Outpatient, HHA, Hopsice
    // and SNF match
    TransformerTestUtils.assertEobCommonItemRevenueEquals(eobItem0, eob, claimLine1.getRevenueCenter(), claimLine1.getRateAmount(), claimLine1.getTotalChargeAmount(), claimLine1.getNonCoveredChargeAmount(), claimLine1.getUnitCount(), claimControlNumber, claimLine1.getNationalDrugCodeQuantity(), claimLine1.getNationalDrugCodeQualifierCode(), claimLine1.getRevenueCenterRenderingPhysicianNPI(), 0);
    // verify {@link
    // TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
    // method worked as expected for this claim type
    TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.INPATIENT, Optional.of(org.hl7.fhir.dstu3.model.codesystems.ClaimType.INSTITUTIONAL), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
    // Test lastUpdated
    TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
Also used : CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) BigDecimal(java.math.BigDecimal) InpatientClaimLine(gov.cms.bfd.model.rif.InpatientClaimLine)

Aggregations

ItemComponent (org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent)17 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)16 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)10 BigDecimal (java.math.BigDecimal)9 ExplanationOfBenefit (org.hl7.fhir.r4.model.ExplanationOfBenefit)9 CCWProcedure (gov.cms.bfd.server.war.commons.CCWProcedure)8 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)8 ItemComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent)8 Reference (org.hl7.fhir.r4.model.Reference)6 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)5 MedicareSegment (gov.cms.bfd.server.war.commons.MedicareSegment)5 C4BBOrganizationIdentifierType (gov.cms.bfd.server.war.commons.carin.C4BBOrganizationIdentifierType)5 BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)5 Address (org.hl7.fhir.dstu3.model.Address)5 DMEClaimLine (gov.cms.bfd.model.rif.DMEClaimLine)4 HospiceClaimLine (gov.cms.bfd.model.rif.HospiceClaimLine)4 InvalidRifValueException (gov.cms.bfd.model.rif.parse.InvalidRifValueException)4 ProfileConstants (gov.cms.bfd.server.war.commons.ProfileConstants)4 C4BBClaimInstitutionalCareTeamRole (gov.cms.bfd.server.war.commons.carin.C4BBClaimInstitutionalCareTeamRole)4 C4BBPractitionerIdentifierType (gov.cms.bfd.server.war.commons.carin.C4BBPractitionerIdentifierType)4