Search in sources :

Example 16 with SupportingInformationComponent

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

the class CarrierClaimTransformerV2Test method shouldHaveSupportingInfoListForClaimReceivedDate2.

@Test
public void shouldHaveSupportingInfoListForClaimReceivedDate2() {
    SupportingInformationComponent sic = TransformerTestUtilsV2.findSupportingInfoByCode("info", eob.getSupportingInfo());
    SupportingInformationComponent compare = TransformerTestUtilsV2.createSupportingInfo(// We don't care what the sequence number is here
    sic.getSequence(), // Category
    Arrays.asList(new Coding("http://terminology.hl7.org/CodeSystem/claiminformationcategory", "info", "Information"), new Coding("https://bluebutton.cms.gov/resources/codesystem/information", "https://bluebutton.cms.gov/resources/variables/line_hct_hgb_rslt_num", "Hematocrit / Hemoglobin Test Results")));
    compare.setValue(new Reference("#line-observation-6"));
    assertTrue(compare.equalsDeep(sic));
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) Test(org.junit.jupiter.api.Test)

Example 17 with SupportingInformationComponent

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

the class TransformerUtilsV2 method addInformation.

/**
 * Returns a new {@link SupportingInformationComponent} that has been added to the specified
 * {@link ExplanationOfBenefit}.
 *
 * @param eob the {@link ExplanationOfBenefit} to modify
 * @return the newly-added {@link SupportingInformationComponent} entry
 */
static SupportingInformationComponent addInformation(ExplanationOfBenefit eob) {
    int maxSequence = eob.getSupportingInfo().stream().mapToInt(i -> i.getSequence()).max().orElse(0);
    SupportingInformationComponent infoComponent = new SupportingInformationComponent();
    infoComponent.setSequence(maxSequence + 1);
    eob.getSupportingInfo().add(infoComponent);
    return infoComponent;
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent)

Example 18 with SupportingInformationComponent

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

the class TransformerUtilsV2 method addInformationWithCode.

/**
 * Returns a new {@link SupportingInformationComponent} that has been added to the specified
 * {@link ExplanationOfBenefit}. Unlike {@link #addInformation(ExplanationOfBenefit,
 * CcwCodebookInterface)}, this also sets the {@link SupportingInformationComponent#getCode()}
 * based on the values provided.
 *
 * @param eob the {@link ExplanationOfBenefit} to modify
 * @param categoryVariable {@link CcwCodebookInterface} to map to {@link
 *     SupportingInformationComponent#getCategory()}
 * @param codeSystemVariable the {@link CcwCodebookInterface} to map to the {@link
 *     Coding#getSystem()} used in the {@link SupportingInformationComponent#getCode()}
 * @param codeValue the value to map to the {@link Coding#getCode()} used in the {@link
 *     SupportingInformationComponent#getCode()}
 * @return the newly-added {@link SupportingInformationComponent} entry
 */
