Search in sources :

Example 61 with Claim

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

the class PartDEventTransformerV2 method transformClaim.

/**
 * @param claimGroup the CCW {@link PartDEvent} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     PartDEvent}
 */
private static ExplanationOfBenefit transformClaim(PartDEvent claimGroup) {
    ExplanationOfBenefit eob = new ExplanationOfBenefit();
    eob.getMeta().addProfile(ProfileConstants.C4BB_EOB_PHARMACY_PROFILE_URL);
    // Common group level fields between all claim types
    // Claim Type + Claim ID
    // => ExplanationOfBenefit.id
    // PDE_ID           => ExplanationOfBenefit.identifier
    // CLM_GRP_ID       => ExplanationOfBenefit.identifier
    // BENE_ID + Coverage Type
    // => ExplanationOfBenefit.insurance.coverage (reference)
    // BENE_ID          => ExplanationOfBenefit.patient (reference)
    // FINAL_ACTION     => ExplanationOfBenefit.status
    // SRVC_DT          => ExplanationOfBenefit.billablePeriod.start
    // SRVC_DT          => ExplanationOfBenefit.billablePeriod.end
    TransformerUtilsV2.mapEobCommonClaimHeaderData(eob, claimGroup.getEventId(), claimGroup.getBeneficiaryId(), ClaimTypeV2.PDE, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_D, Optional.of(claimGroup.getPrescriptionFillDate()), Optional.of(claimGroup.getPrescriptionFillDate()), Optional.empty(), claimGroup.getFinalAction());
    // RX_SRVC_RFRNC_NUM => ExplanationOfBenefit.identifier
    eob.addIdentifier(TransformerUtilsV2.createClaimIdentifier(CcwCodebookVariable.RX_SRVC_RFRNC_NUM, claimGroup.getPrescriptionReferenceNumber().toPlainString()));
    // map eob type codes into FHIR
    // EOB Type               => ExplanationOfBenefit.type.coding
    // Claim Type  (pharmacy) => ExplanationOfBenefit.type.coding
    TransformerUtilsV2.mapEobType(eob, ClaimTypeV2.PDE, Optional.empty(), Optional.empty());
    // Coverage object is not optional, and we want to add extensions to it. This is safe.
    // PLAN_CNTRCT_REC_ID => ExplanationOfBenefit.insurance.coverage.extension
    eob.getInsuranceFirstRep().getCoverage().addExtension(TransformerUtilsV2.createExtensionIdentifier(CcwCodebookVariable.PLAN_CNTRCT_REC_ID, claimGroup.getPlanContractId()));
    // PLAN_PBP_REC_NUM => ExplanationOfBenefit.insurance.coverage.extension
    eob.getInsuranceFirstRep().getCoverage().addExtension(TransformerUtilsV2.createExtensionIdentifier(CcwCodebookVariable.PLAN_PBP_REC_NUM, claimGroup.getPlanBenefitPackageId()));
    // PD_DT => ExplanationOfBenefit.payment.date
    if (claimGroup.getPaymentDate().isPresent()) {
        eob.getPayment().setDate(TransformerUtilsV2.convertToDate(claimGroup.getPaymentDate().get()));
    }
    ItemComponent rxItem = eob.addItem();
    // 1 => ExplanationOfBenefit.item.sequence
    rxItem.setSequence(1);
    // CMPND_CD => ExplanationOfBenefit.item.programCode
    switch(claimGroup.getCompoundCode()) {
        // COMPOUNDED
        case 2:
            /* Pharmacy dispense invoice for a compound */
            TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.COMPOUND_CODE).setCode(new CodeableConcept().addCoding(new Coding().setSystem(V3ActCode.RXCINV.getSystem()).setCode(V3ActCode.RXCINV.toCode()).setDisplay(V3ActCode.RXCINV.getDisplay())));
            break;
        // NOT_COMPOUNDED
        case 1:
            /*
         * Pharmacy dispense invoice not involving a compound
         */
            TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.COMPOUND_CODE).setCode(new CodeableConcept().addCoding(new Coding().setSystem(V3ActCode.RXDINV.getSystem()).setCode(V3ActCode.RXDINV.toCode()).setDisplay(V3ActCode.RXDINV.getDisplay())));
            break;
        // NOT_SPECIFIED
        case 0:
            /*
         * Pharmacy dispense invoice not specified - do not set a value
         */
            break;
        default:
            /*
         * Unexpected value encountered - compound code should be either
         * compounded or not compounded.
         */
            throw new InvalidRifValueException("Unexpected value encountered - compound code should be either compounded or not compounded: " + claimGroup.getCompoundCode());
    }
    // SRVC_DT => ExplanationOfBenefit.item.servicedDate
    rxItem.setServiced(new DateType().setValue(TransformerUtilsV2.convertToDate(claimGroup.getPrescriptionFillDate())));
    /*
     * Create an adjudication for either CVRD_D_PLAN_PD_AMT or NCVRD_PLAN_PD_AMT,
     * depending on the value of DRUG_CVRG_STUS_CD. Stick DRUG_CVRG_STUS_CD into the
     * adjudication.reason field. CARING Slicing and CARING Adjudication Value Sets.
     */
    if (claimGroup.getDrugCoverageStatusCode() == 'C') {
        // CVRD_D_PLAN_PD_AMT => ExplanationOfBenefit.item.adjudication.amount
        TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.CVRD_D_PLAN_PD_AMT, C4BBAdjudication.BENEFIT, claimGroup.getPartDPlanCoveredPaidAmount()));
    } else {
        // NCVRD_PLAN_PD_AMT => ExplanationOfBenefit.item.adjudication.amount
        TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.CVRD_D_PLAN_PD_AMT, C4BBAdjudication.NONCOVERED, claimGroup.getPartDPlanNonCoveredPaidAmount()));
    }
    // GDC_BLW_OOPT_AMT => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.GDC_BLW_OOPT_AMT, C4BBAdjudication.COINSURANCE, claimGroup.getGrossCostBelowOutOfPocketThreshold()));
    // GDC_ABV_OOPT_AMT => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.GDC_ABV_OOPT_AMT, C4BBAdjudication.COINSURANCE, claimGroup.getGrossCostAboveOutOfPocketThreshold()));
    // PTNT_PAY_AMT => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.PTNT_PAY_AMT, C4BBAdjudication.PAID_BY_PATIENT, claimGroup.getPatientPaidAmount()));
    // OTHR_TROOP_AMT => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.OTHR_TROOP_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, claimGroup.getOtherTrueOutOfPocketPaidAmount()));
    // LICS_AMT => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.LICS_AMT, C4BBAdjudication.DISCOUNT, claimGroup.getLowIncomeSubsidyPaidAmount()));
    // PLRO_AMT => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.PLRO_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, claimGroup.getPatientLiabilityReductionOtherPaidAmount()));
    // TOT_RX_CST_AMT => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.TOT_RX_CST_AMT, C4BBAdjudication.DRUG_COST, claimGroup.getTotalPrescriptionCost()));
    // RPTD_GAP_DSCNT_NUM => ExplanationOfBenefit.item.adjudication.amount
    TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.RPTD_GAP_DSCNT_NUM, C4BBAdjudication.DISCOUNT, claimGroup.getGapDiscountAmount()));
    // Validate PRESCRBR_ID
    if (claimGroup.getPrescriberIdQualifierCode() == null || !claimGroup.getPrescriberIdQualifierCode().equalsIgnoreCase("01")) {
        throw new InvalidRifValueException("Prescriber ID Qualifier Code is invalid: " + claimGroup.getPrescriberIdQualifierCode());
    }
    // PRSCRBR_ID => ExplanationOfBenefit.careTeam.provider
    TransformerUtilsV2.addCareTeamMember(eob, rxItem, C4BBPractitionerIdentifierType.NPI, C4BBClaimPharmacyTeamRole.PRESCRIBING, Optional.ofNullable(claimGroup.getPrescriberId()));
    // This can't use TransformerUtilsV2.addNationalDrugCode because it maps differently
    // PROD_SRVC_ID => ExplanationOfBenefit.item.productOrService
    rxItem.setProductOrService(TransformerUtilsV2.createCodeableConcept(TransformerConstants.CODING_NDC, null, TransformerUtilsV2.retrieveFDADrugCodeDisplay(claimGroup.getNationalDrugCode()), claimGroup.getNationalDrugCode()));
    // QTY_DSPNSD_NUM => ExplanationOfBenefit.item.quantity
    rxItem.setQuantity(new SimpleQuantity().setValue(claimGroup.getQuantityDispensed()));
    // FILL_NUM => ExplanationOfBenefit.item.quantity.extension
    TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.REFILL_NUM).setValue(new SimpleQuantity().setValue(claimGroup.getFillNumber()));
    // DAYS_SUPLY_NUM => ExplanationOfBenefit.item.quantity.extension
    TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.DAYS_SUPPLY).setValue(new SimpleQuantity().setValue(claimGroup.getDaysSupply()));
    /*
     * This chart is to display the different code values for the different service provider id qualifier
     * codes below
     *   Code	    Code value
     *   01        National Provider Identifier (NPI)
     *   06        Unique Physician Identification Number (UPIN)
     *   07        National Council for Prescription Drug Programs (NCPDP) provider identifier
     *   08        State license number
     *   11        Federal tax number
     *   99        Other
     */
    C4BBOrganizationIdentifierType identifierType;
    if (!claimGroup.getServiceProviderId().isEmpty()) {
        switch(claimGroup.getServiceProviderIdQualiferCode()) {
            case "01":
                identifierType = C4BBOrganizationIdentifierType.NPI;
                break;
            case "06":
                identifierType = C4BBOrganizationIdentifierType.UPIN;
                break;
            case "07":
                identifierType = C4BBOrganizationIdentifierType.NCPDP;
                break;
            case "08":
                identifierType = C4BBOrganizationIdentifierType.SL;
                break;
            case "11":
                identifierType = C4BBOrganizationIdentifierType.TAX;
                break;
            default:
                identifierType = null;
                break;
        }
        // SRVC_PRVDR_ID => ExplanationOfBenefit.facility
        if (identifierType != null) {
            eob.setFacility(TransformerUtilsV2.createIdentifierReference(identifierType, claimGroup.getServiceProviderId()));
        }
    }
    /*
     * Storing code values in EOB.information below
     */
    // DRUG_CVRG_STUS_CD => ExplanationOfBenefit.supportingInfo.code
    TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DRUG_CVRG_STUS_CD, CcwCodebookVariable.DRUG_CVRG_STUS_CD, claimGroup.getDrugCoverageStatusCode());
    // DAW_PROD_SLCTN_CD => ExplanationOfBenefit.supportingInfo.code
    TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DAW_PROD_SLCTN_CD, CcwCodebookVariable.DAW_PROD_SLCTN_CD, claimGroup.getDispenseAsWrittenProductSelectionCode());
    // DAW_PROD_SLCTN_CD => ExplanationOfBenefit.supportingInfo.code
    if (claimGroup.getDispensingStatusCode().isPresent()) {
        TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DSPNSNG_STUS_CD, CcwCodebookVariable.DSPNSNG_STUS_CD, claimGroup.getDispensingStatusCode());
    }
    // DRUG_CVRG_STUS_CD => ExplanationOfBenefit.supportingInfo.code
    TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DRUG_CVRG_STUS_CD, CcwCodebookVariable.DRUG_CVRG_STUS_CD, claimGroup.getDrugCoverageStatusCode());
    // ADJSTMT_DLTN_CD => => ExplanationOfBenefit.supportingInfo.code
    if (claimGroup.getAdjustmentDeletionCode().isPresent()) {
        TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.ADJSTMT_DLTN_CD, CcwCodebookVariable.ADJSTMT_DLTN_CD, claimGroup.getAdjustmentDeletionCode());
    }
    // NSTD_FRMT_CD => ExplanationOfBenefit.supportingInfo.code
    if (claimGroup.getNonstandardFormatCode().isPresent()) {
        TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.NSTD_FRMT_CD, CcwCodebookVariable.NSTD_FRMT_CD, claimGroup.getNonstandardFormatCode());
    }
    // PRCNG_EXCPTN_CD => ExplanationOfBenefit.supportingInfo.code
    if (claimGroup.getPricingExceptionCode().isPresent()) {
        TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.PRCNG_EXCPTN_CD, CcwCodebookVariable.PRCNG_EXCPTN_CD, claimGroup.getPricingExceptionCode());
    }
    // CTSTRPHC_CVRG_CD => ExplanationOfBenefit.supportingInfo.code
    if (claimGroup.getCatastrophicCoverageCode().isPresent()) {
        TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.CTSTRPHC_CVRG_CD, CcwCodebookVariable.CTSTRPHC_CVRG_CD, claimGroup.getCatastrophicCoverageCode());
    }
    // RX_ORGN_CD => ExplanationOfBenefit.supportingInfo:rxorigincode
    TransformerUtilsV2.addInformationSliceWithCode(eob, C4BBSupportingInfoType.RX_ORIGIN_CODE, CcwCodebookVariable.RX_ORGN_CD, CcwCodebookVariable.RX_ORGN_CD, claimGroup.getPrescriptionOriginationCode());
    // BRND_GNRC_CD => ExplanationOfBenefit.supportingInfo:brandgenericcode
    TransformerUtilsV2.addInformationSliceWithCode(eob, C4BBSupportingInfoType.BRAND_GENERIC_CODE, CcwCodebookVariable.BRND_GNRC_CD, CcwCodebookVariable.BRND_GNRC_CD, claimGroup.getBrandGenericCode());
    // PHRMCY_SRVC_TYPE_CD => ExplanationOfBenefit.facility.extension
    eob.getFacility().addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.PHRMCY_SRVC_TYPE_CD, claimGroup.getPharmacyTypeCode()));
    // PTNT_RSDNC_CD => ExplanationOfBenefit.supportingInfo.code
    TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.PTNT_RSDNC_CD, CcwCodebookVariable.PTNT_RSDNC_CD, claimGroup.getPatientResidenceCode());
    // SUBMSN_CLR_CD => ExplanationOfBenefit.supportingInfo.code
    if (claimGroup.getSubmissionClarificationCode().isPresent()) {
        TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.SUBMSN_CLR_CD, CcwCodebookVariable.SUBMSN_CLR_CD, claimGroup.getSubmissionClarificationCode());
    }
    // Last Updated => ExplanationOfBenefit.meta.lastUpdated
    TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) InvalidRifValueException(gov.cms.bfd.model.rif.parse.InvalidRifValueException) C4BBOrganizationIdentifierType(gov.cms.bfd.server.war.commons.carin.C4BBOrganizationIdentifierType) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) DateType(org.hl7.fhir.r4.model.DateType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 62 with Claim

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

the class R4ExplanationOfBenefitResourceProvider method compareByClaimIdThenClaimType.

/*
   * @param eob1 an {@link ExplanationOfBenefit} to be compared
   *
   * @param eob2 an {@link ExplanationOfBenefit} to be compared
   */
private static int compareByClaimIdThenClaimType(IBaseResource res1, IBaseResource res2) {
    /*
     * In order for paging to be meaningful (and stable), the claims have to be
     * consistently sorted across different app server instances (in case page 1
     * comes from Server A but page 2 comes from Server B). Right now, we don't have
     * anything "useful" to sort by, so we just sort by claim ID (subsorted by claim
     * type). TODO once we have metadata from BLUEBUTTON-XXX on when each claim was
     * first loaded into our DB, we should sort by that.
     */
    ExplanationOfBenefit eob1 = (ExplanationOfBenefit) res1;
    ExplanationOfBenefit eob2 = (ExplanationOfBenefit) res2;
    if (TransformerUtilsV2.getUnprefixedClaimId(eob1).equals(TransformerUtilsV2.getUnprefixedClaimId(eob2))) {
        return TransformerUtilsV2.getClaimType(eob1).compareTo(TransformerUtilsV2.getClaimType(eob2));
    } else {
        return TransformerUtilsV2.getUnprefixedClaimId(eob1).compareTo(TransformerUtilsV2.getUnprefixedClaimId(eob2));
    }
}
Also used : ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit)

