Search in sources :

Example 36 with ItemComponent

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

the class DMEClaimTransformer method transformClaim.

/**
 * @param includeTaxNumbers whether or not to include tax numbers in the result (see {@link
 *     ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
 *     false</code>)
 * @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();
    // Common group level fields between all claim types
    TransformerUtils.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimType.DME, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
    TransformerUtils.mapEobWeeklyProcessDate(eob, claimGroup.getWeeklyProcessDate());
    // map eob type codes into FHIR
    TransformerUtils.mapEobType(eob, ClaimType.DME, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    // TODO is this column nullable? If so, why isn't it Optional?
    if (claimGroup.getPrimaryPayerPaidAmount() != null) {
        TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.PRPAYAMT, claimGroup.getPrimaryPayerPaidAmount());
    }
    // Common group level fields between Carrier and DME
    TransformerUtils.mapEobCommonGroupCarrierDME(eob, claimGroup.getBeneficiaryId(), claimGroup.getCarrierNumber(), claimGroup.getClinicalTrialNumber(), claimGroup.getBeneficiaryPartBDeductAmount(), claimGroup.getPaymentDenialCode(), claimGroup.getReferringPhysicianNpi(), Optional.of(claimGroup.getProviderAssignmentIndicator()), claimGroup.getProviderPaymentAmount(), claimGroup.getBeneficiaryPaymentAmount(), claimGroup.getSubmittedChargeAmount(), claimGroup.getAllowedChargeAmount(), claimGroup.getClaimDispositionCode(), claimGroup.getClaimCarrierControlNumber());
    for (Diagnosis diagnosis : TransformerUtils.extractDiagnoses1Thru12(claimGroup.getDiagnosisPrincipalCode(), claimGroup.getDiagnosisPrincipalCodeVersion(), claimGroup.getDiagnosis1Code(), claimGroup.getDiagnosis1CodeVersion(), claimGroup.getDiagnosis2Code(), claimGroup.getDiagnosis2CodeVersion(), claimGroup.getDiagnosis3Code(), claimGroup.getDiagnosis3CodeVersion(), claimGroup.getDiagnosis4Code(), claimGroup.getDiagnosis4CodeVersion(), claimGroup.getDiagnosis5Code(), claimGroup.getDiagnosis5CodeVersion(), claimGroup.getDiagnosis6Code(), claimGroup.getDiagnosis6CodeVersion(), claimGroup.getDiagnosis7Code(), claimGroup.getDiagnosis7CodeVersion(), claimGroup.getDiagnosis8Code(), claimGroup.getDiagnosis8CodeVersion(), claimGroup.getDiagnosis9Code(), claimGroup.getDiagnosis9CodeVersion(), claimGroup.getDiagnosis10Code(), claimGroup.getDiagnosis10CodeVersion(), claimGroup.getDiagnosis11Code(), claimGroup.getDiagnosis11CodeVersion(), claimGroup.getDiagnosis12Code(), claimGroup.getDiagnosis12CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
    for (DMEClaimLine claimLine : claimGroup.getLines()) {
        ItemComponent item = eob.addItem();
        item.setSequence(claimLine.getLineNumber().intValue());
        /*
       * add an extension for the provider billing number as there is not a good place
       * to map this in the existing FHIR specification
       */
        if (claimLine.getProviderBillingNumber().isPresent()) {
            item.addExtension(TransformerUtils.createExtensionIdentifier(CcwCodebookVariable.SUPLRNUM, claimLine.getProviderBillingNumber()));
        }
        /*
       * Per Michelle at GDIT, and also Tony Dean at OEDA, the performing provider
       * _should_ always be present. However, we've found some examples in production
       * where it's not for some claim lines. (This is annoying, as it's present on
       * other lines in the same claim, and the data indicates that the same NPI
       * probably applies to the lines where it's not specified. Still, it's not safe
       * to guess at this, so we'll leave it blank.)
       */
        if (claimLine.getProviderNPI().isPresent()) {
            ExplanationOfBenefit.CareTeamComponent performingCareTeamMember = TransformerUtils.addCareTeamPractitioner(eob, item, TransformerConstants.CODING_NPI_US, claimLine.getProviderNPI().get(), ClaimCareteamrole.PRIMARY);
            performingCareTeamMember.setResponsible(true);
            /*
         * The provider's "specialty" and "type" code are equivalent.
         * However, the "specialty" codes are more granular, and seem to
         * better match the example FHIR
         * `http://hl7.org/fhir/ex-providerqualification` code set.
         * Accordingly, we map the "specialty" codes to the
         * `qualification` field here, and stick the "type" code into an
         * extension. TODO: suggest that the spec allows more than one
         * `qualification` entry.
         */
            performingCareTeamMember.setQualification(TransformerUtils.createCodeableConcept(eob, CcwCodebookVariable.PRVDR_SPCLTY, claimLine.getProviderSpecialityCode()));
            performingCareTeamMember.addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.PRTCPTNG_IND_CD, claimLine.getProviderParticipatingIndCode()));
        }
        TransformerUtils.mapHcpcs(eob, item, claimGroup.getHcpcsYearCode(), claimLine.getHcpcsCode(), Arrays.asList(claimLine.getHcpcsInitialModifierCode(), claimLine.getHcpcsSecondModifierCode(), claimLine.getHcpcsThirdModifierCode(), claimLine.getHcpcsFourthModifierCode()));
        /*
       * FIXME This value seems to be just a "synonym" for the performing physician NPI and should
       * probably be mapped as an extra identifier with it (if/when that lands in a contained
       * Practitioner resource).
       */
        if (includeTaxNumbers.orElse(false)) {
            ExplanationOfBenefit.CareTeamComponent providerTaxNumber = TransformerUtils.addCareTeamPractitioner(eob, item, IdentifierType.TAX.getSystem(), claimLine.getProviderTaxNumber(), ClaimCareteamrole.OTHER);
            providerTaxNumber.setResponsible(true);
        }
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.LINE_PRMRY_ALOWD_CHRG_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getPrimaryPayerAllowedChargeAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.LINE_DME_PRCHS_PRICE_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getPurchasePriceAmount()));
        if (claimLine.getScreenSavingsAmount().isPresent()) {
            // TODO should this be an adjudication?
            item.addExtension(TransformerUtils.createExtensionQuantity(CcwCodebookVariable.DMERC_LINE_SCRN_SVGS_AMT, claimLine.getScreenSavingsAmount()));
        }
        Extension mtusQuantityExtension = TransformerUtils.createExtensionQuantity(CcwCodebookVariable.DMERC_LINE_MTUS_CNT, claimLine.getMtusCount());
        item.addExtension(mtusQuantityExtension);
        if (claimLine.getMtusCode().isPresent()) {
            Quantity mtusQuantity = (Quantity) mtusQuantityExtension.getValue();
            TransformerUtils.setQuantityUnitInfo(CcwCodebookVariable.DMERC_LINE_MTUS_CD, claimLine.getMtusCode(), eob, mtusQuantity);
        }
        // Common item level fields between Carrier and DME
        TransformerUtils.mapEobCommonItemCarrierDME(item, eob, claimGroup.getClaimId(), claimLine.getServiceCount(), claimLine.getPlaceOfServiceCode(), claimLine.getFirstExpenseDate(), claimLine.getLastExpenseDate(), claimLine.getBeneficiaryPaymentAmount(), claimLine.getProviderPaymentAmount(), claimLine.getBeneficiaryPartBDeductAmount(), claimLine.getPrimaryPayerCode(), claimLine.getPrimaryPayerPaidAmount(), claimLine.getBetosCode(), claimLine.getPaymentAmount(), claimLine.getPaymentCode(), claimLine.getCoinsuranceAmount(), claimLine.getSubmittedChargeAmount(), claimLine.getAllowedChargeAmount(), claimLine.getProcessingIndicatorCode(), claimLine.getServiceDeductibleCode(), claimLine.getDiagnosisCode(), claimLine.getDiagnosisCodeVersion(), claimLine.getHctHgbTestTypeCode(), claimLine.getHctHgbTestResult(), claimLine.getCmsServiceTypeCode(), claimLine.getNationalDrugCode());
        if (!claimLine.getProviderStateCode().isEmpty()) {
            // FIXME Should this be pulled to a common mapping method?
            item.getLocation().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.PRVDR_STATE_CD, claimLine.getProviderStateCode()));
        }
        if (claimLine.getPricingStateCode().isPresent()) {
            item.getLocation().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.DMERC_LINE_PRCNG_STATE_CD, claimLine.getPricingStateCode()));
        }
        if (claimLine.getSupplierTypeCode().isPresent()) {
            // TODO should this be elsewhere; does it item.location make sense?
            item.getLocation().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.DMERC_LINE_SUPPLR_TYPE_CD, claimLine.getSupplierTypeCode()));
        }
    }
    TransformerUtils.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Quantity(org.hl7.fhir.dstu3.model.Quantity) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) DMEClaimLine(gov.cms.bfd.model.rif.DMEClaimLine)

