Search in sources :

Example 46 with DateType

use of org.hl7.fhir.r4.model.DateType in project beneficiary-fhir-data by CMSgov.

the class DMEClaimTransformerV2Test method shouldHaveClaimReceivedDateSupInfo.

@Test
public void shouldHaveClaimReceivedDateSupInfo() {
    SupportingInformationComponent sic = TransformerTestUtilsV2.findSupportingInfoByCode("clmrecvddate", eob.getSupportingInfo());
    SupportingInformationComponent compare = TransformerTestUtilsV2.createSupportingInfo(// We don't care what the sequence number is here
    sic.getSequence(), // Category
    Arrays.asList(new Coding("http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBSupportingInfoType", "clmrecvddate", "Claim Received Date"), new Coding("https://bluebutton.cms.gov/resources/codesystem/information", "https://bluebutton.cms.gov/resources/variables/nch_wkly_proc_dt", "NCH Weekly Claim Processing Date"))).setTiming(new DateType("2014-02-14"));
    assertTrue(compare.equalsDeep(sic));
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Coding(org.hl7.fhir.r4.model.Coding) DateType(org.hl7.fhir.r4.model.DateType) Test(org.junit.jupiter.api.Test)

Example 47 with DateType

use of org.hl7.fhir.r4.model.DateType in project beneficiary-fhir-data by CMSgov.

the class SNFClaimTransformerV2Test method shouldHaveClaimReceivedDateSupInfo.

@Test
public void shouldHaveClaimReceivedDateSupInfo() {
    SupportingInformationComponent sic = TransformerTestUtilsV2.findSupportingInfoByCode("clmrecvddate", eob.getSupportingInfo());
    SupportingInformationComponent compare = TransformerTestUtilsV2.createSupportingInfo(// We don't care what the sequence number is here
    sic.getSequence(), // Category
    Arrays.asList(new Coding("http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBSupportingInfoType", "clmrecvddate", "Claim Received Date"), new Coding("https://bluebutton.cms.gov/resources/codesystem/information", "https://bluebutton.cms.gov/resources/variables/nch_wkly_proc_dt", "NCH Weekly Claim Processing Date"))).setTiming(new DateType("2014-02-14"));
    assertTrue(compare.equalsDeep(sic));
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Coding(org.hl7.fhir.r4.model.Coding) DateType(org.hl7.fhir.r4.model.DateType) Test(org.junit.jupiter.api.Test)

Example 48 with DateType

use of org.hl7.fhir.r4.model.DateType in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 method createExtensionDate.

/**
 * @param ccwVariable the {@link CcwCodebookInterface} being mapped
 * @param dateYear the value to use for {@link Coding#getCode()} for the resulting {@link Coding}
 * @return the output {@link Extension}, with {@link Extension#getValue()} set to represent the
 *     specified input values
 */
static Extension createExtensionDate(CcwCodebookInterface ccwVariable, Optional<BigDecimal> dateYear) {
    Extension extension = null;
    if (!dateYear.isPresent()) {
        throw new NoSuchElementException();
    }
    try {
        String stringDate = String.format("%04d", dateYear.get().intValue());
        DateType dateYearValue = new DateType(stringDate);
        String extensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
        extension = new Extension(extensionUrl, dateYearValue);
    } catch (DataFormatException e) {
        throw new InvalidRifValueException(String.format("Unable to create DateType with reference year: '%s'.", dateYear.get()), e);
    }
    return extension;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) DataFormatException(ca.uhn.fhir.parser.DataFormatException) InvalidRifValueException(gov.cms.bfd.model.rif.parse.InvalidRifValueException) DateType(org.hl7.fhir.r4.model.DateType) NoSuchElementException(java.util.NoSuchElementException)

Example 49 with DateType

use of org.hl7.fhir.r4.model.DateType in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 method mapEobCommonItemCarrierDME.

/**
 * Transforms the common item level data elements between the {@link CarrierClaimLine} and {@link
 * DMEClaimLine} claim types to FHIR. The method parameter fields from {@link CarrierClaimLine}
 * and {@link DMEClaimLine} are listed below and their corresponding RIF CCW fields (denoted in
 * all CAPS below from {@link CarrierClaimColumn} and {@link DMEClaimColumn}).
 *
 * @param item the {@ ItemComponent} to modify
 * @param eob the {@ ExplanationOfBenefit} to modify
 * @param claimId CLM_ID,
 * @param serviceCount LINE_SRVC_CNT,
 * @param placeOfServiceCode LINE_PLACE_OF_SRVC_CD,
 * @param firstExpenseDate LINE_1ST_EXPNS_DT,
 * @param lastExpenseDate LINE_LAST_EXPNS_DT,
 * @param beneficiaryPaymentAmount LINE_BENE_PMT_AMT,
 * @param providerPaymentAmount LINE_PRVDR_PMT_AMT,
 * @param beneficiaryPartBDeductAmount LINE_BENE_PTB_DDCTBL_AMT,
 * @param primaryPayerCode LINE_BENE_PRMRY_PYR_CD,
 * @param primaryPayerPaidAmount LINE_BENE_PRMRY_PYR_PD_AMT,
 * @param betosCode BETOS_CD,
 * @param paymentAmount LINE_NCH_PMT_AMT,
 * @param paymentCode LINE_PMT_80_100_CD,
 * @param coinsuranceAmount LINE_COINSRNC_AMT,
 * @param submittedChargeAmount LINE_SBMTD_CHRG_AMT,
 * @param allowedChargeAmount LINE_ALOWD_CHRG_AMT,
 * @param processingIndicatorCode LINE_PRCSG_IND_CD,
 * @param serviceDeductibleCode LINE_SERVICE_DEDUCTIBLE,
 * @param hctHgbTestTypeCode LINE_HCT_HGB_TYPE_CD
 * @param hctHgbTestResult LINE_HCT_HGB_RSLT_NUM,
 * @param cmsServiceTypeCode LINE_CMS_TYPE_SRVC_CD,
 * @param nationalDrugCode LINE_NDC_CD,
 * @param beneficiaryId BENE_ID,
 * @param referringPhysicianNpi RFR_PHYSN_NPI
 * @return the {@link ItemComponent}
 */
static ItemComponent mapEobCommonItemCarrierDME(ItemComponent item, ExplanationOfBenefit eob, String claimId, int sequence, BigDecimal serviceCount, String placeOfServiceCode, Optional<LocalDate> firstExpenseDate, Optional<LocalDate> lastExpenseDate, BigDecimal beneficiaryPaymentAmount, BigDecimal providerPaymentAmount, BigDecimal beneficiaryPartBDeductAmount, Optional<Character> primaryPayerCode, BigDecimal primaryPayerPaidAmount, Optional<String> betosCode, BigDecimal paymentAmount, Optional<Character> paymentCode, BigDecimal coinsuranceAmount, BigDecimal submittedChargeAmount, BigDecimal allowedChargeAmount, Optional<String> processingIndicatorCode, Optional<Character> serviceDeductibleCode, Optional<String> hctHgbTestTypeCode, BigDecimal hctHgbTestResult, char cmsServiceTypeCode, Optional<String> nationalDrugCode) {
    // LINE_SRVC_CNT => ExplanationOfBenefit.item.quantity
    item.setQuantity(new SimpleQuantity().setValue(serviceCount));
    // LINE_CMS_TYPE_SRVC_CD => ExplanationOfBenefit.item.category
    item.setCategory(createCodeableConcept(eob, CcwCodebookVariable.LINE_CMS_TYPE_SRVC_CD, cmsServiceTypeCode));
    // LINE_PLACE_OF_SRVC_CD => ExplanationOfBenefit.item.location
    item.setLocation(createCodeableConcept(eob, CcwCodebookVariable.LINE_PLACE_OF_SRVC_CD, placeOfServiceCode));
    // BETOS_CD => ExplanationOfBenefit.item.extension
    betosCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.BETOS_CD, code)));
    // LINE_LAST_EXPNS_DT => ExplanationOfBenefit.item.servicedPeriod
    if (firstExpenseDate.isPresent() && lastExpenseDate.isPresent()) {
        validatePeriodDates(firstExpenseDate, lastExpenseDate);
        item.setServiced(new Period().setStart((convertToDate(firstExpenseDate.get())), TemporalPrecisionEnum.DAY).setEnd((convertToDate(lastExpenseDate.get())), TemporalPrecisionEnum.DAY));
    } else // LINE_1ST_EXPNS_DT => ExplanationOfBenefit.item.servicedDate
    if (firstExpenseDate.isPresent()) {
        item.setServiced(new DateType(convertToDate(firstExpenseDate.get())));
    }
    // LINE_NCH_PMT_AMT => ExplanationOfBenefit.item.adjudication
    Optional<AdjudicationComponent> nchPmtAmtAdjudication = createAdjudicationAmtSlice(CcwCodebookVariable.LINE_NCH_PMT_AMT, C4BBAdjudication.BENEFIT, paymentAmount);
    addAdjudication(item, nchPmtAmtAdjudication);
    // LINE_PMT_80_100_CD => ExplanationOfBenefit.item.adjudication.extension
    if (paymentCode.isPresent() && nchPmtAmtAdjudication.isPresent()) {
        nchPmtAmtAdjudication.get().addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_PMT_80_100_CD, paymentCode));
    }
    // PAID_TO_PATIENT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_BENE_PMT_AMT, C4BBAdjudication.PAID_TO_PATIENT, beneficiaryPaymentAmount));
    // LINE_PRVDR_PMT_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_PRVDR_PMT_AMT, C4BBAdjudication.PAID_TO_PROVIDER, providerPaymentAmount));
    // LINE_BENE_PTB_DDCTBL_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_BENE_PTB_DDCTBL_AMT, C4BBAdjudication.DEDUCTIBLE, beneficiaryPartBDeductAmount));
    // LINE_BENE_PRMRY_PYR_CD => ExplanationOfBenefit.item.extension
    primaryPayerCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_BENE_PRMRY_PYR_CD, code)));
    // LINE_BENE_PRMRY_PYR_PD_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_BENE_PRMRY_PYR_PD_AMT, C4BBAdjudication.PRIOR_PAYER_PAID, primaryPayerPaidAmount));
    // LINE_COINSRNC_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_COINSRNC_AMT, C4BBAdjudication.COINSURANCE, coinsuranceAmount));
    // LINE_SBMTD_CHRG_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_SBMTD_CHRG_AMT, C4BBAdjudication.SUBMITTED, submittedChargeAmount));
    // LINE_ALOWD_CHRG_AMT => ExplanationOfBenefit.item.adjudication
    addAdjudication(item, createAdjudicationAmtSlice(CcwCodebookVariable.LINE_ALOWD_CHRG_AMT, C4BBAdjudication.ELIGIBLE, submittedChargeAmount));
    // LINE_BENE_PRMRY_PYR_CD => ExplanationOfBenefit.item.extension
    processingIndicatorCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_PRCSG_IND_CD, code)));
    // LINE_SERVICE_DEDUCTIBLE => ExplanationOfBenefit.item.extension
    serviceDeductibleCode.ifPresent(code -> item.addExtension(createExtensionCoding(eob, CcwCodebookVariable.LINE_SERVICE_DEDUCTIBLE, code)));
    // LINE_HCT_HGB_RSLT_NUM => Observation.value
    if (hctHgbTestTypeCode.isPresent()) {
        String observationId = "line-observation-" + sequence;
        String observationRef = "#" + observationId;
        // The `item` will link to a `supportingInfo` that references the embedded Observation
        SupportingInformationComponent comp = addInformation(eob, CcwCodebookVariable.LINE_HCT_HGB_RSLT_NUM);
        comp.setValue(new Reference(observationRef));
        // Create embedded Observation in ExplanationOfBenefit.contained
        Observation hctHgbObservation = findOrCreateContainedObservation(eob, observationId);
        hctHgbObservation.setStatus(ObservationStatus.UNKNOWN);
        hctHgbObservation.setCode(createCodeableConcept(eob, CcwCodebookVariable.LINE_HCT_HGB_TYPE_CD, hctHgbTestTypeCode));
        hctHgbObservation.setValue(new Quantity().setValue(hctHgbTestResult));
        // Link item.informationSequence to the new `supportingInfo` entry
        item.addInformationSequence(comp.getSequence());
    }
    // LINE_NDC_CD => ExplanationOfBenefit.item.productOrService.extension
    addNationalDrugCode(item, nationalDrugCode);
    return item;
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) Reference(org.hl7.fhir.r4.model.Reference) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Observation(org.hl7.fhir.r4.model.Observation) Period(org.hl7.fhir.r4.model.Period) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Quantity(org.hl7.fhir.r4.model.Quantity) DateType(org.hl7.fhir.r4.model.DateType)

