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;
}
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())));
}
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;
}
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);
}
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();
}
Aggregations