Search in sources :

Example 1 with Coverage

use of org.hl7.fhir.dstu3.model.Coverage in project beneficiary-fhir-data by CMSgov.

the class TransformerUtils method addResourcesToBundle.

/**
 * @param bundle a {@link Bundle} to add the list of {@link ExplanationOfBenefit} resources to.
 * @param resources a list of either {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
 *     Patient}s, of which a portion will be added to the bundle based on the paging values
 * @return Returns a {@link Bundle} of {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
 *     Patient}s, which may contain multiple matching resources, or may also be empty.
 */
public static Bundle addResourcesToBundle(Bundle bundle, List<IBaseResource> resources) {
    Set<String> beneIds = new HashSet<String>();
    for (IBaseResource res : resources) {
        BundleEntryComponent entry = bundle.addEntry();
        entry.setResource((Resource) res);
        if (entry.getResource().getResourceType() == ResourceType.ExplanationOfBenefit) {
            ExplanationOfBenefit eob = ((ExplanationOfBenefit) entry.getResource());
            if (eob != null && eob.getPatient() != null && !Strings.isNullOrEmpty(eob.getPatient().getReference())) {
                String reference = eob.getPatient().getReference().replace("Patient/", "");
                if (!Strings.isNullOrEmpty(reference)) {
                    beneIds.add(reference);
                }
            }
        } else if (entry.getResource().getResourceType() == ResourceType.Patient) {
            Patient patient = ((Patient) entry.getResource());
            if (patient != null && !Strings.isNullOrEmpty(patient.getId())) {
                beneIds.add(patient.getId());
            }
        } else if (entry.getResource().getResourceType() == ResourceType.Coverage) {
            Coverage coverage = ((Coverage) entry.getResource());
            if (coverage != null && coverage.getBeneficiary() != null && !Strings.isNullOrEmpty(coverage.getBeneficiary().getReference())) {
                String reference = coverage.getBeneficiary().getReference().replace("Patient/", "");
                if (!Strings.isNullOrEmpty(reference)) {
                    beneIds.add(reference);
                }
            }
        }
    }
    logBeneIdToMdc(beneIds);
    return bundle;
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Patient(org.hl7.fhir.dstu3.model.Patient) Coverage(org.hl7.fhir.dstu3.model.Coverage) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) HashSet(java.util.HashSet)

Example 2 with Coverage

use of org.hl7.fhir.dstu3.model.Coverage in project beneficiary-fhir-data by CMSgov.

the class CoverageResourceProvider method searchByBeneficiary.

/**
 * Adds support for the FHIR "search" operation for {@link Coverage}s, allowing users to search by
 * {@link Coverage#getBeneficiary()}.
 *
 * <p>The {@link Search} annotation indicates that this method supports the search operation.
 * There may be many different methods annotated with this {@link Search} annotation, to support
 * many different search criteria.
 *
 * @param beneficiary a {@link ReferenceParam} for the {@link Coverage#getBeneficiary()} to try
 *     and find matches for
 * @param startIndex an {@link OptionalParam} for the startIndex (or offset) used to determine
 *     pagination
 * @param lastUpdated an {@link OptionalParam} to filter the results based on the passed date
 *     range
 * @param requestDetails a {@link RequestDetails} containing the details of the request URL, used
 *     to parse out pagination values
 * @return Returns a {@link List} of {@link Coverage}s, which may contain multiple matching
 *     resources, or may also be empty.
 */
