use of org.hl7.fhir.dstu2016may.model.Resource in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProvider method read.
/**
* Adds support for the FHIR "read" operation, for {@link ExplanationOfBenefit}s. The {@link Read}
* annotation indicates that this method supports the read operation.
*
* <p>Read operations take a single parameter annotated with {@link IdParam}, and should return a
* single resource instance.
*
* @param eobId The read operation takes one parameter, which must be of type {@link IdType} and
* must be annotated with the {@link IdParam} annotation.
* @param requestDetails the request details for the read
* @return Returns a resource matching the specified {@link IdDt}, or <code>null</code> if none
* exists.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Read(version = false)
@Trace
public ExplanationOfBenefit read(@IdParam IdType eobId, RequestDetails requestDetails) {
if (eobId == null)
throw new IllegalArgumentException();
if (eobId.getVersionIdPartAsLong() != null)
throw new IllegalArgumentException();
String eobIdText = eobId.getIdPart();
if (eobIdText == null || eobIdText.trim().isEmpty())
throw new IllegalArgumentException();
Matcher eobIdMatcher = EOB_ID_PATTERN.matcher(eobIdText);
if (!eobIdMatcher.matches())
throw new IllegalArgumentException("Unsupported ID pattern: " + eobIdText);
String eobIdTypeText = eobIdMatcher.group(1);
Optional<ClaimTypeV2> eobIdType = ClaimTypeV2.parse(eobIdTypeText);
if (!eobIdType.isPresent())
throw new ResourceNotFoundException(eobId);
String eobIdClaimIdText = eobIdMatcher.group(2);
boolean includeTaxNumbers = returnIncludeTaxNumbers(requestDetails);
Operation operation = new Operation(Operation.Endpoint.V2_EOB);
operation.setOption("IncludeTaxNumbers", "" + includeTaxNumbers);
operation.setOption("by", "id");
operation.publishOperationName();
Class<?> entityClass = eobIdType.get().getEntityClass();
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery criteria = builder.createQuery(entityClass);
Root root = criteria.from(entityClass);
eobIdType.get().getEntityLazyAttributes().stream().forEach(a -> root.fetch(a));
criteria.select(root);
criteria.where(builder.equal(root.get(eobIdType.get().getEntityIdAttribute()), eobIdClaimIdText));
Object claimEntity = null;
Long eobByIdQueryNanoSeconds = null;
Timer.Context timerEobQuery = metricRegistry.timer(MetricRegistry.name(getClass().getSimpleName(), "query", "eob_by_id")).time();
try {
claimEntity = entityManager.createQuery(criteria).getSingleResult();
} catch (NoResultException e) {
throw new ResourceNotFoundException(eobId);
} finally {
eobByIdQueryNanoSeconds = timerEobQuery.stop();
TransformerUtilsV2.recordQueryInMdc("eob_by_id", eobByIdQueryNanoSeconds, claimEntity == null ? 0 : 1);
}
ExplanationOfBenefit eob = eobIdType.get().getTransformer().transform(metricRegistry, claimEntity, Optional.of(includeTaxNumbers));
return eob;
}
use of org.hl7.fhir.dstu2016may.model.Resource in project beneficiary-fhir-data by CMSgov.
the class CoverageTransformerV2 method transformPartB.
/**
* @param metricRegistry the {@link MetricRegistry} to use
* @param beneficiary the {@link Beneficiary} to generate a {@link MedicareSegment#PART_B} {@link
* Coverage} resource for
* @return {@link MedicareSegment#PART_B} {@link Coverage} resource for the specified {@link
* Beneficiary}
*/
private static Coverage transformPartB(MetricRegistry metricRegistry, Beneficiary beneficiary) {
Timer.Context timer = getTimerContext(metricRegistry, "part_b");
Coverage coverage = new Coverage();
coverage.getMeta().addProfile(ProfileConstants.C4BB_COVERAGE_URL);
coverage.setId(TransformerUtilsV2.buildCoverageId(MedicareSegment.PART_B, beneficiary));
setCoverageStatus(coverage, beneficiary.getPartBTerminationCode());
TransformerUtilsV2.setPeriodStart(coverage.getPeriod(), beneficiary.getMedicareCoverageStartDate());
beneficiary.getMedicareBeneficiaryId().ifPresent(value -> coverage.setSubscriberId(value));
setTypeAndIssuer(coverage);
setCoverageRelationship(coverage, SubscriberPolicyRelationship.SELF);
createCoverageClass(coverage, CoverageClass.GROUP, TransformerConstants.COVERAGE_PLAN, Optional.empty());
createCoverageClass(coverage, CoverageClass.PLAN, TransformerConstants.COVERAGE_PLAN_PART_B, Optional.empty());
coverage.setBeneficiary(TransformerUtilsV2.referencePatient(beneficiary));
addCoverageExtension(coverage, CcwCodebookVariable.MS_CD, beneficiary.getMedicareEnrollmentStatusCode());
addCoverageCodeExtension(coverage, CcwCodebookVariable.B_TRM_CD, beneficiary.getPartATerminationCode());
addCoverageDecimalExtension(coverage, CcwCodebookVariable.RFRNC_YR, beneficiary.getBeneEnrollmentReferenceYear());
// Monthly Medicare-Medicaid dual eligibility codes
transformEntitlementDualEligibility(coverage, beneficiary);
// Medicare Entitlement Buy In Indicator
transformEntitlementBuyInIndicators(coverage, beneficiary);
// update Coverage.meta.lastUpdated
TransformerUtilsV2.setLastUpdated(coverage, beneficiary.getLastUpdated());
timer.stop();
return coverage;
}
use of org.hl7.fhir.dstu2016may.model.Resource in project beneficiary-fhir-data by CMSgov.
the class CoverageTransformerV2 method transformPartC.
/**
* @param metricRegistry the {@link MetricRegistry} to use
* @param beneficiary the {@link Beneficiary} to generate a {@link MedicareSegment#PART_C} {@link
* Coverage} resource for
* @return {@link MedicareSegment#PART_C} {@link Coverage} resource for the specified {@link
* Beneficiary}
*/
private static Coverage transformPartC(MetricRegistry metricRegistry, Beneficiary beneficiary) {
Timer.Context timer = getTimerContext(metricRegistry, "part_c");
Coverage coverage = new Coverage();
coverage.getMeta().addProfile(ProfileConstants.C4BB_COVERAGE_URL);
coverage.setId(TransformerUtilsV2.buildCoverageId(MedicareSegment.PART_C, beneficiary));
coverage.setStatus(CoverageStatus.ACTIVE);
beneficiary.getMedicareBeneficiaryId().ifPresent(value -> coverage.setSubscriberId(value));
setTypeAndIssuer(coverage);
setCoverageRelationship(coverage, SubscriberPolicyRelationship.SELF);
createCoverageClass(coverage, CoverageClass.GROUP, TransformerConstants.COVERAGE_PLAN, Optional.empty());
createCoverageClass(coverage, CoverageClass.PLAN, TransformerConstants.COVERAGE_PLAN_PART_C, Optional.empty());
coverage.setBeneficiary(TransformerUtilsV2.referencePatient(beneficiary));
// Contract Number
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_01, beneficiary.getPartCContractNumberJanId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_02, beneficiary.getPartCContractNumberFebId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_03, beneficiary.getPartCContractNumberMarId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_04, beneficiary.getPartCContractNumberAprId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_05, beneficiary.getPartCContractNumberMayId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_06, beneficiary.getPartCContractNumberJunId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_07, beneficiary.getPartCContractNumberJulId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_08, beneficiary.getPartCContractNumberAugId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_09, beneficiary.getPartCContractNumberSeptId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_10, beneficiary.getPartCContractNumberOctId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_11, beneficiary.getPartCContractNumberNovId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_12, beneficiary.getPartCContractNumberDecId());
// PBP
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_01, beneficiary.getPartCPbpNumberJanId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_02, beneficiary.getPartCPbpNumberFebId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_03, beneficiary.getPartCPbpNumberMarId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_04, beneficiary.getPartCPbpNumberAprId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_05, beneficiary.getPartCPbpNumberMayId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_06, beneficiary.getPartCPbpNumberJunId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_07, beneficiary.getPartCPbpNumberJulId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_08, beneficiary.getPartCPbpNumberAugId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_09, beneficiary.getPartCPbpNumberSeptId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_10, beneficiary.getPartCPbpNumberOctId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_11, beneficiary.getPartCPbpNumberNovId());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PBP_ID_12, beneficiary.getPartCPbpNumberDecId());
// Plan Type
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_01, beneficiary.getPartCPlanTypeJanCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_02, beneficiary.getPartCPlanTypeFebCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_03, beneficiary.getPartCPlanTypeMarCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_04, beneficiary.getPartCPlanTypeAprCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_05, beneficiary.getPartCPlanTypeMayCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_06, beneficiary.getPartCPlanTypeJunCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_07, beneficiary.getPartCPlanTypeJulCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_08, beneficiary.getPartCPlanTypeAugCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_09, beneficiary.getPartCPlanTypeSeptCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_10, beneficiary.getPartCPlanTypeOctCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_11, beneficiary.getPartCPlanTypeNovCode());
addCoverageExtension(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_12, beneficiary.getPartCPlanTypeDecCode());
// Monthly Medicare Advantage (MA) enrollment indicators:
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_01, beneficiary.getHmoIndicatorJanInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_02, beneficiary.getHmoIndicatorFebInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_03, beneficiary.getHmoIndicatorMarInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_04, beneficiary.getHmoIndicatorAprInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_05, beneficiary.getHmoIndicatorMayInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_06, beneficiary.getHmoIndicatorJunInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_07, beneficiary.getHmoIndicatorJulInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_08, beneficiary.getHmoIndicatorAugInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_09, beneficiary.getHmoIndicatorSeptInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_10, beneficiary.getHmoIndicatorOctInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_11, beneficiary.getHmoIndicatorNovInd());
addCoverageCodeExtension(coverage, CcwCodebookVariable.HMO_IND_12, beneficiary.getHmoIndicatorDecInd());
// The reference year of the enrollment data
addCoverageDecimalExtension(coverage, CcwCodebookVariable.RFRNC_YR, beneficiary.getBeneEnrollmentReferenceYear());
// Monthly Medicare-Medicaid dual eligibility codes
transformEntitlementDualEligibility(coverage, beneficiary);
// update Coverage.meta.lastUpdated
TransformerUtilsV2.setLastUpdated(coverage, beneficiary.getLastUpdated());
timer.stop();
return coverage;
}
use of org.hl7.fhir.dstu2016may.model.Resource in project beneficiary-fhir-data by CMSgov.
the class DMEClaimTransformerV2 method transform.
/**
* @param metricRegistry the {@link MetricRegistry} to use
* @param claim the CCW {@link DMEClaim} to transform
* @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
* DMEClaim}
*/
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
Timer.Context timer = metricRegistry.timer(MetricRegistry.name(DMEClaimTransformerV2.class.getSimpleName(), "transform")).time();
if (!(claim instanceof DMEClaim)) {
throw new BadCodeMonkeyException();
}
ExplanationOfBenefit eob = transformClaim((DMEClaim) claim, includeTaxNumbers);
timer.stop();
return eob;
}
use of org.hl7.fhir.dstu2016may.model.Resource in project beneficiary-fhir-data by CMSgov.
the class DMEClaimTransformerV2 method transformClaim.
/**
* @param claimGroup the CCW {@link DMEClaim} to transform
* @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
* DMEClaim}
*/
private static ExplanationOfBenefit transformClaim(DMEClaim claimGroup, Optional<Boolean> includeTaxNumbers) {
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)pwd
// 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.DME, 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 (Professional) => ExplanationOfBenefit.type.coding
// NCH_NEAR_LINE_REC_IDENT_CD => ExplanationOfBenefit.extension
TransformerUtilsV2.mapEobType(eob, ClaimTypeV2.DME, 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()));
// NCH_WKLY_PROC_DT => ExplanationOfBenefit.supportinginfo.timingDate
TransformerUtilsV2.addInformation(eob, TransformerUtilsV2.createInformationRecievedDateSlice(eob, CcwCodebookVariable.NCH_WKLY_PROC_DT, Optional.of(claimGroup.getWeeklyProcessDate())));
// 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(), Optional.of(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.DME);
}
// CARR_CLM_ENTRY_CD => ExplanationOfBenefit.extension
eob.addExtension(TransformerUtilsV2.createExtensionCoding(eob, CcwCodebookVariable.CARR_CLM_ENTRY_CD, claimGroup.getClaimEntryCode()));
handleClaimLines(claimGroup, eob, includeTaxNumbers);
TransformerUtilsV2.setLastUpdated(eob, claimGroup.getLastUpdated());
return eob;
}
Aggregations