use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.
the class InpatientClaimTransformer method transform.
/**
* @param metricRegistry the {@link MetricRegistry} to use
* @param claim the CCW {@link InpatientClaim} to transform
* @param includeTaxNumbers whether or not to include tax numbers in the result (see {@link
* ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
* false</code>)
* @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
* InpatientClaim}
*/
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
Timer.Context timer = metricRegistry.timer(MetricRegistry.name(InpatientClaimTransformer.class.getSimpleName(), "transform")).time();
if (!(claim instanceof InpatientClaim))
throw new BadCodeMonkeyException();
ExplanationOfBenefit eob = transformClaim((InpatientClaim) claim);
timer.stop();
return eob;
}
use of gov.cms.bfd.model.rif.InpatientClaim 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.InpatientClaim in project beneficiary-fhir-data by CMSgov.
the class InpatientClaimTransformerV2Test method generateClaim.
/**
* Generates the Claim object to be used in multiple tests
*
* @return
* @throws FHIRException
*/
public InpatientClaim generateClaim() throws FHIRException {
List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
InpatientClaim claim = parsedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
claim.setLastUpdated(Instant.now());
return claim;
}
use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.
the class InpatientClaimTransformerV2 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(InpatientClaim 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 (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.INPATIENT, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_A, Optional.of(claimGroup.getDateFrom()), Optional.of(claimGroup.getDateThrough()), Optional.of(claimGroup.getPaymentAmount()), claimGroup.getFinalAction());
// 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.INPATIENT, 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_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()));
// 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.getCoveredCareThoughDate(), claimGroup.getMedicareBenefitsExhaustedDate(), claimGroup.getDiagnosisRelatedGroupCd());
// IME_OP_CLM_VAL_AMT => ExplanationOfBenefit.extension
TransformerUtilsV2.addAdjudicationTotal(eob, CcwCodebookVariable.IME_OP_CLM_VAL_AMT, claimGroup.getIndirectMedicalEducationAmount());
// DSH_OP_CLM_VAL_AMT => ExplanationOfBenefit.extension
TransformerUtilsV2.addAdjudicationTotal(eob, CcwCodebookVariable.DSH_OP_CLM_VAL_AMT, claimGroup.getDisproportionateShareAmount());
// CLM_PASS_THRU_PER_DIEM_AMT => ExplanationOfBenefit.benefitBalance.financial
TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.CLM_PASS_THRU_PER_DIEM_AMT, Optional.ofNullable(claimGroup.getPassThruPerDiemAmount()));
// NCH_PROFNL_CMPNT_CHRG_AMT => ExplanationOfBenefit.benefitBalance.financial
TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.NCH_PROFNL_CMPNT_CHRG_AMT, Optional.ofNullable(claimGroup.getProfessionalComponentCharge()));
// CLM_TOT_PPS_CPTL_AMT => ExplanationOfBenefit.benefitBalance.financial
TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.CLM_TOT_PPS_CPTL_AMT, claimGroup.getClaimTotalPPSCapitalAmount());
/*
* 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());
// NCH_DRG_OUTLIER_APRVD_PMT_AMT => ExplanationOfBenefit.extension
TransformerUtilsV2.addBenefitBalanceFinancialMedicalAmt(eob, CcwCodebookVariable.NCH_DRG_OUTLIER_APRVD_PMT_AMT, claimGroup.getDrgOutlierApprovedPaymentAmount());
// 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 (PRPAYAMT)
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());
// CLM_UTLZTN_DAY_CNT => ExplanationOfBenefit.benefitBalance.financial
TransformerUtilsV2.addBenefitBalanceFinancialMedicalInt(eob, CcwCodebookVariable.CLM_UTLZTN_DAY_CNT, Optional.of(claimGroup.getUtilizationDayCount()));
// CLM_E_POA_IND_SW(1-12) => diagnosis.type
for (Diagnosis diagnosis : DiagnosisUtilV2.extractDiagnoses(claimGroup)) {
DiagnosisUtilV2.addDiagnosisCode(eob, diagnosis, ClaimTypeV2.INPATIENT);
}
// 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()));
// NCH_WKLY_PROC_DT => ExplanationOfBenefit.supportinginfo.timingDate
TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationRecievedDateSlice(eob, CcwCodebookVariable.NCH_WKLY_PROC_DT, Optional.of(claimGroup.getWeeklyProcessDate())));
// CLM_PPS_CPTL_DRG_WT_NUM => ExplanationOfBenefit.benefitBalance.financial
TransformerUtilsV2.addBenefitBalanceFinancialMedicalInt(eob, CcwCodebookVariable.CLM_PPS_CPTL_DRG_WT_NUM, claimGroup.getClaimPPSCapitalDrgWeightNumber());
// BENE_LRD_USED_CNT => ExplanationOfBenefit.benefitBalance.financial
TransformerUtilsV2.addBenefitBalanceFinancialMedicalInt(eob, CcwCodebookVariable.BENE_LRD_USED_CNT, claimGroup.getLifetimeReservedDaysUsedCount());
// ClaimLine => ExplanationOfBenefit.item
for (InpatientClaimLine line : claimGroup.getLines()) {
ItemComponent item = TransformerUtilsV2.addItem(eob);
// Override the default sequence
// CLM_LINE_NUM => item.sequence
item.setSequence(line.getLineNumber().intValue());
// PRVDR_STATE_CD => item.location
TransformerUtilsV2.addLocationState(item, claimGroup.getProviderStateCode());
// 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());
// HCPCS_CD => item.productOrService
line.getHcpcsCode().ifPresent(c -> item.setProductOrService(new CodeableConcept().setCoding(Arrays.asList(new Coding().setSystem(CCWUtils.calculateVariableReferenceUrl(CcwCodebookVariable.HCPCS_CD)).setCode(c), new Coding().setSystem(TransformerConstants.CODING_SYSTEM_HCPCS).setCode(c)))));
// 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.InpatientClaim in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessor method buildInpatientClaimEvent.
/**
* @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#INPATIENT} {@link RifFile}
* @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
*/
private static RifRecordEvent<InpatientClaim> buildInpatientClaimEvent(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"));
InpatientClaim claim = InpatientClaimParser.parseRif(csvRecords);
return new RifRecordEvent<InpatientClaim>(fileEvent, csvRecords, recordAction, claim.getBeneficiaryId(), claim);
}
Aggregations