@Search
@Trace
public Bundle searchByBeneficiary(@RequiredParam(name = Coverage.SP_BENEFICIARY) @Description(shortDefinition = "The patient identifier to search for") ReferenceParam beneficiary, @OptionalParam(name = "startIndex") @Description(shortDefinition = "The offset used for result pagination") String startIndex, @OptionalParam(name = "_lastUpdated") @Description(shortDefinition = "Include resources last updated in the given range") DateRangeParam lastUpdated, RequestDetails requestDetails) {
    List<IBaseResource> coverages;
    try {
        Beneficiary beneficiaryEntity = findBeneficiaryById(beneficiary.getIdPart(), lastUpdated);
        if (!beneficiaryEntity.getBeneEnrollmentReferenceYear().isPresent()) {
            throw new ResourceNotFoundException("Cannot find coverage for non present enrollment year");
        }
        coverages = CoverageTransformer.transform(metricRegistry, beneficiaryEntity);
    } catch (NoResultException e) {
        coverages = new LinkedList<IBaseResource>();
    }
    OffsetLinkBuilder paging = new OffsetLinkBuilder(requestDetails, "/Coverage?");
    Operation operation = new Operation(Operation.Endpoint.V1_COVERAGE);
    operation.setOption("by", "beneficiary");
    operation.setOption("pageSize", paging.isPagingRequested() ? "" + paging.getPageSize() : "*");
    operation.setOption("_lastUpdated", Boolean.toString(lastUpdated != null && !lastUpdated.isEmpty()));
    operation.publishOperationName();
    // Add bene_id to MDC logs
    TransformerUtils.logBeneIdToMdc(Arrays.asList(beneficiary.getIdPart()));
    return TransformerUtils.createBundle(paging, coverages, loadedFilterManager.getTransactionTime());
}
Also used : OffsetLinkBuilder(gov.cms.bfd.server.war.commons.OffsetLinkBuilder) NoResultException(javax.persistence.NoResultException) Operation(gov.cms.bfd.server.war.Operation) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) LinkedList(java.util.LinkedList) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Trace(com.newrelic.api.agent.Trace) Search(ca.uhn.fhir.rest.annotation.Search)

Example 3 with Coverage

use of org.hl7.fhir.dstu3.model.Coverage in project beneficiary-fhir-data by CMSgov.

the class CoverageTransformer method transformPartA.

/**
 * @param metricRegistry the {@link MetricRegistry} to use
 * @param beneficiary the {@link Beneficiary} to generate a {@link MedicareSegment#PART_A} {@link
 *     Coverage} resource for
 * @return {@link MedicareSegment#PART_A} {@link Coverage} resource for the specified {@link
 *     Beneficiary}
 */
private static Coverage transformPartA(MetricRegistry metricRegistry, Beneficiary beneficiary) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name(CoverageTransformer.class.getSimpleName(), "transform", "part_a")).time();
    Objects.requireNonNull(beneficiary);
    Coverage coverage = new Coverage();
    coverage.setId(TransformerUtils.buildCoverageId(MedicareSegment.PART_A, beneficiary));
    if (beneficiary.getPartATerminationCode().isPresent() && beneficiary.getPartATerminationCode().get().equals('0'))
        coverage.setStatus(CoverageStatus.ACTIVE);
    else
        coverage.setStatus(CoverageStatus.CANCELLED);
    if (beneficiary.getMedicareCoverageStartDate().isPresent()) {
        TransformerUtils.setPeriodStart(coverage.getPeriod(), beneficiary.getMedicareCoverageStartDate().get());
    }
    // deh start
    coverage.addContract().setId("ptc-contract1");
    Contract newContract = new Contract();
    LocalDate localDate = LocalDate.now();
    newContract.setIdentifier(new Identifier().setSystem("part C System").setValue("contract 5555"));
    newContract.setApplies((new Period().setStart((TransformerUtils.convertToDate(localDate)), TemporalPrecisionEnum.DAY)));
    coverage.addContained(newContract);
    coverage.addContract(TransformerUtils.referenceCoverage("contract1 reference", MedicareSegment.PART_A));
    coverage.getGrouping().setSubGroup(TransformerConstants.COVERAGE_PLAN).setSubPlan(TransformerConstants.COVERAGE_PLAN_PART_A);
    coverage.setType(TransformerUtils.createCodeableConcept(TransformerConstants.COVERAGE_PLAN, TransformerConstants.COVERAGE_PLAN_PART_A));
    coverage.setBeneficiary(TransformerUtils.referencePatient(beneficiary));
    if (beneficiary.getMedicareEnrollmentStatusCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.MS_CD, beneficiary.getMedicareEnrollmentStatusCode()));
    }
    if (beneficiary.getEntitlementCodeOriginal().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.OREC, beneficiary.getEntitlementCodeOriginal()));
    }
    if (beneficiary.getEntitlementCodeCurrent().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.CREC, beneficiary.getEntitlementCodeCurrent()));
    }
    if (beneficiary.getEndStageRenalDiseaseCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.ESRD_IND, beneficiary.getEndStageRenalDiseaseCode()));
    }
    if (beneficiary.getPartATerminationCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.A_TRM_CD, beneficiary.getPartATerminationCode()));
    }
    // The reference year of the enrollment data
    if (beneficiary.getBeneEnrollmentReferenceYear().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionDate(CcwCodebookVariable.RFRNC_YR, beneficiary.getBeneEnrollmentReferenceYear()));
    }
    // Monthly Medicare-Medicaid dual eligibility codes
    if (beneficiary.getMedicaidDualEligibilityJanCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_01, beneficiary.getMedicaidDualEligibilityJanCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityFebCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_02, beneficiary.getMedicaidDualEligibilityFebCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityMarCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_03, beneficiary.getMedicaidDualEligibilityMarCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityAprCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_04, beneficiary.getMedicaidDualEligibilityAprCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityMayCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_05, beneficiary.getMedicaidDualEligibilityMayCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityJunCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_06, beneficiary.getMedicaidDualEligibilityJunCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityJulCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_07, beneficiary.getMedicaidDualEligibilityJulCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityAugCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_08, beneficiary.getMedicaidDualEligibilityAugCode()));
    }
    if (beneficiary.getMedicaidDualEligibilitySeptCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_09, beneficiary.getMedicaidDualEligibilitySeptCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityOctCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_10, beneficiary.getMedicaidDualEligibilityOctCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityNovCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_11, beneficiary.getMedicaidDualEligibilityNovCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityDecCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_12, beneficiary.getMedicaidDualEligibilityDecCode()));
    }
    transformEntitlementBuyInIndicators(coverage, beneficiary);
    TransformerUtils.setLastUpdated(coverage, beneficiary.getLastUpdated());
    timer.stop();
    return coverage;
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Timer(com.codahale.metrics.Timer) Period(org.hl7.fhir.dstu3.model.Period) Coverage(org.hl7.fhir.dstu3.model.Coverage) Contract(org.hl7.fhir.dstu3.model.Contract) LocalDate(java.time.LocalDate)