Example 37 with ItemComponent

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

the class HospiceClaimTransformer method transformClaim.

/**
 * @param claimGroup the CCW {@link HospiceClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     HospiceClaim}
 */
private static ExplanationOfBenefit transformClaim(HospiceClaim claimGroup) {
    ExplanationOfBenefit eob = new ExplanationOfBenefit();
    // Common group level fields between all claim types
    TransformerUtils.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimType.HOSPICE, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
    TransformerUtils.mapEobWeeklyProcessDate(eob, claimGroup.getWeeklyProcessDate());
    // map eob type codes into FHIR
    TransformerUtils.mapEobType(eob, ClaimType.HOSPICE, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    // set the provider number which is common among several claim types
    TransformerUtils.setProviderNumber(eob, claimGroup.getProviderNumber());
    if (claimGroup.getPatientStatusCd().isPresent()) {
        TransformerUtils.addInformationWithCode(eob, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, claimGroup.getPatientStatusCd());
    }
    // Common group level fields between Inpatient, HHA, Hospice and SNF
    TransformerUtils.mapEobCommonGroupInpHHAHospiceSNF(eob, claimGroup.getClaimHospiceStartDate(), claimGroup.getBeneficiaryDischargeDate(), Optional.of(claimGroup.getUtilizationDayCount()));
    if (claimGroup.getHospicePeriodCount().isPresent()) {
        eob.getHospitalization().addExtension(TransformerUtils.createExtensionQuantity(CcwCodebookVariable.BENE_HOSPC_PRD_CNT, claimGroup.getHospicePeriodCount()));
    }
    // Common group level fields between Inpatient, Outpatient Hospice, HHA and SNF
    TransformerUtils.mapEobCommonGroupInpOutHHAHospiceSNF(eob, claimGroup.getOrganizationNpi(), claimGroup.getClaimFacilityTypeCode(), claimGroup.getClaimFrequencyCode(), claimGroup.getClaimNonPaymentReasonCode(), claimGroup.getPatientDischargeStatusCode(), claimGroup.getClaimServiceClassificationTypeCode(), claimGroup.getClaimPrimaryPayerCode(), claimGroup.getAttendingPhysicianNpi(), claimGroup.getTotalChargeAmount(), claimGroup.getPrimaryPayerPaidAmount(), claimGroup.getFiscalIntermediaryNumber(), claimGroup.getFiDocumentClaimControlNumber(), claimGroup.getFiOriginalClaimControlNumber());
    for (Diagnosis diagnosis : TransformerUtils.extractDiagnoses1Thru12(claimGroup.getDiagnosisPrincipalCode(), claimGroup.getDiagnosisPrincipalCodeVersion(), claimGroup.getDiagnosis1Code(), claimGroup.getDiagnosis1CodeVersion(), claimGroup.getDiagnosis2Code(), claimGroup.getDiagnosis2CodeVersion(), claimGroup.getDiagnosis3Code(), claimGroup.getDiagnosis3CodeVersion(), claimGroup.getDiagnosis4Code(), claimGroup.getDiagnosis4CodeVersion(), claimGroup.getDiagnosis5Code(), claimGroup.getDiagnosis5CodeVersion(), claimGroup.getDiagnosis6Code(), claimGroup.getDiagnosis6CodeVersion(), claimGroup.getDiagnosis7Code(), claimGroup.getDiagnosis7CodeVersion(), claimGroup.getDiagnosis8Code(), claimGroup.getDiagnosis8CodeVersion(), claimGroup.getDiagnosis9Code(), claimGroup.getDiagnosis9CodeVersion(), claimGroup.getDiagnosis10Code(), claimGroup.getDiagnosis10CodeVersion(), claimGroup.getDiagnosis11Code(), claimGroup.getDiagnosis11CodeVersion(), claimGroup.getDiagnosis12Code(), claimGroup.getDiagnosis12CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
    for (Diagnosis diagnosis : TransformerUtils.extractDiagnoses13Thru25(claimGroup.getDiagnosis13Code(), claimGroup.getDiagnosis13CodeVersion(), claimGroup.getDiagnosis14Code(), claimGroup.getDiagnosis14CodeVersion(), claimGroup.getDiagnosis15Code(), claimGroup.getDiagnosis15CodeVersion(), claimGroup.getDiagnosis16Code(), claimGroup.getDiagnosis16CodeVersion(), claimGroup.getDiagnosis17Code(), claimGroup.getDiagnosis17CodeVersion(), claimGroup.getDiagnosis18Code(), claimGroup.getDiagnosis18CodeVersion(), claimGroup.getDiagnosis19Code(), claimGroup.getDiagnosis19CodeVersion(), claimGroup.getDiagnosis20Code(), claimGroup.getDiagnosis20CodeVersion(), claimGroup.getDiagnosis21Code(), claimGroup.getDiagnosis21CodeVersion(), claimGroup.getDiagnosis22Code(), claimGroup.getDiagnosis22CodeVersion(), claimGroup.getDiagnosis23Code(), claimGroup.getDiagnosis23CodeVersion(), claimGroup.getDiagnosis24Code(), claimGroup.getDiagnosis24CodeVersion(), claimGroup.getDiagnosis25Code(), claimGroup.getDiagnosis25CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
    for (Diagnosis diagnosis : TransformerUtils.extractExternalDiagnoses1Thru12(claimGroup.getDiagnosisExternalFirstCode(), claimGroup.getDiagnosisExternalFirstCodeVersion(), claimGroup.getDiagnosisExternal1Code(), claimGroup.getDiagnosisExternal1CodeVersion(), claimGroup.getDiagnosisExternal2Code(), claimGroup.getDiagnosisExternal2CodeVersion(), claimGroup.getDiagnosisExternal3Code(), claimGroup.getDiagnosisExternal3CodeVersion(), claimGroup.getDiagnosisExternal4Code(), claimGroup.getDiagnosisExternal4CodeVersion(), claimGroup.getDiagnosisExternal5Code(), claimGroup.getDiagnosisExternal5CodeVersion(), claimGroup.getDiagnosisExternal6Code(), claimGroup.getDiagnosisExternal6CodeVersion(), claimGroup.getDiagnosisExternal7Code(), claimGroup.getDiagnosisExternal7CodeVersion(), claimGroup.getDiagnosisExternal8Code(), claimGroup.getDiagnosisExternal8CodeVersion(), claimGroup.getDiagnosisExternal9Code(), claimGroup.getDiagnosisExternal9CodeVersion(), claimGroup.getDiagnosisExternal10Code(), claimGroup.getDiagnosisExternal10CodeVersion(), claimGroup.getDiagnosisExternal11Code(), claimGroup.getDiagnosisExternal11CodeVersion(), claimGroup.getDiagnosisExternal12Code(), claimGroup.getDiagnosisExternal12CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
    for (HospiceClaimLine claimLine : claimGroup.getLines()) {
        ItemComponent item = eob.addItem();
        item.setSequence(claimLine.getLineNumber().intValue());
        item.setLocation(new Address().setState((claimGroup.getProviderStateCode())));
        TransformerUtils.mapHcpcs(eob, item, Optional.empty(), claimLine.getHcpcsCode(), Arrays.asList(claimLine.getHcpcsInitialModifierCode(), claimLine.getHcpcsSecondModifierCode()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_PRVDR_PMT_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getProviderPaymentAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_BENE_PMT_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getBenficiaryPaymentAmount()));
        // Common item level fields between Inpatient, Outpatient, HHA, Hospice and SNF
        TransformerUtils.mapEobCommonItemRevenue(item, eob, claimLine.getRevenueCenterCode(), claimLine.getRateAmount(), claimLine.getTotalChargeAmount(), claimLine.getNonCoveredChargeAmount().get(), claimLine.getUnitCount(), claimLine.getNationalDrugCodeQuantity(), claimLine.getNationalDrugCodeQualifierCode(), claimLine.getRevenueCenterRenderingPhysicianNPI());
        // Common item level fields between Outpatient, HHA and Hospice
        TransformerUtils.mapEobCommonItemRevenueOutHHAHospice(item, claimLine.getRevenueCenterDate(), claimLine.getPaymentAmount());
        // Common group level field coinsurance between Inpatient, HHA, Hospice and SNF
        TransformerUtils.mapEobCommonGroupInpHHAHospiceSNFCoinsurance(eob, item, claimLine.getDeductibleCoinsuranceCd());
    }
    TransformerUtils.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : HospiceClaimLine(gov.cms.bfd.model.rif.HospiceClaimLine) Address(org.hl7.fhir.dstu3.model.Address) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit)

Example 38 with ItemComponent

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

the class OutpatientClaimTransformer method transformClaim.

/**
 * @param claimGroup the CCW {@link OutpatientClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     OutpatientClaim}
 */
private static ExplanationOfBenefit transformClaim(OutpatientClaim claimGroup) {
    ExplanationOfBenefit eob = new ExplanationOfBenefit();
    // Common group level fields between all claim types
    TransformerUtils.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimType.OUTPATIENT, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
    TransformerUtils.mapEobWeeklyProcessDate(eob, claimGroup.getWeeklyProcessDate());
    // map eob type codes into FHIR
    TransformerUtils.mapEobType(eob, ClaimType.OUTPATIENT, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    // set the provider number which is common among several claim types
    TransformerUtils.setProviderNumber(eob, claimGroup.getProviderNumber());
    // TODO If this is actually nullable, should be Optional.
    if (claimGroup.getProfessionalComponentCharge() != null) {
        TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.NCH_PROFNL_CMPNT_CHRG_AMT, claimGroup.getProfessionalComponentCharge());
    }
    // TODO If this is actually nullable, should be Optional.
    if (claimGroup.getDeductibleAmount() != null) {
        TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.NCH_BENE_PTB_DDCTBL_AMT, claimGroup.getDeductibleAmount());
    }
    // TODO If this is actually nullable, should be Optional.
    if (claimGroup.getCoinsuranceAmount() != null) {
        TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.NCH_BENE_PTB_COINSRNC_AMT, claimGroup.getCoinsuranceAmount());
    }
    // TODO If this is actually nullable, should be Optional.
    if (claimGroup.getProviderPaymentAmount() != null) {
        TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.CLM_OP_PRVDR_PMT_AMT, claimGroup.getProviderPaymentAmount());
    }
    // TODO If this is actually nullable, should be Optional.
    if (claimGroup.getBeneficiaryPaymentAmount() != null) {
        TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.CLM_OP_BENE_PMT_AMT, claimGroup.getBeneficiaryPaymentAmount());
    }
    // Common group level fields between Inpatient, Outpatient and SNF
    TransformerUtils.mapEobCommonGroupInpOutSNF(eob, claimGroup.getBloodDeductibleLiabilityAmount(), claimGroup.getOperatingPhysicianNpi(), claimGroup.getOtherPhysicianNpi(), claimGroup.getClaimQueryCode(), claimGroup.getMcoPaidSw());
    // Common group level fields between Inpatient, Outpatient Hospice, HHA and SNF
    TransformerUtils.mapEobCommonGroupInpOutHHAHospiceSNF(eob, claimGroup.getOrganizationNpi(), claimGroup.getClaimFacilityTypeCode(), claimGroup.getClaimFrequencyCode(), claimGroup.getClaimNonPaymentReasonCode(), claimGroup.getPatientDischargeStatusCode().get(), claimGroup.getClaimServiceClassificationTypeCode(), claimGroup.getClaimPrimaryPayerCode(), claimGroup.getAttendingPhysicianNpi(), claimGroup.getTotalChargeAmount(), claimGroup.getPrimaryPayerPaidAmount(), claimGroup.getFiscalIntermediaryNumber(), claimGroup.getFiDocumentClaimControlNumber(), claimGroup.getFiOriginalClaimControlNumber());
    for (Diagnosis diagnosis : TransformerUtils.extractDiagnoses1Thru12(claimGroup.getDiagnosisPrincipalCode(), claimGroup.getDiagnosisPrincipalCodeVersion(), claimGroup.getDiagnosis1Code(), claimGroup.getDiagnosis1CodeVersion(), claimGroup.getDiagnosis2Code(), claimGroup.getDiagnosis2CodeVersion(), claimGroup.getDiagnosis3Code(), claimGroup.getDiagnosis3CodeVersion(), claimGroup.getDiagnosis4Code(), claimGroup.getDiagnosis4CodeVersion(), claimGroup.getDiagnosis5Code(), claimGroup.getDiagnosis5CodeVersion(), claimGroup.getDiagnosis6Code(), claimGroup.getDiagnosis6CodeVersion(), claimGroup.getDiagnosis7Code(), claimGroup.getDiagnosis7CodeVersion(), claimGroup.getDiagnosis8Code(), claimGroup.getDiagnosis8CodeVersion(), claimGroup.getDiagnosis9Code(), claimGroup.getDiagnosis9CodeVersion(), claimGroup.getDiagnosis10Code(), claimGroup.getDiagnosis10CodeVersion(), claimGroup.getDiagnosis11Code(), claimGroup.getDiagnosis11CodeVersion(), claimGroup.getDiagnosis12Code(), claimGroup.getDiagnosis12CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
    for (Diagnosis diagnosis : TransformerUtils.extractDiagnoses13Thru25(claimGroup.getDiagnosis13Code(), claimGroup.getDiagnosis13CodeVersion(), claimGroup.getDiagnosis14Code(), claimGroup.getDiagnosis14CodeVersion(), claimGroup.getDiagnosis15Code(), claimGroup.getDiagnosis15CodeVersion(), claimGroup.getDiagnosis16Code(), claimGroup.getDiagnosis16CodeVersion(), claimGroup.getDiagnosis17Code(), claimGroup.getDiagnosis17CodeVersion(), claimGroup.getDiagnosis18Code(), claimGroup.getDiagnosis18CodeVersion(), claimGroup.getDiagnosis19Code(), claimGroup.getDiagnosis19CodeVersion(), claimGroup.getDiagnosis20Code(), claimGroup.getDiagnosis20CodeVersion(), claimGroup.getDiagnosis21Code(), claimGroup.getDiagnosis21CodeVersion(), claimGroup.getDiagnosis22Code(), claimGroup.getDiagnosis22CodeVersion(), claimGroup.getDiagnosis23Code(), claimGroup.getDiagnosis23CodeVersion(), claimGroup.getDiagnosis24Code(), claimGroup.getDiagnosis24CodeVersion(), claimGroup.getDiagnosis25Code(), claimGroup.getDiagnosis25CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
    for (Diagnosis diagnosis : TransformerUtils.extractExternalDiagnoses1Thru12(claimGroup.getDiagnosisExternalFirstCode(), claimGroup.getDiagnosisExternalFirstCodeVersion(), claimGroup.getDiagnosisExternal1Code(), claimGroup.getDiagnosisExternal1CodeVersion(), claimGroup.getDiagnosisExternal2Code(), claimGroup.getDiagnosisExternal2CodeVersion(), claimGroup.getDiagnosisExternal3Code(), claimGroup.getDiagnosisExternal3CodeVersion(), claimGroup.getDiagnosisExternal4Code(), claimGroup.getDiagnosisExternal4CodeVersion(), claimGroup.getDiagnosisExternal5Code(), claimGroup.getDiagnosisExternal5CodeVersion(), claimGroup.getDiagnosisExternal6Code(), claimGroup.getDiagnosisExternal6CodeVersion(), claimGroup.getDiagnosisExternal7Code(), claimGroup.getDiagnosisExternal7CodeVersion(), claimGroup.getDiagnosisExternal8Code(), claimGroup.getDiagnosisExternal8CodeVersion(), claimGroup.getDiagnosisExternal9Code(), claimGroup.getDiagnosisExternal9CodeVersion(), claimGroup.getDiagnosisExternal10Code(), claimGroup.getDiagnosisExternal10CodeVersion(), claimGroup.getDiagnosisExternal11Code(), claimGroup.getDiagnosisExternal11CodeVersion(), claimGroup.getDiagnosisExternal12Code(), claimGroup.getDiagnosisExternal12CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
    if (claimGroup.getDiagnosisAdmission1Code().isPresent())
        TransformerUtils.addDiagnosisCode(eob, Diagnosis.from(claimGroup.getDiagnosisAdmission1Code(), claimGroup.getDiagnosisAdmission1CodeVersion(), DiagnosisLabel.REASONFORVISIT).get());
    if (claimGroup.getDiagnosisAdmission2Code().isPresent())
        TransformerUtils.addDiagnosisCode(eob, Diagnosis.from(claimGroup.getDiagnosisAdmission2Code(), claimGroup.getDiagnosisAdmission2CodeVersion(), DiagnosisLabel.REASONFORVISIT).get());
    if (claimGroup.getDiagnosisAdmission3Code().isPresent())
        TransformerUtils.addDiagnosisCode(eob, Diagnosis.from(claimGroup.getDiagnosisAdmission3Code(), claimGroup.getDiagnosisAdmission3CodeVersion(), DiagnosisLabel.REASONFORVISIT).get());
    for (CCWProcedure procedure : TransformerUtils.extractCCWProcedures(claimGroup.getProcedure1Code(), claimGroup.getProcedure1CodeVersion(), claimGroup.getProcedure1Date(), claimGroup.getProcedure2Code(), claimGroup.getProcedure2CodeVersion(), claimGroup.getProcedure2Date(), claimGroup.getProcedure3Code(), claimGroup.getProcedure3CodeVersion(), claimGroup.getProcedure3Date(), claimGroup.getProcedure4Code(), claimGroup.getProcedure4CodeVersion(), claimGroup.getProcedure4Date(), claimGroup.getProcedure5Code(), claimGroup.getProcedure5CodeVersion(), claimGroup.getProcedure5Date(), claimGroup.getProcedure6Code(), claimGroup.getProcedure6CodeVersion(), claimGroup.getProcedure6Date(), claimGroup.getProcedure7Code(), claimGroup.getProcedure7CodeVersion(), claimGroup.getProcedure7Date(), claimGroup.getProcedure8Code(), claimGroup.getProcedure8CodeVersion(), claimGroup.getProcedure8Date(), claimGroup.getProcedure9Code(), claimGroup.getProcedure9CodeVersion(), claimGroup.getProcedure9Date(), claimGroup.getProcedure10Code(), claimGroup.getProcedure10CodeVersion(), claimGroup.getProcedure10Date(), claimGroup.getProcedure11Code(), claimGroup.getProcedure11CodeVersion(), claimGroup.getProcedure11Date(), claimGroup.getProcedure12Code(), claimGroup.getProcedure12CodeVersion(), claimGroup.getProcedure12Date(), claimGroup.getProcedure13Code(), claimGroup.getProcedure13CodeVersion(), claimGroup.getProcedure13Date(), claimGroup.getProcedure14Code(), claimGroup.getProcedure14CodeVersion(), claimGroup.getProcedure14Date(), claimGroup.getProcedure15Code(), claimGroup.getProcedure15CodeVersion(), claimGroup.getProcedure15Date(), claimGroup.getProcedure16Code(), claimGroup.getProcedure16CodeVersion(), claimGroup.getProcedure16Date(), claimGroup.getProcedure17Code(), claimGroup.getProcedure17CodeVersion(), claimGroup.getProcedure17Date(), claimGroup.getProcedure18Code(), claimGroup.getProcedure18CodeVersion(), claimGroup.getProcedure18Date(), claimGroup.getProcedure19Code(), claimGroup.getProcedure19CodeVersion(), claimGroup.getProcedure19Date(), claimGroup.getProcedure20Code(), claimGroup.getProcedure20CodeVersion(), claimGroup.getProcedure20Date(), claimGroup.getProcedure21Code(), claimGroup.getProcedure21CodeVersion(), claimGroup.getProcedure21Date(), claimGroup.getProcedure22Code(), claimGroup.getProcedure22CodeVersion(), claimGroup.getProcedure22Date(), claimGroup.getProcedure23Code(), claimGroup.getProcedure23CodeVersion(), claimGroup.getProcedure23Date(), claimGroup.getProcedure24Code(), claimGroup.getProcedure24CodeVersion(), claimGroup.getProcedure24Date(), claimGroup.getProcedure25Code(), claimGroup.getProcedure25CodeVersion(), claimGroup.getProcedure25Date())) TransformerUtils.addProcedureCode(eob, procedure);
    for (OutpatientClaimLine claimLine : claimGroup.getLines()) {
        ItemComponent item = eob.addItem();
        item.setSequence(claimLine.getLineNumber().intValue());
        item.setLocation(new Address().setState((claimGroup.getProviderStateCode())));
        if (claimLine.getRevCntr1stAnsiCd().isPresent()) {
            item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_1ST_ANSI_CD)).setReason(TransformerUtils.createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR_1ST_ANSI_CD, claimLine.getRevCntr1stAnsiCd()));
        }
        if (claimLine.getRevCntr2ndAnsiCd().isPresent()) {
            item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_2ND_ANSI_CD)).setReason(TransformerUtils.createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR_2ND_ANSI_CD, claimLine.getRevCntr2ndAnsiCd()));
        }
        if (claimLine.getRevCntr3rdAnsiCd().isPresent()) {
            item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_3RD_ANSI_CD)).setReason(TransformerUtils.createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR_3RD_ANSI_CD, claimLine.getRevCntr3rdAnsiCd()));
        }
        if (claimLine.getRevCntr4thAnsiCd().isPresent()) {
            item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_4TH_ANSI_CD)).setReason(TransformerUtils.createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR_4TH_ANSI_CD, claimLine.getRevCntr4thAnsiCd()));
        }
        TransformerUtils.mapHcpcs(eob, item, Optional.empty(), claimLine.getHcpcsCode(), Arrays.asList(claimLine.getHcpcsInitialModifierCode(), claimLine.getHcpcsSecondModifierCode()));
        if (claimLine.getNationalDrugCode().isPresent()) {
            item.getService().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.REV_CNTR_IDE_NDC_UPC_NUM, claimLine.getNationalDrugCode()));
        }
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_BLOOD_DDCTBL_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getBloodDeductibleAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_CASH_DDCTBL_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getCashDeductibleAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_COINSRNC_WGE_ADJSTD_C)).setAmount(TransformerUtils.createMoney(claimLine.getWageAdjustedCoinsuranceAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_RDCD_COINSRNC_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getReducedCoinsuranceAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_1ST_MSP_PD_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getFirstMspPaidAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_2ND_MSP_PD_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getSecondMspPaidAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_PRVDR_PMT_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getProviderPaymentAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_BENE_PMT_AMT)).setAmount(TransformerUtils.createMoney(claimLine.getBenficiaryPaymentAmount()));
        item.addAdjudication().setCategory(TransformerUtils.createAdjudicationCategory(CcwCodebookVariable.REV_CNTR_PTNT_RSPNSBLTY_PMT)).setAmount(TransformerUtils.createMoney(claimLine.getPatientResponsibilityAmount()));
        // Common item level fields between Outpatient, HHA and Hospice
        TransformerUtils.mapEobCommonItemRevenueOutHHAHospice(item, claimLine.getRevenueCenterDate(), claimLine.getPaymentAmount());
        // Common item level fields between Inpatient, Outpatient, HHA, Hospice and SNF
        TransformerUtils.mapEobCommonItemRevenue(item, eob, claimLine.getRevenueCenterCode(), claimLine.getRateAmount(), claimLine.getTotalChargeAmount(), claimLine.getNonCoveredChargeAmount(), claimLine.getUnitCount(), claimLine.getNationalDrugCodeQuantity(), claimLine.getNationalDrugCodeQualifierCode(), claimLine.getRevenueCenterRenderingPhysicianNPI());
        // Dt: 6-18-20 Handling for optional status code claim line: BFD-252
        if (claimLine.getStatusCode().isPresent()) {
            item.getRevenue().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.REV_CNTR_STUS_IND_CD, claimLine.getStatusCode()));
        }
    }
    TransformerUtils.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : Address(org.hl7.fhir.dstu3.model.Address) CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) OutpatientClaimLine(gov.cms.bfd.model.rif.OutpatientClaimLine) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit)

