use of org.hl7.fhir.r4.model.Type 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;
}
use of org.hl7.fhir.r4.model.Type in project beneficiary-fhir-data by CMSgov.
the class R4CoverageResourceProvider method read.
/**
* Adds support for the FHIR "read" operation, for {@link Coverage}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 coverageId The read operation takes one parameter, which must be of type {@link IdType}
* and must be annotated with the {@link IdParam} annotation.
* @return Returns a resource matching the specified {@link IdDt}, or <code>null</code> if none
* exists.
*/
@Read(version = false)
@Trace
public Coverage read(@IdParam IdType coverageId) {
if (coverageId == null)
throw new IllegalArgumentException();
if (coverageId.getVersionIdPartAsLong() != null)
throw new IllegalArgumentException();
String coverageIdText = coverageId.getIdPart();
if (coverageIdText == null || coverageIdText.trim().isEmpty())
throw new IllegalArgumentException();
Operation operation = new Operation(Operation.Endpoint.V2_COVERAGE);
operation.setOption("by", "id");
operation.publishOperationName();
Matcher coverageIdMatcher = COVERAGE_ID_PATTERN.matcher(coverageIdText);
if (!coverageIdMatcher.matches())
throw new IllegalArgumentException("Unsupported ID pattern: " + coverageIdText);
String coverageIdSegmentText = coverageIdMatcher.group(1);
Optional<MedicareSegment> coverageIdSegment = MedicareSegment.selectByUrlPrefix(coverageIdSegmentText);
if (!coverageIdSegment.isPresent())
throw new ResourceNotFoundException(coverageId);
String coverageIdBeneficiaryIdText = coverageIdMatcher.group(2);
Beneficiary beneficiaryEntity;
try {
beneficiaryEntity = findBeneficiaryById(coverageIdBeneficiaryIdText, null);
if (!beneficiaryEntity.getBeneEnrollmentReferenceYear().isPresent()) {
throw new ResourceNotFoundException("Cannot find coverage for non present enrollment year");
}
} catch (NoResultException e) {
throw new ResourceNotFoundException(new IdDt(Beneficiary.class.getSimpleName(), coverageIdBeneficiaryIdText));
}
Coverage coverage = CoverageTransformerV2.transform(metricRegistry, coverageIdSegment.get(), beneficiaryEntity);
return coverage;
}
use of org.hl7.fhir.r4.model.Type 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.r4.model.Type in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProvider method compareByClaimIdThenClaimType.
/*
* @param eob1 an {@link ExplanationOfBenefit} to be compared
*
* @param eob2 an {@link ExplanationOfBenefit} to be compared
*/
private static int compareByClaimIdThenClaimType(IBaseResource res1, IBaseResource res2) {
/*
* In order for paging to be meaningful (and stable), the claims have to be
* consistently sorted across different app server instances (in case page 1
* comes from Server A but page 2 comes from Server B). Right now, we don't have
* anything "useful" to sort by, so we just sort by claim ID (subsorted by claim
* type). TODO once we have metadata from BLUEBUTTON-XXX on when each claim was
* first loaded into our DB, we should sort by that.
*/
ExplanationOfBenefit eob1 = (ExplanationOfBenefit) res1;
ExplanationOfBenefit eob2 = (ExplanationOfBenefit) res2;
if (TransformerUtilsV2.getUnprefixedClaimId(eob1).equals(TransformerUtilsV2.getUnprefixedClaimId(eob2))) {
return TransformerUtilsV2.getClaimType(eob1).compareTo(TransformerUtilsV2.getClaimType(eob2));
} else {
return TransformerUtilsV2.getUnprefixedClaimId(eob1).compareTo(TransformerUtilsV2.getUnprefixedClaimId(eob2));
}
}
use of org.hl7.fhir.r4.model.Type 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;
}
Aggregations