Example 4 with Coverage

use of org.hl7.fhir.dstu3.model.Coverage in project beneficiary-fhir-data by CMSgov.

the class CoverageTransformer 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 = metricRegistry.timer(MetricRegistry.name(CoverageTransformer.class.getSimpleName(), "transform", "part_c")).time();
    Objects.requireNonNull(beneficiary);
    Coverage coverage = new Coverage();
    coverage.setId(TransformerUtils.buildCoverageId(MedicareSegment.PART_C, beneficiary));
    coverage.setStatus(CoverageStatus.ACTIVE);
    coverage.getGrouping().setSubGroup(TransformerConstants.COVERAGE_PLAN).setSubPlan(TransformerConstants.COVERAGE_PLAN_PART_C);
    coverage.setType(TransformerUtils.createCodeableConcept(TransformerConstants.COVERAGE_PLAN, TransformerConstants.COVERAGE_PLAN_PART_C));
    coverage.setBeneficiary(TransformerUtils.referencePatient(beneficiary));
    // Contract Number
    if (beneficiary.getPartCContractNumberJanId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_01, beneficiary.getPartCContractNumberJanId()));
    }
    if (beneficiary.getPartCContractNumberFebId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_02, beneficiary.getPartCContractNumberFebId()));
    }
    if (beneficiary.getPartCContractNumberMarId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_03, beneficiary.getPartCContractNumberMarId()));
    }
    if (beneficiary.getPartCContractNumberAprId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_04, beneficiary.getPartCContractNumberAprId()));
    }
    if (beneficiary.getPartCContractNumberMayId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_05, beneficiary.getPartCContractNumberMayId()));
    }
    if (beneficiary.getPartCContractNumberJunId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_06, beneficiary.getPartCContractNumberJunId()));
    }
    if (beneficiary.getPartCContractNumberJulId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_07, beneficiary.getPartCContractNumberJulId()));
    }
    if (beneficiary.getPartCContractNumberAugId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_08, beneficiary.getPartCContractNumberAugId()));
    }
    if (beneficiary.getPartCContractNumberSeptId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_09, beneficiary.getPartCContractNumberSeptId()));
    }
    if (beneficiary.getPartCContractNumberOctId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_10, beneficiary.getPartCContractNumberOctId()));
    }
    if (beneficiary.getPartCContractNumberNovId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_11, beneficiary.getPartCContractNumberNovId()));
    }
    if (beneficiary.getPartCContractNumberDecId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_CNTRCT_ID_12, beneficiary.getPartCContractNumberDecId()));
    }
    // PBP
    if (beneficiary.getPartCPbpNumberJanId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_01, beneficiary.getPartCPbpNumberJanId()));
    }
    if (beneficiary.getPartCPbpNumberFebId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_02, beneficiary.getPartCPbpNumberFebId()));
    }
    if (beneficiary.getPartCPbpNumberMarId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_03, beneficiary.getPartCPbpNumberMarId()));
    }
    if (beneficiary.getPartCPbpNumberAprId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_04, beneficiary.getPartCPbpNumberAprId()));
    }
    if (beneficiary.getPartCPbpNumberMayId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_05, beneficiary.getPartCPbpNumberMayId()));
    }
    if (beneficiary.getPartCPbpNumberJunId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_06, beneficiary.getPartCPbpNumberJunId()));
    }
    if (beneficiary.getPartCPbpNumberJulId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_07, beneficiary.getPartCPbpNumberJulId()));
    }
    if (beneficiary.getPartCPbpNumberAugId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_08, beneficiary.getPartCPbpNumberAugId()));
    }
    if (beneficiary.getPartCPbpNumberSeptId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_09, beneficiary.getPartCPbpNumberSeptId()));
    }
    if (beneficiary.getPartCPbpNumberOctId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_10, beneficiary.getPartCPbpNumberOctId()));
    }
    if (beneficiary.getPartCPbpNumberNovId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_11, beneficiary.getPartCPbpNumberNovId()));
    }
    if (beneficiary.getPartCPbpNumberDecId().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PBP_ID_12, beneficiary.getPartCPbpNumberDecId()));
    }
    // Plan Type
    if (beneficiary.getPartCPlanTypeJanCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_01, beneficiary.getPartCPlanTypeJanCode()));
    }
    if (beneficiary.getPartCPlanTypeFebCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_02, beneficiary.getPartCPlanTypeFebCode()));
    }
    if (beneficiary.getPartCPlanTypeMarCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_03, beneficiary.getPartCPlanTypeMarCode()));
    }
    if (beneficiary.getPartCPlanTypeAprCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_04, beneficiary.getPartCPlanTypeAprCode()));
    }
    if (beneficiary.getPartCPlanTypeMayCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_05, beneficiary.getPartCPlanTypeMayCode()));
    }
    if (beneficiary.getPartCPlanTypeJunCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_06, beneficiary.getPartCPlanTypeJunCode()));
    }
    if (beneficiary.getPartCPlanTypeJulCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_07, beneficiary.getPartCPlanTypeJulCode()));
    }
    if (beneficiary.getPartCPlanTypeAugCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_08, beneficiary.getPartCPlanTypeAugCode()));
    }
    if (beneficiary.getPartCPlanTypeSeptCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_09, beneficiary.getPartCPlanTypeSeptCode()));
    }
    if (beneficiary.getPartCPlanTypeOctCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_10, beneficiary.getPartCPlanTypeOctCode()));
    }
    if (beneficiary.getPartCPlanTypeNovCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_11, beneficiary.getPartCPlanTypeNovCode()));
    }
    if (beneficiary.getPartCPlanTypeDecCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.PTC_PLAN_TYPE_CD_12, beneficiary.getPartCPlanTypeDecCode()));
    }
    // Monthly Medicare Advantage (MA) enrollment indicators:
    if (beneficiary.getHmoIndicatorJanInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_01, beneficiary.getHmoIndicatorJanInd()));
    }
    if (beneficiary.getHmoIndicatorFebInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_02, beneficiary.getHmoIndicatorFebInd()));
    }
    if (beneficiary.getHmoIndicatorMarInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_03, beneficiary.getHmoIndicatorMarInd()));
    }
    if (beneficiary.getHmoIndicatorAprInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_04, beneficiary.getHmoIndicatorAprInd()));
    }
    if (beneficiary.getHmoIndicatorMayInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_05, beneficiary.getHmoIndicatorMayInd()));
    }
    if (beneficiary.getHmoIndicatorJunInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_06, beneficiary.getHmoIndicatorJunInd()));
    }
    if (beneficiary.getHmoIndicatorJulInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_07, beneficiary.getHmoIndicatorJulInd()));
    }
    if (beneficiary.getHmoIndicatorAugInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_08, beneficiary.getHmoIndicatorAugInd()));
    }
    if (beneficiary.getHmoIndicatorSeptInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_09, beneficiary.getHmoIndicatorSeptInd()));
    }
    if (beneficiary.getHmoIndicatorOctInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_10, beneficiary.getHmoIndicatorOctInd()));
    }
    if (beneficiary.getHmoIndicatorNovInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_11, beneficiary.getHmoIndicatorNovInd()));
    }
    if (beneficiary.getHmoIndicatorDecInd().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.HMO_IND_12, beneficiary.getHmoIndicatorDecInd()));
    }
    TransformerUtils.setLastUpdated(coverage, beneficiary.getLastUpdated());
    // The reference year of the enrollment data
    if (beneficiary.getBeneEnrollmentReferenceYear().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionDate(CcwCodebookVariable.RFRNC_YR, beneficiary.getBeneEnrollmentReferenceYear()));
    }
    // Monthly Medicare-Medicaid dual eligibility codes
    if (beneficiary.getMedicaidDualEligibilityJanCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_01, beneficiary.getMedicaidDualEligibilityJanCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityFebCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_02, beneficiary.getMedicaidDualEligibilityFebCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityMarCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_03, beneficiary.getMedicaidDualEligibilityMarCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityAprCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_04, beneficiary.getMedicaidDualEligibilityAprCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityMayCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_05, beneficiary.getMedicaidDualEligibilityMayCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityJunCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_06, beneficiary.getMedicaidDualEligibilityJunCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityJulCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_07, beneficiary.getMedicaidDualEligibilityJulCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityAugCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_08, beneficiary.getMedicaidDualEligibilityAugCode()));
    }
    if (beneficiary.getMedicaidDualEligibilitySeptCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_09, beneficiary.getMedicaidDualEligibilitySeptCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityOctCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_10, beneficiary.getMedicaidDualEligibilityOctCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityNovCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_11, beneficiary.getMedicaidDualEligibilityNovCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityDecCode().isPresent()) {
        coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_12, beneficiary.getMedicaidDualEligibilityDecCode()));
    }
    timer.stop();
    return coverage;
}
Also used : Timer(com.codahale.metrics.Timer) Coverage(org.hl7.fhir.dstu3.model.Coverage)

