Search in sources :

Example 1 with OutpatientClaim

use of gov.cms.bfd.model.rif.OutpatientClaim in project beneficiary-fhir-data by CMSgov.

the class OutpatientClaimTransformerV2Test method generateClaim.

/**
 * Generates the Claim object to be used in multiple tests
 *
 * @return
 * @throws FHIRException
 */
public OutpatientClaim generateClaim() throws FHIRException {
    List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    OutpatientClaim claim = parsedRecords.stream().filter(r -> r instanceof OutpatientClaim).map(r -> (OutpatientClaim) r).findFirst().get();
    claim.setLastUpdated(Instant.now());
    return claim;
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) ExplanationOfBenefitStatus(org.hl7.fhir.r4.model.ExplanationOfBenefit.ExplanationOfBenefitStatus) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) SimpleDateFormat(java.text.SimpleDateFormat) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) BenefitComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent) Use(org.hl7.fhir.r4.model.ExplanationOfBenefit.Use) ProfileConstants(gov.cms.bfd.server.war.commons.ProfileConstants) Reference(org.hl7.fhir.r4.model.Reference) Disabled(org.junit.jupiter.api.Disabled) ProcedureComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ProcedureComponent) PaymentComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.PaymentComponent) Money(org.hl7.fhir.r4.model.Money) Address(org.hl7.fhir.r4.model.Address) FhirContext(ca.uhn.fhir.context.FhirContext) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) Quantity(org.hl7.fhir.r4.model.Quantity) CareTeamComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.CareTeamComponent) DecimalType(org.hl7.fhir.r4.model.DecimalType) IParser(ca.uhn.fhir.parser.IParser) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) MetricRegistry(com.codahale.metrics.MetricRegistry) DateType(org.hl7.fhir.r4.model.DateType) InsuranceComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.InsuranceComponent) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) List(java.util.List) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) Coding(org.hl7.fhir.r4.model.Coding) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) FHIRException(org.hl7.fhir.exceptions.FHIRException) Extension(org.hl7.fhir.r4.model.Extension) DiagnosisComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.DiagnosisComponent) TotalComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.TotalComponent) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim)

Example 2 with OutpatientClaim

use of gov.cms.bfd.model.rif.OutpatientClaim in project beneficiary-fhir-data by CMSgov.

the class ClaimTypeV2Test method verifyServiceEndAttributeFunc.

/**
 * Verifies that our service end date function is working as expected. Since we are type casting
 * our claim object, we need to verify that every ClaimType is tested.
 */
@Test
public void verifyServiceEndAttributeFunc() {
    LocalDate start = LocalDate.now();
    LocalDate end = start.plusDays(10);
    CarrierClaim carrierClaim = new CarrierClaim();
    carrierClaim.setDateFrom(start);
    carrierClaim.setDateThrough(end);
    DMEClaim dmeClaim = new DMEClaim();
    dmeClaim.setDateFrom(start);
    dmeClaim.setDateThrough(end);
    HospiceClaim hospiceClaim = new HospiceClaim();
    hospiceClaim.setDateFrom(start);
    hospiceClaim.setDateThrough(end);
    PartDEvent partDEvent = new PartDEvent();
    partDEvent.setPrescriptionFillDate(end);
    InpatientClaim inpatientClaim = new InpatientClaim();
    inpatientClaim.setDateFrom(start);
    inpatientClaim.setDateThrough(end);
    OutpatientClaim outpatientClaim = new OutpatientClaim();
    outpatientClaim.setDateFrom(start);
    outpatientClaim.setDateThrough(end);
    SNFClaim snfClaim = new SNFClaim();
    snfClaim.setDateFrom(start);
    snfClaim.setDateThrough(end);
    HHAClaim hhaClaim = new HHAClaim();
    hhaClaim.setDateFrom(start);
    hhaClaim.setDateThrough(end);
    ImmutableMap.Builder<ClaimTypeV2, Object> builder = ImmutableMap.builder();
    builder.put(ClaimTypeV2.CARRIER, carrierClaim);
    builder.put(ClaimTypeV2.DME, dmeClaim);
    builder.put(ClaimTypeV2.PDE, partDEvent);
    builder.put(ClaimTypeV2.INPATIENT, inpatientClaim);
    builder.put(ClaimTypeV2.OUTPATIENT, outpatientClaim);
    builder.put(ClaimTypeV2.HOSPICE, hospiceClaim);
    builder.put(ClaimTypeV2.SNF, snfClaim);
    builder.put(ClaimTypeV2.HHA, hhaClaim);
    Map<ClaimTypeV2, Object> claimTypeToClaim = builder.build();
    // Verify that we're testing all of the ClaimTypes that are defined
    EnumSet.allOf(ClaimTypeV2.class).stream().forEach(claimType -> assertTrue(claimTypeToClaim.containsKey(claimType), String.format("ClaimType %s not tested", claimType.name())));
    claimTypeToClaim.entrySet().forEach(entry -> assertEquals(end, entry.getKey().getServiceEndAttributeFunction().apply(entry.getValue()), String.format("Claim type %s does not match expectations", entry.getKey().name())));
}
Also used : InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) LocalDate(java.time.LocalDate) PartDEvent(gov.cms.bfd.model.rif.PartDEvent) ImmutableMap(com.google.common.collect.ImmutableMap) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) Test(org.junit.jupiter.api.Test)

