Search in sources :

Example 31 with ItemComponent

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

the class TransformerUtilsV2 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 nationalDrugCodeQuantity REV_CNTR_NDC_QTY,
 * @param nationalDrugCodeQualifierCode REV_CNTR_NDC_QTY_QLFR_CD,
 * @return the {@link ItemComponent}
 */
static ItemComponent mapEobCommonItemRevenue(ItemComponent item, ExplanationOfBenefit eob, String revenueCenterCode, BigDecimal rateAmount, BigDecimal totalChargeAmount, Optional<BigDecimal> nonCoveredChargeAmount, Optional<BigDecimal> nationalDrugCodeQuantity, Optional<String> nationalDrugCodeQualifierCode) {
    // REV_CNTR => ExplanationOfBenefit.item.revenue
    item.setRevenue(createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR, revenueCenterCode));
    // REV_CNTR_RATE_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_RATE_AMT, C4BBAdjudication.SUBMITTED, rateAmount));
    // REV_CNTR_TOT_CHRG_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_TOT_CHRG_AMT, C4BBAdjudication.SUBMITTED, totalChargeAmount));
    // REV_CNTR_NCVRD_CHRG_AMT => ExplanationOfBenefit.item.adjudication
    if (nonCoveredChargeAmount.isPresent()) {
        addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_NCVRD_CHRG_AMT, C4BBAdjudication.NONCOVERED, nonCoveredChargeAmount));
    }
    // REV_CNTR_NDC_QTY_QLFR_CD => ExplanationOfBenefit.item.modifier
    if (nationalDrugCodeQualifierCode.isPresent()) {
        item.getModifier().add(TransformerUtilsV2.createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR_NDC_QTY_QLFR_CD, nationalDrugCodeQualifierCode));
    }
    // REV_CNTR_NDC_QTY => ExplanationOfBenefit.item.quantity
    if (nationalDrugCodeQuantity.isPresent()) {
        Extension drugQuantityExtension = createExtensionQuantity(CcwCodebookVariable.REV_CNTR_NDC_QTY, nationalDrugCodeQuantity);
        Quantity drugQuantity = (Quantity) drugQuantityExtension.getValue();
        item.setQuantity(drugQuantity);
    }
    return item;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Quantity(org.hl7.fhir.r4.model.Quantity)

Example 32 with ItemComponent

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

the class TransformerUtilsV2 method addCareTeamPractitioner.

/**
 * Ensures that the specified {@link ExplanationOfBenefit} has the specified {@link
 * CareTeamComponent}, and links the specified {@link ItemComponent} to that {@link
 * CareTeamComponent} (via {@link ItemComponent#addCareTeamLinkId(int)}).
 *
 * @param eob the {@link ExplanationOfBenefit} that the {@link CareTeamComponent} should be part
 *     of
 * @param eobItem the {@link ItemComponent} that should be linked to the {@link CareTeamComponent}
 * @param practitionerIdSystem the {@link Identifier#getSystem()} of the practitioner to reference
 *     in {@link CareTeamComponent#getProvider()}
 * @param practitionerIdValue the {@link Identifier#getValue()} of the practitioner to reference
 *     in {@link CareTeamComponent#getProvider()}
 * @param careTeamRole the {@link ClaimCareteamrole} to use for the {@link
 *     CareTeamComponent#getRole()}
 * @return the {@link CareTeamComponent} that was created/linked
 */
