Search in sources :

Example 36 with Value

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

the class PatientResourceProviderIT method readExistingPatientWithNoHistoryIncludeIdentifiersTrue.

/**
 * Verifies that {@link
 * gov.cms.bfd.server.war.stu3.providers.PatientResourceProvider#read(org.hl7.fhir.dstu3.model.IdType)}
 * works as expected for a {@link Patient} that does exist in the DB but has no {@link
 * BeneficiaryHistory} or {@link MedicareBeneficiaryIdHistory} records when include identifiers
 * value = ["true"].
 */
@Test
public void readExistingPatientWithNoHistoryIncludeIdentifiersTrue() {
    List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResource.SAMPLE_A_BENES));
    RequestHeaders requestHeader = RequestHeaders.getHeaderWrapper(PatientResourceProvider.HEADER_NAME_INCLUDE_IDENTIFIERS, "true", PatientResourceProvider.HEADER_NAME_INCLUDE_ADDRESS_FIELDS, "true");
    IGenericClient fhirClient = createFhirClient(requestHeader);
    Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
    Patient patient = fhirClient.read().resource(Patient.class).withId(beneficiary.getBeneficiaryId()).execute();
    assertNotNull(patient);
    BeneficiaryTransformerTest.assertMatches(beneficiary, patient, requestHeader);
    /*
     * Ensure the unhashed values for HICN and MBI are present.
     */
    Boolean hicnUnhashedPresent = false;
    Boolean mbiUnhashedPresent = false;
    Iterator<Identifier> identifiers = patient.getIdentifier().iterator();
    while (identifiers.hasNext()) {
        Identifier identifier = identifiers.next();
        if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_BENE_HICN_UNHASHED))
            hicnUnhashedPresent = true;
        if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED))
            mbiUnhashedPresent = true;
    }
    assertTrue(hicnUnhashedPresent);
    assertTrue(mbiUnhashedPresent);
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) Bundle(org.hl7.fhir.dstu3.model.Bundle) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) Date(java.util.Date) Identifier(org.hl7.fhir.dstu3.model.Identifier) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Constants(ca.uhn.fhir.rest.api.Constants) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) CCWUtils(gov.cms.bfd.server.war.commons.CCWUtils) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CriteriaUpdate(javax.persistence.criteria.CriteriaUpdate) BeforeAll(org.junit.jupiter.api.BeforeAll) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) CommonHeaders(gov.cms.bfd.server.war.commons.CommonHeaders) Root(javax.persistence.criteria.Root) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Iterator(java.util.Iterator) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) BeneficiaryMonthly_(gov.cms.bfd.model.rif.BeneficiaryMonthly_) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) BeneficiaryMonthly(gov.cms.bfd.model.rif.BeneficiaryMonthly) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) Stream(java.util.stream.Stream) Year(java.time.Year) Patient(org.hl7.fhir.dstu3.model.Patient) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) LocalDate(java.time.LocalDate) Identifier(org.hl7.fhir.dstu3.model.Identifier) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Patient(org.hl7.fhir.dstu3.model.Patient) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Example 37 with Value

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

the class SamhsaMatcherFromClaimTransformerTest method verifySamhsaMatcherForProcedureIcd.

/**
 * Verify SAMHSA matcher for ICD item with the given system, code and if the expectation is that
 * there should be a match for this combination.
 *
 * @param system the system value
 * @param code the code
 * @param shouldMatch if the matcher should match on this combination
 */
private void verifySamhsaMatcherForProcedureIcd(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set diagnosis to empty so we dont check it for matches
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        CodeableConcept codeableConcept = diagnosisComponent.getDiagnosisCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        if (codeableConcept != null) {
            codeableConcept.setCoding(codingList);
            diagnosisComponent.setPackageCode(null);
        }
    }
    // Set procedure
    for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
        CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codingList.add(new Coding().setSystem(system).setCode(code));
        codeableConcept.setCoding(codingList);
    }
    // Set item coding to non-SAMHSA so we dont check it for matches
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(TransformerConstants.CODING_SYSTEM_HCPCS);
    coding.setCode(NON_SAMHSA_HCPCS_CODE);
    codings.add(coding);
    modifiedEob.getItem().get(0).getService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcher.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 38 with Value

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

the class SamhsaMatcherFromClaimTransformerTest method verifySamhsaMatcherForDiagnosisPackage.

/**
 * Verify SAMHSA matcher for package with the given system, code and if the expectation is that
 * there should be a match for this combination.
 *
 * @param system the system value
 * @param code the code
 * @param shouldMatch if the matcher should match on this combination
 */
