Search in sources :

Example 36 with PlanDefinition

use of org.hl7.fhir.r5.model.PlanDefinition in project cqf-ruler by DBCG.

the class DiscoveryElementStu3 method getAsJson.

public JsonObject getAsJson() {
    JsonObject service = new JsonObject();
    if (planDefinition != null) {
        if (planDefinition.hasAction()) {
            // TODO - this needs some work - too naive
            if (planDefinition.getActionFirstRep().hasTriggerDefinition()) {
                if (planDefinition.getActionFirstRep().getTriggerDefinitionFirstRep().hasEventName()) {
                    service.addProperty("hook", planDefinition.getActionFirstRep().getTriggerDefinitionFirstRep().getEventName());
                }
            }
        }
        if (planDefinition.hasName()) {
            service.addProperty("name", planDefinition.getName());
        }
        if (planDefinition.hasTitle()) {
            service.addProperty("title", planDefinition.getTitle());
        }
        if (planDefinition.hasDescription()) {
            service.addProperty("description", planDefinition.getDescription());
        }
        service.addProperty("id", planDefinition.getIdElement().getIdPart());
        if (prefetchUrlList == null) {
            prefetchUrlList = new PrefetchUrlList();
        }
        JsonObject prefetchContent = new JsonObject();
        int itemNo = 0;
        if (!prefetchUrlList.stream().anyMatch(p -> p.equals("Patient/{{context.patientId}}") || p.equals("Patient?_id={{context.patientId}}") || p.equals("Patient?_id=Patient/{{context.patientId}}"))) {
            prefetchContent.addProperty("item1", "Patient?_id={{context.patientId}}");
            ++itemNo;
        }
        for (String item : prefetchUrlList) {
            prefetchContent.addProperty("item" + Integer.toString(++itemNo), item);
        }
        service.add("prefetch", prefetchContent);
        return service;
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) PlanDefinition(org.hl7.fhir.dstu3.model.PlanDefinition) JsonObject(com.google.gson.JsonObject)

Example 37 with PlanDefinition

use of org.hl7.fhir.r5.model.PlanDefinition in project pathling by aehrc.

the class LightweightFhirEncodersTest method testIdCollection.

@Test
public void testIdCollection() {
    final ExpressionEncoder<PlanDefinition> encoder = fhirEncoders.of(PlanDefinition.class);
    final PlanDefinition planDefinition = new PlanDefinition();
    final PlanDefinitionActionComponent actionComponent = planDefinition.getActionFirstRep();
    actionComponent.addGoalId(new IdType("Condition", "goal-1", "1").getValue());
    actionComponent.addGoalId(new IdType("Condition", "goal-2", "2").getValue());
    actionComponent.addGoalId(new IdType("Patient", "goal-3", "3").getValue());
    assertSerDeIsIdentity(encoder, planDefinition);
}
Also used : PlanDefinitionActionComponent(org.hl7.fhir.r4.model.PlanDefinition.PlanDefinitionActionComponent) Test(org.junit.Test)

Example 38 with PlanDefinition

use of org.hl7.fhir.r5.model.PlanDefinition in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composePlanDefinitionPlanDefinitionActionConditionComponent.

protected void composePlanDefinitionPlanDefinitionActionConditionComponent(Complex parent, String parentType, String name, PlanDefinition.PlanDefinitionActionConditionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "condition", name, element, index);
    if (element.hasKindElement())
        composeEnum(t, "PlanDefinition", "kind", element.getKindElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "PlanDefinition", "description", element.getDescriptionElement(), -1);
    if (element.hasLanguageElement())
        composeString(t, "PlanDefinition", "language", element.getLanguageElement(), -1);
    if (element.hasExpressionElement())
        composeString(t, "PlanDefinition", "expression", element.getExpressionElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 39 with PlanDefinition

use of org.hl7.fhir.r5.model.PlanDefinition in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method cacheResource.

public void cacheResource(Resource r) throws FHIRException {
    synchronized (lock) {
        Map<String, Resource> map = allResourcesById.get(r.fhirType());
        if (map == null) {
            map = new HashMap<String, Resource>();
            allResourcesById.put(r.fhirType(), map);
        }
        map.put(r.getId(), r);
        if (r instanceof MetadataResource) {
            MetadataResource m = (MetadataResource) r;
            String url = m.getUrl();
            if (!allowLoadingDuplicates && hasResource(r.getClass(), url))
                throw new DefinitionException("Duplicate Resource " + url);
            if (r instanceof StructureDefinition)
                seeMetadataResource((StructureDefinition) m, structures, false);
            else if (r instanceof ValueSet)
                seeMetadataResource((ValueSet) m, valueSets, false);
            else if (r instanceof CodeSystem)
                seeMetadataResource((CodeSystem) m, codeSystems, false);
            else if (r instanceof ImplementationGuide)
                seeMetadataResource((ImplementationGuide) m, guides, false);
            else if (r instanceof CapabilityStatement)
                seeMetadataResource((CapabilityStatement) m, capstmts, false);
            else if (r instanceof SearchParameter)
                seeMetadataResource((SearchParameter) m, searchParameters, false);
            else if (r instanceof PlanDefinition)
                seeMetadataResource((PlanDefinition) m, plans, false);
            else if (r instanceof OperationDefinition)
                seeMetadataResource((OperationDefinition) m, operations, false);
            else if (r instanceof Questionnaire)
                seeMetadataResource((Questionnaire) m, questionnaires, true);
            else if (r instanceof ConceptMap)
                seeMetadataResource((ConceptMap) m, maps, false);
            else if (r instanceof StructureMap)
                seeMetadataResource((StructureMap) m, transforms, false);
            else if (r instanceof NamingSystem)
                systems.add((NamingSystem) r);
        }
    }
}
Also used : DefinitionException(org.hl7.fhir.exceptions.DefinitionException)

Example 40 with PlanDefinition

use of org.hl7.fhir.r5.model.PlanDefinition in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composePlanDefinitionPlanDefinitionActionParticipantComponent.

protected void composePlanDefinitionPlanDefinitionActionParticipantComponent(Complex parent, String parentType, String name, PlanDefinition.PlanDefinitionActionParticipantComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "participant", name, element, index);
    if (element.hasTypeElement())
        composeEnum(t, "PlanDefinition", "type", element.getTypeElement(), -1);
    if (element.hasRole())
        composeCodeableConcept(t, "PlanDefinition", "role", element.getRole(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)8 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)8 PlanDefinition (org.hl7.fhir.dstu3.model.PlanDefinition)7 PlanDefinition (org.hl7.fhir.r4.model.PlanDefinition)7 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)6 Test (org.junit.jupiter.api.Test)6 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 ArrayList (java.util.ArrayList)5 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)5 JsonObject (com.google.gson.JsonObject)4 DomainResource (org.hl7.fhir.dstu3.model.DomainResource)4 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)3 Library (org.hl7.fhir.r4.model.Library)3 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)3 CanonicalResourceProxy (org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy)3 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)3 FhirContext (ca.uhn.fhir.context.FhirContext)2 Operation (ca.uhn.fhir.rest.annotation.Operation)2 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)2