Search in sources :

Example 1 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project beneficiary-fhir-data by CMSgov.

the class BeneficiaryTransformerV2 method transform.

/**
 * @param beneficiary the CCW {@link Beneficiary} to transform
 * @param requestHeader {@link RequestHeaders} the holder that contains all supported resource
 *     request headers
 * @return a FHIR {@link Patient} resource that represents the specified {@link Beneficiary}
 */
private static Patient transform(Beneficiary beneficiary, RequestHeaders requestHeader) {
    Objects.requireNonNull(beneficiary);
    Patient patient = new Patient();
    /*
     * Notify end users when they receive Patient records impacted by
     * https://jira.cms.gov/browse/BFD-1566. See the documentation on
     * LoadAppOptions.isFilteringNonNullAndNon2022Benes() for details.
     */
    if (!beneficiary.getSkippedRifRecords().isEmpty()) {
        patient.getMeta().addTag(TransformerConstants.CODING_SYSTEM_BFD_TAGS, TransformerConstants.CODING_BFD_TAGS_DELAYED_BACKDATED_ENROLLMENT, TransformerConstants.CODING_BFD_TAGS_DELAYED_BACKDATED_ENROLLMENT_DISPLAY);
    }
    // Required values not directly mapped
    patient.getMeta().addProfile(ProfileConstants.C4BB_PATIENT_URL);
    patient.setId(beneficiary.getBeneficiaryId());
    // BENE_ID => patient.identifier
    TransformerUtilsV2.addIdentifierSlice(patient, TransformerUtilsV2.createCodeableConcept(TransformerConstants.CODING_SYSTEM_HL7_IDENTIFIER_TYPE, null, TransformerConstants.PATIENT_MB_ID_DISPLAY, "MB"), Optional.of(beneficiary.getBeneficiaryId()), Optional.of(TransformerConstants.CODING_BBAPI_BENE_ID));
    // Unhashed MBI
    if (beneficiary.getMedicareBeneficiaryId().isPresent()) {
        Period mbiPeriod = new Period();
        if (beneficiary.getMbiEffectiveDate().isPresent()) {
            TransformerUtilsV2.setPeriodStart(mbiPeriod, beneficiary.getMbiEffectiveDate().get());
        }
        if (beneficiary.getMbiObsoleteDate().isPresent()) {
            TransformerUtilsV2.setPeriodEnd(mbiPeriod, beneficiary.getMbiObsoleteDate().get());
        }
        addUnhashedIdentifier(patient, beneficiary.getMedicareBeneficiaryId().get(), TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED, TransformerUtilsV2.createIdentifierCurrencyExtension(CurrencyIdentifier.CURRENT), mbiPeriod);
    }
    // Add lastUpdated
    TransformerUtilsV2.setLastUpdated(patient, beneficiary.getLastUpdated());
    /**
     * The following logic attempts to distill {@link MedicareBeneficiaryIdHistory} data into only
     * those records which have an endDate present. This is due to the fact that it includes the
     * CURRENT MBI record which was handle previously. Also, the {@link
     * MedicareBeneficiaryIdHistory} table appears to contain spurious records with the only
     * difference is the generated surrogate key identifier.
     */
    if (requestHeader.isMBIinIncludeIdentifiers()) {
        HashMap<LocalDate, MedicareBeneficiaryIdHistory> mbiHistMap = new HashMap<LocalDate, MedicareBeneficiaryIdHistory>();
        for (MedicareBeneficiaryIdHistory mbiHistory : beneficiary.getMedicareBeneficiaryIdHistories()) {
            // and will have been previously provided as the CURRENT rcd.
            if (mbiHistory.getMbiEndDate().isPresent()) {
                mbiHistMap.put(mbiHistory.getMbiEndDate().get(), mbiHistory);
            }
            // would come in ascending order, so any rcd would have a later
            // update date than prev rcd.
            TransformerUtilsV2.updateMaxLastUpdated(patient, mbiHistory.getLastUpdated());
        }
        if (mbiHistMap.size() > 0) {
            Extension historicalIdentifier = TransformerUtilsV2.createIdentifierCurrencyExtension(CurrencyIdentifier.HISTORIC);
            for (MedicareBeneficiaryIdHistory mbi : mbiHistMap.values()) {
                addUnhashedIdentifier(patient, mbi.getMedicareBeneficiaryId().get(), TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED, historicalIdentifier, null);
            }
        }
    }
    // support header includeAddressFields from downstream components e.g. BB2
    // per requirement of BFD-379, BB2 always send header includeAddressFields = False
    Boolean addrHdrVal = requestHeader.getValue(R4PatientResourceProvider.HEADER_NAME_INCLUDE_ADDRESS_FIELDS);
    if (addrHdrVal != null && addrHdrVal) {
        patient.addAddress().setState(beneficiary.getStateCode()).setPostalCode(beneficiary.getPostalCode()).setCity(beneficiary.getDerivedCityName().orElse(null)).addLine(beneficiary.getDerivedMailingAddress1().orElse(null)).addLine(beneficiary.getDerivedMailingAddress2().orElse(null)).addLine(beneficiary.getDerivedMailingAddress3().orElse(null)).addLine(beneficiary.getDerivedMailingAddress4().orElse(null)).addLine(beneficiary.getDerivedMailingAddress5().orElse(null)).addLine(beneficiary.getDerivedMailingAddress6().orElse(null));
    } else {
        patient.addAddress().setState(beneficiary.getStateCode()).setPostalCode(beneficiary.getPostalCode());
    }
    if (beneficiary.getBirthDate() != null) {
        patient.setBirthDate(TransformerUtilsV2.convertToDate(beneficiary.getBirthDate()));
    }
    // "Patient.deceased[x]": ["boolean", "dateTime"],
    if (beneficiary.getBeneficiaryDateOfDeath().isPresent()) {
        patient.setDeceased(new DateTimeType(TransformerUtilsV2.convertToDate(beneficiary.getBeneficiaryDateOfDeath().get()), TemporalPrecisionEnum.DAY));
    } else {
        patient.setDeceased(new BooleanType(false));
    }
    char sex = beneficiary.getSex();
    if (sex == Sex.MALE.getCode())
        patient.setGender((AdministrativeGender.MALE));
    else if (sex == Sex.FEMALE.getCode())
        patient.setGender((AdministrativeGender.FEMALE));
    else
        patient.setGender((AdministrativeGender.UNKNOWN));
    if (beneficiary.getRace().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.RACE, beneficiary.getRace().get()));
        // for race category, v2 will just treat all race codes as Unknown (UNK);
        // thus we'll simply pass in the Unknown race code .
        RaceCategory raceCategory = TransformerUtilsV2.getRaceCategory('0');
        Extension raceChildOMBExt1 = new Extension().setValue(new Coding().setCode(raceCategory.toCode()).setSystem(raceCategory.getSystem()).setDisplay(raceCategory.getDisplay())).setUrl("ombCategory");
        Extension raceChildOMBExt2 = new Extension().setValue(new StringType().setValue(raceCategory.getDisplay())).setUrl("text");
        Extension parentOMBRace = new Extension().setUrl(TransformerConstants.CODING_RACE_US);
        parentOMBRace.addExtension(raceChildOMBExt1);
        parentOMBRace.addExtension(raceChildOMBExt2);
        patient.addExtension(parentOMBRace);
    }
    HumanName name = patient.addName().addGiven(beneficiary.getNameGiven()).setFamily(beneficiary.getNameSurname()).setUse(HumanName.NameUse.USUAL);
    if (beneficiary.getNameMiddleInitial().isPresent()) {
        name.addGiven(String.valueOf(beneficiary.getNameMiddleInitial().get()));
    }
    // The reference year of the enrollment data
    if (beneficiary.getBeneEnrollmentReferenceYear().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionDate(CcwCodebookVariable.RFRNC_YR, beneficiary.getBeneEnrollmentReferenceYear()));
    }
    // Monthly Medicare-Medicaid dual eligibility codes
    if (beneficiary.getMedicaidDualEligibilityJanCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_01, beneficiary.getMedicaidDualEligibilityJanCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityFebCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_02, beneficiary.getMedicaidDualEligibilityFebCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityMarCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_03, beneficiary.getMedicaidDualEligibilityMarCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityAprCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_04, beneficiary.getMedicaidDualEligibilityAprCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityMayCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_05, beneficiary.getMedicaidDualEligibilityMayCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityJunCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_06, beneficiary.getMedicaidDualEligibilityJunCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityJulCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_07, beneficiary.getMedicaidDualEligibilityJulCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityAugCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_08, beneficiary.getMedicaidDualEligibilityAugCode()));
    }
    if (beneficiary.getMedicaidDualEligibilitySeptCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_09, beneficiary.getMedicaidDualEligibilitySeptCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityOctCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_10, beneficiary.getMedicaidDualEligibilityOctCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityNovCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_11, beneficiary.getMedicaidDualEligibilityNovCode()));
    }
    if (beneficiary.getMedicaidDualEligibilityDecCode().isPresent()) {
        patient.addExtension(TransformerUtilsV2.createExtensionCoding(patient, CcwCodebookVariable.DUAL_12, beneficiary.getMedicaidDualEligibilityDecCode()));
    }
    // Last Updated => Patient.meta.lastUpdated
    TransformerUtilsV2.setLastUpdated(patient, beneficiary.getLastUpdated());
    return patient;
}
Also used : HashMap(java.util.HashMap) StringType(org.hl7.fhir.r4.model.StringType) BooleanType(org.hl7.fhir.r4.model.BooleanType) Patient(org.hl7.fhir.r4.model.Patient) Period(org.hl7.fhir.r4.model.Period) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) LocalDate(java.time.LocalDate) Extension(org.hl7.fhir.r4.model.Extension) HumanName(org.hl7.fhir.r4.model.HumanName) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Coding(org.hl7.fhir.r4.model.Coding) RaceCategory(gov.cms.bfd.server.war.commons.RaceCategory)