Example 50 with DateType

use of org.hl7.fhir.r4.model.DateType in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsV2 method addCommonEobInformationInpatientSNF.

/**
 * Adds EOB information to fields that are common between the Inpatient and SNF claim types.
 *
 * @param eob the {@link ExplanationOfBenefit} that fields will be added to by this method
 * @param admissionTypeCd CLM_IP_ADMSN_TYPE_CD: a {@link Character} shared field representing the
 *     admission type cd for the claim
 * @param sourceAdmissionCd CLM_SRC_IP_ADMSN_CD: an {@link Optional}&lt;{@link Character}&gt;
 *     shared field representing the source admission cd for the claim
 * @param noncoveredStayFromDate NCH_VRFD_NCVRD_STAY_FROM_DT: an {@link Optional}&lt;{@link
 *     LocalDate}&gt; shared field representing the non-covered stay from date for the claim
 * @param noncoveredStayThroughDate NCH_VRFD_NCVRD_STAY_THRU_DT: an {@link Optional}&lt;{@link
 *     LocalDate}&gt; shared field representing the non-covered stay through date for the claim
 * @param coveredCareThroughDate NCH_ACTV_OR_CVRD_LVL_CARE_THRU: an {@link Optional}&lt;{@link
 *     LocalDate}&gt; shared field representing the covered stay through date for the claim
 * @param medicareBenefitsExhaustedDate NCH_BENE_MDCR_BNFTS_EXHTD_DT_I: an {@link
 *     Optional}&lt;{@link LocalDate}&gt; shared field representing the medicare benefits
 *     exhausted date for the claim
 * @param diagnosisRelatedGroupCd CLM_DRG_CD: an {@link Optional}&lt;{@link String}&gt; shared
 *     field representing the non-covered stay from date for the claim
 */