private static CareTeamComponent addCareTeamPractitioner(ExplanationOfBenefit eob, ItemComponent eobItem, C4BBPractitionerIdentifierType type, String practitionerIdValue, String roleSystem, String roleCode, String roleDisplay) {
    // Try to find a matching pre-existing entry.
    CareTeamComponent careTeamEntry = eob.getCareTeam().stream().filter(ctc -> ctc.getProvider().hasIdentifier()).filter(ctc -> type.getSystem().equals(ctc.getProvider().getIdentifier().getSystem()) && practitionerIdValue.equals(ctc.getProvider().getIdentifier().getValue())).filter(ctc -> ctc.hasRole()).filter(ctc -> roleCode.equals(ctc.getRole().getCodingFirstRep().getCode()) && roleSystem.equals(ctc.getRole().getCodingFirstRep().getSystem())).findAny().orElse(null);
    // <ID Value> => ExplanationOfBenefit.careTeam.provider
    if (careTeamEntry == null) {
        careTeamEntry = eob.addCareTeam();
        // addItem adds and returns, so we want size() not size() + 1 here
        careTeamEntry.setSequence(eob.getCareTeam().size());
        careTeamEntry.setProvider(createPractitionerIdentifierReference(type, practitionerIdValue));
        CodeableConcept careTeamRoleConcept = createCodeableConcept(roleSystem, roleCode);
        careTeamRoleConcept.getCodingFirstRep().setDisplay(roleDisplay);
        careTeamEntry.setRole(careTeamRoleConcept);
    }
    // care team entry is at eob level so no need to create item link id
    if (eobItem == null) {
        return careTeamEntry;
    }
    // ExplanationOfBenefit.careTeam.sequence => ExplanationOfBenefit.item.careTeamSequence
    if (!eobItem.getCareTeamSequence().contains(new PositiveIntType(careTeamEntry.getSequence()))) {
        eobItem.addCareTeamSequence(careTeamEntry.getSequence());
    }
    return careTeamEntry;
}
Also used : Arrays(java.util.Arrays) CcwCodebookInterface(gov.cms.bfd.model.codebook.model.CcwCodebookInterface) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Constants(ca.uhn.fhir.rest.api.Constants) Identifier(org.hl7.fhir.r4.model.Identifier) Reference(org.hl7.fhir.r4.model.Reference) StringUtils(org.apache.commons.lang3.StringUtils) BigDecimal(java.math.BigDecimal) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Map(java.util.Map) CcwCodebookMissingVariable(gov.cms.bfd.model.codebook.data.CcwCodebookMissingVariable) TemporalPrecisionEnum(ca.uhn.fhir.model.api.TemporalPrecisionEnum) Value(gov.cms.bfd.model.codebook.model.Value) Coverage(org.hl7.fhir.r4.model.Coverage) IdDt(ca.uhn.fhir.model.primitive.IdDt) ReflectionUtils(gov.cms.bfd.server.war.commons.ReflectionUtils) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) BenefitBalanceComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitBalanceComponent) Period(org.hl7.fhir.r4.model.Period) Set(java.util.Set) StandardCharsets(java.nio.charset.StandardCharsets) ZoneId(java.time.ZoneId) UncheckedIOException(java.io.UncheckedIOException) Coding(org.hl7.fhir.r4.model.Coding) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) RaceCategory(gov.cms.bfd.server.war.commons.RaceCategory) ExplanationOfBenefitStatus(org.hl7.fhir.r4.model.ExplanationOfBenefit.ExplanationOfBenefitStatus) Use(org.hl7.fhir.r4.model.ExplanationOfBenefit.Use) C4BBClaimIdentifierType(gov.cms.bfd.server.war.commons.carin.C4BBClaimIdentifierType) IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) Money(org.hl7.fhir.r4.model.Money) Strings(com.google.common.base.Strings) CCWUtils(gov.cms.bfd.server.war.commons.CCWUtils) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) UnsignedIntType(org.hl7.fhir.r4.model.UnsignedIntType) CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) Quantity(org.hl7.fhir.r4.model.Quantity) CareTeamComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.CareTeamComponent) OffsetLinkBuilder(gov.cms.bfd.server.war.commons.OffsetLinkBuilder) LinkBuilder(gov.cms.bfd.server.war.commons.LinkBuilder) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) IOException(java.io.IOException) C4BBClaimProfessionalAndNonClinicianCareTeamRole(gov.cms.bfd.server.war.commons.carin.C4BBClaimProfessionalAndNonClinicianCareTeamRole) InputStreamReader(java.io.InputStreamReader) FDADrugDataUtilityApp(gov.cms.bfd.server.war.FDADrugDataUtilityApp) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) MDC(org.slf4j.MDC) Bundle(org.hl7.fhir.r4.model.Bundle) BufferedReader(java.io.BufferedReader) TotalComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.TotalComponent) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) BenefitComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent) ProcedureComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ProcedureComponent) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) C4BBAdjudicationDiscriminator(gov.cms.bfd.server.war.commons.carin.C4BBAdjudicationDiscriminator) Patient(org.hl7.fhir.r4.model.Patient) DateType(org.hl7.fhir.r4.model.DateType) Collection(java.util.Collection) Resource(org.hl7.fhir.r4.model.Resource) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) C4BBOrganizationIdentifierType(gov.cms.bfd.server.war.commons.carin.C4BBOrganizationIdentifierType) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Extension(org.hl7.fhir.r4.model.Extension) PositiveIntType(org.hl7.fhir.r4.model.PositiveIntType) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ClaimCareteamrole(org.hl7.fhir.r4.model.codesystems.ClaimCareteamrole) DataFormatException(ca.uhn.fhir.parser.DataFormatException) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) ProfileConstants(gov.cms.bfd.server.war.commons.ProfileConstants) HashMap(java.util.HashMap) ExBenefitcategory(org.hl7.fhir.r4.model.codesystems.ExBenefitcategory) HashSet(java.util.HashSet) C4BBClaimPharmacyTeamRole(gov.cms.bfd.server.war.commons.carin.C4BBClaimPharmacyTeamRole) C4BBIdentifierType(gov.cms.bfd.server.war.commons.carin.C4BBIdentifierType) Address(org.hl7.fhir.r4.model.Address) InvalidRifValueException(gov.cms.bfd.model.rif.parse.InvalidRifValueException) NoSuchElementException(java.util.NoSuchElementException) Nonnull(javax.annotation.Nonnull) C4BBAdjudication(gov.cms.bfd.server.war.commons.carin.C4BBAdjudication) Observation(org.hl7.fhir.r4.model.Observation) ObservationStatus(org.hl7.fhir.r4.model.Observation.ObservationStatus) C4BBPractitionerIdentifierType(gov.cms.bfd.server.war.commons.carin.C4BBPractitionerIdentifierType) C4BBSupportingInfoType(gov.cms.bfd.server.war.commons.carin.C4BBSupportingInfoType) Logger(org.slf4j.Logger) C4BBClaimInstitutionalCareTeamRole(gov.cms.bfd.server.war.commons.carin.C4BBClaimInstitutionalCareTeamRole) Organization(org.hl7.fhir.r4.model.Organization) ResourceType(org.hl7.fhir.r4.model.ResourceType) CurrencyIdentifier(gov.cms.bfd.server.war.r4.providers.BeneficiaryTransformerV2.CurrencyIdentifier) URLEncoder(java.net.URLEncoder) RemittanceOutcome(org.hl7.fhir.r4.model.ExplanationOfBenefit.RemittanceOutcome) InputStream(java.io.InputStream) Assert(org.springframework.util.Assert) CareTeamComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.CareTeamComponent) PositiveIntType(org.hl7.fhir.r4.model.PositiveIntType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 33 with ItemComponent

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

the class SNFClaimTransformerV2 method transformClaim.

/**
 * @param claimGroup the CCW {@link SNFClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     SNFClaim}
 */
private static ExplanationOfBenefit transformClaim(SNFClaim claimGroup) {
    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)
    // 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.SNF, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, 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 (Professional)  => ExplanationOfBenefit.type.coding
    // NCH_NEAR_LINE_REC_IDENT_CD => ExplanationOfBenefit.extension
    TransformerUtilsV2.mapEobType(eob, ClaimTypeV2.SNF, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    // PRVDR_NUM => ExplanationOfBenefit.provider.identifier
    TransformerUtilsV2.addProviderSlice(eob, C4BBOrganizationIdentifierType.PRN, claimGroup.getProviderNumber(), claimGroup.getLastUpdated());
    // add EOB information to fields that are common between the Inpatient and SNF claim types
    // CLM_IP_ADMSN_TYPE_CD             => ExplanationOfBenefit.supportingInfo.code
    // CLM_SRC_IP_ADMSN_CD              => ExplanationOfBenefit.supportingInfo.code
    // NCH_VRFD_NCVRD_STAY_FROM_DT      => ExplanationOfBenefit.supportingInfo.timingPeriod
    // NCH_VRFD_NCVRD_STAY_THRU_DT      => ExplanationOfBenefit.supportingInfo.timingPeriod
    // NCH_ACTV_OR_CVRD_LVL_CARE_THRU   => ExplanationOfBenefit.supportingInfo.timingDate
    // NCH_BENE_MDCR_BNFTS_EXHTD_DT_I   => ExplanationOfBenefit.supportingInfo.timingDate
    // CLM_DRG_CD                       => ExplanationOfBenefit.supportingInfo.code
    TransformerUtilsV2.addCommonEobInformationInpatientSNF(eob, claimGroup.getAdmissionTypeCd(), claimGroup.getSourceAdmissionCd(), claimGroup.getNoncoveredStayFromDate(), claimGroup.getNoncoveredStayThroughDate(), claimGroup.getCoveredCareThroughDate(), claimGroup.getMedicareBenefitsExhaustedDate(), claimGroup.getDiagnosisRelatedGroupCd());
    // NCH_PTNT_STUS_IND_CD => ExplanationOfBenefit.supportingInfo.code
    claimGroup.getPatientStatusCd().ifPresent(c -> TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, c));
    // CLM_ADMSN_DT       => ExplanationOfBenefit.supportingInfo:admissionperiod
    // NCH_BENE_DSCHRG_DT => ExplanationOfBenefit.supportingInfo:admissionperiod
    TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationAdmPeriodSlice(eob, claimGroup.getClaimAdmissionDate(), claimGroup.getBeneficiaryDischargeDate()));
    // CLM_UTLZTN_DAY_CNT => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.addBenefitBalanceFinancialMedicalInt(eob, CcwCodebookVariable.CLM_UTLZTN_DAY_CNT, claimGroup.getUtilizationDayCount());
    // NCH_QLFYD_STAY_THRU_DT => ExplanationOfBenefit.supportingInfo
    if (claimGroup.getQualifiedStayFromDate().isPresent() || claimGroup.getQualifiedStayThroughDate().isPresent()) {
        TransformerUtilsV2.validatePeriodDates(claimGroup.getQualifiedStayFromDate(), claimGroup.getQualifiedStayThroughDate());
        Period period = new Period();
        // NCH_QLFYD_STAY_FROM_DT
        claimGroup.getQualifiedStayFromDate().ifPresent(c -> period.setStart(TransformerUtilsV2.convertToDate(c), TemporalPrecisionEnum.DAY));
        // NCH_QLFYD_STAY_THRU_DT
        claimGroup.getQualifiedStayThroughDate().ifPresent(c -> period.setEnd(TransformerUtilsV2.convertToDate(c), TemporalPrecisionEnum.DAY));
        // Add to EOB
        TransformerUtilsV2.addInformation(eob, CcwCodebookVariable.NCH_QLFYD_STAY_FROM_DT).setTiming(period);
    }
    // CLM_PPS_IND_CODE => ExplanationOfBenefit.supportingInfo
    claimGroup.getProspectivePaymentCode().ifPresent(c -> TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.CLM_PPS_IND_CD, CcwCodebookVariable.CLM_PPS_IND_CD, c));
    /*
     * add field values to the benefit balances that are common between the
     * Inpatient and SNF claim types
     */
    // BENE_TOT_COINSRNC_DAYS_CNT       => ExplanationOfBenefit.benefitBalance.financial
    // CLM_NON_UTLZTN_DAYS_CNT          => ExplanationOfBenefit.benefitBalance.financial
    // NCH_BENE_IP_DDCTBL_AMT           => ExplanationOfBenefit.benefitBalance.financial
    // NCH_BENE_PTA_COINSRNC_LBLTY_AMT  => ExplanationOfBenefit.benefitBalance.financial
    // NCH_BLOOD_PNTS_FRNSHD_QTY        => ExplanationOfBenefit.supportingInfo.valueQuantity
    // NCH_IP_NCVRD_CHRG_AMT            => ExplanationOfBenefit.benefitBalance.financial
    // NCH_IP_TOT_DDCTN_AMT             => ExplanationOfBenefit.benefitBalance.financial
    // CLM_PPS_CPTL_DSPRPRTNT_SHR_AMT   => ExplanationOfBenefit.benefitBalance.financial
    // CLM_PPS_CPTL_EXCPTN_AMT          => ExplanationOfBenefit.benefitBalance.financial
    // CLM_PPS_CPTL_FSP_AMT             => ExplanationOfBenefit.benefitBalance.financial
    // CLM_PPS_CPTL_IME_AMT             => ExplanationOfBenefit.benefitBalance.financial
    // CLM_PPS_CPTL_OUTLIER_AMT         => ExplanationOfBenefit.benefitBalance.financial
    // CLM_PPS_OLD_CPTL_HLD_HRMLS_AMT   => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.addCommonGroupInpatientSNF(eob, claimGroup.getCoinsuranceDayCount(), claimGroup.getNonUtilizationDayCount(), claimGroup.getDeductibleAmount(), claimGroup.getPartACoinsuranceLiabilityAmount(), claimGroup.getBloodPintsFurnishedQty(), claimGroup.getNoncoveredCharge(), claimGroup.getTotalDeductionAmount(), claimGroup.getClaimPPSCapitalDisproportionateShareAmt(), claimGroup.getClaimPPSCapitalExceptionAmount(), claimGroup.getClaimPPSCapitalFSPAmount(), claimGroup.getClaimPPSCapitalIMEAmount(), claimGroup.getClaimPPSCapitalOutlierAmount(), claimGroup.getClaimPPSOldCapitalHoldHarmlessAmount());
    // Map care team
    // AT_PHYSN_NPI     => ExplanationOfBenefit.careTeam.provider (Primary)
    // AT_PHYSN_UPIN    => ExplanationOfBenefit.careTeam.provider
    // OP_PHYSN_NPI     => ExplanationOfBenefit.careTeam.provider (Assisting)
    // OP_PHYSN_NPI     => ExplanationOfBenefit.careTeam.provider
    // OT_PHYSN_NPI     => ExplanationOfBenefit.careTeam.provider (Other)
    // OT_PHYSN_UPIN    => ExplanationOfBenefit.careTeam.provider
    TransformerUtilsV2.mapCareTeam(eob, claimGroup.getAttendingPhysicianNpi(), claimGroup.getOperatingPhysicianNpi(), claimGroup.getOtherPhysicianNpi(), claimGroup.getAttendingPhysicianUpin(), claimGroup.getOperatingPhysicianUpin(), claimGroup.getOtherPhysicianUpin());
    // Common group level fields between Inpatient, Outpatient and SNF
    // NCH_BENE_BLOOD_DDCTBL_LBLTY_AM   => ExplanationOfBenefit.benefitBalance.financial
    // CLAIM_QUERY_CODE                 => ExplanationOfBenefit.billablePeriod.extension
    // CLM_MCO_PD_SW                    => ExplanationOfBenefit.supportingInfo.code
    TransformerUtilsV2.mapEobCommonGroupInpOutSNF(eob, claimGroup.getBloodDeductibleLiabilityAmount(), claimGroup.getClaimQueryCode(), claimGroup.getMcoPaidSw());
    // 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());
    // ICD_DGNS_E_VRSN_CD(1-12) => diagnosis.diagnosisCodeableConcept
    for (Diagnosis diagnosis : DiagnosisUtilV2.extractDiagnoses(claimGroup)) {
        DiagnosisUtilV2.addDiagnosisCode(eob, diagnosis, ClaimTypeV2.SNF);
    }
    // Handle Procedures
    // ICD_PRCDR_CD(1-25)        => ExplanationOfBenefit.procedure.procedureCodableConcept
    // ICD_PRCDR_VRSN_CD(1-25)   => ExplanationOfBenefit.procedure.procedureCodableConcept
    // PRCDR_DT(1-25)            => ExplanationOfBenefit.procedure.date
    final int FIRST_PROCEDURE = 1;
    final int LAST_PROCEDURE = 25;
    IntStream.range(FIRST_PROCEDURE, LAST_PROCEDURE + 1).mapToObj(i -> TransformerUtilsV2.extractCCWProcedure(i, claimGroup)).filter(p -> p.isPresent()).forEach(p -> TransformerUtilsV2.addProcedureCode(eob, p.get()));
    for (SNFClaimLine 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
        TransformerUtilsV2.mapHcpcs(eob, item, line.getHcpcsCode(), Optional.empty(), Collections.emptyList());
        // 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.getRevenueCenter(), line.getRateAmount(), line.getTotalChargeAmount(), Optional.of(line.getNonCoveredChargeAmount()), line.getNationalDrugCodeQuantity(), line.getNationalDrugCodeQualifierCode());
        // 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, C4BBClaimInstitutionalCareTeamRole.PERFORMING, line.getRevenueCenterRenderingPhysicianUPIN());
        // RNDRNG_PHYSN_NPI => ExplanationOfBenefit.careTeam.provider
        TransformerUtilsV2.addCareTeamMember(eob, item, C4BBPractitionerIdentifierType.NPI, C4BBClaimInstitutionalCareTeamRole.PERFORMING, line.getRevenueCenterRenderingPhysicianNPI());
    }
    // Last Updated => ExplanationOfBenefit.meta.lastUpdated
    TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : IntStream(java.util.stream.IntStream) MetricRegistry(com.codahale.metrics.MetricRegistry) C4BBPractitionerIdentifierType(gov.cms.bfd.server.war.commons.carin.C4BBPractitionerIdentifierType) Trace(com.newrelic.api.agent.Trace) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) Period(org.hl7.fhir.r4.model.Period) ProfileConstants(gov.cms.bfd.server.war.commons.ProfileConstants) C4BBClaimInstitutionalCareTeamRole(gov.cms.bfd.server.war.commons.carin.C4BBClaimInstitutionalCareTeamRole) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) SNFClaimLine(gov.cms.bfd.model.rif.SNFClaimLine) C4BBOrganizationIdentifierType(gov.cms.bfd.server.war.commons.carin.C4BBOrganizationIdentifierType) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) Timer(com.codahale.metrics.Timer) Optional(java.util.Optional) TemporalPrecisionEnum(ca.uhn.fhir.model.api.TemporalPrecisionEnum) Collections(java.util.Collections) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) SNFClaimLine(gov.cms.bfd.model.rif.SNFClaimLine) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) Period(org.hl7.fhir.r4.model.Period) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit)