static SupportingInformationComponent addInformationWithCode(ExplanationOfBenefit eob, CcwCodebookInterface categoryVariable, CcwCodebookInterface codeSystemVariable, Optional<?> codeValue) {
    SupportingInformationComponent infoComponent = addInformation(eob, categoryVariable);
    CodeableConcept infoCode = new CodeableConcept().addCoding(createCoding(eob, codeSystemVariable, codeValue));
    infoComponent.setCode(infoCode);
    return infoComponent;
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 19 with SupportingInformationComponent

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

the class R4ExplanationOfBenefitResourceProviderIT method assertEobEquals.

/**
 * Compares two ExplanationOfBenefit objects in detail while working around serialization issues
 * like comparing "0" and "0.0" or creation differences like using "Quantity" vs "SimpleQuantity"
 *
 * @param expected the expected
 * @param actual the actual
 */
private static void assertEobEquals(ExplanationOfBenefit expected, ExplanationOfBenefit actual) {
    // ID in the bundle will have `ExplanationOfBenefit/` in front, so make sure the last bit
    // matches up
    assertTrue(actual.getId().endsWith(expected.getId()));
    // Clean them out so we can do a deep compare later
    actual.setId("");
    expected.setId("");
    // If there are any contained resources, they might have lastupdate times in them too
    assertEquals(expected.getContained().size(), actual.getContained().size());
    for (int i = 0; i < expected.getContained().size(); i++) {
        Resource expectedContained = expected.getContained().get(i);
        Resource actualContained = actual.getContained().get(i);
        expectedContained.getMeta().setLastUpdated(null);
        actualContained.getMeta().setLastUpdated(null);
        // TODO: HAPI seems to be inserting the `#` in the ID of the contained element.
        // This is incorrect according to the FHIR spec:
        // https://build.fhir.org/references.html#contained
        // This works around that problem
        assertEquals("#" + expectedContained.getId(), actualContained.getId());
        expectedContained.setId("");
        actualContained.setId("");
    }
    // Dates are not easy to compare so just make sure they are there
    assertNotNull(actual.getMeta().getLastUpdated());
    // We compared all of meta that we care about so get it out of the way
    expected.getMeta().setLastUpdated(null);
    actual.getMeta().setLastUpdated(null);
    // Created is required, but can't be compared
    assertNotNull(actual.getCreated());
    expected.setCreated(null);
    actual.setCreated(null);
    // Extensions may have `valueMoney` elements
    assertEquals(expected.getExtension().size(), actual.getExtension().size());
    for (int i = 0; i < expected.getExtension().size(); i++) {
        Extension expectedEx = expected.getExtension().get(i);
        Extension actualEx = actual.getExtension().get(i);
        // We have to deal with Money objects separately
        if (expectedEx.hasValue() && expectedEx.getValue() instanceof Money) {
            assertTrue(actualEx.getValue() instanceof Money);
            assertCurrencyEquals((Money) expectedEx.getValue(), (Money) actualEx.getValue());
            // Now remove since we validated so we can compare the rest directly
            expectedEx.setValue(null);
            actualEx.setValue(null);
        }
    }
    // SupportingInfo can have `valueQuantity` that has the 0 vs 0.0 issue
    assertEquals(expected.getSupportingInfo().size(), actual.getSupportingInfo().size());
    for (int i = 0; i < expected.getSupportingInfo().size(); i++) {
        SupportingInformationComponent expectedSup = expected.getSupportingInfo().get(i);
        SupportingInformationComponent actualSup = actual.getSupportingInfo().get(i);
        // We have to deal with Money objects separately
        if (expectedSup.hasValueQuantity()) {
            assertTrue(actualSup.hasValueQuantity());
            assertEquals(expectedSup.getValueQuantity().getValue().floatValue(), actualSup.getValueQuantity().getValue().floatValue(), 0.0);
            // Now remove since we validated so we can compare the rest directly
            expectedSup.setValue(null);
            actualSup.setValue(null);
        }
    }
    // line items
    assertEquals(expected.getItem().size(), actual.getItem().size());
    for (int i = 0; i < expected.getItem().size(); i++) {
        ItemComponent expectedItem = expected.getItem().get(i);
        ItemComponent actualItem = actual.getItem().get(i);
        // Compare value directly because SimpleQuantity vs Quantity can't be compared
        assertEquals(expectedItem.getQuantity().getValue().floatValue(), actualItem.getQuantity().getValue().floatValue(), 0.0);
        expectedItem.setQuantity(null);
        actualItem.setQuantity(null);
        assertEquals(expectedItem.getAdjudication().size(), actualItem.getAdjudication().size());
        for (int j = 0; j < expectedItem.getAdjudication().size(); j++) {
            AdjudicationComponent expectedAdj = expectedItem.getAdjudication().get(j);
            AdjudicationComponent actualAdj = actualItem.getAdjudication().get(j);
            // Here is where we start getting into trouble with "0" vs "0.0", so we do this manually
            if (expectedAdj.hasAmount()) {
                assertNotNull(actualAdj.getAmount());
                assertCurrencyEquals(expectedAdj.getAmount(), actualAdj.getAmount());
            } else {
                // If expected doesn't have an amount, actual shouldn't
                assertFalse(actualAdj.hasAmount());
            }
            // We just checked manually, so null them out and check the rest of the fields
            expectedAdj.setAmount(null);
            actualAdj.setAmount(null);
        }
    }
    // Total has the same problem with values
    assertEquals(expected.getTotal().size(), actual.getTotal().size());
    for (int i = 0; i < expected.getTotal().size(); i++) {
        TotalComponent expectedTot = expected.getTotal().get(i);
        TotalComponent actualTot = actual.getTotal().get(i);
        if (expectedTot.hasAmount()) {
            assertNotNull(actualTot.getAmount());
            assertCurrencyEquals(expectedTot.getAmount(), actualTot.getAmount());
        } else {
            // If expected doesn't have an amount, actual shouldn't
            assertFalse(actualTot.hasAmount());
        }
        expectedTot.setAmount(null);
        actualTot.setAmount(null);
    }
    // Benefit Balance Financial components
    assertEquals(expected.getBenefitBalance().size(), actual.getBenefitBalance().size());
    for (int i = 0; i < expected.getBenefitBalance().size(); i++) {
        BenefitBalanceComponent expectedBen = expected.getBenefitBalance().get(i);
        BenefitBalanceComponent actualBen = actual.getBenefitBalance().get(i);
        assertEquals(expectedBen.getFinancial().size(), actualBen.getFinancial().size());
        for (int j = 0; j < expectedBen.getFinancial().size(); j++) {
            BenefitComponent expectedFinancial = expectedBen.getFinancial().get(j);
            BenefitComponent actualFinancial = actualBen.getFinancial().get(j);
            // Are we dealing with Money?
            if (expectedFinancial.hasUsedMoney()) {
                assertNotNull(actualFinancial.getUsedMoney());
                assertCurrencyEquals(expectedFinancial.getUsedMoney(), actualFinancial.getUsedMoney());
                // Clean up
                expectedFinancial.setUsed(null);
                actualFinancial.setUsed(null);
            }
        }
    }
    // As does payment
    if (expected.hasPayment()) {
        assertTrue(actual.hasPayment());
        assertCurrencyEquals(expected.getPayment().getAmount(), actual.getPayment().getAmount());
    } else {
        // If expected doesn't have an amount, actual shouldn't
        assertFalse(actual.hasPayment());
    }
    expected.getPayment().setAmount(null);
    actual.getPayment().setAmount(null);
    // Now for the grand finale, we can do an `equalsDeep` on the rest
    assertTrue(expected.equalsDeep(actual));
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) TotalComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.TotalComponent) Money(org.hl7.fhir.r4.model.Money) SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) BenefitBalanceComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitBalanceComponent) BenefitComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent)