Example 3 with OutpatientClaim

use of gov.cms.bfd.model.rif.OutpatientClaim in project beneficiary-fhir-data by CMSgov.

the class OutpatientClaimTransformerV2 method transformClaim.

/**
 * @param claimGroup the CCW {@link InpatientClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     InpatientClaim}
 */
private static ExplanationOfBenefit transformClaim(OutpatientClaim claimGroup) {
    ExplanationOfBenefit eob = new ExplanationOfBenefit();
    // Required values not directly mapped
    eob.getMeta().addProfile(ProfileConstants.C4BB_EOB_OUTPATIENT_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
    // 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.OUTPATIENT, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
    // NCH_WKLY_PROC_DT => ExplanationOfBenefit.supportinginfo.timingDate
    TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationRecievedDateSlice(eob, CcwCodebookVariable.NCH_WKLY_PROC_DT, Optional.of(claimGroup.getWeeklyProcessDate())));
    // Map 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());
    // map eob type codes into FHIR
    // NCH_CLM_TYPE_CD => ExplanationOfBenefit.type.coding
    // EOB Type => ExplanationOfBenefit.type.coding
    // Claim Type (institutional) => ExplanationOfBenefit.type.coding
    // NCH_NEAR_LINE_REC_IDENT_CD => ExplanationOfBenefit.extension
    TransformerUtilsV2.mapEobType(eob, ClaimTypeV2.OUTPATIENT, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
    // set the provider number which is common among several claim types
    // PRVDR_NUM => ExplanationOfBenefit.provider.identifier
    TransformerUtilsV2.addProviderSlice(eob, C4BBOrganizationIdentifierType.PRN, claimGroup.getProviderNumber(), claimGroup.getLastUpdated());
    // NCH_PROFNL_CMPNT_CHRG_AMT => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.NCH_PROFNL_CMPNT_CHRG_AMT, Optional.ofNullable(claimGroup.getProfessionalComponentCharge()));
    // NCH_BENE_PTB_DDCTBL_AMT => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.NCH_BENE_PTB_DDCTBL_AMT, Optional.ofNullable(claimGroup.getDeductibleAmount()));
    // NCH_BENE_PTB_COINSRNC_AMT => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.NCH_BENE_PTB_COINSRNC_AMT, Optional.ofNullable(claimGroup.getCoinsuranceAmount()));
    // CLM_OP_PRVDR_PMT_AMT => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.CLM_OP_PRVDR_PMT_AMT, Optional.ofNullable(claimGroup.getProviderPaymentAmount()));
    // CLM_OP_PRVDR_PMT_AMT => ExplanationOfBenefit.benefitBalance.financial
    TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.CLM_OP_BENE_PMT_AMT, Optional.ofNullable(claimGroup.getBeneficiaryPaymentAmount()));
    // 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 (PRPAYAMT)
    TransformerUtilsV2.mapEobCommonGroupInpOutHHAHospiceSNF(eob, claimGroup.getOrganizationNpi(), claimGroup.getClaimFacilityTypeCode(), claimGroup.getClaimFrequencyCode(), claimGroup.getClaimNonPaymentReasonCode(), claimGroup.getPatientDischargeStatusCode().get(), 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.OUTPATIENT);
    }
    // Handle Inpatient Diagnosis.  Only three, so just brute force it
    // RSN_VISIT_CD1        => diagnosis.diagnosisCodeableConcept
    // RSN_VISIT_VRSN_CD1   => diagnosis.diagnosisCodeableConcept
    DiagnosisUtilV2.addDiagnosisCode(eob, DiagnosisUtilV2.extractDiagnosis("Admission1", claimGroup, Optional.empty(), DiagnosisLabel.REASONFORVISIT), ClaimTypeV2.OUTPATIENT);
    // RSN_VISIT_CD2        => diagnosis.diagnosisCodeableConcept
    // RSN_VISIT_VRSN_CD2   => diagnosis.diagnosisCodeableConcept
    DiagnosisUtilV2.addDiagnosisCode(eob, DiagnosisUtilV2.extractDiagnosis("Admission2", claimGroup, Optional.empty(), DiagnosisLabel.REASONFORVISIT), ClaimTypeV2.OUTPATIENT);
    // RSN_VISIT_CD3        => diagnosis.diagnosisCodeableConcept
    // RSN_VISIT_VRSN_CD3   => diagnosis.diagnosisCodeableConcept
    DiagnosisUtilV2.addDiagnosisCode(eob, DiagnosisUtilV2.extractDiagnosis("Admission3", claimGroup, Optional.empty(), DiagnosisLabel.REASONFORVISIT), ClaimTypeV2.OUTPATIENT);
    // 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()));
    // ClaimLine => ExplanationOfBenefit.item
    for (OutpatientClaimLine line : claimGroup.getLines()) {
        ItemComponent item = TransformerUtilsV2.addItem(eob);
        // CLM_LINE_NUM => item.sequence
        item.setSequence(line.getLineNumber().intValue());
        // PRVDR_STATE_CD => item.location
        TransformerUtilsV2.addLocationState(item, claimGroup.getProviderStateCode());
        // REV_CNTR => item.revenue
        item.setRevenue(TransformerUtilsV2.createCodeableConcept(eob, CcwCodebookVariable.REV_CNTR, line.getRevenueCenterCode()));
        // REV_CNTR_1ST_ANSI_CD => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationDenialReasonSlice(eob, CcwCodebookVariable.REV_CNTR_1ST_ANSI_CD, line.getRevCntr1stAnsiCd()));
        // REV_CNTR_2ND_ANSI_CD => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationDenialReasonSlice(eob, CcwCodebookVariable.REV_CNTR_2ND_ANSI_CD, line.getRevCntr2ndAnsiCd()));
        // REV_CNTR_3RD_ANSI_CD => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationDenialReasonSlice(eob, CcwCodebookVariable.REV_CNTR_3RD_ANSI_CD, line.getRevCntr3rdAnsiCd()));
        // REV_CNTR_4RD_ANSI_CD => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationDenialReasonSlice(eob, CcwCodebookVariable.REV_CNTR_4TH_ANSI_CD, line.getRevCntr4thAnsiCd()));
        // HCPCS_CD               => ExplanationOfBenefit.item.productOrService
        // HCPCS_1ST_MDFR_CD      => ExplanationOfBenefit.item.modifier
        // HCPCS_2ND_MDFR_CD      => ExplanationOfBenefit.item.modifier
        TransformerUtilsV2.mapHcpcs(eob, item, line.getHcpcsCode(), Optional.empty(), Arrays.asList(line.getHcpcsInitialModifierCode(), line.getHcpcsSecondModifierCode()));
        // REV_CNTR                   => ExplanationOfBenefit.item.revenue
        // REV_CNTR_RATE_AMT          => ExplanationOfBenefit.item.adjudication
        // REV_CNTR_TOT_CHRG_AMT      => ExplanationOfBenefit.item.adjudication
        // REV_CNTR_NCVRD_CHRG_AMT    => ExplanationOfBenefit.item.adjudication
        // REV_CNTR_NDC_QTY           => ExplanationOfBenefit.item.quantity
        // REV_CNTR_NDC_QTY_QLFR_CD   => ExplanationOfBenefit.modifier
        TransformerUtilsV2.mapEobCommonItemRevenue(item, eob, line.getRevenueCenterCode(), line.getRateAmount(), line.getTotalChargeAmount(), Optional.of(line.getNonCoveredChargeAmount()), line.getNationalDrugCodeQuantity(), line.getNationalDrugCodeQualifierCode());
        // REV_CNTR_BLOOD_DDCTBL_AMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_BLOOD_DDCTBL_AMT, C4BBAdjudication.DEDUCTIBLE, line.getBloodDeductibleAmount()));
        // REV_CNTR_CASH_DDCTBL_AMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_CASH_DDCTBL_AMT, C4BBAdjudication.DEDUCTIBLE, line.getCashDeductibleAmount()));
        // REV_CNTR_COINSRNC_WGE_ADJSTD_C => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_COINSRNC_WGE_ADJSTD_C, C4BBAdjudication.COINSURANCE, line.getWageAdjustedCoinsuranceAmount()));
        // REV_CNTR_RDCD_COINSRNC_AMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_RDCD_COINSRNC_AMT, C4BBAdjudication.COINSURANCE, line.getReducedCoinsuranceAmount()));
        // REV_CNTR_1ST_MSP_PD_AMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_1ST_MSP_PD_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, line.getFirstMspPaidAmount()));
        // REV_CNTR_2ND_MSP_PD_AMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_2ND_MSP_PD_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, line.getSecondMspPaidAmount()));
        // REV_CNTR_PRVDR_PMT_AMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_PRVDR_PMT_AMT, C4BBAdjudication.PAID_TO_PROVIDER, line.getProviderPaymentAmount()));
        // REV_CNTR_BENE_PMT_AMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_BENE_PMT_AMT, C4BBAdjudication.PAID_TO_PATIENT, line.getBenficiaryPaymentAmount()));
        // REV_CNTR_PTNT_RSPNSBLTY_PMT => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.REV_CNTR_PTNT_RSPNSBLTY_PMT, C4BBAdjudication.PAID_BY_PATIENT, line.getPatientResponsibilityAmount()));
        // Common item level fields between Outpatient, HHA and Hospice
        // REV_CNTR_DT              => ExplanationOfBenefit.item.servicedDate
        // REV_CNTR_PMT_AMT_AMT     => ExplanationOfBenefit.item.adjudication
        TransformerUtilsV2.mapEobCommonItemRevenueOutHHAHospice(item, line.getRevenueCenterDate(), line.getPaymentAmount());
        // REV_CNTR_IDE_NDC_UPC_NUM => ExplanationOfBenefit.item.productOrService.extension
        TransformerUtilsV2.addNationalDrugCode(item, line.getNationalDrugCode());
        // 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());
        // REV_CNTR_STUS_IND_CD => ExplanationOfBenefit.item.revenue.extension
        TransformerUtilsV2.mapEobCommonItemRevenueStatusCode(item, eob, line.getStatusCode());
    }
    TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
    return eob;
}
Also used : OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) 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) ProfileConstants(gov.cms.bfd.server.war.commons.ProfileConstants) OutpatientClaimLine(gov.cms.bfd.model.rif.OutpatientClaimLine) DiagnosisLabel(gov.cms.bfd.server.war.commons.Diagnosis.DiagnosisLabel) C4BBClaimInstitutionalCareTeamRole(gov.cms.bfd.server.war.commons.carin.C4BBClaimInstitutionalCareTeamRole) 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) C4BBAdjudication(gov.cms.bfd.server.war.commons.carin.C4BBAdjudication) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) OutpatientClaimLine(gov.cms.bfd.model.rif.OutpatientClaimLine) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit)