Example 39 with ItemComponent

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

the class TransformerTestUtils method assertEobCommonItemCarrierDMEEquals.

/**
 * Test the transformation of the 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 test
 * @param eob the {@ ExplanationOfBenefit} to test
 * @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 diagnosisCode LINE_ICD_DGNS_CD,
 * @param diagnosisCodeVersion LINE_ICD_DGNS_VRSN_CD,
 * @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
 * @throws FHIRException
 */
static void assertEobCommonItemCarrierDMEEquals(ItemComponent item, ExplanationOfBenefit eob, 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> diagnosisCode, Optional<Character> diagnosisCodeVersion, Optional<String> hctHgbTestTypeCode, BigDecimal hctHgbTestResult, char cmsServiceTypeCode, Optional<String> nationalDrugCode) throws FHIRException {
    assertEquals(serviceCount, item.getQuantity().getValue());
    assertHasCoding(CcwCodebookVariable.LINE_CMS_TYPE_SRVC_CD, cmsServiceTypeCode, item.getCategory());
    assertHasCoding(CcwCodebookVariable.LINE_PLACE_OF_SRVC_CD, placeOfServiceCode, item.getLocationCodeableConcept());
    assertExtensionCodingEquals(CcwCodebookVariable.BETOS_CD, betosCode, item);
    assertDateEquals(firstExpenseDate.get(), item.getServicedPeriod().getStartElement());
    assertDateEquals(lastExpenseDate.get(), item.getServicedPeriod().getEndElement());
    AdjudicationComponent adjudicationForPayment = assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_NCH_PMT_AMT, paymentAmount, item.getAdjudication());
    assertExtensionCodingEquals(CcwCodebookVariable.LINE_PMT_80_100_CD, paymentCode, adjudicationForPayment);
    assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_BENE_PMT_AMT, beneficiaryPaymentAmount, item.getAdjudication());
    assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_PRVDR_PMT_AMT, providerPaymentAmount, item.getAdjudication());
    assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_BENE_PTB_DDCTBL_AMT, beneficiaryPartBDeductAmount, item.getAdjudication());
    assertExtensionCodingEquals(CcwCodebookVariable.LINE_BENE_PRMRY_PYR_CD, primaryPayerCode, item);
    assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_BENE_PRMRY_PYR_PD_AMT, primaryPayerPaidAmount, item.getAdjudication());
    assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_COINSRNC_AMT, coinsuranceAmount, item.getAdjudication());
    assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_SBMTD_CHRG_AMT, submittedChargeAmount, item.getAdjudication());
    assertAdjudicationAmountEquals(CcwCodebookVariable.LINE_ALOWD_CHRG_AMT, allowedChargeAmount, item.getAdjudication());
    assertAdjudicationReasonEquals(CcwCodebookVariable.LINE_PRCSG_IND_CD, processingIndicatorCode, item.getAdjudication());
    assertExtensionCodingEquals(CcwCodebookVariable.LINE_SERVICE_DEDUCTIBLE, serviceDeductibleCode, item);
    assertDiagnosisLinkPresent(Diagnosis.from(diagnosisCode, diagnosisCodeVersion), eob, item);
    List<Extension> hctHgbObservationExtension = item.getExtensionsByUrl(CCWUtils.calculateVariableReferenceUrl(CcwCodebookVariable.LINE_HCT_HGB_RSLT_NUM));
    assertEquals(1, hctHgbObservationExtension.size());
    assertTrue(hctHgbObservationExtension.get(0).getValue() instanceof Reference);
    Reference hctHgbReference = (Reference) hctHgbObservationExtension.get(0).getValue();
    assertTrue(hctHgbReference.getResource() instanceof Observation);
    Observation hctHgbObservation = (Observation) hctHgbReference.getResource();
    assertHasCoding(CcwCodebookVariable.LINE_HCT_HGB_TYPE_CD, hctHgbTestTypeCode, hctHgbObservation.getCode());
    assertEquals(hctHgbTestResult, hctHgbObservation.getValueQuantity().getValue());
    assertExtensionCodingEquals(item, TransformerConstants.CODING_NDC, TransformerConstants.CODING_NDC, nationalDrugCode.get());
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) AdjudicationComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.AdjudicationComponent) Reference(org.hl7.fhir.dstu3.model.Reference) Observation(org.hl7.fhir.dstu3.model.Observation)