private void verifySamhsaMatcherForDiagnosisPackage(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set diagnosis DRG
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        if (diagnosisComponent.getDiagnosisCodeableConcept() != null) {
            diagnosisComponent.getDiagnosisCodeableConcept().setCoding(new ArrayList<>());
        }
        CodeableConcept codeableConcept = new CodeableConcept();
        Coding coding = new Coding(system, code, null);
        codeableConcept.setCoding(Collections.singletonList(coding));
        diagnosisComponent.setPackageCode(codeableConcept);
    }
    // Set procedure to empty so we dont check it for matches
    for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
        CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codeableConcept.setCoding(codingList);
    }
    // Set item coding to non-SAMHSA so we dont check it for matches
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(TransformerConstants.CODING_SYSTEM_HCPCS);
    coding.setCode(NON_SAMHSA_HCPCS_CODE);
    codings.add(coding);
    modifiedEob.getItem().get(0).getService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcher.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 39 with Value

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

the class R4PatientResourceProviderIT method assertExistingPatientIncludeIdentifiersExpected.

/**
 * Asserts that {@link
 * gov.cms.bfd.server.war.r4.providers.R4PatientResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
 * contains expected/present identifiers for a {@link Patient}.
 *
 * @param includeIdentifiersValue header value
 * @param expectingMbi true if expecting a MBI
 * @param includeAddressValues header value
 */
public void assertExistingPatientIncludeIdentifiersExpected(boolean expectingMbi, RequestHeaders requestHeader) {
    List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
    Patient expected = BeneficiaryTransformerV2.transform(PipelineTestUtils.get().getPipelineApplicationState().getMetrics(), beneficiary, requestHeader);
    IGenericClient fhirClient = createFhirClient(requestHeader);
    Patient patient = fhirClient.read().resource(Patient.class).withId(beneficiary.getBeneficiaryId()).execute();
    // Because of how transform doesn't go through R4PatientResourceProvider, `expected` won't have
    // the historical MBI data.
    // Also, SAMPLE_A does not have mbi history (it used to); however, what used to be denoted as
    // historical
    // is not provided as the 'current' MBI identifier (no historical).
    comparePatient(expected, patient);
    /*
     * Ensure the unhashed values for MBI are present.
     */
    Boolean mbiUnhashedPresent = false;
    Iterator<Identifier> identifiers = patient.getIdentifier().iterator();
    while (identifiers.hasNext()) {
        Identifier identifier = identifiers.next();
        if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_BENE_ID)) {
            mbiUnhashedPresent = true;
        }
    }
    // Unhashed MBI should always be present in V2
    assertTrue(mbiUnhashedPresent);
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) Date(java.util.Date) ExtraParamsInterceptor(gov.cms.bfd.server.war.stu3.providers.ExtraParamsInterceptor) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Constants(ca.uhn.fhir.rest.api.Constants) Identifier(org.hl7.fhir.r4.model.Identifier) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) CCWUtils(gov.cms.bfd.server.war.commons.CCWUtils) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) BeforeAll(org.junit.jupiter.api.BeforeAll) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) Patient(org.hl7.fhir.r4.model.Patient) Iterator(java.util.Iterator) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) Stream(java.util.stream.Stream) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Bundle(org.hl7.fhir.r4.model.Bundle) Identifier(org.hl7.fhir.r4.model.Identifier) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Patient(org.hl7.fhir.r4.model.Patient) Beneficiary(gov.cms.bfd.model.rif.Beneficiary)

Example 40 with Value

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

the class R4PatientResourceProviderIT method testLastUpdatedUrls.

/**
 * Test the set of lastUpdated values
 *
 * @param fhirClient to use
 * @param id the beneficiary id to use
 * @param urls is a list of lastUpdate values to test to find
 * @param expectedValue number of matches
 */
private void testLastUpdatedUrls(IGenericClient fhirClient, String id, List<String> urls, int expectedValue) {
    String baseResourceUrl = "Patient?_id=" + id + "&_format=application%2Fjson%2Bfhir";
    // Search for each lastUpdated value
    for (String lastUpdatedValue : urls) {
        String theSearchUrl = baseResourceUrl + "&" + lastUpdatedValue;
        Bundle searchResults = fhirClient.search().byUrl(theSearchUrl).returnBundle(Bundle.class).execute();
        assertEquals(expectedValue, searchResults.getTotal(), String.format("Expected %s to filter resources using lastUpdated correctly", lastUpdatedValue));
    }
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle)

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