Example 4 with OutpatientClaim

use of gov.cms.bfd.model.rif.OutpatientClaim in project beneficiary-fhir-data by CMSgov.

the class RifFilesProcessor method buildOutpatientClaimEvent.

/**
 * @param fileEvent the {@link RifFileEvent} being processed that is being processed
 * @param csvRecords the {@link CSVRecord}s to be mapped, which must be from a {@link
 *     RifFileType#OUTPATIENT} {@link RifFile}
 * @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
 */
private static RifRecordEvent<OutpatientClaim> buildOutpatientClaimEvent(RifFileEvent fileEvent, List<CSVRecord> csvRecords) {
    if (LOGGER.isTraceEnabled())
        LOGGER.trace(csvRecords.toString());
    CSVRecord firstCsvRecord = csvRecords.get(0);
    RecordAction recordAction = RecordAction.match(firstCsvRecord.get("DML_IND"));
    OutpatientClaim claim = OutpatientClaimParser.parseRif(csvRecords);
    return new RifRecordEvent<OutpatientClaim>(fileEvent, csvRecords, recordAction, claim.getBeneficiaryId(), claim);
}
Also used : OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) RifRecordEvent(gov.cms.bfd.model.rif.RifRecordEvent) CSVRecord(org.apache.commons.csv.CSVRecord) RecordAction(gov.cms.bfd.model.rif.RecordAction)

