use of gov.cms.bfd.model.rif.SNFClaimLine in project beneficiary-fhir-data by CMSgov.
the class SNFClaimTransformer 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();
// Common group level fields between all claim types
TransformerUtils.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimType.SNF, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
TransformerUtils.mapEobWeeklyProcessDate(eob, claimGroup.getWeeklyProcessDate());
// map eob type codes into FHIR
TransformerUtils.mapEobType(eob, ClaimType.SNF, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
// set the provider number which is common among several claim types
TransformerUtils.setProviderNumber(eob, claimGroup.getProviderNumber());
// add EOB information to fields that are common between the Inpatient and SNF claim types
TransformerUtils.addCommonEobInformationInpatientSNF(eob, claimGroup.getAdmissionTypeCd(), claimGroup.getSourceAdmissionCd(), claimGroup.getNoncoveredStayFromDate(), claimGroup.getNoncoveredStayThroughDate(), claimGroup.getCoveredCareThroughDate(), claimGroup.getMedicareBenefitsExhaustedDate(), claimGroup.getDiagnosisRelatedGroupCd());
if (claimGroup.getPatientStatusCd().isPresent()) {
TransformerUtils.addInformationWithCode(eob, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, claimGroup.getPatientStatusCd().get());
}
// Common group level fields between Inpatient, HHA, Hospice and SNF
TransformerUtils.mapEobCommonGroupInpHHAHospiceSNF(eob, claimGroup.getClaimAdmissionDate(), claimGroup.getBeneficiaryDischargeDate(), Optional.of(claimGroup.getUtilizationDayCount()));
/*
* add field values to the benefit balances that are common between the
* Inpatient and SNF claim types
*/
TransformerUtils.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());
if (claimGroup.getQualifiedStayFromDate().isPresent() || claimGroup.getQualifiedStayThroughDate().isPresent()) {
TransformerUtils.validatePeriodDates(claimGroup.getQualifiedStayFromDate(), claimGroup.getQualifiedStayThroughDate());
SupportingInformationComponent nchQlfydStayInfo = TransformerUtils.addInformation(eob, CcwCodebookVariable.NCH_QLFYD_STAY_FROM_DT);
Period nchQlfydStayPeriod = new Period();
if (claimGroup.getQualifiedStayFromDate().isPresent())
nchQlfydStayPeriod.setStart(TransformerUtils.convertToDate((claimGroup.getQualifiedStayFromDate().get())), TemporalPrecisionEnum.DAY);
if (claimGroup.getQualifiedStayThroughDate().isPresent())
nchQlfydStayPeriod.setEnd(TransformerUtils.convertToDate((claimGroup.getQualifiedStayThroughDate().get())), TemporalPrecisionEnum.DAY);
nchQlfydStayInfo.setTiming(nchQlfydStayPeriod);
}
// Common group level fields between Inpatient, Outpatient and SNF
TransformerUtils.mapEobCommonGroupInpOutSNF(eob, claimGroup.getBloodDeductibleLiabilityAmount(), claimGroup.getOperatingPhysicianNpi(), claimGroup.getOtherPhysicianNpi(), claimGroup.getClaimQueryCode(), claimGroup.getMcoPaidSw());
// Common group level fields between Inpatient, Outpatient Hospice, HHA and SNF
TransformerUtils.mapEobCommonGroupInpOutHHAHospiceSNF(eob, claimGroup.getOrganizationNpi(), claimGroup.getClaimFacilityTypeCode(), claimGroup.getClaimFrequencyCode(), claimGroup.getClaimNonPaymentReasonCode(), claimGroup.getPatientDischargeStatusCode(), claimGroup.getClaimServiceClassificationTypeCode(), claimGroup.getClaimPrimaryPayerCode(), claimGroup.getAttendingPhysicianNpi(), claimGroup.getTotalChargeAmount(), claimGroup.getPrimaryPayerPaidAmount(), claimGroup.getFiscalIntermediaryNumber(), claimGroup.getFiDocumentClaimControlNumber(), claimGroup.getFiOriginalClaimControlNumber());
for (Diagnosis diagnosis : TransformerUtils.extractDiagnoses1Thru12(claimGroup.getDiagnosisAdmittingCode(), claimGroup.getDiagnosisAdmittingCodeVersion(), claimGroup.getDiagnosisPrincipalCode(), claimGroup.getDiagnosisPrincipalCodeVersion(), claimGroup.getDiagnosis1Code(), claimGroup.getDiagnosis1CodeVersion(), claimGroup.getDiagnosis2Code(), claimGroup.getDiagnosis2CodeVersion(), claimGroup.getDiagnosis3Code(), claimGroup.getDiagnosis3CodeVersion(), claimGroup.getDiagnosis4Code(), claimGroup.getDiagnosis4CodeVersion(), claimGroup.getDiagnosis5Code(), claimGroup.getDiagnosis5CodeVersion(), claimGroup.getDiagnosis6Code(), claimGroup.getDiagnosis6CodeVersion(), claimGroup.getDiagnosis7Code(), claimGroup.getDiagnosis7CodeVersion(), claimGroup.getDiagnosis8Code(), claimGroup.getDiagnosis8CodeVersion(), claimGroup.getDiagnosis9Code(), claimGroup.getDiagnosis9CodeVersion(), claimGroup.getDiagnosis10Code(), claimGroup.getDiagnosis10CodeVersion(), claimGroup.getDiagnosis11Code(), claimGroup.getDiagnosis11CodeVersion(), claimGroup.getDiagnosis12Code(), claimGroup.getDiagnosis12CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
for (Diagnosis diagnosis : TransformerUtils.extractDiagnoses13Thru25(claimGroup.getDiagnosis13Code(), claimGroup.getDiagnosis13CodeVersion(), claimGroup.getDiagnosis14Code(), claimGroup.getDiagnosis14CodeVersion(), claimGroup.getDiagnosis15Code(), claimGroup.getDiagnosis15CodeVersion(), claimGroup.getDiagnosis16Code(), claimGroup.getDiagnosis16CodeVersion(), claimGroup.getDiagnosis17Code(), claimGroup.getDiagnosis17CodeVersion(), claimGroup.getDiagnosis18Code(), claimGroup.getDiagnosis18CodeVersion(), claimGroup.getDiagnosis19Code(), claimGroup.getDiagnosis19CodeVersion(), claimGroup.getDiagnosis20Code(), claimGroup.getDiagnosis20CodeVersion(), claimGroup.getDiagnosis21Code(), claimGroup.getDiagnosis21CodeVersion(), claimGroup.getDiagnosis22Code(), claimGroup.getDiagnosis22CodeVersion(), claimGroup.getDiagnosis23Code(), claimGroup.getDiagnosis23CodeVersion(), claimGroup.getDiagnosis24Code(), claimGroup.getDiagnosis24CodeVersion(), claimGroup.getDiagnosis25Code(), claimGroup.getDiagnosis25CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
for (Diagnosis diagnosis : TransformerUtils.extractExternalDiagnoses1Thru12(claimGroup.getDiagnosisExternalFirstCode(), claimGroup.getDiagnosisExternalFirstCodeVersion(), claimGroup.getDiagnosisExternal1Code(), claimGroup.getDiagnosisExternal1CodeVersion(), claimGroup.getDiagnosisExternal2Code(), claimGroup.getDiagnosisExternal2CodeVersion(), claimGroup.getDiagnosisExternal3Code(), claimGroup.getDiagnosisExternal3CodeVersion(), claimGroup.getDiagnosisExternal4Code(), claimGroup.getDiagnosisExternal4CodeVersion(), claimGroup.getDiagnosisExternal5Code(), claimGroup.getDiagnosisExternal5CodeVersion(), claimGroup.getDiagnosisExternal6Code(), claimGroup.getDiagnosisExternal6CodeVersion(), claimGroup.getDiagnosisExternal7Code(), claimGroup.getDiagnosisExternal7CodeVersion(), claimGroup.getDiagnosisExternal8Code(), claimGroup.getDiagnosisExternal8CodeVersion(), claimGroup.getDiagnosisExternal9Code(), claimGroup.getDiagnosisExternal9CodeVersion(), claimGroup.getDiagnosisExternal10Code(), claimGroup.getDiagnosisExternal10CodeVersion(), claimGroup.getDiagnosisExternal11Code(), claimGroup.getDiagnosisExternal11CodeVersion(), claimGroup.getDiagnosisExternal12Code(), claimGroup.getDiagnosisExternal12CodeVersion())) TransformerUtils.addDiagnosisCode(eob, diagnosis);
for (CCWProcedure procedure : TransformerUtils.extractCCWProcedures(claimGroup.getProcedure1Code(), claimGroup.getProcedure1CodeVersion(), claimGroup.getProcedure1Date(), claimGroup.getProcedure2Code(), claimGroup.getProcedure2CodeVersion(), claimGroup.getProcedure2Date(), claimGroup.getProcedure3Code(), claimGroup.getProcedure3CodeVersion(), claimGroup.getProcedure3Date(), claimGroup.getProcedure4Code(), claimGroup.getProcedure4CodeVersion(), claimGroup.getProcedure4Date(), claimGroup.getProcedure5Code(), claimGroup.getProcedure5CodeVersion(), claimGroup.getProcedure5Date(), claimGroup.getProcedure6Code(), claimGroup.getProcedure6CodeVersion(), claimGroup.getProcedure6Date(), claimGroup.getProcedure7Code(), claimGroup.getProcedure7CodeVersion(), claimGroup.getProcedure7Date(), claimGroup.getProcedure8Code(), claimGroup.getProcedure8CodeVersion(), claimGroup.getProcedure8Date(), claimGroup.getProcedure9Code(), claimGroup.getProcedure9CodeVersion(), claimGroup.getProcedure9Date(), claimGroup.getProcedure10Code(), claimGroup.getProcedure10CodeVersion(), claimGroup.getProcedure10Date(), claimGroup.getProcedure11Code(), claimGroup.getProcedure11CodeVersion(), claimGroup.getProcedure11Date(), claimGroup.getProcedure12Code(), claimGroup.getProcedure12CodeVersion(), claimGroup.getProcedure12Date(), claimGroup.getProcedure13Code(), claimGroup.getProcedure13CodeVersion(), claimGroup.getProcedure13Date(), claimGroup.getProcedure14Code(), claimGroup.getProcedure14CodeVersion(), claimGroup.getProcedure14Date(), claimGroup.getProcedure15Code(), claimGroup.getProcedure15CodeVersion(), claimGroup.getProcedure15Date(), claimGroup.getProcedure16Code(), claimGroup.getProcedure16CodeVersion(), claimGroup.getProcedure16Date(), claimGroup.getProcedure17Code(), claimGroup.getProcedure17CodeVersion(), claimGroup.getProcedure17Date(), claimGroup.getProcedure18Code(), claimGroup.getProcedure18CodeVersion(), claimGroup.getProcedure18Date(), claimGroup.getProcedure19Code(), claimGroup.getProcedure19CodeVersion(), claimGroup.getProcedure19Date(), claimGroup.getProcedure20Code(), claimGroup.getProcedure20CodeVersion(), claimGroup.getProcedure20Date(), claimGroup.getProcedure21Code(), claimGroup.getProcedure21CodeVersion(), claimGroup.getProcedure21Date(), claimGroup.getProcedure22Code(), claimGroup.getProcedure22CodeVersion(), claimGroup.getProcedure22Date(), claimGroup.getProcedure23Code(), claimGroup.getProcedure23CodeVersion(), claimGroup.getProcedure23Date(), claimGroup.getProcedure24Code(), claimGroup.getProcedure24CodeVersion(), claimGroup.getProcedure24Date(), claimGroup.getProcedure25Code(), claimGroup.getProcedure25CodeVersion(), claimGroup.getProcedure25Date())) TransformerUtils.addProcedureCode(eob, procedure);
for (SNFClaimLine claimLine : claimGroup.getLines()) {
ItemComponent item = eob.addItem();
item.setSequence(claimLine.getLineNumber().intValue());
item.setLocation(new Address().setState((claimGroup.getProviderStateCode())));
TransformerUtils.mapHcpcs(eob, item, Optional.empty(), claimLine.getHcpcsCode(), Collections.emptyList());
// Common item level fields between Inpatient, Outpatient, HHA, Hospice and SNF
TransformerUtils.mapEobCommonItemRevenue(item, eob, claimLine.getRevenueCenter(), claimLine.getRateAmount(), claimLine.getTotalChargeAmount(), claimLine.getNonCoveredChargeAmount(), BigDecimal.valueOf(claimLine.getUnitCount()), claimLine.getNationalDrugCodeQuantity(), claimLine.getNationalDrugCodeQualifierCode(), claimLine.getRevenueCenterRenderingPhysicianNPI());
// Common group level field coinsurance between Inpatient, HHA, Hospice and SNF
TransformerUtils.mapEobCommonGroupInpHHAHospiceSNFCoinsurance(eob, item, claimLine.getDeductibleCoinsuranceCd());
}
TransformerUtils.setLastUpdated(eob, claimGroup.getLastUpdated());
return eob;
}
use of gov.cms.bfd.model.rif.SNFClaimLine in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessorTest method process1SNFClaimRecord.
/**
* Ensures that {@link RifFilesProcessor} can correctly handle {@link
* StaticRifResource#SAMPLE_A_SNF}.
*/
@Test
public void process1SNFClaimRecord() {
RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_SNF.toRifFile());
RifFilesProcessor processor = new RifFilesProcessor();
RifFileRecords rifFileRecords = processor.produceRecords(filesEvent.getFileEvents().get(0));
List<RifRecordEvent<?>> rifEventsList = rifFileRecords.getRecords().collect(Collectors.toList());
assertEquals(StaticRifResource.SAMPLE_A_SNF.getRecordCount(), rifEventsList.size());
RifRecordEvent<?> rifRecordEvent = rifEventsList.get(0);
assertEquals(StaticRifResource.SAMPLE_A_SNF.getRifFileType(), rifRecordEvent.getFileEvent().getFile().getFileType());
assertNotNull(rifRecordEvent.getRecord());
assertTrue(rifRecordEvent.getRecord() instanceof SNFClaim);
// Verify the claim header.
SNFClaim claimGroup = (SNFClaim) rifRecordEvent.getRecord();
assertEquals(RecordAction.INSERT, rifRecordEvent.getRecordAction());
assertEquals(claimGroup.getBeneficiaryId(), rifRecordEvent.getBeneficiaryId());
assertEquals("567834", claimGroup.getBeneficiaryId());
assertEquals("777777777", claimGroup.getClaimId());
assertEquals(new BigDecimal(900), claimGroup.getClaimGroupId());
assertEquals('V', claimGroup.getNearLineRecordIdCode());
assertEquals("20", claimGroup.getClaimTypeCode());
assertEquals(LocalDate.of(2013, 12, 01), claimGroup.getDateFrom());
assertEquals(LocalDate.of(2013, 12, 18), claimGroup.getDateThrough());
assertEquals('3', claimGroup.getClaimQueryCode());
assertEquals("299999", claimGroup.getProviderNumber());
assertEquals("B", claimGroup.getClaimNonPaymentReasonCode().get());
assertEquals('1', claimGroup.getClaimServiceClassificationTypeCode());
assertEquals(new BigDecimal("3333.33"), claimGroup.getPaymentAmount());
assertEquals(new BigDecimal("11.00"), claimGroup.getPrimaryPayerPaidAmount());
assertEquals("FL", claimGroup.getProviderStateCode());
assertEquals("1111111111", claimGroup.getOrganizationNpi().get());
assertEquals("2222222222", claimGroup.getAttendingPhysicianNpi().get());
assertEquals("3333333333", claimGroup.getOperatingPhysicianNpi().get());
assertEquals("4444444444", claimGroup.getOtherPhysicianNpi().get());
assertEquals("1", claimGroup.getPatientDischargeStatusCode());
assertEquals(new BigDecimal("5555.03"), claimGroup.getTotalChargeAmount());
assertEquals(LocalDate.of(2013, 11, 5), claimGroup.getClaimAdmissionDate().get());
assertEquals('3', claimGroup.getAdmissionTypeCd());
assertEquals('4', claimGroup.getSourceAdmissionCd().get().charValue());
assertEquals(new BigDecimal("112.00"), claimGroup.getDeductibleAmount());
assertEquals(new BigDecimal("5.00"), claimGroup.getPartACoinsuranceLiabilityAmount());
assertEquals(new BigDecimal("6.00"), claimGroup.getBloodDeductibleLiabilityAmount());
assertEquals(new BigDecimal("33.00"), claimGroup.getNoncoveredCharge());
assertEquals(new BigDecimal("14.00"), claimGroup.getTotalDeductionAmount());
assertEquals(new BigDecimal("9.00"), claimGroup.getClaimPPSCapitalFSPAmount().get());
assertEquals(new BigDecimal("8.00"), claimGroup.getClaimPPSCapitalOutlierAmount().get());
assertEquals(new BigDecimal("7.00"), claimGroup.getClaimPPSCapitalDisproportionateShareAmt().get());
assertEquals(new BigDecimal("6.00"), claimGroup.getClaimPPSCapitalIMEAmount().get());
assertEquals(new BigDecimal("5.00"), claimGroup.getClaimPPSCapitalExceptionAmount().get());
assertEquals(new BigDecimal("4.00"), claimGroup.getClaimPPSOldCapitalHoldHarmlessAmount().get());
assertEquals(new BigDecimal(17), claimGroup.getUtilizationDayCount());
assertEquals(new BigDecimal(17), claimGroup.getCoinsuranceDayCount());
assertEquals(new BigDecimal(0), claimGroup.getNonUtilizationDayCount());
assertEquals(new BigDecimal(19), claimGroup.getBloodPintsFurnishedQty());
assertEquals(LocalDate.of(2013, 9, 23), claimGroup.getQualifiedStayFromDate().get());
assertEquals(LocalDate.of(2013, 11, 5), claimGroup.getQualifiedStayThroughDate().get());
assertEquals(LocalDate.of(2002, 1, 11), claimGroup.getNoncoveredStayFromDate().get());
assertEquals(LocalDate.of(2002, 1, 21), claimGroup.getNoncoveredStayThroughDate().get());
assertFalse(claimGroup.getCoveredCareThroughDate().isPresent());
assertEquals(LocalDate.of(2002, 1, 31), claimGroup.getMedicareBenefitsExhaustedDate().get());
assertEquals(LocalDate.of(2013, 12, 18), claimGroup.getBeneficiaryDischargeDate().get());
assertEquals("R4444", claimGroup.getDiagnosisAdmittingCode().get());
assertEquals('9', claimGroup.getDiagnosisAdmittingCodeVersion().get().charValue());
assertEquals("R2222", claimGroup.getDiagnosisExternal1Code().get());
assertEquals('9', claimGroup.getDiagnosisExternal1CodeVersion().get().charValue());
assertEquals("23443453453", claimGroup.getFiDocumentClaimControlNumber().get());
assertEquals("34534535535", claimGroup.getFiOriginalClaimControlNumber().get());
assertEquals(1, claimGroup.getLines().size());
// Verify one of the claim lines.
SNFClaimLine claimLine = claimGroup.getLines().get(0);
assertEquals("MMM", claimLine.getHcpcsCode().get());
assertEquals(new BigDecimal("95.00"), claimLine.getTotalChargeAmount());
assertEquals(new BigDecimal("88.00"), claimLine.getNonCoveredChargeAmount());
assertEquals("345345345", claimLine.getRevenueCenterRenderingPhysicianNPI().get());
}
use of gov.cms.bfd.model.rif.SNFClaimLine 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;
}
use of gov.cms.bfd.model.rif.SNFClaimLine in project beneficiary-fhir-data by CMSgov.
the class SNFClaimTransformerTest method assertMatches.
/**
* Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
* the specified {@link SNFClaim}.
*
* @param claim the {@link SNFClaim} that the {@link ExplanationOfBenefit} was generated from
* @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
* SNFClaim}
* @throws FHIRException (indicates test failure)
*/
static void assertMatches(SNFClaim claim, ExplanationOfBenefit eob) throws FHIRException {
// Test to ensure group level fields between all claim types match
TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.SNF, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
// test the common field provider number is set as expected in the EOB
TransformerTestUtils.assertProviderNumber(eob, claim.getProviderNumber());
// test common benefit components between SNF and Inpatient claims are set as expected
TransformerTestUtils.assertCommonGroupInpatientSNF(eob, claim.getCoinsuranceDayCount(), claim.getNonUtilizationDayCount(), claim.getDeductibleAmount(), claim.getPartACoinsuranceLiabilityAmount(), claim.getBloodPintsFurnishedQty(), claim.getNoncoveredCharge(), claim.getTotalDeductionAmount(), claim.getClaimPPSCapitalDisproportionateShareAmt(), claim.getClaimPPSCapitalExceptionAmount(), claim.getClaimPPSCapitalFSPAmount(), claim.getClaimPPSCapitalIMEAmount(), claim.getClaimPPSCapitalOutlierAmount(), claim.getClaimPPSOldCapitalHoldHarmlessAmount());
if (claim.getQualifiedStayFromDate().isPresent() || claim.getQualifiedStayThroughDate().isPresent()) {
SupportingInformationComponent nchQlyfdStayInfo = TransformerTestUtils.assertHasInfo(CcwCodebookVariable.NCH_QLFYD_STAY_FROM_DT, eob);
TransformerTestUtils.assertPeriodEquals(claim.getQualifiedStayFromDate(), claim.getQualifiedStayThroughDate(), (Period) nchQlyfdStayInfo.getTiming());
}
// test common eob information between SNF and Inpatient claims are set as expected
TransformerTestUtils.assertCommonEobInformationInpatientSNF(eob, claim.getNoncoveredStayFromDate(), claim.getNoncoveredStayThroughDate(), claim.getCoveredCareThroughDate(), claim.getMedicareBenefitsExhaustedDate(), claim.getDiagnosisRelatedGroupCd());
TransformerTestUtils.assertDateEquals(claim.getClaimAdmissionDate().get(), eob.getHospitalization().getStartElement());
TransformerTestUtils.assertDateEquals(claim.getBeneficiaryDischargeDate().get(), eob.getHospitalization().getEndElement());
// test common eob information between Inpatient, HHA, Hospice and SNF claims are set as
// expected
TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFEquals(eob, claim.getClaimAdmissionDate(), claim.getBeneficiaryDischargeDate(), Optional.of(claim.getUtilizationDayCount()));
// Test to ensure common group fields between Inpatient, Outpatient and SNF
TransformerTestUtils.assertEobCommonGroupInpOutSNFEquals(eob, claim.getBloodDeductibleLiabilityAmount(), claim.getOperatingPhysicianNpi(), claim.getOtherPhysicianNpi(), claim.getClaimQueryCode(), claim.getMcoPaidSw());
// Test to ensure common group fields between Inpatient, Outpatient HHA, Hospice
// and SNF match
TransformerTestUtils.assertEobCommonGroupInpOutHHAHospiceSNFEquals(eob, claim.getOrganizationNpi(), claim.getClaimFacilityTypeCode(), claim.getClaimFrequencyCode(), claim.getClaimNonPaymentReasonCode(), claim.getPatientDischargeStatusCode(), claim.getClaimServiceClassificationTypeCode(), claim.getClaimPrimaryPayerCode(), claim.getAttendingPhysicianNpi(), claim.getTotalChargeAmount(), claim.getPrimaryPayerPaidAmount(), claim.getFiscalIntermediaryNumber(), claim.getFiDocumentClaimControlNumber(), claim.getFiOriginalClaimControlNumber());
assertEquals(6, eob.getDiagnosis().size());
CCWProcedure ccwProcedure = new CCWProcedure(claim.getProcedure1Code(), claim.getProcedure1CodeVersion(), claim.getProcedure1Date());
TransformerTestUtils.assertHasCoding(ccwProcedure.getFhirSystem().toString(), claim.getProcedure1Code().get(), eob.getProcedure().get(0).getProcedureCodeableConcept().getCoding());
assertEquals(TransformerUtils.convertToDate(claim.getProcedure1Date().get()), eob.getProcedure().get(0).getDate());
assertEquals(1, eob.getItem().size());
SNFClaimLine claimLine1 = claim.getLines().get(0);
ItemComponent eobItem0 = eob.getItem().get(0);
assertEquals(claimLine1.getLineNumber(), new BigDecimal(eobItem0.getSequence()));
assertEquals(claim.getProviderStateCode(), eobItem0.getLocationAddress().getState());
TransformerTestUtils.assertHasCoding(CcwCodebookVariable.REV_CNTR, claimLine1.getRevenueCenter(), eobItem0.getRevenue());
TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), Optional.empty(), Optional.empty(), Optional.empty(), 0);
// Test to ensure common group field coinsurance between Inpatient, HHA, Hospice and SNF match
TransformerTestUtils.assertEobCommonGroupInpHHAHospiceSNFCoinsuranceEquals(eobItem0, claimLine1.getDeductibleCoinsuranceCd());
String claimControlNumber = "0000000000";
// Test to ensure item level fields between Inpatient, Outpatient, HHA, Hopsice
// and SNF match
TransformerTestUtils.assertEobCommonItemRevenueEquals(eobItem0, eob, claimLine1.getRevenueCenter(), claimLine1.getRateAmount(), claimLine1.getTotalChargeAmount(), claimLine1.getNonCoveredChargeAmount(), BigDecimal.valueOf(claimLine1.getUnitCount()), claimControlNumber, claimLine1.getNationalDrugCodeQuantity(), claimLine1.getNationalDrugCodeQualifierCode(), claimLine1.getRevenueCenterRenderingPhysicianNPI(), 1);
// verify {@link
// TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
// method worked as expected for this claim type
TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.SNF, Optional.of(org.hl7.fhir.dstu3.model.codesystems.ClaimType.INSTITUTIONAL), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
// Test lastUpdated
TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
Aggregations