Example 5 with Coverage

use of org.hl7.fhir.dstu3.model.Coverage in project beneficiary-fhir-data by CMSgov.

the class OutpatientClaimTransformerV2Test method shouldReferenceCoverageInInsurance.

/**
 * Insurance
 */
@Test
public void shouldReferenceCoverageInInsurance() {
    // Only one insurance object
    assertEquals(1, eob.getInsurance().size());
    InsuranceComponent insurance = eob.getInsuranceFirstRep();
    InsuranceComponent compare = new InsuranceComponent().setCoverage(new Reference().setReference("Coverage/part-b-567834"));
    assertTrue(compare.equalsDeep(insurance));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) InsuranceComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.InsuranceComponent) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)29 Coverage (org.hl7.fhir.r4.model.Coverage)28 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)16 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)16 MedicareSegment (gov.cms.bfd.server.war.commons.MedicareSegment)15 Coverage (org.hl7.fhir.dstu3.model.Coverage)15 Reference (org.hl7.fhir.r4.model.Reference)14 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)13 Arrays (java.util.Arrays)13 Instant (java.time.Instant)12 List (java.util.List)12 Date (java.util.Date)11 Constants (ca.uhn.fhir.rest.api.Constants)10 Timer (com.codahale.metrics.Timer)10 Bundle (org.hl7.fhir.r4.model.Bundle)10 Logger (org.slf4j.Logger)10 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)9 Patient (org.hl7.fhir.r4.model.Patient)9 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)9 Resource (org.hl7.fhir.r4.model.Resource)8