use of gov.cms.bfd.model.rif.CarrierClaimLine in project beneficiary-fhir-data by CMSgov.
the class CarrierClaimTransformerV2 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();
// Required values not directly mapped
eob.getMeta().addProfile(ProfileConstants.C4BB_EOB_NONCLINICIAN_PROFILE_URL);
// TODO: ExplanationOfBenefit.outcome is a required field. Needs to be mapped.
// eob.setOutcome(?)
// 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
// (reference)
// 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.CARRIER, 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 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.CARRIER, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
// CARR_CLM_PRMRY_PYR_PD_AMT => ExplanationOfBenefit.total.amount
TransformerUtilsV2.addTotal(eob, TransformerUtilsV2.createTotalAdjudicationAmountSlice(eob, CcwCodebookVariable.CLM_TOT_CHRG_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, claimGroup.getPrimaryPayerPaidAmount()));
// Common group level fields between Carrier and DME
// BENE_ID =>
// CARR_NUM => ExplanationOfBenefit.extension
// CLM_CLNCL_TRIL_NUM => ExplanationOfBenefit.extension
// CARR_CLM_CASH_DDCTBL_APLD_AMT => ExplanationOfBenefit.benefitBalance.financial
// CARR_CLM_PMT_DNL_CD => ExplanationOfBenefit.extension
// RFR_PHYSN_NPI => ExplanationOfBenefit.referral.identifier
// => ExplanationOfBenefit.careteam.provider
// RFR_PHYSN_UPIN => ExplanationOfBenefit.referral.identifier
// => ExplanationOfBenefit.careteam.provider
// CARR_CLM_PRVDR_ASGNMT_IND_SW => ExplanationOfBenefit.extension
// NCH_CLM_PRVDR_PMT_AMT => ExplanationOfBenefit.benefitBalance.financial
// NCH_CLM_BENE_PMT_AMT => ExplanationOfBenefit.benefitBalance.financial
// NCH_CARR_CLM_SBMTD_CHRG_AMT => ExplanationOfBenefit.benefitBalance.financial
// NCH_CARR_CLM_ALOWD_AMT => ExplanationOfBenefit.benefitBalance.financial
// CLM_DISP_CD => ExplanationOfBenefit.disposition
// CARR_CLM_CNTL_NUM => ExplanationOfBenefit.extension
TransformerUtilsV2.mapEobCommonGroupCarrierDME(eob, claimGroup.getBeneficiaryId(), claimGroup.getCarrierNumber(), claimGroup.getClinicalTrialNumber(), claimGroup.getBeneficiaryPartBDeductAmount(), claimGroup.getPaymentDenialCode(), claimGroup.getReferringPhysicianNpi(), claimGroup.getReferringPhysicianUpin(), claimGroup.getProviderAssignmentIndicator(), claimGroup.getProviderPaymentAmount(), claimGroup.getBeneficiaryPaymentAmount(), claimGroup.getSubmittedChargeAmount(), claimGroup.getAllowedChargeAmount(), claimGroup.getClaimDispositionCode(), claimGroup.getClaimCarrierControlNumber());
// ICD_DGNS_VRSN_CD(1-12) => diagnosis.diagnosisCodeableConcept
for (Diagnosis diagnosis : DiagnosisUtilV2.extractDiagnoses(claimGroup)) {
DiagnosisUtilV2.addDiagnosisCode(eob, diagnosis, ClaimTypeV2.CARRIER);
}
// CARR_CLM_RFRNG_PIN_NUM => ExplanationOfBenefit.careteam.provider
TransformerUtilsV2.addCareTeamMember(eob, C4BBPractitionerIdentifierType.NPI, C4BBClaimProfessionalAndNonClinicianCareTeamRole.REFERRING, Optional.ofNullable(claimGroup.getReferringProviderIdNumber()));
// CARR_CLM_ENTRY_CD => ExplanationOfBenefit.extension
eob.addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.CARR_CLM_ENTRY_CD, claimGroup.getClaimEntryCode()));
// Process line items
for (CarrierClaimLine line : claimGroup.getLines()) {
ItemComponent item = eob.addItem();
// LINE_NUM => ExplanationOfBenefit.item.sequence
item.setSequence(line.getLineNumber().intValue());
// PRF_PHYSN_NPI => ExplanationOfBenefit.careTeam.provider
Optional<CareTeamComponent> performing = TransformerUtilsV2.addCareTeamMember(eob, item, C4BBPractitionerIdentifierType.NPI, C4BBClaimProfessionalAndNonClinicianCareTeamRole.PERFORMING, line.getPerformingPhysicianNpi());
// Fall back to UPIN if NPI not present
if (!line.getPerformingPhysicianNpi().isPresent()) {
performing = TransformerUtilsV2.addCareTeamMember(eob, item, C4BBPractitionerIdentifierType.UPIN, C4BBClaimProfessionalAndNonClinicianCareTeamRole.PERFORMING, line.getPerformingPhysicianUpin());
}
// Update the responsible flag
performing.ifPresent(p -> {
p.setResponsible(true);
// PRVDR_SPCLTY => ExplanationOfBenefit.careTeam.qualification
p.setQualification(TransformerUtilsV2.createCodeableConcept(eob, CcwCodebookVariable.PRVDR_SPCLTY, line.getProviderSpecialityCode()));
// CARR_LINE_PRVDR_TYPE_CD => ExplanationOfBenefit.careTeam.extension
p.addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.CARR_LINE_PRVDR_TYPE_CD, line.getProviderTypeCode()));
// PRTCPTNG_IND_CD => ExplanationOfBenefit.careTeam.extension
p.addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.PRTCPTNG_IND_CD, line.getProviderParticipatingIndCode()));
});
// ORG_NPI_NUM => ExplanationOfBenefit.careTeam.provider
TransformerUtilsV2.addCareTeamMember(eob, item, C4BBPractitionerIdentifierType.NPI, C4BBClaimProfessionalAndNonClinicianCareTeamRole.PRIMARY, line.getOrganizationNpi());
// CARR_LINE_RDCD_PMT_PHYS_ASTN_C => ExplanationOfBenefit.item.adjudication
TransformerUtilsV2.addAdjudication(item, TransformerUtilsV2.createAdjudicationDenialReasonSlice(eob, CcwCodebookVariable.CARR_LINE_RDCD_PMT_PHYS_ASTN_C, String.valueOf(line.getReducedPaymentPhysicianAsstCode())));
// HCPCS_CD => ExplanationOfBenefit.item.productOrService
// HCPCS_1ST_MDFR_CD => ExplanationOfBenefit.item.modifier
// HCPCS_2ND_MDFR_CD => ExplanationOfBenefit.item.modifier
// CARR_CLM_HCPCS_YR_CD => ExplanationOfBenefit.item.modifier.version
TransformerUtilsV2.mapHcpcs(eob, item, line.getHcpcsCode(), claimGroup.getHcpcsYearCode(), Arrays.asList(line.getHcpcsInitialModifierCode(), line.getHcpcsSecondModifierCode()));
// tax num should be as a extension
if (includeTaxNumbers.orElse(false)) {
item.addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.TAX_NUM, line.getProviderTaxNumber()));
}
// CARR_LINE_ANSTHSA_UNIT_CNT => ExplanationOfBenefit.item.extension
if (line.getAnesthesiaUnitCount().compareTo(BigDecimal.ZERO) > 0) {
item.addExtension(TransformerUtilsV2.createExtensionQuantity(CcwCodebookVariable.CARR_LINE_ANSTHSA_UNIT_CNT, line.getAnesthesiaUnitCount()));
}
// CARR_LINE_MTUS_CNT => ExplanationOfBenefit.item.extension
if (!line.getMtusCount().equals(BigDecimal.ZERO)) {
item.addExtension(TransformerUtilsV2.createExtensionQuantity(CcwCodebookVariable.CARR_LINE_MTUS_CNT, line.getMtusCount()));
}
// CARR_LINE_MTUS_CD => ExplanationOfBenefit.item.extension
line.getMtusCode().ifPresent(code -> item.addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.CARR_LINE_MTUS_CNT, code)));
// Common item level fields between Carrier and DME
// LINE_SRVC_CNT => ExplanationOfBenefit.item.quantity
// LINE_CMS_TYPE_SRVC_CD => ExplanationOfBenefit.item.category
// LINE_PLACE_OF_SRVC_CD => ExplanationOfBenefit.item.location
// BETOS_CD => ExplanationOfBenefit.item.extension
// LINE_1ST_EXPNS_DT => ExplanationOfBenefit.item.servicedPeriod
// LINE_LAST_EXPNS_DT => ExplanationOfBenefit.item.servicedPeriod
// LINE_NCH_PMT_AMT => ExplanationOfBenefit.item.adjudication
// LINE_PMT_80_100_CD => ExplanationOfBenefit.item.adjudication.extension
// PAID_TO_PATIENT => ExplanationOfBenefit.item.adjudication
// LINE_PRVDR_PMT_AMT => ExplanationOfBenefit.item.adjudication
// LINE_BENE_PTB_DDCTBL_AMT => ExplanationOfBenefit.item.adjudication
// LINE_BENE_PRMRY_PYR_CD => ExplanationOfBenefit.item.extension
// LINE_BENE_PRMRY_PYR_PD_AMT => ExplanationOfBenefit.item.adjudication
// LINE_COINSRNC_AMT => ExplanationOfBenefit.item.adjudication
// LINE_SBMTD_CHRG_AMT => ExplanationOfBenefit.item.adjudication
// LINE_ALOWD_CHRG_AMT => ExplanationOfBenefit.item.adjudication
// LINE_BENE_PRMRY_PYR_CD => ExplanationOfBenefit.item.extension
// LINE_SERVICE_DEDUCTIBLE => ExplanationOfBenefit.item.extension
// LINE_HCT_HGB_TYPE_CD => Observation.code
// LINE_HCT_HGB_RSLT_NUM => Observation.value
// LINE_NDC_CD => ExplanationOfBenefit.item.productOrService
TransformerUtilsV2.mapEobCommonItemCarrierDME(item, eob, claimGroup.getClaimId(), item.getSequence(), line.getServiceCount(), line.getPlaceOfServiceCode(), line.getFirstExpenseDate(), line.getLastExpenseDate(), line.getBeneficiaryPaymentAmount(), line.getProviderPaymentAmount(), line.getBeneficiaryPartBDeductAmount(), line.getPrimaryPayerCode(), line.getPrimaryPayerPaidAmount(), line.getBetosCode(), line.getPaymentAmount(), line.getPaymentCode(), line.getCoinsuranceAmount(), line.getSubmittedChargeAmount(), line.getAllowedChargeAmount(), line.getProcessingIndicatorCode(), line.getServiceDeductibleCode(), line.getHctHgbTestTypeCode(), line.getHctHgbTestResult(), line.getCmsServiceTypeCode(), line.getNationalDrugCode());
// LINE_ICD_DGNS_CD => ExplanationOfBenefit.item.diagnosisSequence
// LINE_ICD_DGNS_VRSN_CD => ExplanationOfBenefit.item.diagnosisSequence
DiagnosisUtilV2.addDiagnosisLink(eob, item, Diagnosis.from(line.getDiagnosisCode(), line.getDiagnosisCodeVersion(), DiagnosisLabel.OTHER), ClaimTypeV2.CARRIER);
// PRVDR_STATE_CD => ExplanationOfBenefit.item.location.extension
line.getProviderStateCode().ifPresent(code -> item.getLocation().addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.PRVDR_STATE_CD, code)));
// PRVDR_ZIP => ExplanationOfBenefit.item.location.extension
line.getProviderZipCode().ifPresent(code -> item.getLocation().addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.PRVDR_ZIP, code)));
// CARR_LINE_PRCNG_LCLTY_CD => ExplanationOfBenefit.item.location.extension
item.getLocation().addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.CARR_LINE_PRCNG_LCLTY_CD, line.getLinePricingLocalityCode()));
// CARR_LINE_CLIA_LAB_NUM => ExplanationOfBenefit.item.location.extension
line.getCliaLabNumber().ifPresent(num -> item.getLocation().addExtension(TransformerUtilsV2.createExtensionIdentifier(CcwCodebookVariable.CARR_LINE_CLIA_LAB_NUM, num)));
}
TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
return eob;
}
use of gov.cms.bfd.model.rif.CarrierClaimLine in project beneficiary-fhir-data by CMSgov.
the class CarrierClaimTransformerTest method assertMatches.
/**
* Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
* the specified {@link CarrierClaim}.
*
* @param claim the {@link CarrierClaim} that the {@link ExplanationOfBenefit} was generated from
* @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
* CarrierClaim}
* @param includedTaxNumbers whether or not to include tax numbers are expected to be included in
* the result (see {@link
* ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
* false</code>)
* @throws FHIRException (indicates test failure)
*/
static void assertMatches(CarrierClaim claim, ExplanationOfBenefit eob, Optional<Boolean> includedTaxNumbers) throws FHIRException {
// Test to ensure group level fields between all claim types match
TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.CARRIER, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
// Test to ensure common group fields between Carrier and DME match
TransformerTestUtils.assertEobCommonGroupCarrierDMEEquals(eob, claim.getBeneficiaryId(), claim.getCarrierNumber(), claim.getClinicalTrialNumber(), claim.getBeneficiaryPartBDeductAmount(), claim.getPaymentDenialCode(), claim.getReferringPhysicianNpi(), claim.getProviderAssignmentIndicator(), claim.getProviderPaymentAmount(), claim.getBeneficiaryPaymentAmount(), claim.getSubmittedChargeAmount(), claim.getAllowedChargeAmount());
assertEquals(5, eob.getDiagnosis().size());
assertEquals(1, eob.getItem().size());
TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.PRPAYAMT, claim.getPrimaryPayerPaidAmount(), eob);
CarrierClaimLine claimLine1 = claim.getLines().get(0);
ItemComponent eobItem0 = eob.getItem().get(0);
assertEquals(claimLine1.getLineNumber(), new BigDecimal(eobItem0.getSequence()));
TransformerTestUtils.assertCareTeamEquals(claimLine1.getPerformingPhysicianNpi().get(), ClaimCareteamrole.PRIMARY, eob);
CareTeamComponent performingCareTeamEntry = TransformerTestUtils.findCareTeamEntryForProviderNpi(claimLine1.getPerformingPhysicianNpi().get(), eob.getCareTeam());
TransformerTestUtils.assertHasCoding(CcwCodebookVariable.PRVDR_SPCLTY, claimLine1.getProviderSpecialityCode(), performingCareTeamEntry.getQualification());
TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.CARR_LINE_PRVDR_TYPE_CD, claimLine1.getProviderTypeCode(), performingCareTeamEntry);
TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRTCPTNG_IND_CD, claimLine1.getProviderParticipatingIndCode(), performingCareTeamEntry);
TransformerTestUtils.assertExtensionCodingEquals(performingCareTeamEntry, TransformerConstants.CODING_NPI_US, TransformerConstants.CODING_NPI_US, "" + claimLine1.getOrganizationNpi().get());
CareTeamComponent taxNumberCareTeamEntry = TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(claimLine1.getProviderTaxNumber(), eob.getCareTeam());
if (includedTaxNumbers.orElse(false)) {
assertNotNull(taxNumberCareTeamEntry);
} else {
assertNull(taxNumberCareTeamEntry);
}
TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRVDR_STATE_CD, claimLine1.getProviderStateCode(), eobItem0.getLocation());
TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRVDR_STATE_CD, claimLine1.getProviderStateCode(), eobItem0.getLocation());
TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.CARR_LINE_PRCNG_LCLTY_CD, claimLine1.getLinePricingLocalityCode(), eobItem0.getLocation());
TransformerTestUtils.assertHasCoding(TransformerConstants.CODING_SYSTEM_HCPCS, "" + claim.getHcpcsYearCode().get(), null, claimLine1.getHcpcsCode().get(), eobItem0.getService().getCoding());
assertEquals(1, eobItem0.getModifier().size());
TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), claimLine1.getHcpcsInitialModifierCode(), claimLine1.getHcpcsSecondModifierCode(), claim.getHcpcsYearCode(), 0);
if (claimLine1.getAnesthesiaUnitCount().compareTo(BigDecimal.ZERO) > 0) {
TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.CARR_LINE_ANSTHSA_UNIT_CNT, claimLine1.getAnesthesiaUnitCount(), eobItem0.getService());
}
TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.CARR_LINE_MTUS_CD, claimLine1.getMtusCode(), eobItem0);
TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.CARR_LINE_MTUS_CNT, claimLine1.getMtusCount(), eobItem0);
TransformerTestUtils.assertAdjudicationReasonEquals(CcwCodebookVariable.CARR_LINE_RDCD_PMT_PHYS_ASTN_C, claimLine1.getReducedPaymentPhysicianAsstCode(), eobItem0.getAdjudication());
TransformerTestUtils.assertExtensionIdentifierEquals(CcwCodebookVariable.CARR_LINE_CLIA_LAB_NUM, claimLine1.getCliaLabNumber(), eobItem0.getLocation());
// verify {@link
// TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
// method worked as expected for this claim type
TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.CARRIER, Optional.of(org.hl7.fhir.dstu3.model.codesystems.ClaimType.PROFESSIONAL), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
// Test to ensure common item fields between Carrier and DME match
TransformerTestUtils.assertEobCommonItemCarrierDMEEquals(eobItem0, eob, claimLine1.getServiceCount(), claimLine1.getPlaceOfServiceCode(), claimLine1.getFirstExpenseDate(), claimLine1.getLastExpenseDate(), claimLine1.getBeneficiaryPaymentAmount(), claimLine1.getProviderPaymentAmount(), claimLine1.getBeneficiaryPartBDeductAmount(), claimLine1.getPrimaryPayerCode(), claimLine1.getPrimaryPayerPaidAmount(), claimLine1.getBetosCode(), claimLine1.getPaymentAmount(), claimLine1.getPaymentCode(), claimLine1.getCoinsuranceAmount(), claimLine1.getSubmittedChargeAmount(), claimLine1.getAllowedChargeAmount(), claimLine1.getProcessingIndicatorCode(), claimLine1.getServiceDeductibleCode(), claimLine1.getDiagnosisCode(), claimLine1.getDiagnosisCodeVersion(), claimLine1.getHctHgbTestTypeCode(), claimLine1.getHctHgbTestResult(), claimLine1.getCmsServiceTypeCode(), claimLine1.getNationalDrugCode());
// Test lastUpdated
TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
use of gov.cms.bfd.model.rif.CarrierClaimLine in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessorTest method process1CarrierClaimRecord.
/**
* Ensures that {@link RifFilesProcessor} can correctly handle {@link
* StaticRifResource#SAMPLE_A_CARRIER}.
*/
@Test
public void process1CarrierClaimRecord() {
RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_CARRIER.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_CARRIER.getRecordCount(), rifEventsList.size());
RifRecordEvent<?> rifRecordEvent = rifEventsList.get(0);
assertEquals(StaticRifResource.SAMPLE_A_CARRIER.getRifFileType(), rifRecordEvent.getFileEvent().getFile().getFileType());
assertNotNull(rifRecordEvent.getRecord());
assertTrue(rifRecordEvent.getRecord() instanceof CarrierClaim);
// Verify the claim header.
CarrierClaim claimGroup = (CarrierClaim) rifRecordEvent.getRecord();
assertEquals(RecordAction.INSERT, rifRecordEvent.getRecordAction());
assertEquals(claimGroup.getBeneficiaryId(), rifRecordEvent.getBeneficiaryId());
assertEquals("567834", claimGroup.getBeneficiaryId());
assertEquals("9991831999", claimGroup.getClaimId());
assertEquals(new BigDecimal(900), claimGroup.getClaimGroupId());
assertEquals('O', claimGroup.getNearLineRecordIdCode());
assertEquals("71", claimGroup.getClaimTypeCode());
assertEquals(LocalDate.of(1999, 10, 27), claimGroup.getDateFrom());
assertEquals(LocalDate.of(1999, 10, 27), claimGroup.getDateThrough());
assertEquals(LocalDate.of(1999, 11, 6), claimGroup.getWeeklyProcessDate());
assertEquals('1', claimGroup.getClaimEntryCode());
assertEquals("1", claimGroup.getClaimDispositionCode());
assertEquals("61026", claimGroup.getCarrierNumber());
assertEquals("1", claimGroup.getPaymentDenialCode());
assertEquals(new BigDecimal("199.99"), claimGroup.getPaymentAmount());
assertEquals(new BigDecimal("0"), claimGroup.getPrimaryPayerPaidAmount());
assertEquals("1234534", claimGroup.getReferringPhysicianUpin().get());
assertEquals("8765676", claimGroup.getReferringPhysicianNpi().get());
assertEquals(new Character('A'), claimGroup.getProviderAssignmentIndicator().get());
assertEquals(new BigDecimal("123.45"), claimGroup.getProviderPaymentAmount());
assertEquals(new BigDecimal("888.00"), claimGroup.getBeneficiaryPaymentAmount());
assertEquals(new BigDecimal("245.04"), claimGroup.getSubmittedChargeAmount());
assertEquals(new BigDecimal("166.23"), claimGroup.getAllowedChargeAmount());
assertEquals(new BigDecimal("777.00"), claimGroup.getBeneficiaryPartBDeductAmount());
assertEquals(new Character('5'), claimGroup.getHcpcsYearCode().get());
assertEquals("K25852", claimGroup.getReferringProviderIdNumber());
assertEquals("H5555", claimGroup.getDiagnosisPrincipalCode().get());
assertEquals(new Character('0'), claimGroup.getDiagnosisPrincipalCodeVersion().get());
assertEquals("H5555", claimGroup.getDiagnosis1Code().get());
assertEquals(new Character('0'), claimGroup.getDiagnosis1CodeVersion().get());
assertEquals("H8888", claimGroup.getDiagnosis2Code().get());
assertEquals(new Character('0'), claimGroup.getDiagnosis2CodeVersion().get());
assertEquals("H66666", claimGroup.getDiagnosis3Code().get());
assertEquals(new Character('0'), claimGroup.getDiagnosis3CodeVersion().get());
assertEquals("H77777", claimGroup.getDiagnosis4Code().get());
assertEquals(new Character('0'), claimGroup.getDiagnosis4CodeVersion().get());
assertFalse(claimGroup.getDiagnosis5Code().isPresent());
assertFalse(claimGroup.getDiagnosis5CodeVersion().isPresent());
assertEquals(1, claimGroup.getLines().size());
assertEquals("0", claimGroup.getClinicalTrialNumber().get());
assertEquals("74655592568216", claimGroup.getClaimCarrierControlNumber().get());
// Verify one of the claim lines.
CarrierClaimLine claimLine = claimGroup.getLines().get(0);
assertEquals(new BigDecimal(6), claimLine.getLineNumber());
assertEquals("K25555", claimLine.getPerformingProviderIdNumber());
assertFalse(claimLine.getPerformingPhysicianUpin().isPresent());
assertEquals("1923124", claimLine.getPerformingPhysicianNpi().get());
assertTrue(claimLine.getOrganizationNpi().isPresent());
assertEquals('0', claimLine.getProviderTypeCode());
assertEquals("204299999", claimLine.getProviderTaxNumber());
assertEquals("IL", claimLine.getProviderStateCode().get());
assertEquals("555558202", claimLine.getProviderZipCode().get());
assertEquals("41", claimLine.getProviderSpecialityCode().get());
assertEquals(new Character('1'), claimLine.getProviderParticipatingIndCode().get());
assertEquals('0', claimLine.getReducedPaymentPhysicianAsstCode());
assertEquals(new BigDecimal(1), claimLine.getServiceCount());
assertEquals('1', claimLine.getCmsServiceTypeCode());
assertEquals("11", claimLine.getPlaceOfServiceCode());
assertEquals("15", claimLine.getLinePricingLocalityCode());
assertEquals(LocalDate.of(1999, 10, 27), claimLine.getFirstExpenseDate().get());
assertEquals(LocalDate.of(1999, 10, 27), claimLine.getLastExpenseDate().get());
assertEquals("92999", claimLine.getHcpcsCode().get());
assertTrue(claimLine.getHcpcsInitialModifierCode().isPresent());
assertFalse(claimLine.getHcpcsSecondModifierCode().isPresent());
assertEquals("T2D", claimLine.getBetosCode().get());
assertEquals(new BigDecimal("37.5"), claimLine.getPaymentAmount());
assertEquals(new BigDecimal("0"), claimLine.getBeneficiaryPaymentAmount());
assertEquals(new BigDecimal("37.5"), claimLine.getProviderPaymentAmount());
assertEquals(new BigDecimal("0"), claimLine.getBeneficiaryPartBDeductAmount());
assertTrue(claimLine.getPrimaryPayerCode().isPresent());
assertEquals(new BigDecimal("0"), claimLine.getPrimaryPayerPaidAmount());
assertEquals(new BigDecimal("9.57"), claimLine.getCoinsuranceAmount());
assertEquals(new BigDecimal("75"), claimLine.getSubmittedChargeAmount());
assertEquals(new BigDecimal("47.84"), claimLine.getAllowedChargeAmount());
assertEquals("A", claimLine.getProcessingIndicatorCode().get());
assertEquals(new Character('0'), claimLine.getPaymentCode().get());
assertEquals(new Character('0'), claimLine.getServiceDeductibleCode().get());
assertEquals(new BigDecimal("1"), claimLine.getMtusCount());
assertEquals(new Character('3'), claimLine.getMtusCode().get());
assertEquals("H12345", claimLine.getDiagnosisCode().get());
assertEquals(new Character('0'), claimLine.getDiagnosisCodeVersion().get());
assertFalse(claimLine.getHpsaScarcityCode().isPresent());
assertFalse(claimLine.getRxNumber().isPresent());
assertEquals(new BigDecimal("42.0"), claimLine.getHctHgbTestResult());
assertEquals("R1", claimLine.getHctHgbTestTypeCode().get());
assertEquals("49035044700", claimLine.getNationalDrugCode().get());
assertEquals("BB889999AA", claimLine.getCliaLabNumber().get());
assertEquals(new BigDecimal(0), claimLine.getAnesthesiaUnitCount());
}
use of gov.cms.bfd.model.rif.CarrierClaimLine in project beneficiary-fhir-data by CMSgov.
the class RifLoaderIT method loadSampleU.
/**
* Runs {@link RifLoader} against the {@link StaticRifResourceGroup#SAMPLE_U} data.
*/
@Test
@Disabled
public void loadSampleU() {
loadSample(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
loadSample(Arrays.asList(StaticRifResourceGroup.SAMPLE_U.getResources()));
verifyRecordPrimaryKeysPresent(Arrays.asList(StaticRifResourceGroup.SAMPLE_U.getResources()));
// Ensure no records were skipped
validateBeneficiaryAndSkippedCountsInDatabase(1, 0);
/*
* Verify that the updates worked as expected by manually checking some fields.
*/
EntityManagerFactory entityManagerFactory = PipelineTestUtils.get().getPipelineApplicationState().getEntityManagerFactory();
EntityManager entityManager = null;
try {
entityManager = entityManagerFactory.createEntityManager();
CriteriaQuery<BeneficiaryHistory> beneficiaryHistoryCriteria = entityManager.getCriteriaBuilder().createQuery(BeneficiaryHistory.class);
List<BeneficiaryHistory> beneficiaryHistoryEntries = entityManager.createQuery(beneficiaryHistoryCriteria.select(beneficiaryHistoryCriteria.from(BeneficiaryHistory.class))).getResultList();
for (BeneficiaryHistory beneHistory : beneficiaryHistoryEntries) {
assertEquals("567834", beneHistory.getBeneficiaryId());
// A recent lastUpdated timestamp
assertTrue(beneHistory.getLastUpdated().isPresent(), "Expected a lastUpdated field");
beneHistory.getLastUpdated().ifPresent(lastUpdated -> {
assertTrue(lastUpdated.isAfter(Instant.now().minus(10, ChronoUnit.MINUTES)), "Expected a recent lastUpdated timestamp");
});
}
assertEquals(4, beneficiaryHistoryEntries.size());
Beneficiary beneficiaryFromDb = entityManager.find(Beneficiary.class, "567834");
// Last Name inserted with value of "Johnson"
assertEquals("Johnson", beneficiaryFromDb.getNameSurname());
// Following fields were NOT changed in update record
assertEquals("John", beneficiaryFromDb.getNameGiven());
assertEquals(new Character('A'), beneficiaryFromDb.getNameMiddleInitial().get());
assertEquals(Optional.of("SSSS"), beneficiaryFromDb.getMedicareBeneficiaryId(), "Beneficiary has MBI");
assertEquals(Optional.of("401441595efcc68bc5b26f4e88bd9fa550004e068d69ff75761ab946ec553a02"), beneficiaryFromDb.getMbiHash(), "Beneficiary has mbiHash");
// A recent lastUpdated timestamp
assertTrue(beneficiaryFromDb.getLastUpdated().isPresent(), "Expected a lastUpdated field");
beneficiaryFromDb.getLastUpdated().ifPresent(lastUpdated -> {
assertTrue(lastUpdated.isAfter(Instant.now().minus(1, ChronoUnit.MINUTES)), "Expected a recent lastUpdated timestamp");
});
CarrierClaim carrierRecordFromDb = entityManager.find(CarrierClaim.class, "9991831999");
assertEquals('N', carrierRecordFromDb.getFinalAction());
// DateThrough inserted with value 10-27-1999
assertEquals(LocalDate.of(2000, Month.OCTOBER, 27), carrierRecordFromDb.getDateThrough());
assertEquals(1, carrierRecordFromDb.getLines().size());
// A recent lastUpdated timestamp
assertTrue(carrierRecordFromDb.getLastUpdated().isPresent(), "Expected a lastUpdated field");
carrierRecordFromDb.getLastUpdated().ifPresent(lastUpdated -> {
assertTrue(lastUpdated.isAfter(Instant.now().minus(1, ChronoUnit.MINUTES)), "Expected a recent lastUpdated timestamp");
});
CarrierClaimLine carrierLineRecordFromDb = carrierRecordFromDb.getLines().get(0);
// CliaLabNumber inserted with value BB889999AA
assertEquals("GG443333HH", carrierLineRecordFromDb.getCliaLabNumber().get());
} finally {
if (entityManager != null)
entityManager.close();
}
}
use of gov.cms.bfd.model.rif.CarrierClaimLine 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;
}
Aggregations