use of org.hl7.fhir.r4.model.ExplanationOfBenefit 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 org.hl7.fhir.r4.model.ExplanationOfBenefit in project beneficiary-fhir-data by CMSgov.
the class InpatientClaimTransformer 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();
// Common group level fields between all claim types
TransformerUtils.mapEobCommonClaimHeaderData(eob, claimGroup.getClaimId(), claimGroup.getBeneficiaryId(), ClaimType.INPATIENT, 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.INPATIENT, Optional.of(claimGroup.getNearLineRecordIdCode()), Optional.of(claimGroup.getClaimTypeCode()));
// set the provider number which is common among several claim types
TransformerUtils.setProviderNumber(eob, claimGroup.getProviderNumber());
if (claimGroup.getPatientStatusCd().isPresent()) {
TransformerUtils.addInformationWithCode(eob, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, CcwCodebookVariable.NCH_PTNT_STUS_IND_CD, claimGroup.getPatientStatusCd());
}
// 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.getCoveredCareThoughDate(), claimGroup.getMedicareBenefitsExhaustedDate(), claimGroup.getDiagnosisRelatedGroupCd());
// Claim Operational Indirect Medical Education Amount
if (claimGroup.getIndirectMedicalEducationAmount().isPresent()) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.IME_OP_CLM_VAL_AMT, claimGroup.getIndirectMedicalEducationAmount());
}
// Claim Operational disproportionate Amount
if (claimGroup.getDisproportionateShareAmount().isPresent()) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.DSH_OP_CLM_VAL_AMT, claimGroup.getDisproportionateShareAmount());
}
// TODO If actually nullable, should be Optional.
if (claimGroup.getPassThruPerDiemAmount() != null) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.CLM_PASS_THRU_PER_DIEM_AMT, claimGroup.getPassThruPerDiemAmount());
}
// TODO If actually nullable, should be Optional.
if (claimGroup.getProfessionalComponentCharge() != null) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.NCH_PROFNL_CMPNT_CHRG_AMT, claimGroup.getProfessionalComponentCharge());
}
// TODO If actually nullable, should be Optional.
if (claimGroup.getClaimTotalPPSCapitalAmount() != null) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.CLM_TOT_PPS_CPTL_AMT, claimGroup.getClaimTotalPPSCapitalAmount());
}
if (claimGroup.getIndirectMedicalEducationAmount().isPresent()) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.IME_OP_CLM_VAL_AMT, claimGroup.getIndirectMedicalEducationAmount().get());
}
// Claim Uncompensated Care Payment Amount
if (claimGroup.getClaimUncompensatedCareAmount().isPresent()) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.CLM_UNCOMPD_CARE_PMT_AMT, claimGroup.getClaimUncompensatedCareAmount().get());
}
/*
* 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());
// TODO If this is actually nullable, should be Optional.
if (claimGroup.getDrgOutlierApprovedPaymentAmount() != null) {
TransformerUtils.addAdjudicationTotal(eob, CcwCodebookVariable.NCH_DRG_OUTLIER_APRVD_PMT_AMT, claimGroup.getDrgOutlierApprovedPaymentAmount());
}
// 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());
// Common group level fields between Inpatient, HHA, Hospice and SNF
TransformerUtils.mapEobCommonGroupInpHHAHospiceSNF(eob, claimGroup.getClaimAdmissionDate(), claimGroup.getBeneficiaryDischargeDate(), Optional.of(claimGroup.getUtilizationDayCount()));
for (Diagnosis diagnosis : extractDiagnoses(claimGroup)) 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 (InpatientClaimLine claimLine : claimGroup.getLines()) {
ItemComponent item = eob.addItem();
item.setSequence(claimLine.getLineNumber().intValue());
TransformerUtils.mapHcpcs(eob, item, Optional.empty(), claimLine.getHcpcsCode(), Collections.emptyList());
item.setLocation(new Address().setState((claimGroup.getProviderStateCode())));
// Common item level fields between Inpatient, Outpatient, HHA, Hospice and SNF
TransformerUtils.mapEobCommonItemRevenue(item, eob, claimLine.getRevenueCenter(), claimLine.getRateAmount(), claimLine.getTotalChargeAmount(), claimLine.getNonCoveredChargeAmount(), 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 org.hl7.fhir.r4.model.ExplanationOfBenefit in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method mapHcpcs.
/**
* @param eob the {@link ExplanationOfBenefit} that the HCPCS code is being mapped into
* @param item the {@link ItemComponent} that the HCPCS code is being mapped into
* @param year the {@link CcwCodebookVariable#CARR_CLM_HCPCS_YR_CD} identifying the HCPCS code
* version in use
* @param modifiers the {@link CcwCodebookVariable#HCPCS_1ST_MDFR_CD}, etc. values to be mapped
* (if any)
*/
static void mapHcpcs(ExplanationOfBenefit eob, ItemComponent item, Optional<String> hcpcsCode, Optional<Character> year, List<Optional<String>> modifiers) {
hcpcsCode.ifPresent(code -> item.setProductOrService(createCodeableConcept(TransformerConstants.CODING_SYSTEM_HCPCS, code)));
for (Optional<String> hcpcsModifier : modifiers) {
if (hcpcsModifier.isPresent()) {
CodeableConcept modifier = createCodeableConcept(TransformerConstants.CODING_SYSTEM_HCPCS, hcpcsModifier.get());
// Set Coding.version for all of the mappings, if it's available.
if (year.isPresent()) {
// Note: Only CARRIER and DME claims have the year/version field.
modifier.getCodingFirstRep().setVersion(year.get().toString());
}
item.addModifier(modifier);
}
}
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method mapEobType.
/**
* maps a blue button claim type to a FHIR claim type
*
* @param eob the {@link CodeableConcept} that will get remapped
* @param blueButtonClaimType the blue button {@link ClaimTypeV2} we are mapping from
* @param ccwNearLineRecordIdCode if present, the blue button near line id code {@link
* Optional}<{@link Character}> gets remapped to a ccw record id code
* @param ccwClaimTypeCode if present, the blue button claim type code {@link Optional}<{@link
* String}> gets remapped to a nch claim type code
*/
static void mapEobType(ExplanationOfBenefit eob, ClaimTypeV2 blueButtonClaimType, Optional<Character> ccwNearLineRecordIdCode, Optional<String> ccwClaimTypeCode) {
// NCH_CLM_TYPE_CD => ExplanationOfBenefit.type.coding
if (ccwClaimTypeCode.isPresent()) {
eob.getType().addCoding(createCoding(eob, CcwCodebookVariable.NCH_CLM_TYPE_CD, ccwClaimTypeCode));
}
// This Coding MUST always be present as it's the only one we can definitely map
// for all 8 of our claim types.
// EOB Type => ExplanationOfBenefit.type.coding
eob.getType().addCoding().setSystem(TransformerConstants.CODING_SYSTEM_BBAPI_EOB_TYPE).setCode(blueButtonClaimType.name());
// Map a Coding for FHIR's ClaimType coding system, if we can.
org.hl7.fhir.r4.model.codesystems.ClaimType fhirClaimType;
switch(blueButtonClaimType) {
case PDE:
fhirClaimType = org.hl7.fhir.r4.model.codesystems.ClaimType.PHARMACY;
break;
case INPATIENT:
case OUTPATIENT:
case HOSPICE:
case SNF:
case DME:
fhirClaimType = org.hl7.fhir.r4.model.codesystems.ClaimType.INSTITUTIONAL;
break;
case CARRIER:
case HHA:
fhirClaimType = org.hl7.fhir.r4.model.codesystems.ClaimType.PROFESSIONAL;
break;
default:
// All options on ClaimTypeV2 are covered above, but this is there to appease linter
throw new BadCodeMonkeyException("No match found for ClaimTypeV2");
}
// Claim Type => ExplanationOfBenefit.type.coding
if (fhirClaimType != null) {
eob.getType().addCoding(new Coding(fhirClaimType.getSystem(), fhirClaimType.toCode(), fhirClaimType.getDisplay()));
}
// NCH_NEAR_LINE_REC_IDENT_CD => ExplanationOfBenefit.extension
if (ccwNearLineRecordIdCode.isPresent()) {
eob.addExtension(createExtensionCoding(eob, CcwCodebookVariable.NCH_NEAR_LINE_REC_IDENT_CD, ccwNearLineRecordIdCode));
}
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method findOrCreateContainedOrg.
/**
* Looks for an {@link Organization} with the given resource ID in {@link
* ExplanationOfBenefit#getContained()} or adds one if it doesn't exist
*
* @param eob the {@link ExplanationOfBenefit} to modify
* @param id The resource ID
* @return The found or new {@link Organization} resource
*/
static Resource findOrCreateContainedOrg(ExplanationOfBenefit eob, String id) {
Optional<Resource> org = eob.getContained().stream().filter(r -> r.getId() == id).findFirst();
// If it isn't there, add one
if (!org.isPresent()) {
org = Optional.of(new Organization().setId(id));
org.get().getMeta().addProfile(ProfileConstants.C4BB_ORGANIZATION_URL);
eob.getContained().add(org.get());
}
return org.get();
}
Aggregations