static void addCommonEobInformationInpatientSNF(ExplanationOfBenefit eob, Character admissionTypeCd, Optional<Character> sourceAdmissionCd, Optional<LocalDate> noncoveredStayFromDate, Optional<LocalDate> noncoveredStayThroughDate, Optional<LocalDate> coveredCareThroughDate, Optional<LocalDate> medicareBenefitsExhaustedDate, Optional<String> diagnosisRelatedGroupCd) {
    // CLM_IP_ADMSN_TYPE_CD => ExplanationOfBenefit.supportingInfo.code
    addInformationWithCode(eob, CcwCodebookVariable.CLM_IP_ADMSN_TYPE_CD, CcwCodebookVariable.CLM_IP_ADMSN_TYPE_CD, admissionTypeCd);
    // CLM_SRC_IP_ADMSN_CD => ExplanationOfBenefit.supportingInfo.code
    if (sourceAdmissionCd.isPresent()) {
        addInformationWithCode(eob, CcwCodebookVariable.CLM_SRC_IP_ADMSN_CD, CcwCodebookVariable.CLM_SRC_IP_ADMSN_CD, sourceAdmissionCd);
    }
    // ExplanationOfBenefit.supportingInfo.timingPeriod
    if (noncoveredStayFromDate.isPresent() || noncoveredStayThroughDate.isPresent()) {
        validatePeriodDates(noncoveredStayFromDate, noncoveredStayThroughDate);
        SupportingInformationComponent nchVrfdNcvrdStayInfo = addInformation(eob, CcwCodebookVariable.NCH_VRFD_NCVRD_STAY_FROM_DT);
        Period nchVrfdNcvrdStayPeriod = new Period();
        noncoveredStayFromDate.ifPresent(d -> nchVrfdNcvrdStayPeriod.setStart(convertToDate(d), TemporalPrecisionEnum.DAY));
        noncoveredStayThroughDate.ifPresent(d -> nchVrfdNcvrdStayPeriod.setEnd(convertToDate(d), TemporalPrecisionEnum.DAY));
        nchVrfdNcvrdStayInfo.setTiming(nchVrfdNcvrdStayPeriod);
    }
    // ExplanationOfBenefit.supportingInfo.timingDate
    if (coveredCareThroughDate.isPresent()) {
        SupportingInformationComponent nchActvOrCvrdLvlCareThruInfo = TransformerUtilsV2.addInformation(eob, CcwCodebookVariable.NCH_ACTV_OR_CVRD_LVL_CARE_THRU);
        nchActvOrCvrdLvlCareThruInfo.setTiming(new DateType(TransformerUtilsV2.convertToDate(coveredCareThroughDate.get())));
    }
    // ExplanationOfBenefit.supportingInfo.timingDate
    if (medicareBenefitsExhaustedDate.isPresent()) {
        SupportingInformationComponent nchBeneMdcrBnftsExhtdDtIInfo = TransformerUtilsV2.addInformation(eob, CcwCodebookVariable.NCH_BENE_MDCR_BNFTS_EXHTD_DT_I);
        nchBeneMdcrBnftsExhtdDtIInfo.setTiming(new DateType(TransformerUtilsV2.convertToDate(medicareBenefitsExhaustedDate.get())));
    }
    // diagnosisRelatedGroupCd
    // CLM_DRG_CD => ExplanationOfBenefit.supportingInfo
    diagnosisRelatedGroupCd.ifPresent(cd -> addInformationWithCode(eob, CcwCodebookVariable.CLM_DRG_CD, CcwCodebookVariable.CLM_DRG_CD, cd));
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Period(org.hl7.fhir.r4.model.Period) DateType(org.hl7.fhir.r4.model.DateType)

Aggregations

DateType (org.hl7.fhir.r4.model.DateType)36 Test (org.junit.jupiter.api.Test)21 Date (java.util.Date)17 Coding (org.hl7.fhir.r4.model.Coding)15 Test (org.junit.Test)11 SupportingInformationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent)10 DateType (org.hl7.fhir.r4b.model.DateType)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)9 ArrayList (java.util.ArrayList)8 DateType (org.hl7.fhir.r5.model.DateType)8 DateType (org.hl7.fhir.dstu3.model.DateType)7 Extension (org.hl7.fhir.r4.model.Extension)6 Calendar (java.util.Calendar)5 DisplayName (org.junit.jupiter.api.DisplayName)5 InvalidRifValueException (gov.cms.bfd.model.rif.parse.InvalidRifValueException)4 DateType (org.hl7.fhir.dstu2016may.model.DateType)4 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)4 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)4 Patient (org.hl7.fhir.r4.model.Patient)4 Reference (org.hl7.fhir.r4.model.Reference)4