Example 63 with Claim

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

the class DMEClaimTransformerV2 method transform.

/**
 * @param metricRegistry the {@link MetricRegistry} to use
 * @param claim the CCW {@link DMEClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     DMEClaim}
 */
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name(DMEClaimTransformerV2.class.getSimpleName(), "transform")).time();
    if (!(claim instanceof DMEClaim)) {
        throw new BadCodeMonkeyException();
    }
    ExplanationOfBenefit eob = transformClaim((DMEClaim) claim, includeTaxNumbers);
    timer.stop();
    return eob;
}
Also used : DMEClaim(gov.cms.bfd.model.rif.DMEClaim) Timer(com.codahale.metrics.Timer) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) Trace(com.newrelic.api.agent.Trace)

Example 64 with Claim

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

the class DMEClaimTransformerV2 method transformClaim.

/**
 * @param claimGroup the CCW {@link DMEClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     DMEClaim}
 */
private static ExplanationOfBenefit transformClaim(DMEClaim claimGroup, Optional<Boolean> includeTaxNumbers) {
    ExplanationOfBenefit eob = new ExplanationOfBenefit();
    // Required values not directly mapped
    eob.getMeta().addProfile(ProfileConstants.C4BB_EOB_INPATIENT_PROFILE_URL);
    // Common group level fields between all claim types
    // Claim Type + Claim ID    => ExplanationOfBenefit.id
    // CLM_ID                   => ExplanationOfBenefit.identifier
    // CLM_GRP_ID               => ExplanationOfBenefit.identifier
    // BENE_ID + Coverage Type  => ExplanationOfBenefit.insurance.coverage
    // BENE_ID                  => ExplanationOfBenefit.patient (reference)pwd
    // FINAL_ACTION             => ExplanationOfBenefit.status
    // CLM_FROM_DT              => ExplanationOfBenefit.billablePeriod.start
    // CLM_THRU_DT              => ExplanationOfBenefit.billablePeriod.end
    // CLM_PMT_AMT              => ExplanationOfBenefit.payment.amount
    TransformerUtilsV2.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimTypeV2.DME, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
    // map eob type codes into FHIR
    // NCH_CLM_TYPE_CD            => ExplanationOfBenefit.type.coding
    // EOB Type                   => ExplanationOfBenefit.type.coding
    // Claim Type (Professional)  => ExplanationOfBenefit.type.coding
    // NCH_NEAR_LINE_REC_IDENT_CD => ExplanationOfBenefit.extension
    TransformerUtilsV2.mapEobType(eob, ClaimTypeV2.DME, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    // CARR_CLM_PRMRY_PYR_PD_AMT => ExplanationOfBenefit.total.amount
    TransformerUtilsV2.addTotal(eob, TransformerUtilsV2.createTotalAdjudicationAmountSlice(eob, CcwCodebookVariable.CLM_TOT_CHRG_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, claimGroup.getPrimaryPayerPaidAmount()));
    // NCH_WKLY_PROC_DT => ExplanationOfBenefit.supportinginfo.timingDate
    TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationRecievedDateSlice(eob, CcwCodebookVariable.NCH_WKLY_PROC_DT, Optional.of(claimGroup.getWeeklyProcessDate())));
    // Common group level fields between Carrier and DME
    // BENE_ID =>
    // CARR_NUM                       => ExplanationOfBenefit.extension
    // CLM_CLNCL_TRIL_NUM             => ExplanationOfBenefit.extension
    // CARR_CLM_CASH_DDCTBL_APLD_AMT  => ExplanationOfBenefit.benefitBalance.financial
    // CARR_CLM_PMT_DNL_CD            => ExplanationOfBenefit.extension
    // RFR_PHYSN_NPI                  => ExplanationOfBenefit.referral.identifier
    // => ExplanationOfBenefit.careteam.provider
    // RFR_PHYSN_UPIN                 => ExplanationOfBenefit.referral.identifier
    // => ExplanationOfBenefit.careteam.provider
    // CARR_CLM_PRVDR_ASGNMT_IND_SW   => ExplanationOfBenefit.extension
    // NCH_CLM_PRVDR_PMT_AMT          => ExplanationOfBenefit.benefitBalance.financial
    // NCH_CLM_BENE_PMT_AMT           => ExplanationOfBenefit.benefitBalance.financial
    // NCH_CARR_CLM_SBMTD_CHRG_AMT    => ExplanationOfBenefit.benefitBalance.financial
    // NCH_CARR_CLM_ALOWD_AMT         => ExplanationOfBenefit.benefitBalance.financial
    // CLM_DISP_CD                    => ExplanationOfBenefit.disposition
    // CARR_CLM_CNTL_NUM              => ExplanationOfBenefit.extension
    TransformerUtilsV2.mapEobCommonGroupCarrierDME(eob, claimGroup.getBeneficiaryId(), claimGroup.getCarrierNumber(), claimGroup.getClinicalTrialNumber(), claimGroup.getBeneficiaryPartBDeductAmount(), claimGroup.getPaymentDenialCode(), claimGroup.getReferringPhysicianNpi(), claimGroup.getReferringPhysicianUpin(), Optional.of(claimGroup.getProviderAssignmentIndicator()), claimGroup.getProviderPaymentAmount(), claimGroup.getBeneficiaryPaymentAmount(), claimGroup.getSubmittedChargeAmount(), claimGroup.getAllowedChargeAmount(), claimGroup.getClaimDispositionCode(), claimGroup.getClaimCarrierControlNumber());
    // ICD_DGNS_VRSN_CD(1-12)   => diagnosis.diagnosisCodeableConcept
    for (Diagnosis diagnosis : DiagnosisUtilV2.extractDiagnoses(claimGroup)) {
        DiagnosisUtilV2.addDiagnosisCode(eob, diagnosis, ClaimTypeV2.DME);
    }
    // CARR_CLM_ENTRY_CD => ExplanationOfBenefit.extension
    eob.addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.CARR_CLM_ENTRY_CD, claimGroup.getClaimEntryCode()));
    handleClaimLines(claimGroup, eob, includeTaxNumbers);
    TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit)