Example 2 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project beneficiary-fhir-data by CMSgov.

the class CarrierClaimTransformerTest method assertMatches.

/**
 * Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
 * the specified {@link CarrierClaim}.
 *
 * @param claim the {@link CarrierClaim} that the {@link ExplanationOfBenefit} was generated from
 * @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
 *     CarrierClaim}
 * @param includedTaxNumbers whether or not to include tax numbers are expected to be included in
 *     the result (see {@link
 *     ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
 *     false</code>)
 * @throws FHIRException (indicates test failure)
 */
static void assertMatches(CarrierClaim claim, ExplanationOfBenefit eob, Optional<Boolean> includedTaxNumbers) throws FHIRException {
    // Test to ensure group level fields between all claim types match
    TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.CARRIER, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
    // Test to ensure common group fields between Carrier and DME match
    TransformerTestUtils.assertEobCommonGroupCarrierDMEEquals(eob, claim.getBeneficiaryId(), claim.getCarrierNumber(), claim.getClinicalTrialNumber(), claim.getBeneficiaryPartBDeductAmount(), claim.getPaymentDenialCode(), claim.getReferringPhysicianNpi(), claim.getProviderAssignmentIndicator(), claim.getProviderPaymentAmount(), claim.getBeneficiaryPaymentAmount(), claim.getSubmittedChargeAmount(), claim.getAllowedChargeAmount());
    assertEquals(5, eob.getDiagnosis().size());
    assertEquals(1, eob.getItem().size());
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.PRPAYAMT, claim.getPrimaryPayerPaidAmount(), eob);
    CarrierClaimLine claimLine1 = claim.getLines().get(0);
    ItemComponent eobItem0 = eob.getItem().get(0);
    assertEquals(claimLine1.getLineNumber(), new BigDecimal(eobItem0.getSequence()));
    TransformerTestUtils.assertCareTeamEquals(claimLine1.getPerformingPhysicianNpi().get(), ClaimCareteamrole.PRIMARY, eob);
    CareTeamComponent performingCareTeamEntry = TransformerTestUtils.findCareTeamEntryForProviderNpi(claimLine1.getPerformingPhysicianNpi().get(), eob.getCareTeam());
    TransformerTestUtils.assertHasCoding(CcwCodebookVariable.PRVDR_SPCLTY, claimLine1.getProviderSpecialityCode(), performingCareTeamEntry.getQualification());
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.CARR_LINE_PRVDR_TYPE_CD, claimLine1.getProviderTypeCode(), performingCareTeamEntry);
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRTCPTNG_IND_CD, claimLine1.getProviderParticipatingIndCode(), performingCareTeamEntry);
    TransformerTestUtils.assertExtensionCodingEquals(performingCareTeamEntry, TransformerConstants.CODING_NPI_US, TransformerConstants.CODING_NPI_US, "" + claimLine1.getOrganizationNpi().get());
    CareTeamComponent taxNumberCareTeamEntry = TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(claimLine1.getProviderTaxNumber(), eob.getCareTeam());
    if (includedTaxNumbers.orElse(false)) {
        assertNotNull(taxNumberCareTeamEntry);
    } else {
        assertNull(taxNumberCareTeamEntry);
    }
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRVDR_STATE_CD, claimLine1.getProviderStateCode(), eobItem0.getLocation());
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.PRVDR_STATE_CD, claimLine1.getProviderStateCode(), eobItem0.getLocation());
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.CARR_LINE_PRCNG_LCLTY_CD, claimLine1.getLinePricingLocalityCode(), eobItem0.getLocation());
    TransformerTestUtils.assertHasCoding(TransformerConstants.CODING_SYSTEM_HCPCS, "" + claim.getHcpcsYearCode().get(), null, claimLine1.getHcpcsCode().get(), eobItem0.getService().getCoding());
    assertEquals(1, eobItem0.getModifier().size());
    TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), claimLine1.getHcpcsInitialModifierCode(), claimLine1.getHcpcsSecondModifierCode(), claim.getHcpcsYearCode(), 0);
    if (claimLine1.getAnesthesiaUnitCount().compareTo(BigDecimal.ZERO) > 0) {
        TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.CARR_LINE_ANSTHSA_UNIT_CNT, claimLine1.getAnesthesiaUnitCount(), eobItem0.getService());
    }
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.CARR_LINE_MTUS_CD, claimLine1.getMtusCode(), eobItem0);
    TransformerTestUtils.assertExtensionQuantityEquals(CcwCodebookVariable.CARR_LINE_MTUS_CNT, claimLine1.getMtusCount(), eobItem0);
    TransformerTestUtils.assertAdjudicationReasonEquals(CcwCodebookVariable.CARR_LINE_RDCD_PMT_PHYS_ASTN_C, claimLine1.getReducedPaymentPhysicianAsstCode(), eobItem0.getAdjudication());
    TransformerTestUtils.assertExtensionIdentifierEquals(CcwCodebookVariable.CARR_LINE_CLIA_LAB_NUM, claimLine1.getCliaLabNumber(), eobItem0.getLocation());
    // verify {@link
    // TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
    // method worked as expected for this claim type
    TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.CARRIER, Optional.of(org.hl7.fhir.dstu3.model.codesystems.ClaimType.PROFESSIONAL), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
    // Test to ensure common item fields between Carrier and DME match
    TransformerTestUtils.assertEobCommonItemCarrierDMEEquals(eobItem0, eob, claimLine1.getServiceCount(), claimLine1.getPlaceOfServiceCode(), claimLine1.getFirstExpenseDate(), claimLine1.getLastExpenseDate(), claimLine1.getBeneficiaryPaymentAmount(), claimLine1.getProviderPaymentAmount(), claimLine1.getBeneficiaryPartBDeductAmount(), claimLine1.getPrimaryPayerCode(), claimLine1.getPrimaryPayerPaidAmount(), claimLine1.getBetosCode(), claimLine1.getPaymentAmount(), claimLine1.getPaymentCode(), claimLine1.getCoinsuranceAmount(), claimLine1.getSubmittedChargeAmount(), claimLine1.getAllowedChargeAmount(), claimLine1.getProcessingIndicatorCode(), claimLine1.getServiceDeductibleCode(), claimLine1.getDiagnosisCode(), claimLine1.getDiagnosisCodeVersion(), claimLine1.getHctHgbTestTypeCode(), claimLine1.getHctHgbTestResult(), claimLine1.getCmsServiceTypeCode(), claimLine1.getNationalDrugCode());
    // Test lastUpdated
    TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
