Search in sources :

Example 81 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testValueSetMembership.

@Test
public /**
 * This test exists to validate the the engine correctly expands a valueset
 * and correctly determines resources that overlap the valueset membership.
 *
 * @throws Exception on any error.
 */
void testValueSetMembership() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1983-12-02");
    Condition condition = new Condition();
    condition.setId("Condition");
    condition.setSubject(new Reference(patient));
    condition.getCode().addCoding().setSystem("SNOMED-CT").setCode("1234");
    // This stub works for [Condition] c where c.code in "ValueSet"
    mockFhirResourceRetrieval("/Condition?subject=Patient%2F123&_format=json", condition);
    // These stub works for [Condition: "ValueSet"]
    mockFhirResourceRetrieval("/Condition?code=SNOMED-CT%7C1234&subject=Patient%2F123&_format=json", makeBundle(condition));
    mockFhirResourceRetrieval("/Condition?code=SNOMED-CT%7C5678&subject=Patient%2F123&_format=json", makeBundle());
    mockValueSetRetrieval("https://cts.nlm.nih.gov/fhir/ValueSet/1.2.3.4", "SNOMED-CT", "1234");
    mockValueSetRetrieval("https://cts.nlm.nih.gov/fhir/ValueSet/5.6.7.8", "SNOMED-CT", "5678");
    // We have to add a one off mock valueset endpoint for when the engine checks if 1234 is in the 5.6.7.8 valueset
    Parameters response = new Parameters();
    response.addParameter().setValue(new BooleanType(false));
    mockFhirResourceRetrieval("/ValueSet/5.6.7.8/$validate-code?code=1234&system=SNOMED-CT&_format=json", response);
    CqlEvaluator evaluator = setupTestFor(patient, "cql.valueset", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test", "1.0.0"), newPatientContext("123"));
    Map<String, Object> results = actual.getExpressionResults();
    Assert.assertEquals(5, results.size());
    Assert.assertEquals(true, results.get("RHSRetrieveMatches"));
    Assert.assertEquals(true, results.get("RHSInOperatorMatches"));
    Assert.assertEquals(true, results.get("RHSRetrieveNotMatches"));
    Assert.assertEquals(true, results.get("RHSInOperatorNotMatches"));
    assertFhirEquals(patient, (IBaseResource) results.get("Patient"));
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Parameters(org.hl7.fhir.r4.model.Parameters) Reference(org.hl7.fhir.r4.model.Reference) BooleanType(org.hl7.fhir.r4.model.BooleanType) Patient(org.hl7.fhir.r4.model.Patient) CqlEvaluationResult(com.ibm.cohort.cql.evaluation.CqlEvaluationResult) CqlEvaluator(com.ibm.cohort.cql.evaluation.CqlEvaluator) CqlVersionedIdentifier(com.ibm.cohort.cql.library.CqlVersionedIdentifier) Test(org.junit.Test)

Example 82 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeMessageHeaderMessageSourceComponent.

protected void composeMessageHeaderMessageSourceComponent(Complex parent, String parentType, String name, MessageHeader.MessageSourceComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "source", name, element, index);
    if (element.hasNameElement())
        composeString(t, "MessageHeader", "name", element.getNameElement(), -1);
    if (element.hasSoftwareElement())
        composeString(t, "MessageHeader", "software", element.getSoftwareElement(), -1);
    if (element.hasVersionElement())
        composeString(t, "MessageHeader", "version", element.getVersionElement(), -1);
    if (element.hasContact())
        composeContactPoint(t, "MessageHeader", "contact", element.getContact(), -1);
    if (element.hasEndpointElement())
        composeUri(t, "MessageHeader", "endpoint", element.getEndpointElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 83 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeMessageHeaderMessageDestinationComponent.

protected void composeMessageHeaderMessageDestinationComponent(Complex parent, String parentType, String name, MessageHeader.MessageDestinationComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "destination", name, element, index);
    if (element.hasNameElement())
        composeString(t, "MessageHeader", "name", element.getNameElement(), -1);
    if (element.hasTarget())
        composeReference(t, "MessageHeader", "target", element.getTarget(), -1);
    if (element.hasEndpointElement())
        composeUri(t, "MessageHeader", "endpoint", element.getEndpointElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 84 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeConformanceConformanceMessagingComponent.

protected void composeConformanceConformanceMessagingComponent(Complex parent, String parentType, String name, Conformance.ConformanceMessagingComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "messaging", name, element, index);
    for (int i = 0; i < element.getEndpoint().size(); i++) composeConformanceConformanceMessagingEndpointComponent(t, "Conformance", "endpoint", element.getEndpoint().get(i), i);
    if (element.hasReliableCacheElement())
        composeUnsignedInt(t, "Conformance", "reliableCache", element.getReliableCacheElement(), -1);
    if (element.hasDocumentationElement())
        composeString(t, "Conformance", "documentation", element.getDocumentationElement(), -1);
    for (int i = 0; i < element.getEvent().size(); i++) composeConformanceConformanceMessagingEventComponent(t, "Conformance", "event", element.getEvent().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 85 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeEndpoint.

protected void composeEndpoint(Complex parent, String parentType, String name, Endpoint element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Endpoint", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Endpoint", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Endpoint", "status", element.getStatusElement(), -1);
    if (element.hasConnectionType())
        composeCoding(t, "Endpoint", "connectionType", element.getConnectionType(), -1);
    if (element.hasNameElement())
        composeString(t, "Endpoint", "name", element.getNameElement(), -1);
    if (element.hasManagingOrganization())
        composeReference(t, "Endpoint", "managingOrganization", element.getManagingOrganization(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactPoint(t, "Endpoint", "contact", element.getContact().get(i), i);
    if (element.hasPeriod())
        composePeriod(t, "Endpoint", "period", element.getPeriod(), -1);
    for (int i = 0; i < element.getPayloadType().size(); i++) composeCodeableConcept(t, "Endpoint", "payloadType", element.getPayloadType().get(i), i);
    for (int i = 0; i < element.getPayloadMimeType().size(); i++) composeCode(t, "Endpoint", "payloadMimeType", element.getPayloadMimeType().get(i), i);
    if (element.hasAddressElement())
        composeUri(t, "Endpoint", "address", element.getAddressElement(), -1);
    for (int i = 0; i < element.getHeader().size(); i++) composeString(t, "Endpoint", "header", element.getHeader().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

Test (org.junit.jupiter.api.Test)36 Endpoint (org.hl7.fhir.dstu3.model.Endpoint)21 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)18 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)16 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)15 Endpoint (org.hl7.fhir.r4.model.Endpoint)15 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)14 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)14 Bundle (org.hl7.fhir.r4.model.Bundle)12 Organization (org.hl7.fhir.dstu3.model.Organization)11 Resource (org.hl7.fhir.r4.model.Resource)10 Resource (org.hl7.fhir.dstu3.model.Resource)9 Operation (ca.uhn.fhir.rest.annotation.Operation)7 List (java.util.List)7 Bundle (org.hl7.fhir.dstu3.model.Bundle)7 Description (ca.uhn.fhir.model.api.annotation.Description)6 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)6 ArrayList (java.util.ArrayList)6