Example 40 with ItemComponent

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

the class PartDEventTransformerTest method assertMatches.

/**
 * Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
 * the specified {@link PartDEvent}.
 *
 * @param claim the {@link PartDEvent} that the {@link ExplanationOfBenefit} was generated from
 * @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
 *     PartDEvent}
 * @throws FHIRException (indicates test failure)
 */
static void assertMatches(PartDEvent claim, ExplanationOfBenefit eob) throws FHIRException {
    // Test to ensure group level fields between all claim types match
    TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getEventId(), claim.getBeneficiaryId(), ClaimType.PDE, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_D, Optional.of(claim.getPrescriptionFillDate()), Optional.of(claim.getPrescriptionFillDate()), Optional.empty(), claim.getFinalAction());
    TransformerTestUtils.assertExtensionIdentifierEquals(CcwCodebookVariable.PLAN_CNTRCT_REC_ID, claim.getPlanContractId(), eob.getInsurance().getCoverage());
    TransformerTestUtils.assertExtensionIdentifierEquals(CcwCodebookVariable.PLAN_PBP_REC_NUM, claim.getPlanBenefitPackageId(), eob.getInsurance().getCoverage());
    assertEquals("01", claim.getServiceProviderIdQualiferCode());
    assertEquals("01", claim.getPrescriberIdQualifierCode());
    ItemComponent rxItem = eob.getItem().stream().filter(i -> i.getSequence() == 1).findAny().get();
    TransformerTestUtils.assertHasCoding(TransformerConstants.CODING_NDC, null, TransformerUtils.retrieveFDADrugCodeDisplay(claim.getNationalDrugCode()), claim.getNationalDrugCode(), rxItem.getService().getCoding());
    TransformerTestUtils.assertHasCoding(V3ActCode.RXDINV.getSystem(), V3ActCode.RXDINV.toCode(), rxItem.getDetail().get(0).getType().getCoding());
    assertEquals(Date.valueOf(claim.getPrescriptionFillDate()), rxItem.getServicedDateType().getValue());
    TransformerTestUtils.assertReferenceEquals(TransformerConstants.CODING_NPI_US, claim.getServiceProviderId(), eob.getOrganization());
    TransformerTestUtils.assertReferenceEquals(TransformerConstants.CODING_NPI_US, claim.getServiceProviderId(), eob.getFacility());
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PHRMCY_SRVC_TYPE_CD, claim.getPharmacyTypeCode(), eob.getFacility());
    if (claim.getDrugCoverageStatusCode() == 'C')
        TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.CVRD_D_PLAN_PD_AMT, claim.getPartDPlanCoveredPaidAmount(), rxItem.getAdjudication());
    else
        TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.NCVRD_PLAN_PD_AMT, claim.getPartDPlanCoveredPaidAmount(), rxItem.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.PTNT_PAY_AMT, claim.getPatientPaidAmount(), rxItem.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.OTHR_TROOP_AMT, claim.getOtherTrueOutOfPocketPaidAmount(), rxItem.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.LICS_AMT, claim.getLowIncomeSubsidyPaidAmount(), rxItem.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.PLRO_AMT, claim.getPatientLiabilityReductionOtherPaidAmount(), rxItem.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.TOT_RX_CST_AMT, claim.getTotalPrescriptionCost(), rxItem.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.RPTD_GAP_DSCNT_NUM, claim.getGapDiscountAmount(), rxItem.getAdjudication());
    TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.FILL_NUM, claim.getFillNumber(), rxItem.getQuantity());
    TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.DAYS_SUPLY_NUM, claim.getDaysSupply(), rxItem.getQuantity());
    // verify {@link
    // TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
    // method worked as expected for this claim type
    TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.PDE, Optional.of(org.hl7.fhir.dstu3.model.codesystems.ClaimType.PHARMACY), Optional.empty(), Optional.empty());
    TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.DAW_PROD_SLCTN_CD, CcwCodebookVariable.DAW_PROD_SLCTN_CD, claim.getDispenseAsWrittenProductSelectionCode(), eob);
    if (claim.getDispensingStatusCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.DSPNSNG_STUS_CD, CcwCodebookVariable.DSPNSNG_STUS_CD, claim.getDispensingStatusCode(), eob);
    TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.DRUG_CVRG_STUS_CD, CcwCodebookVariable.DRUG_CVRG_STUS_CD, claim.getDrugCoverageStatusCode(), eob);
    if (claim.getAdjustmentDeletionCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.ADJSTMT_DLTN_CD, CcwCodebookVariable.ADJSTMT_DLTN_CD, claim.getAdjustmentDeletionCode(), eob);
    if (claim.getNonstandardFormatCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.NSTD_FRMT_CD, CcwCodebookVariable.NSTD_FRMT_CD, claim.getNonstandardFormatCode(), eob);
    if (claim.getPricingExceptionCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.PRCNG_EXCPTN_CD, CcwCodebookVariable.PRCNG_EXCPTN_CD, claim.getPricingExceptionCode(), eob);
    if (claim.getCatastrophicCoverageCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.CTSTRPHC_CVRG_CD, CcwCodebookVariable.CTSTRPHC_CVRG_CD, claim.getCatastrophicCoverageCode(), eob);
    if (claim.getPrescriptionOriginationCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.RX_ORGN_CD, CcwCodebookVariable.RX_ORGN_CD, claim.getPrescriptionOriginationCode(), eob);
    if (claim.getBrandGenericCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.BRND_GNRC_CD, CcwCodebookVariable.BRND_GNRC_CD, claim.getBrandGenericCode(), eob);
    TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.PHRMCY_SRVC_TYPE_CD, CcwCodebookVariable.PHRMCY_SRVC_TYPE_CD, claim.getPharmacyTypeCode(), eob);
    TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.PTNT_RSDNC_CD, CcwCodebookVariable.PTNT_RSDNC_CD, claim.getPatientResidenceCode(), eob);
    if (claim.getSubmissionClarificationCode().isPresent())
        TransformerTestUtils.assertInfoWithCodeEquals(CcwCodebookVariable.SUBMSN_CLR_CD, CcwCodebookVariable.SUBMSN_CLR_CD, claim.getSubmissionClarificationCode(), eob);
    TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
    try {
        TransformerTestUtils.assertFDADrugCodeDisplayEquals(claim.getNationalDrugCode(), "ACETAMINOPHEN AND CODEINE PHOSPHATE - ACETAMINOPHEN; CODEINE PHOSPHATE");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    try {
        TransformerTestUtils.assertNPICodeDisplayEquals(claim.getPrescriberId(), "DR. ROBERT BISBEE MD");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

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