Search in sources :

Example 31 with Value

use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.

the class TransformerTestUtils method assertExtensionIdentifierEqualsString.

/**
 * Tests that the specified extension list contains a single Identifier with the expected string
 * value
 *
 * @param extension a {@link List}<{@link Extension}> containing an Identifier
 * @param expected a {@link String} containing the expected value of the Identifier
 */
static void assertExtensionIdentifierEqualsString(List<Extension> extension, String expected) {
    assertEquals(1, extension.size());
    assertTrue(extension.get(0).getValue() instanceof Identifier);
    Identifier identifier = (Identifier) extension.get(0).getValue();
    assertEquals(expected, identifier.getValue());
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier)

Example 32 with Value

use of org.hl7.fhir.utilities.graphql.Value 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)

Example 33 with Value

use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.

the class TransformerTestUtils method assertInfoWithCodeEquals.

/**
 * @param categoryVariable the {@link CcwCodebookVariable} matching the {@link
 *     SupportingInformationComponent#getCategory()} to find
 * @param codeSystemVariable the {@link CcwCodebookVariable} that should have been mapped to
 *     {@link SupportingInformationComponent#getCode()}'s {@link Coding#getSystem()}
 * @param codeValue the value that should have been mapped to {@link
 *     SupportingInformationComponent#getCode()}'s {@link Coding#getCode()}
 * @param eob the actual {@link ExplanationOfBenefit} to search
 */
static void assertInfoWithCodeEquals(CcwCodebookVariable categoryVariable, CcwCodebookVariable codeSystemVariable, Optional<?> codeValue, ExplanationOfBenefit eob) {
    SupportingInformationComponent info = assertHasInfo(categoryVariable, eob);
    assertHasCoding(codeSystemVariable, codeValue, info.getCode());
}
Also used : SupportingInformationComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.SupportingInformationComponent)

Example 34 with Value

use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.

the class TransformerTestUtils method assertBenefitBalanceUsedIntEquals.

/**
 * @param expectedBenefitCategory the {@link BenefitCategory} for the expected {@link
 *     BenefitBalanceComponent#getCategory()}
 * @param expectedFinancialType the {@link CcwCodebookVariable} for the expected {@link
 *     BenefitComponent#getType()}
 * @param expectedUsedInt the expected {@link BenefitComponent#getUsedUnsignedIntType()} value
 * @param eob the {@link ExplanationOfBenefit} to verify the actual {@link BenefitComponent}
 *     within
 */
static void assertBenefitBalanceUsedIntEquals(BenefitCategory expectedBenefitCategory, CcwCodebookVariable expectedFinancialType, Integer expectedUsedInt, ExplanationOfBenefit eob) {
    Optional<BenefitBalanceComponent> benefitBalanceComponent = eob.getBenefitBalance().stream().filter(bb -> isCodeInConcept(bb.getCategory(), expectedBenefitCategory.getSystem(), expectedBenefitCategory.toCode())).findAny();
    assertTrue(benefitBalanceComponent.isPresent());
    Optional<BenefitComponent> benefitBalanceFinancialEntry = benefitBalanceComponent.get().getFinancial().stream().filter(f -> isCodeInConcept(f.getType(), TransformerConstants.CODING_BBAPI_BENEFIT_BALANCE_TYPE, CCWUtils.calculateVariableReferenceUrl(expectedFinancialType))).findAny();
    assertTrue(benefitBalanceFinancialEntry.isPresent());
    try {
        assertEquals(expectedUsedInt, benefitBalanceFinancialEntry.get().getUsedUnsignedIntType().getValue());
    } 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) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) FHIRException(org.hl7.fhir.exceptions.FHIRException) BenefitBalanceComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.BenefitBalanceComponent) BenefitComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.BenefitComponent)

Example 35 with Value

use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.

the class TransformerUtilsTest method createCodeableConcept_display.

/**
 * Verifies that {@link
 * gov.cms.bfd.server.war.stu3.providers.TransformerUtils#createCodeableConcept(org.hl7.fhir.instance.model.api.IAnyResource,
 * CcwCodebookVariable, String)} sets {@link Coding#getDisplay()} correctly.
 */
@Test
public void createCodeableConcept_display() {
    Patient patientA = new Patient();
    patientA.setId("12345");
    CodeableConcept raceConcept_4 = TransformerUtils.createCodeableConcept(patientA, CcwCodebookVariable.RACE, "4");
    assertEquals("Asian", raceConcept_4.getCodingFirstRep().getDisplay());
    // This code isn't valid and shouldn't end up with a matching display.
    CodeableConcept raceConcept_12 = TransformerUtils.createCodeableConcept(patientA, CcwCodebookVariable.RACE, "12");
    assertNull(raceConcept_12.getCodingFirstRep().getDisplay());
    /*
     * The REV_CNTR_PMT_MTHD_IND_CD Variable has value collisions. Verify that those
     * are handled correctly.
     */
    CodeableConcept paymentMethodConcept_1 = TransformerUtils.createCodeableConcept(patientA, CcwCodebookVariable.REV_CNTR_PMT_MTHD_IND_CD, "1");
    assertNull(paymentMethodConcept_1.getCodingFirstRep().getDisplay());
}
Also used : Patient(org.hl7.fhir.dstu3.model.Patient) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)222 ArrayList (java.util.ArrayList)183 FHIRException (org.hl7.fhir.exceptions.FHIRException)107 List (java.util.List)97 DisplayName (org.junit.jupiter.api.DisplayName)96 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)89 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)85 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)70 Identifier (org.hl7.fhir.r4.model.Identifier)69 Test (org.junit.Test)66 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)64 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)54 IOException (java.io.IOException)52 Bundle (org.hl7.fhir.r4.model.Bundle)49 Coding (org.hl7.fhir.r4.model.Coding)49 ValueSet (org.hl7.fhir.r5.model.ValueSet)48 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)46 Resource (org.hl7.fhir.r4.model.Resource)46 BigDecimal (java.math.BigDecimal)45 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)44