Example 5 with OutpatientClaim

use of gov.cms.bfd.model.rif.OutpatientClaim in project beneficiary-fhir-data by CMSgov.

the class R4ExplanationOfBenefitResourceProviderIT method adjustOutpatientRecordForSamhsaDiagnosis.

/**
 * Adjusts the first outpatient record to support samhsa.
 *
 * @param loadedRecords the loaded records
 * @param entityManager the entity manager
 */
private void adjustOutpatientRecordForSamhsaDiagnosis(List<Object> loadedRecords, EntityManager entityManager) {
    OutpatientClaim outpatientRifRecord = loadedRecords.stream().filter(r -> r instanceof OutpatientClaim).map(r -> (OutpatientClaim) r).findFirst().get();
    entityManager.getTransaction().begin();
    outpatientRifRecord = entityManager.find(OutpatientClaim.class, outpatientRifRecord.getClaimId());
    outpatientRifRecord.setDiagnosis2Code(Optional.of(Stu3EobSamhsaMatcherTest.SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE));
    outpatientRifRecord.setDiagnosis2CodeVersion(Optional.of('9'));
    entityManager.merge(outpatientRifRecord);
    entityManager.getTransaction().commit();
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) Constants(ca.uhn.fhir.rest.api.Constants) BenefitComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) Stu3EobSamhsaMatcherTest(gov.cms.bfd.server.war.stu3.providers.Stu3EobSamhsaMatcherTest) PartDEvent(gov.cms.bfd.model.rif.PartDEvent) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) BeforeAll(org.junit.jupiter.api.BeforeAll) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Triple(org.apache.commons.lang3.tuple.Triple) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) IdDt(ca.uhn.fhir.model.primitive.IdDt) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) BenefitBalanceComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitBalanceComponent) Resource(org.hl7.fhir.r4.model.Resource) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ExplanationOfBenefitResourceProvider(gov.cms.bfd.server.war.stu3.providers.ExplanationOfBenefitResourceProvider) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) EntityManagerFactory(javax.persistence.EntityManagerFactory) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) Optional(java.util.Optional) Extension(org.hl7.fhir.r4.model.Extension) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Money(org.hl7.fhir.r4.model.Money) ArrayList(java.util.ArrayList) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) ImmutableList(com.google.common.collect.ImmutableList) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) CommonHeaders(gov.cms.bfd.server.war.commons.CommonHeaders) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) EntityManager(javax.persistence.EntityManager) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) AfterEach(org.junit.jupiter.api.AfterEach) ChronoUnit(java.time.temporal.ChronoUnit) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) FHIRException(org.hl7.fhir.exceptions.FHIRException) Bundle(org.hl7.fhir.r4.model.Bundle) TotalComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.TotalComponent) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim)

Aggregations

OutpatientClaim (gov.cms.bfd.model.rif.OutpatientClaim)21 Arrays (java.util.Arrays)15 Optional (java.util.Optional)15 Test (org.junit.jupiter.api.Test)15 StaticRifResourceGroup (gov.cms.bfd.model.rif.samples.StaticRifResourceGroup)14 ServerTestUtils (gov.cms.bfd.server.war.ServerTestUtils)14 List (java.util.List)14 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)14 Collectors (java.util.stream.Collectors)13 CarrierClaim (gov.cms.bfd.model.rif.CarrierClaim)12 DMEClaim (gov.cms.bfd.model.rif.DMEClaim)12 HHAClaim (gov.cms.bfd.model.rif.HHAClaim)12 HospiceClaim (gov.cms.bfd.model.rif.HospiceClaim)12 InpatientClaim (gov.cms.bfd.model.rif.InpatientClaim)12 PartDEvent (gov.cms.bfd.model.rif.PartDEvent)12 SNFClaim (gov.cms.bfd.model.rif.SNFClaim)12 FHIRException (org.hl7.fhir.exceptions.FHIRException)12 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)12 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)11 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)11