Example 34 with ItemComponent

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

the class TransformerUtilsV2 method mapEobCommonItemCarrierDME.

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

Example 35 with ItemComponent

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

the class CarrierClaimTransformer method transformClaim.

/**
 * @param claimGroup the CCW {@link CarrierClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     CarrierClaim}
 */
private static ExplanationOfBenefit transformClaim(CarrierClaim claimGroup, Optional<Boolean> includeTaxNumbers) {
    ExplanationOfBenefit eob = new ExplanationOfBenefit();
    // Common group level fields between all claim types
    TransformerUtils.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimType.CARRIER, 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.CARRIER, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    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(), 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 (CarrierClaimLine claimLine : claimGroup.getLines()) {
        ItemComponent item = eob.addItem();
        item.setSequence(claimLine.getLineNumber().intValue());
        /*
       * 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.getPerformingPhysicianNpi().isPresent()) {
            ExplanationOfBenefit.CareTeamComponent performingCareTeamMember = TransformerUtils.addCareTeamPractitioner(eob, item, TransformerConstants.CODING_NPI_US, claimLine.getPerformingPhysicianNpi().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.CARR_LINE_PRVDR_TYPE_CD, claimLine.getProviderTypeCode()));
            performingCareTeamMember.addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.PRTCPTNG_IND_CD, claimLine.getProviderParticipatingIndCode()));
            // addExtensionReference
            if (claimLine.getOrganizationNpi().isPresent()) {
                TransformerUtils.addExtensionCoding(performingCareTeamMember, TransformerConstants.CODING_NPI_US, TransformerConstants.CODING_NPI_US, TransformerUtils.retrieveNpiCodeDisplay(claimLine.getOrganizationNpi().get()), "" + claimLine.getOrganizationNpi().get());
            }
        }
        /*
       * 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(TransformerUtils.createAdjudicationWithReason(eob, CcwCodebookVariable.CARR_LINE_RDCD_PMT_PHYS_ASTN_C, claimLine.getReducedPaymentPhysicianAsstCode()));
        TransformerUtils.mapHcpcs(eob, item, claimGroup.getHcpcsYearCode(), claimLine.getHcpcsCode(), Arrays.asList(claimLine.getHcpcsInitialModifierCode(), claimLine.getHcpcsSecondModifierCode()));
        if (claimLine.getAnesthesiaUnitCount().compareTo(BigDecimal.ZERO) > 0) {
            item.getService().addExtension(TransformerUtils.createExtensionQuantity(CcwCodebookVariable.CARR_LINE_ANSTHSA_UNIT_CNT, claimLine.getAnesthesiaUnitCount()));
        }
        if (claimLine.getMtusCode().isPresent()) {
            item.addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.CARR_LINE_MTUS_CD, claimLine.getMtusCode()));
        }
        if (!claimLine.getMtusCount().equals(BigDecimal.ZERO)) {
            item.addExtension(TransformerUtils.createExtensionQuantity(CcwCodebookVariable.CARR_LINE_MTUS_CNT, claimLine.getMtusCount()));
        }
        // 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().isPresent()) {
            item.getLocation().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.PRVDR_STATE_CD, claimLine.getProviderStateCode()));
        }
        if (claimLine.getProviderZipCode().isPresent()) {
            item.getLocation().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.PRVDR_ZIP, claimLine.getProviderZipCode()));
        }
        item.getLocation().addExtension(TransformerUtils.createExtensionCoding(eob, CcwCodebookVariable.CARR_LINE_PRCNG_LCLTY_CD, claimLine.getLinePricingLocalityCode()));
        if (claimLine.getCliaLabNumber().isPresent()) {
            item.getLocation().addExtension(TransformerUtils.createExtensionIdentifier(CcwCodebookVariable.CARR_LINE_CLIA_LAB_NUM, claimLine.getCliaLabNumber()));
        }
    }
    TransformerUtils.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : CarrierClaimLine(gov.cms.bfd.model.rif.CarrierClaimLine) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit)

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