Also used : CarrierClaimLine(gov.cms.bfd.model.rif.CarrierClaimLine) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) CareTeamComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.CareTeamComponent) BigDecimal(java.math.BigDecimal)

Example 3 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project beneficiary-fhir-data by CMSgov.

the class OutpatientClaimTransformerTest method assertMatches.

/**
 * Verifies that the {@link ExplanationOfBenefit} "looks like" it should, if it were produced from
 * the specified {@link OutpatientClaim}.
 *
 * @param claim the {@link OutpatientClaim} that the {@link ExplanationOfBenefit} was generated
 *     from
 * @param eob the {@link ExplanationOfBenefit} that was generated from the specified {@link
 *     OutpatientClaim}
 * @throws FHIRException (indicates test failure)
 */
static void assertMatches(OutpatientClaim claim, ExplanationOfBenefit eob) throws FHIRException {
    // Test to ensure group level fields between all claim types match
    TransformerTestUtils.assertEobCommonClaimHeaderData(eob, claim.getClaimId(), claim.getBeneficiaryId(), ClaimType.OUTPATIENT, claim.getClaimGroupId().toPlainString(), MedicareSegment.PART_B, Optional.of(claim.getDateFrom()), Optional.of(claim.getDateThrough()), Optional.of(claim.getPaymentAmount()), claim.getFinalAction());
    // test the common field provider number is set as expected in the EOB
    TransformerTestUtils.assertProviderNumber(eob, claim.getProviderNumber());
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.NCH_BENE_PTB_DDCTBL_AMT, claim.getDeductibleAmount(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.NCH_PROFNL_CMPNT_CHRG_AMT, claim.getProfessionalComponentCharge(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.NCH_BENE_PTB_COINSRNC_AMT, claim.getCoinsuranceAmount(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.CLM_OP_PRVDR_PMT_AMT, claim.getProviderPaymentAmount(), eob);
    TransformerTestUtils.assertAdjudicationTotalAmountEquals(CcwCodebookVariable.CLM_OP_BENE_PMT_AMT, claim.getBeneficiaryPaymentAmount(), eob);
    // Test to ensure common group fields between Inpatient, Outpatient and SNF
    TransformerTestUtils.assertEobCommonGroupInpOutSNFEquals(eob, claim.getBloodDeductibleLiabilityAmount(), claim.getOperatingPhysicianNpi(), claim.getOtherPhysicianNpi(), claim.getClaimQueryCode(), claim.getMcoPaidSw());
    // Test to ensure common group fields between Inpatient, Outpatient HHA, Hospice
    // and SNF match
    TransformerTestUtils.assertEobCommonGroupInpOutHHAHospiceSNFEquals(eob, claim.getOrganizationNpi(), claim.getClaimFacilityTypeCode(), claim.getClaimFrequencyCode(), claim.getClaimNonPaymentReasonCode(), claim.getPatientDischargeStatusCode().get(), claim.getClaimServiceClassificationTypeCode(), claim.getClaimPrimaryPayerCode(), claim.getAttendingPhysicianNpi(), claim.getTotalChargeAmount(), claim.getPrimaryPayerPaidAmount(), claim.getFiscalIntermediaryNumber(), claim.getFiDocumentClaimControlNumber(), claim.getFiOriginalClaimControlNumber());
    assertTrue(countDiagnosisCodes(claim) >= eob.getDiagnosis().size(), "Expect actual diagnosis count is less than or equal to the claim count");
    if (claim.getProcedure1Code().isPresent()) {
        CCWProcedure ccwProcedure = new CCWProcedure(claim.getProcedure1Code(), claim.getProcedure1CodeVersion(), claim.getProcedure1Date());
        TransformerTestUtils.assertHasCoding(ccwProcedure.getFhirSystem().toString(), claim.getProcedure1Code().get(), eob.getProcedure().get(0).getProcedureCodeableConcept().getCoding());
        assertEquals(claim.getProcedure1Date().get().atStartOfDay(ZoneId.systemDefault()).toInstant(), eob.getProcedure().get(0).getDate().toInstant());
    }
    assertTrue(1 <= eob.getItem().size(), "Expect actual item count is above 0");
    ItemComponent eobItem0 = eob.getItem().get(0);
    OutpatientClaimLine claimLine1 = claim.getLines().get(0);
    assertEquals(new Integer(claimLine1.getLineNumber().intValue()), new Integer(eobItem0.getSequence()));
    assertEquals(claim.getProviderStateCode(), eobItem0.getLocationAddress().getState());
    // TODO re-map as described in CBBF-111
    /*
     * TransformerTestUtils.assertHasCoding(TransformerConstants.CODING_NDC,
     * claimLine1.getNationalDrugCode().get(), eobItem0.getService());
     */
    TransformerTestUtils.assertAdjudicationReasonEquals(CcwCodebookVariable.REV_CNTR_1ST_ANSI_CD, claimLine1.getRevCntr1stAnsiCd(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationReasonEquals(CcwCodebookVariable.REV_CNTR_2ND_ANSI_CD, claimLine1.getRevCntr2ndAnsiCd(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationReasonEquals(CcwCodebookVariable.REV_CNTR_3RD_ANSI_CD, claimLine1.getRevCntr3rdAnsiCd(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationReasonEquals(CcwCodebookVariable.REV_CNTR_4TH_ANSI_CD, claimLine1.getRevCntr4thAnsiCd(), eobItem0.getAdjudication());
    TransformerTestUtils.assertHcpcsCodes(eobItem0, claimLine1.getHcpcsCode(), claimLine1.getHcpcsInitialModifierCode(), claimLine1.getHcpcsSecondModifierCode(), Optional.empty(), 0);
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.REV_CNTR_IDE_NDC_UPC_NUM, claimLine1.getNationalDrugCode(), eobItem0.getService());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_BLOOD_DDCTBL_AMT, claimLine1.getBloodDeductibleAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_CASH_DDCTBL_AMT, claimLine1.getCashDeductibleAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_COINSRNC_WGE_ADJSTD_C, claimLine1.getWageAdjustedCoinsuranceAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_RDCD_COINSRNC_AMT, claimLine1.getReducedCoinsuranceAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_1ST_MSP_PD_AMT, claimLine1.getFirstMspPaidAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_1ST_MSP_PD_AMT, claimLine1.getSecondMspPaidAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_PRVDR_PMT_AMT, claimLine1.getProviderPaymentAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_BENE_PMT_AMT, claimLine1.getBenficiaryPaymentAmount(), eobItem0.getAdjudication());
    TransformerTestUtils.assertAdjudicationAmountEquals(CcwCodebookVariable.REV_CNTR_PTNT_RSPNSBLTY_PMT, claimLine1.getPatientResponsibilityAmount(), eobItem0.getAdjudication());
    String claimControlNumber = "0000000000";
    // Test to ensure item level fields between Inpatient, Outpatient, HHA, Hopsice
    // and SNF match
    TransformerTestUtils.assertEobCommonItemRevenueEquals(eobItem0, eob, claimLine1.getRevenueCenterCode(), claimLine1.getRateAmount(), claimLine1.getTotalChargeAmount(), claimLine1.getNonCoveredChargeAmount(), claimLine1.getUnitCount(), claimControlNumber, claimLine1.getNationalDrugCodeQuantity(), claimLine1.getNationalDrugCodeQualifierCode(), claimLine1.getRevenueCenterRenderingPhysicianNPI(), 1);
    // Test to ensure item level fields between Outpatient, HHA and Hospice match
    TransformerTestUtils.assertEobCommonItemRevenueOutHHAHospice(eobItem0, claimLine1.getRevenueCenterDate(), claimLine1.getPaymentAmount());
    // verify {@link
    // TransformerUtils#mapEobType(CodeableConcept,ClaimType,Optional,Optional)}
    // method worked as expected for this claim type
    TransformerTestUtils.assertMapEobType(eob.getType(), ClaimType.OUTPATIENT, Optional.of(org.hl7.fhir.dstu3.model.codesystems.ClaimType.PROFESSIONAL), Optional.of(claim.getNearLineRecordIdCode()), Optional.of(claim.getClaimTypeCode()));
    TransformerTestUtils.assertExtensionCodingEquals(CcwCodebookVariable.REV_CNTR_STUS_IND_CD, claimLine1.getStatusCode(), eobItem0.getRevenue());
    // Test lastUpdated
    TransformerTestUtils.assertLastUpdatedEquals(claim.getLastUpdated(), eob);
}
Also used : CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) OutpatientClaimLine(gov.cms.bfd.model.rif.OutpatientClaimLine)

Example 4 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project kindling by HL7.

the class OldSpreadsheetParser method scanNestedTypes.

private void scanNestedTypes(ResourceDefn parent, ElementDefn root, String parentName) throws Exception {
    for (ElementDefn element : root.getElements()) {
        if (element.hasNestedElements()) {
            String nestedTypeName;
            ElementDefn newCompositeType = new ElementDefn();
            // generated name for this nested type
            if (element.typeCode().startsWith("=")) {
                if (isProfile)
                    throw new Exception("Cannot use '=' types in profiles on " + parentName);
                element.setStatedType(element.typeCode().substring(1));
                nestedTypeName = element.typeCode().substring(1);
            } else {
                nestedTypeName = parentName + Utilities.capitalize(element.getName());
            }
            newCompositeType.setAnonymousTypedGroup(true);
            // Add Component to the actually generated name to avoid
            // confusing between the element name and the element's type
            newCompositeType.setName(nestedTypeName + "Component");
            newCompositeType.setDefinition("A nested type in " + parent.getName() + ": " + element.getDefinition());
            newCompositeType.getElements().addAll(element.getElements());
            if (parent.getRoot().getNestedTypes().containsKey(nestedTypeName))
                throw new Exception("Nested type " + nestedTypeName + " already exist in resource " + parent.getName());
            parent.getRoot().getNestedTypes().put(nestedTypeName, newCompositeType);
            // Clear out the name of the local type, so old code
            // will not see a change.
            element.getTypes().clear();
            element.setDeclaredTypeName(newCompositeType.getName());
            scanNestedTypes(parent, element, nestedTypeName);
        }
    }
}
Also used : ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 5 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project kindling by HL7.

the class XSDBaseGenerator method generate.

public void generate(String version, String genDate, boolean outer) throws Exception {
    if (outer) {
        write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
        write("<!-- \r\n");
        write(Config.FULL_LICENSE_CODE);
        write("\r\n");
        write("  Generated on " + genDate + " for FHIR v" + version + " \r\n");
        write("\r\n");
        write("  Note: the schemas &amp; schematrons do not contain all of the rules about what makes resources\r\n");
        write("  valid. Implementers will still need to be familiar with the content of the specification and with\r\n");
        write("  any profiles that apply to the resources in order to make a conformant implementation.\r\n");
        write("\r\n");
        write("-->\r\n");
        write("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://hl7.org/fhir\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" " + "targetNamespace=\"http://hl7.org/fhir\" elementFormDefault=\"qualified\" version=\"1.0\">\r\n");
    }
    write("  <xs:import namespace=\"http://www.w3.org/XML/1998/namespace\" schemaLocation=\"xml.xsd\"/>\r\n");
    write("  <xs:import namespace=\"http://www.w3.org/1999/xhtml\" schemaLocation=\"fhir-xhtml.xsd\"/>\r\n");
    if (outer)
        write("  <xs:include schemaLocation=\"fhir-all.xsd\"/>\r\n");
    // genElementRoot();
    write("\r\n");
    genPrimitives();
    write("\r\n");
    genResourceReference();
    genResourceContainer();
    for (ElementDefn e : definitions.getInfrastructure().values()) genInfrastructure(e);
    for (ElementDefn e : definitions.getTypes().values()) genType(e);
    for (String n : definitions.getBaseResources().keySet()) {
        ResourceDefn r = definitions.getBaseResources().get(n);
        if (r.isAbstract()) {
            genResource(n, r);
        }
    }
    // todo: what to do about this?
    for (BindingSpecification b : definitions.getCommonBindings().values()) if (((b.getUseContexts().size() > 1 || b.isShared()) && isEnum(b)))
        generateEnum(b);
    if (outer) {
        write("</xs:schema>\r\n");
        writer.flush();
    }
}
Also used : ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)37 FHIRException (org.hl7.fhir.exceptions.FHIRException)28 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)24 IOException (java.io.IOException)22 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19 Test (org.junit.Test)18 UnsupportedEncodingException (java.io.UnsupportedEncodingException)14 FileOutputStream (java.io.FileOutputStream)8 ItemComponent (org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent)8 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)8 ParseException (java.text.ParseException)7 BigDecimal (java.math.BigDecimal)6 Narrative (org.hl7.fhir.dstu3.model.Narrative)6 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)6 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)6 XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)6 HashMap (java.util.HashMap)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 OutputStreamWriter (java.io.OutputStreamWriter)4 ArrayList (java.util.ArrayList)4