use of org.hl7.fhir.dstu2016may.model.Reference in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformerV2Test method shouldHaveReferenceYearExtension.
/**
* test to verify that {@link gov.cms.bfd.server.war.r4.providers.BeneficiaryTransformerV2}
* hanldes patient reference year extension.
*/
@Test
public void shouldHaveReferenceYearExtension() {
Extension ex = TransformerTestUtilsV2.findExtensionByUrl("https://bluebutton.cms.gov/resources/variables/rfrnc_yr", patient.getExtension());
DateType yearValue = null;
try {
Date dt = new SimpleDateFormat("yyyy-MM-dd").parse("2018-01-01");
yearValue = new DateType(dt, TemporalPrecisionEnum.YEAR);
} catch (Exception e) {
}
Extension compare = new Extension().setValue(yearValue).setUrl("https://bluebutton.cms.gov/resources/variables/rfrnc_yr");
assertTrue(compare.equalsDeep(ex));
}
use of org.hl7.fhir.dstu2016may.model.Reference in project beneficiary-fhir-data by CMSgov.
the class CarrierClaimTransformerV2Test method shouldHaveSupportingInfoListForClaimReceivedDate2.
@Test
public void shouldHaveSupportingInfoListForClaimReceivedDate2() {
SupportingInformationComponent sic = TransformerTestUtilsV2.findSupportingInfoByCode("info", eob.getSupportingInfo());
SupportingInformationComponent compare = TransformerTestUtilsV2.createSupportingInfo(// We don't care what the sequence number is here
sic.getSequence(), // Category
Arrays.asList(new Coding("http://terminology.hl7.org/CodeSystem/claiminformationcategory", "info", "Information"), new Coding("https://bluebutton.cms.gov/resources/codesystem/information", "https://bluebutton.cms.gov/resources/variables/line_hct_hgb_rslt_num", "Hematocrit / Hemoglobin Test Results")));
compare.setValue(new Reference("#line-observation-6"));
assertTrue(compare.equalsDeep(sic));
}
use of org.hl7.fhir.dstu2016may.model.Reference in project beneficiary-fhir-data by CMSgov.
the class HospiceClaimTransformerV2 method transformClaim.
/**
* @param claimGroup the CCW {@link HospiceClaim} to transform
* @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
* HospiceClaim}
*/
private static ExplanationOfBenefit transformClaim(HospiceClaim 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.HOSPICE, 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.HOSPICE, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
// PRVDR_NUM => ExplanationOfBenefit.provider.identifier
TransformerUtilsV2.addProviderSlice(eob, C4BBOrganizationIdentifierType.PRN, claimGroup.getProviderNumber(), claimGroup.getLastUpdated());
// NCH_PTNT_STUS_IND_CD => ExplanationOfBenefit.supportingInfo.code
if (claimGroup.getPatientStatusCd().isPresent()) {
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, claimGroup.getPatientStatusCd());
}
// CLM_ADMSN_DT => ExplanationOfBenefit.supportingInfo:admissionperiod
// NCH_BENE_DSCHRG_DT => ExplanationOfBenefit.supportingInfo:admissionperiod
TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationAdmPeriodSlice(eob, claimGroup.getClaimHospiceStartDate(), claimGroup.getBeneficiaryDischargeDate()));
// CLM_UTLZTN_DAY_CNT => ExplanationOfBenefit.benefitBalance.financial
TransformerUtilsV2.addBenefitBalanceFinancialMedicalInt(eob, CcwCodebookVariable.CLM_UTLZTN_DAY_CNT, claimGroup.getUtilizationDayCount());
// 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_E_POA_IND_SW(1-12) => diagnosis.type
for (Diagnosis diagnosis : DiagnosisUtilV2.extractDiagnoses(claimGroup)) {
DiagnosisUtilV2.addDiagnosisCode(eob, diagnosis, ClaimTypeV2.HOSPICE);
}
// Map care team
// AT_PHYSN_NPI => ExplanationOfBenefit.careTeam.provider
// AT_PHYSN_UPIN => ExplanationOfBenefit.careTeam.provider
TransformerUtilsV2.mapCareTeam(eob, claimGroup.getAttendingPhysicianNpi(), Optional.empty(), Optional.empty(), claimGroup.getAttendingPhysicianUpin(), Optional.empty(), Optional.empty());
for (HospiceClaimLine 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.getRevenueCenterCode(), line.getRateAmount(), line.getTotalChargeAmount(), 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());
// 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_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()));
// 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());
}
TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
return eob;
}
use of org.hl7.fhir.dstu2016may.model.Reference 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 org.hl7.fhir.dstu2016may.model.Reference in project beneficiary-fhir-data by CMSgov.
the class PartDEventTransformerV2 method transformClaim.
/**
* @param claimGroup the CCW {@link PartDEvent} to transform
* @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
* PartDEvent}
*/
private static ExplanationOfBenefit transformClaim(PartDEvent claimGroup) {
ExplanationOfBenefit eob = new ExplanationOfBenefit();
eob.getMeta().addProfile(ProfileConstants.C4BB_EOB_PHARMACY_PROFILE_URL);
// Common group level fields between all claim types
// Claim Type + Claim ID
// => ExplanationOfBenefit.id
// PDE_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
// SRVC_DT => ExplanationOfBenefit.billablePeriod.start
// SRVC_DT => ExplanationOfBenefit.billablePeriod.end
TransformerUtilsV2.mapEobCommonClaimHeaderData(eob, claimGroup.getEventId(), claimGroup.getBeneficiaryId(), ClaimTypeV2.PDE, claimGroup.getClaimGroupId().toPlainString(), MedicareSegment.PART_D, Optional.of(claimGroup.getPrescriptionFillDate()), Optional.of(claimGroup.getPrescriptionFillDate()), Optional.empty(), claimGroup.getFinalAction());
// RX_SRVC_RFRNC_NUM => ExplanationOfBenefit.identifier
eob.addIdentifier(TransformerUtilsV2.createClaimIdentifier(CcwCodebookVariable.RX_SRVC_RFRNC_NUM, claimGroup.getPrescriptionReferenceNumber().toPlainString()));
// map eob type codes into FHIR
// EOB Type => ExplanationOfBenefit.type.coding
// Claim Type (pharmacy) => ExplanationOfBenefit.type.coding
TransformerUtilsV2.mapEobType(eob, ClaimTypeV2.PDE, Optional.empty(), Optional.empty());
// Coverage object is not optional, and we want to add extensions to it. This is safe.
// PLAN_CNTRCT_REC_ID => ExplanationOfBenefit.insurance.coverage.extension
eob.getInsuranceFirstRep().getCoverage().addExtension(TransformerUtilsV2.createExtensionIdentifier(CcwCodebookVariable.PLAN_CNTRCT_REC_ID, claimGroup.getPlanContractId()));
// PLAN_PBP_REC_NUM => ExplanationOfBenefit.insurance.coverage.extension
eob.getInsuranceFirstRep().getCoverage().addExtension(TransformerUtilsV2.createExtensionIdentifier(CcwCodebookVariable.PLAN_PBP_REC_NUM, claimGroup.getPlanBenefitPackageId()));
// PD_DT => ExplanationOfBenefit.payment.date
if (claimGroup.getPaymentDate().isPresent()) {
eob.getPayment().setDate(TransformerUtilsV2.convertToDate(claimGroup.getPaymentDate().get()));
}
ItemComponent rxItem = eob.addItem();
// 1 => ExplanationOfBenefit.item.sequence
rxItem.setSequence(1);
// CMPND_CD => ExplanationOfBenefit.item.programCode
switch(claimGroup.getCompoundCode()) {
// COMPOUNDED
case 2:
/* Pharmacy dispense invoice for a compound */
TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.COMPOUND_CODE).setCode(new CodeableConcept().addCoding(new Coding().setSystem(V3ActCode.RXCINV.getSystem()).setCode(V3ActCode.RXCINV.toCode()).setDisplay(V3ActCode.RXCINV.getDisplay())));
break;
// NOT_COMPOUNDED
case 1:
/*
* Pharmacy dispense invoice not involving a compound
*/
TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.COMPOUND_CODE).setCode(new CodeableConcept().addCoding(new Coding().setSystem(V3ActCode.RXDINV.getSystem()).setCode(V3ActCode.RXDINV.toCode()).setDisplay(V3ActCode.RXDINV.getDisplay())));
break;
// NOT_SPECIFIED
case 0:
/*
* Pharmacy dispense invoice not specified - do not set a value
*/
break;
default:
/*
* Unexpected value encountered - compound code should be either
* compounded or not compounded.
*/
throw new InvalidRifValueException("Unexpected value encountered - compound code should be either compounded or not compounded: " + claimGroup.getCompoundCode());
}
// SRVC_DT => ExplanationOfBenefit.item.servicedDate
rxItem.setServiced(new DateType().setValue(TransformerUtilsV2.convertToDate(claimGroup.getPrescriptionFillDate())));
/*
* Create an adjudication for either CVRD_D_PLAN_PD_AMT or NCVRD_PLAN_PD_AMT,
* depending on the value of DRUG_CVRG_STUS_CD. Stick DRUG_CVRG_STUS_CD into the
* adjudication.reason field. CARING Slicing and CARING Adjudication Value Sets.
*/
if (claimGroup.getDrugCoverageStatusCode() == 'C') {
// CVRD_D_PLAN_PD_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.CVRD_D_PLAN_PD_AMT, C4BBAdjudication.BENEFIT, claimGroup.getPartDPlanCoveredPaidAmount()));
} else {
// NCVRD_PLAN_PD_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.CVRD_D_PLAN_PD_AMT, C4BBAdjudication.NONCOVERED, claimGroup.getPartDPlanNonCoveredPaidAmount()));
}
// GDC_BLW_OOPT_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.GDC_BLW_OOPT_AMT, C4BBAdjudication.COINSURANCE, claimGroup.getGrossCostBelowOutOfPocketThreshold()));
// GDC_ABV_OOPT_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.GDC_ABV_OOPT_AMT, C4BBAdjudication.COINSURANCE, claimGroup.getGrossCostAboveOutOfPocketThreshold()));
// PTNT_PAY_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.PTNT_PAY_AMT, C4BBAdjudication.PAID_BY_PATIENT, claimGroup.getPatientPaidAmount()));
// OTHR_TROOP_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.OTHR_TROOP_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, claimGroup.getOtherTrueOutOfPocketPaidAmount()));
// LICS_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.LICS_AMT, C4BBAdjudication.DISCOUNT, claimGroup.getLowIncomeSubsidyPaidAmount()));
// PLRO_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.PLRO_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, claimGroup.getPatientLiabilityReductionOtherPaidAmount()));
// TOT_RX_CST_AMT => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.TOT_RX_CST_AMT, C4BBAdjudication.DRUG_COST, claimGroup.getTotalPrescriptionCost()));
// RPTD_GAP_DSCNT_NUM => ExplanationOfBenefit.item.adjudication.amount
TransformerUtilsV2.addAdjudication(rxItem, TransformerUtilsV2.createAdjudicationAmtSlice(CcwCodebookVariable.RPTD_GAP_DSCNT_NUM, C4BBAdjudication.DISCOUNT, claimGroup.getGapDiscountAmount()));
// Validate PRESCRBR_ID
if (claimGroup.getPrescriberIdQualifierCode() == null || !claimGroup.getPrescriberIdQualifierCode().equalsIgnoreCase("01")) {
throw new InvalidRifValueException("Prescriber ID Qualifier Code is invalid: " + claimGroup.getPrescriberIdQualifierCode());
}
// PRSCRBR_ID => ExplanationOfBenefit.careTeam.provider
TransformerUtilsV2.addCareTeamMember(eob, rxItem, C4BBPractitionerIdentifierType.NPI, C4BBClaimPharmacyTeamRole.PRESCRIBING, Optional.ofNullable(claimGroup.getPrescriberId()));
// This can't use TransformerUtilsV2.addNationalDrugCode because it maps differently
// PROD_SRVC_ID => ExplanationOfBenefit.item.productOrService
rxItem.setProductOrService(TransformerUtilsV2.createCodeableConcept(TransformerConstants.CODING_NDC, null, TransformerUtilsV2.retrieveFDADrugCodeDisplay(claimGroup.getNationalDrugCode()), claimGroup.getNationalDrugCode()));
// QTY_DSPNSD_NUM => ExplanationOfBenefit.item.quantity
rxItem.setQuantity(new SimpleQuantity().setValue(claimGroup.getQuantityDispensed()));
// FILL_NUM => ExplanationOfBenefit.item.quantity.extension
TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.REFILL_NUM).setValue(new SimpleQuantity().setValue(claimGroup.getFillNumber()));
// DAYS_SUPLY_NUM => ExplanationOfBenefit.item.quantity.extension
TransformerUtilsV2.addInformationSlice(eob, C4BBSupportingInfoType.DAYS_SUPPLY).setValue(new SimpleQuantity().setValue(claimGroup.getDaysSupply()));
/*
* This chart is to display the different code values for the different service provider id qualifier
* codes below
* Code Code value
* 01 National Provider Identifier (NPI)
* 06 Unique Physician Identification Number (UPIN)
* 07 National Council for Prescription Drug Programs (NCPDP) provider identifier
* 08 State license number
* 11 Federal tax number
* 99 Other
*/
C4BBOrganizationIdentifierType identifierType;
if (!claimGroup.getServiceProviderId().isEmpty()) {
switch(claimGroup.getServiceProviderIdQualiferCode()) {
case "01":
identifierType = C4BBOrganizationIdentifierType.NPI;
break;
case "06":
identifierType = C4BBOrganizationIdentifierType.UPIN;
break;
case "07":
identifierType = C4BBOrganizationIdentifierType.NCPDP;
break;
case "08":
identifierType = C4BBOrganizationIdentifierType.SL;
break;
case "11":
identifierType = C4BBOrganizationIdentifierType.TAX;
break;
default:
identifierType = null;
break;
}
// SRVC_PRVDR_ID => ExplanationOfBenefit.facility
if (identifierType != null) {
eob.setFacility(TransformerUtilsV2.createIdentifierReference(identifierType, claimGroup.getServiceProviderId()));
}
}
/*
* Storing code values in EOB.information below
*/
// DRUG_CVRG_STUS_CD => ExplanationOfBenefit.supportingInfo.code
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DRUG_CVRG_STUS_CD, CcwCodebookVariable.DRUG_CVRG_STUS_CD, claimGroup.getDrugCoverageStatusCode());
// DAW_PROD_SLCTN_CD => ExplanationOfBenefit.supportingInfo.code
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DAW_PROD_SLCTN_CD, CcwCodebookVariable.DAW_PROD_SLCTN_CD, claimGroup.getDispenseAsWrittenProductSelectionCode());
// DAW_PROD_SLCTN_CD => ExplanationOfBenefit.supportingInfo.code
if (claimGroup.getDispensingStatusCode().isPresent()) {
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DSPNSNG_STUS_CD, CcwCodebookVariable.DSPNSNG_STUS_CD, claimGroup.getDispensingStatusCode());
}
// DRUG_CVRG_STUS_CD => ExplanationOfBenefit.supportingInfo.code
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.DRUG_CVRG_STUS_CD, CcwCodebookVariable.DRUG_CVRG_STUS_CD, claimGroup.getDrugCoverageStatusCode());
// ADJSTMT_DLTN_CD => => ExplanationOfBenefit.supportingInfo.code
if (claimGroup.getAdjustmentDeletionCode().isPresent()) {
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.ADJSTMT_DLTN_CD, CcwCodebookVariable.ADJSTMT_DLTN_CD, claimGroup.getAdjustmentDeletionCode());
}
// NSTD_FRMT_CD => ExplanationOfBenefit.supportingInfo.code
if (claimGroup.getNonstandardFormatCode().isPresent()) {
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.NSTD_FRMT_CD, CcwCodebookVariable.NSTD_FRMT_CD, claimGroup.getNonstandardFormatCode());
}
// PRCNG_EXCPTN_CD => ExplanationOfBenefit.supportingInfo.code
if (claimGroup.getPricingExceptionCode().isPresent()) {
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.PRCNG_EXCPTN_CD, CcwCodebookVariable.PRCNG_EXCPTN_CD, claimGroup.getPricingExceptionCode());
}
// CTSTRPHC_CVRG_CD => ExplanationOfBenefit.supportingInfo.code
if (claimGroup.getCatastrophicCoverageCode().isPresent()) {
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.CTSTRPHC_CVRG_CD, CcwCodebookVariable.CTSTRPHC_CVRG_CD, claimGroup.getCatastrophicCoverageCode());
}
// RX_ORGN_CD => ExplanationOfBenefit.supportingInfo:rxorigincode
TransformerUtilsV2.addInformationSliceWithCode(eob, C4BBSupportingInfoType.RX_ORIGIN_CODE, CcwCodebookVariable.RX_ORGN_CD, CcwCodebookVariable.RX_ORGN_CD, claimGroup.getPrescriptionOriginationCode());
// BRND_GNRC_CD => ExplanationOfBenefit.supportingInfo:brandgenericcode
TransformerUtilsV2.addInformationSliceWithCode(eob, C4BBSupportingInfoType.BRAND_GENERIC_CODE, CcwCodebookVariable.BRND_GNRC_CD, CcwCodebookVariable.BRND_GNRC_CD, claimGroup.getBrandGenericCode());
// PHRMCY_SRVC_TYPE_CD => ExplanationOfBenefit.facility.extension
eob.getFacility().addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.PHRMCY_SRVC_TYPE_CD, claimGroup.getPharmacyTypeCode()));
// PTNT_RSDNC_CD => ExplanationOfBenefit.supportingInfo.code
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.PTNT_RSDNC_CD, CcwCodebookVariable.PTNT_RSDNC_CD, claimGroup.getPatientResidenceCode());
// SUBMSN_CLR_CD => ExplanationOfBenefit.supportingInfo.code
if (claimGroup.getSubmissionClarificationCode().isPresent()) {
TransformerUtilsV2.addInformationWithCode(eob, CcwCodebookVariable.SUBMSN_CLR_CD, CcwCodebookVariable.SUBMSN_CLR_CD, claimGroup.getSubmissionClarificationCode());
}
// Last Updated => ExplanationOfBenefit.meta.lastUpdated
TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
return eob;
}
Aggregations