Search in sources :

Example 1 with Contract

use of org.hl7.fhir.dstu3.model.Contract 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 2 with Contract

use of org.hl7.fhir.dstu3.model.Contract 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 3 with Contract

use of org.hl7.fhir.dstu3.model.Contract 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;
}
Also used : Timer(com.codahale.metrics.Timer) Coverage(org.hl7.fhir.r4.model.Coverage)

Example 4 with Contract

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

the class PatientResourceProviderIT method searchByPartDContractForEmptyContract.

/**
 * Verifies that {@link
 * PatientResourceProvider#searchByCoverageContract(ca.uhn.fhir.rest.param.TokenParam,
 * ca.uhn.fhir.rest.param.TokenParam, String, ca.uhn.fhir.rest.api.server.RequestDetails)} works
 * as expected, when searching for a contract-year-month with no benes.
 */
@Test
public void searchByPartDContractForEmptyContract() {
    ServerTestUtils.get().loadData(Arrays.asList(StaticRifResource.SAMPLE_A_BENES));
    IGenericClient fhirClient = createFhirClientWithIncludeIdentifiersMbi();
    // Should return a single match
    Bundle searchResults = fhirClient.search().forResource(Patient.class).where(new TokenClientParam("_has:Coverage.extension").exactly().systemAndIdentifier(CCWUtils.calculateVariableReferenceUrl(CcwCodebookVariable.PTDCNTRCT01), "A1234")).where(new TokenClientParam("_has:Coverage.rfrncyr").exactly().systemAndIdentifier(CCWUtils.calculateVariableReferenceUrl(CcwCodebookVariable.RFRNC_YR), "2010")).returnBundle(Bundle.class).execute();
    assertNotNull(searchResults);
    assertEquals(0, searchResults.getEntry().size());
}
Also used : TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.dstu3.model.Bundle) Test(org.junit.jupiter.api.Test)

Example 5 with Contract

use of org.hl7.fhir.dstu3.model.Contract in project ab2d by CMSgov.

the class CapabilityStatementR4 method populateCS.

public static CapabilityStatement populateCS(String server) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    CapabilityStatement cs = new CapabilityStatement();
    cs.setPublisher("Centers for Medicare & Medicaid Services");
    cs.setKind(CapabilityStatement.CapabilityStatementKind.REQUIREMENTS);
    cs.setStatus(Enumerations.PublicationStatus.DRAFT);
    try {
        Date lastUpdated = sdf.parse("02/22/2020 00:00:00");
        cs.setDate(lastUpdated);
    } catch (Exception ex) {
        cs.setDate(new Date());
    }
    cs.setFhirVersion(Enumerations.FHIRVersion._4_0_0);
    cs.setPurpose("Defines FHIR R4 (V2) version of AB2D bulk data download");
    CodeType codeType = new CodeType();
    codeType.setValue(APPLICATION_JSON);
    CodeType codeType2 = new CodeType();
    codeType2.setValue("application/fhir+json");
    cs.setFormat(List.of(codeType, codeType2));
    CapabilityStatement.CapabilityStatementSoftwareComponent cssc = new CapabilityStatement.CapabilityStatementSoftwareComponent();
    cssc.setName("AB2D");
    cssc.setVersion("V2");
    try {
        Date releaseDate = sdf.parse("05/01/2020 00:00:00");
        cssc.setReleaseDate(releaseDate);
    } catch (Exception ex) {
        cssc.setReleaseDate(new Date());
    }
    cs.setSoftware(cssc);
    CapabilityStatement.CapabilityStatementImplementationComponent implementation = new CapabilityStatement.CapabilityStatementImplementationComponent();
    implementation.setDescription("AB2D FHIR R4 Bulk Data Download Implementation");
    implementation.setUrl(server);
    cs.setImplementation(implementation);
    CapabilityStatement.CapabilityStatementRestComponent rest = new CapabilityStatement.CapabilityStatementRestComponent();
    rest.setMode(CapabilityStatement.RestfulCapabilityMode.SERVER);
    CapabilityStatement.CapabilityStatementRestSecurityComponent security = new CapabilityStatement.CapabilityStatementRestSecurityComponent();
    security.setCors(true);
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = new Coding();
    coding.setSystem("http://hl7.org/fhir/ValueSet/restful-security-service");
    coding.setCode("OAuth");
    coding.setDisplay("OAuth");
    codeableConcept.setCoding(List.of(coding));
    codeableConcept.setText("OAuth");
    security.setService(List.of(codeableConcept));
    rest.setSecurity(security);
    List<CapabilityStatement.CapabilityStatementRestResourceOperationComponent> restComponents = new ArrayList<>();
    restComponents.add(createOperation("export", server + "/Patient/$export"));
    restComponents.add(createOperation("export by contract", server + "/Group/{contractNumber}/$export"));
    restComponents.add(createOperation("cancel", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("status", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("download", server + "/Job/{jobUuid}/file/{filename}"));
    restComponents.add(createOperation("capability", server + "/metadata"));
    rest.setOperation(restComponents);
    rest.setInteraction(List.of(new CapabilityStatement.SystemInteractionComponent().setCode(CapabilityStatement.SystemRestfulInteraction.BATCH)));
    cs.setRest(List.of(rest));
    return cs;
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) CodeType(org.hl7.fhir.r4.model.CodeType) SimpleDateFormat(java.text.SimpleDateFormat) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)17 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)12 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)12 Timer (com.codahale.metrics.Timer)6 Test (org.junit.jupiter.api.Test)6 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)4 CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)4 CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)4 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)4 ArrayList (java.util.ArrayList)4 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)3 CoverageSearchEvent (gov.cms.ab2d.coverage.model.CoverageSearchEvent)3 Coverage (org.hl7.fhir.dstu3.model.Coverage)3 Job (gov.cms.ab2d.common.model.Job)2 PdpClient (gov.cms.ab2d.common.model.PdpClient)2 Identifiers (gov.cms.ab2d.coverage.model.Identifiers)2 LogManager (gov.cms.ab2d.eventlogger.LogManager)2 BundleUtils.createPatient (gov.cms.ab2d.worker.processor.BundleUtils.createPatient)2 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)2 HashMap (java.util.HashMap)2