Example 65 with Claim

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

the class HHAClaimTransformerV2 method transformClaim.

/**
 * @param claimGroup the CCW {@link HHAClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     HHAClaim}
 */
private static ExplanationOfBenefit transformClaim(HHAClaim claimGroup) {
    ExplanationOfBenefit eob = new ExplanationOfBenefit();
    // Required values not directly mapped
    eob.getMeta().addProfile(ProfileConstants.C4BB_EOB_NONCLINICIAN_PROFILE_URL);
    // Common group level fields between all claim types
    // Claim Type + Claim ID    => ExplanationOfBenefit.id
    // CLM_ID                   => ExplanationOfBenefit.identifier
    // CLM_GRP_ID               => ExplanationOfBenefit.identifier
    // BENE_ID + Coverage Type  => ExplanationOfBenefit.insurance.coverage
    // BENE_ID                  => ExplanationOfBenefit.patient (reference)
    // FINAL_ACTION             => ExplanationOfBenefit.status
    // CLM_FROM_DT              => ExplanationOfBenefit.billablePeriod.start
    // CLM_THRU_DT              => ExplanationOfBenefit.billablePeriod.end
    // CLM_PMT_AMT              => ExplanationOfBenefit.payment.amount
    TransformerUtilsV2.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimTypeV2.HHA, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
    // NCH_WKLY_PROC_DT => ExplanationOfBenefit.supportinginfo.timingDate
    TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationRecievedDateSlice(eob, CcwCodebookVariable.NCH_WKLY_PROC_DT, Optional.of(claimGroup.getWeeklyProcessDate())));
    // map eob type codes into FHIR
    // NCH_CLM_TYPE_CD            => ExplanationOfBenefit.type.coding
    // EOB Type                   => ExplanationOfBenefit.type.coding
    // Claim Type                 => ExplanationOfBenefit.type.coding
    // NCH_NEAR_LINE_REC_IDENT_CD => ExplanationOfBenefit.extension
    TransformerUtilsV2.mapEobType(eob, ClaimTypeV2.HHA, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    // PRVDR_NUM => ExplanationOfBenefit.provider.identifier
    TransformerUtilsV2.addProviderSlice(eob, C4BBOrganizationIdentifierType.PRN, claimGroup.getProviderNumber(), claimGroup.getLastUpdated());
    // Common group level fields between Inpatient, Outpatient Hospice, HHA and SNF
    // ORG_NPI_NUM              => ExplanationOfBenefit.provider
    // CLM_FAC_TYPE_CD          => ExplanationOfBenefit.facility.extension
    // CLM_FREQ_CD              => ExplanationOfBenefit.supportingInfo
    // CLM_MDCR_NON_PMT_RSN_CD  => ExplanationOfBenefit.extension
    // PTNT_DSCHRG_STUS_CD      => ExplanationOfBenefit.supportingInfo
    // CLM_SRVC_CLSFCTN_TYPE_CD => ExplanationOfBenefit.extension
    // NCH_PRMRY_PYR_CD         => ExplanationOfBenefit.supportingInfo
    // CLM_TOT_CHRG_AMT         => ExplanationOfBenefit.total.amount
    // NCH_PRMRY_PYR_CLM_PD_AMT => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.mapEobCommonGroupInpOutHHAHospiceSNF(eob, claimGroup.getOrganizationNpi(), claimGroup.getClaimFacilityTypeCode(), claimGroup.getClaimFrequencyCode(), claimGroup.getClaimNonPaymentReasonCode(), claimGroup.getPatientDischargeStatusCode(), claimGroup.getClaimServiceClassificationTypeCode(), claimGroup.getClaimPrimaryPayerCode(), claimGroup.getTotalChargeAmount(), claimGroup.getPrimaryPayerPaidAmount(), claimGroup.getFiscalIntermediaryNumber(), claimGroup.getLastUpdated());
    // CLM_PPS_IND_CODE => ExplanationOfBenefit.supportingInfo
    TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.CLM_PPS_IND_CD, CcwCodebookVariable.CLM_PPS_IND_CD, claimGroup.getProspectivePaymentCode());
    // ICD_DGNS_E_VRSN_CD(1-12) => diagnosis.diagnosisCodeableConcept
    for (Diagnosis diagnosis : DiagnosisUtilV2.extractDiagnoses(claimGroup)) {
        DiagnosisUtilV2.addDiagnosisCode(eob, diagnosis, ClaimTypeV2.HHA);
    }
    // Map care team
    // AT_PHYSN_NPI     => ExplanationOfBenefit.careTeam.provider
    // AT_PHYSN_UPIN    => ExplanationOfBenefit.careTeam.provider
    TransformerUtilsV2.mapCareTeam(eob, claimGroup.getAttendingPhysicianNpi(), Optional.empty(), Optional.empty(), claimGroup.getAttendingPhysicianUpin(), Optional.empty(), Optional.empty());
    // CLM_HHA_LUPA_IND_CD => ExplanationOfBenefit.supportinginfo.code
    claimGroup.getClaimLUPACode().ifPresent(c -> TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.CLM_HHA_LUPA_IND_CD, CcwCodebookVariable.CLM_HHA_LUPA_IND_CD, c));
    // CLM_HHA_RFRL_CD => ExplanationOfBenefit.supportinginfo.code
    claimGroup.getClaimReferralCode().ifPresent(c -> TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.CLM_HHA_RFRL_CD, CcwCodebookVariable.CLM_HHA_RFRL_CD, c));
    // CLM_HHA_TOT_VISIT_CNT => ExplanationOfBenefit.supportinginfo.value[x]
    TransformerUtilsV2.addInformation(eob, CcwCodebookVariable.CLM_HHA_TOT_VISIT_CNT).setValue(new Quantity(claimGroup.getTotalVisitCount().intValue()));
    // CLM_ADMSN_DT => ExplanationOfBenefit.supportingInfo:admissionperiod
    TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationAdmPeriodSlice(eob, claimGroup.getCareStartDate(), Optional.empty()));
    for (HHAClaimLine line : claimGroup.getLines()) {
        ItemComponent item = eob.addItem();
        // Override the default sequence
        // CLM_LINE_NUM => item.sequence
        item.setSequence(line.getLineNumber().intValue());
        // PRVDR_STATE_CD => item.location
        TransformerUtilsV2.addLocationState(item, claimGroup.getProviderStateCode());
        // HCPCS_CD           => ExplanationOfBenefit.item.productOrService
        // HCPCS_1ST_MDFR_CD  => ExplanationOfBenefit.item.modifier
        // HCPCS_2ND_MDFR_CD  => ExplanationOfBenefit.item.modifier
        TransformerUtilsV2.mapHcpcs(eob, item, line.getHcpcsCode(), Optional.empty(), Arrays.asList(line.getHcpcsInitialModifierCode(), line.getHcpcsSecondModifierCode()));
        // REV_CNTR_1ST_ANSI_CD => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationDenialReasonSlice(eob, CcwCodebookVariable.REV_CNTR_1ST_ANSI_CD, line.getRevCntr1stAnsiCd()));
        // REV_CNTR                   => ExplanationOfBenefit.item.revenue
        // REV_CNTR_RATE_AMT          => ExplanationOfBenefit.item.adjudication
        // REV_CNTR_TOT_CHRG_AMT      => ExplanationOfBenefit.item.adjudication
        // REV_CNTR_NCVRD_CHRG_AMT    => ExplanationOfBenefit.item.adjudication
        // REV_CNTR_NDC_QTY           => ExplanationOfBenefit.item.quantity
        // REV_CNTR_NDC_QTY_QLFR_CD   => ExplanationOfBenefit.modifier
        TransformerUtilsV2.mapEobCommonItemRevenue(item, eob, line.getRevenueCenterCode(), line.getRateAmount(), line.getTotalChargeAmount(), Optional.of(line.getNonCoveredChargeAmount()), line.getNationalDrugCodeQuantity(), line.getNationalDrugCodeQualifierCode());
        // Common item level fields between Outpatient, HHA and Hospice
        // REV_CNTR_DT              => ExplanationOfBenefit.item.servicedDate
        // REV_CNTR_PMT_AMT_AMT     => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.mapEobCommonItemRevenueOutHHAHospice(item, line.getRevenueCenterDate(), line.getPaymentAmount());
        // REV_CNTR_DDCTBL_COINSRNC_CD => item.revenue
        TransformerUtilsV2.addItemRevenue(item, eob, CcwCodebookVariable.REV_CNTR_DDCTBL_COINSRNC_CD, line.getDeductibleCoinsuranceCd());
        // RNDRNG_PHYSN_UPIN => ExplanationOfBenefit.careTeam.provider
        TransformerUtilsV2.addCareTeamMember(eob, item, C4BBPractitionerIdentifierType.UPIN, C4BBClaimProfessionalAndNonClinicianCareTeamRole.PERFORMING, line.getRevenueCenterRenderingPhysicianUPIN());
        // RNDRNG_PHYSN_NPI => ExplanationOfBenefit.careTeam.provider
        TransformerUtilsV2.addCareTeamMember(eob, item, C4BBPractitionerIdentifierType.NPI, C4BBClaimProfessionalAndNonClinicianCareTeamRole.PERFORMING, line.getRevenueCenterRenderingPhysicianNPI());
        // REV_CNTR_STUS_IND_CD => ExplanationOfBenefit.item.revenue.extension
        TransformerUtilsV2.mapEobCommonItemRevenueStatusCode(item, eob, line.getStatusCode());
    }
    TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) Quantity(org.hl7.fhir.r4.model.Quantity) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) HHAClaimLine(gov.cms.bfd.model.rif.HHAClaimLine)

Aggregations

Test (org.junit.jupiter.api.Test)149 Coding (org.hl7.fhir.r4.model.Coding)92 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)62 Money (org.hl7.fhir.r4.model.Money)61 BenefitComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent)56 Optional (java.util.Optional)50 Arrays (java.util.Arrays)49 List (java.util.List)49 ExplanationOfBenefit (org.hl7.fhir.r4.model.ExplanationOfBenefit)49 FHIRException (org.hl7.fhir.exceptions.FHIRException)48 SupportingInformationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent)48 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)47 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)47 StaticRifResourceGroup (gov.cms.bfd.model.rif.samples.StaticRifResourceGroup)45 ServerTestUtils (gov.cms.bfd.server.war.ServerTestUtils)45 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)41 Instant (java.time.Instant)40 ArrayList (java.util.ArrayList)39 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)37 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)37