Example 20 with SupportingInformationComponent

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

the class TransformerTestUtils method assertInformationPeriodEquals.

/**
 * @param expectedCategorySystem the expected value for {@link
 *     SupportingInformationComponent#getCategory()}'s {@link Coding#getSystem()}
 * @param expectedCategoryCodeVariable the expected {@link CcwCodebookVariable} for {@link
 *     SupportingInformationComponent#getCategory()}'s {@link Coding#getCode()}
 * @param expectedFromDate the expected {@link
 *     SupportingInformationComponent#getTimingPeriod().getStartElement()}
 * @param expectedThruDate the expected {@link
 *     SupportingInformationComponent#getTimingPeriod().getEndElement()}
 * @param actuals the actual {@link SupportingInformationComponent}s to verify
 */
static void assertInformationPeriodEquals(String expectedCategorySystem, CcwCodebookVariable expectedCategoryCodeVariable, LocalDate expectedFromDate, LocalDate expectedThruDate, List<SupportingInformationComponent> actuals) {
    String expectedCategoryCode = CCWUtils.calculateVariableReferenceUrl(expectedCategoryCodeVariable);
    Optional<SupportingInformationComponent> supportingInformationComponent = actuals.stream().filter(a -> isCodeInConcept(a.getCategory(), expectedCategorySystem, expectedCategoryCode)).findAny();
    assertTrue(supportingInformationComponent.isPresent());
    try {
        assertDateEquals(expectedFromDate, supportingInformationComponent.get().getTimingPeriod().getStartElement());
        assertDateEquals(expectedThruDate, supportingInformationComponent.get().getTimingPeriod().getEndElement());
    } catch (FHIRException e) {
        throw new BadCodeMonkeyException(e);
    }
}
Also used : IBaseHasExtensions(org.hl7.fhir.instance.model.api.IBaseHasExtensions) Arrays(java.util.Arrays) CarrierClaimColumn(gov.cms.bfd.model.rif.CarrierClaimColumn) CcwCodebookInterface(gov.cms.bfd.model.codebook.model.CcwCodebookInterface) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Extension(org.hl7.fhir.dstu3.model.Extension) IBaseExtension(org.hl7.fhir.instance.model.api.IBaseExtension) ClaimCareteamrole(org.hl7.fhir.dstu3.model.codesystems.ClaimCareteamrole) SNFClaimColumn(gov.cms.bfd.model.rif.SNFClaimColumn) BigDecimal(java.math.BigDecimal) FhirContext(ca.uhn.fhir.context.FhirContext) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) SNFClaimLine(gov.cms.bfd.model.rif.SNFClaimLine) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) HHAClaimColumn(gov.cms.bfd.model.rif.HHAClaimColumn) CarrierClaimLine(gov.cms.bfd.model.rif.CarrierClaimLine) Duration(java.time.Duration) BenefitBalanceComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.BenefitBalanceComponent) TemporalPrecisionEnum(ca.uhn.fhir.model.api.TemporalPrecisionEnum) Method(java.lang.reflect.Method) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) Reference(org.hl7.fhir.dstu3.model.Reference) DiagnosisComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.DiagnosisComponent) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) InpatientClaimColumn(gov.cms.bfd.model.rif.InpatientClaimColumn) Instant(java.time.Instant) InvocationTargetException(java.lang.reflect.InvocationTargetException) Quantity(org.hl7.fhir.dstu3.model.Quantity) List(java.util.List) CareTeamComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.CareTeamComponent) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) OutpatientClaimColumn(gov.cms.bfd.model.rif.OutpatientClaimColumn) HospiceClaimLine(gov.cms.bfd.model.rif.HospiceClaimLine) HHAClaimLine(gov.cms.bfd.model.rif.HHAClaimLine) HospiceClaimColumn(gov.cms.bfd.model.rif.HospiceClaimColumn) Money(org.hl7.fhir.dstu3.model.Money) InpatientClaimLine(gov.cms.bfd.model.rif.InpatientClaimLine) ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) OutpatientClaimLine(gov.cms.bfd.model.rif.OutpatientClaimLine) BenefitComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.BenefitComponent) IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) CCWUtils(gov.cms.bfd.server.war.commons.CCWUtils) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) Period(org.hl7.fhir.dstu3.model.Period) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DMEClaimLine(gov.cms.bfd.model.rif.DMEClaimLine) AdjudicationComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.AdjudicationComponent) BenefitCategory(org.hl7.fhir.dstu3.model.codesystems.BenefitCategory) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Resource(org.hl7.fhir.dstu3.model.Resource) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) IOException(java.io.IOException) Observation(org.hl7.fhir.dstu3.model.Observation) BaseDateTimeType(org.hl7.fhir.dstu3.model.BaseDateTimeType) SupportingInformationComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.SupportingInformationComponent) DMEClaimColumn(gov.cms.bfd.model.rif.DMEClaimColumn) FHIRException(org.hl7.fhir.exceptions.FHIRException) IdentifierType(gov.cms.bfd.server.war.commons.IdentifierType) SupportingInformationComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.SupportingInformationComponent) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Aggregations

SupportingInformationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent)68 Coding (org.hl7.fhir.r4.model.Coding)59 Test (org.junit.jupiter.api.Test)59 SupportingInformationComponent (org.hl7.fhir.dstu3.model.ExplanationOfBenefit.SupportingInformationComponent)11 DateType (org.hl7.fhir.r4.model.DateType)11 Period (org.hl7.fhir.r4.model.Period)6 SNFClaimLine (gov.cms.bfd.model.rif.SNFClaimLine)4 Quantity (org.hl7.fhir.r4.model.Quantity)4 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)3 BigDecimal (java.math.BigDecimal)3 SimpleDateFormat (java.text.SimpleDateFormat)3 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)3 SimpleQuantity (org.hl7.fhir.r4.model.SimpleQuantity)3 FhirContext (ca.uhn.fhir.context.FhirContext)2 TemporalPrecisionEnum (ca.uhn.fhir.model.api.TemporalPrecisionEnum)2 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)2 CcwCodebookInterface (gov.cms.bfd.model.codebook.model.CcwCodebookInterface)2 CarrierClaim (gov.cms.bfd.model.rif.CarrierClaim)2 CarrierClaimColumn (gov.cms.bfd.model.rif.CarrierClaimColumn)2 CarrierClaimLine (gov.cms.bfd.model.rif.CarrierClaimLine)2