Search in sources :

Example 21 with PlanDefinition

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

the class BaseWorkerContext method registerResourceFromPackage.

public void registerResourceFromPackage(CanonicalResourceProxy r, PackageVersion packageInfo) throws FHIRException {
    synchronized (lock) {
        if (r.getId() != null) {
            Map<String, ResourceProxy> map = allResourcesById.get(r.getType());
            if (map == null) {
                map = new HashMap<String, ResourceProxy>();
                allResourcesById.put(r.getType(), map);
            }
            if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
                map.put(r.getId(), new ResourceProxy(r));
            }
        }
        String url = r.getUrl();
        if (!allowLoadingDuplicates && hasResource(r.getType(), url)) {
            // spcial workaround for known problems with existing packages
            if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
                return;
            }
            throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
        }
        switch(r.getType()) {
            case "StructureDefinition":
                if ("1.4.0".equals(version)) {
                    StructureDefinition sd = (StructureDefinition) r.getResource();
                    fixOldSD(sd);
                }
                structures.register(r, packageInfo);
                break;
            case "ValueSet":
                valueSets.register(r, packageInfo);
                break;
            case "CodeSystem":
                codeSystems.register(r, packageInfo);
                break;
            case "ImplementationGuide":
                guides.register(r, packageInfo);
                break;
            case "CapabilityStatement":
                capstmts.register(r, packageInfo);
                break;
            case "Measure":
                measures.register(r, packageInfo);
                break;
            case "Library":
                libraries.register(r, packageInfo);
                break;
            case "SearchParameter":
                searchParameters.register(r, packageInfo);
                break;
            case "PlanDefinition":
                plans.register(r, packageInfo);
                break;
            case "OperationDefinition":
                operations.register(r, packageInfo);
                break;
            case "Questionnaire":
                questionnaires.register(r, packageInfo);
                break;
            case "ConceptMap":
                maps.register(r, packageInfo);
                break;
            case "StructureMap":
                transforms.register(r, packageInfo);
                break;
            case "NamingSystem":
                systems.register(r, packageInfo);
                break;
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) CanonicalResourceProxy(org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy)

Example 22 with PlanDefinition

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

the class BaseWorkerContext method cacheResourceFromPackage.

public void cacheResourceFromPackage(Resource r, PackageVersion packageInfo) throws FHIRException {
    synchronized (lock) {
        if (r.getId() != null) {
            Map<String, ResourceProxy> map = allResourcesById.get(r.fhirType());
            if (map == null) {
                map = new HashMap<String, ResourceProxy>();
                allResourcesById.put(r.fhirType(), map);
            }
            if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
                map.put(r.getId(), new ResourceProxy(r));
            } else {
                logger.logDebugMessage(LogCategory.PROGRESS, "Ignore " + r.fhirType() + "/" + r.getId() + " from package " + packageInfo.toString());
            }
        }
        if (r instanceof CodeSystem || r instanceof NamingSystem) {
            oidCache.clear();
        }
        if (r instanceof CanonicalResource) {
            CanonicalResource m = (CanonicalResource) r;
            String url = m.getUrl();
            if (!allowLoadingDuplicates && hasResource(r.getClass(), url)) {
                // special workaround for known problems with existing packages
                if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
                    return;
                }
                throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
            }
            if (r instanceof StructureDefinition) {
                StructureDefinition sd = (StructureDefinition) m;
                if ("1.4.0".equals(version)) {
                    fixOldSD(sd);
                }
                structures.see(sd, packageInfo);
            } else if (r instanceof ValueSet) {
                valueSets.see((ValueSet) m, packageInfo);
            } else if (r instanceof CodeSystem) {
                CodeSystemUtilities.crossLinkCodeSystem((CodeSystem) r);
                codeSystems.see((CodeSystem) m, packageInfo);
            } else if (r instanceof ImplementationGuide) {
                guides.see((ImplementationGuide) m, packageInfo);
            } else if (r instanceof CapabilityStatement) {
                capstmts.see((CapabilityStatement) m, packageInfo);
            } else if (r instanceof Measure) {
                measures.see((Measure) m, packageInfo);
            } else if (r instanceof Library) {
                libraries.see((Library) m, packageInfo);
            } else if (r instanceof SearchParameter) {
                searchParameters.see((SearchParameter) m, packageInfo);
            } else if (r instanceof PlanDefinition) {
                plans.see((PlanDefinition) m, packageInfo);
            } else if (r instanceof OperationDefinition) {
                operations.see((OperationDefinition) m, packageInfo);
            } else if (r instanceof Questionnaire) {
                questionnaires.see((Questionnaire) m, packageInfo);
            } else if (r instanceof ConceptMap) {
                maps.see((ConceptMap) m, packageInfo);
            } else if (r instanceof StructureMap) {
                transforms.see((StructureMap) m, packageInfo);
            } else if (r instanceof NamingSystem) {
                systems.see((NamingSystem) m, packageInfo);
            }
        }
    }
}
Also used : Questionnaire(org.hl7.fhir.r5.model.Questionnaire) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) CanonicalResourceProxy(org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy) StructureMap(org.hl7.fhir.r5.model.StructureMap) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) CapabilityStatement(org.hl7.fhir.r5.model.CapabilityStatement) Measure(org.hl7.fhir.r5.model.Measure) PlanDefinition(org.hl7.fhir.r5.model.PlanDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) Library(org.hl7.fhir.r5.model.Library) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) ValueSet(org.hl7.fhir.r5.model.ValueSet) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition)

Example 23 with PlanDefinition

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

the class RdfParser method composePlanDefinitionPlanDefinitionActionRelatedActionComponent.

protected void composePlanDefinitionPlanDefinitionActionRelatedActionComponent(Complex parent, String parentType, String name, PlanDefinition.PlanDefinitionActionRelatedActionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "relatedAction", name, element, index);
    if (element.hasActionIdElement())
        composeId(t, "PlanDefinition", "actionId", element.getActionIdElement(), -1);
    if (element.hasRelationshipElement())
        composeEnum(t, "PlanDefinition", "relationship", element.getRelationshipElement(), -1);
    if (element.hasOffset())
        composeType(t, "PlanDefinition", "offset", element.getOffset(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 24 with PlanDefinition

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

the class RdfParser method composePlanDefinitionPlanDefinitionActionComponent.

protected void composePlanDefinitionPlanDefinitionActionComponent(Complex parent, String parentType, String name, PlanDefinition.PlanDefinitionActionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "action", name, element, index);
    if (element.hasPrefixElement())
        composeString(t, "PlanDefinition", "prefix", element.getPrefixElement(), -1);
    if (element.hasTitleElement())
        composeString(t, "PlanDefinition", "title", element.getTitleElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "PlanDefinition", "description", element.getDescriptionElement(), -1);
    if (element.hasTextEquivalentElement())
        composeString(t, "PlanDefinition", "textEquivalent", element.getTextEquivalentElement(), -1);
    if (element.hasPriorityElement())
        composeEnum(t, "PlanDefinition", "priority", element.getPriorityElement(), -1);
    for (int i = 0; i < element.getCode().size(); i++) composeCodeableConcept(t, "PlanDefinition", "code", element.getCode().get(i), i);
    for (int i = 0; i < element.getReason().size(); i++) composeCodeableConcept(t, "PlanDefinition", "reason", element.getReason().get(i), i);
    for (int i = 0; i < element.getDocumentation().size(); i++) composeRelatedArtifact(t, "PlanDefinition", "documentation", element.getDocumentation().get(i), i);
    for (int i = 0; i < element.getGoalId().size(); i++) composeId(t, "PlanDefinition", "goalId", element.getGoalId().get(i), i);
    if (element.hasSubject())
        composeType(t, "PlanDefinition", "subject", element.getSubject(), -1);
    for (int i = 0; i < element.getTrigger().size(); i++) composeTriggerDefinition(t, "PlanDefinition", "trigger", element.getTrigger().get(i), i);
    for (int i = 0; i < element.getCondition().size(); i++) composePlanDefinitionPlanDefinitionActionConditionComponent(t, "PlanDefinition", "condition", element.getCondition().get(i), i);
    for (int i = 0; i < element.getInput().size(); i++) composeDataRequirement(t, "PlanDefinition", "input", element.getInput().get(i), i);
    for (int i = 0; i < element.getOutput().size(); i++) composeDataRequirement(t, "PlanDefinition", "output", element.getOutput().get(i), i);
    for (int i = 0; i < element.getRelatedAction().size(); i++) composePlanDefinitionPlanDefinitionActionRelatedActionComponent(t, "PlanDefinition", "relatedAction", element.getRelatedAction().get(i), i);
    if (element.hasTiming())
        composeType(t, "PlanDefinition", "timing", element.getTiming(), -1);
    for (int i = 0; i < element.getParticipant().size(); i++) composePlanDefinitionPlanDefinitionActionParticipantComponent(t, "PlanDefinition", "participant", element.getParticipant().get(i), i);
    if (element.hasType())
        composeCodeableConcept(t, "PlanDefinition", "type", element.getType(), -1);
    if (element.hasGroupingBehaviorElement())
        composeEnum(t, "PlanDefinition", "groupingBehavior", element.getGroupingBehaviorElement(), -1);
    if (element.hasSelectionBehaviorElement())
        composeEnum(t, "PlanDefinition", "selectionBehavior", element.getSelectionBehaviorElement(), -1);
    if (element.hasRequiredBehaviorElement())
        composeEnum(t, "PlanDefinition", "requiredBehavior", element.getRequiredBehaviorElement(), -1);
    if (element.hasPrecheckBehaviorElement())
        composeEnum(t, "PlanDefinition", "precheckBehavior", element.getPrecheckBehaviorElement(), -1);
    if (element.hasCardinalityBehaviorElement())
        composeEnum(t, "PlanDefinition", "cardinalityBehavior", element.getCardinalityBehaviorElement(), -1);
    if (element.hasDefinition())
        composeType(t, "PlanDefinition", "definition", element.getDefinition(), -1);
    if (element.hasTransformElement())
        composeCanonical(t, "PlanDefinition", "transform", element.getTransformElement(), -1);
    for (int i = 0; i < element.getDynamicValue().size(); i++) composePlanDefinitionPlanDefinitionActionDynamicValueComponent(t, "PlanDefinition", "dynamicValue", element.getDynamicValue().get(i), i);
    for (int i = 0; i < element.getAction().size(); i++) composePlanDefinitionPlanDefinitionActionComponent(t, "PlanDefinition", "action", element.getAction().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 25 with PlanDefinition

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

the class DataRenderer method isCanonical.

private boolean isCanonical(String path) {
    if (!path.endsWith(".url"))
        return false;
    String t = path.substring(0, path.length() - 4);
    StructureDefinition sd = getContext().getWorker().fetchTypeDefinition(t);
    if (sd == null)
        return false;
    if (Utilities.existsInList(t, VersionUtilities.getCanonicalResourceNames(getContext().getWorker().getVersion()))) {
        return true;
    }
    if (Utilities.existsInList(t, "ActivityDefinition", "CapabilityStatement", "CapabilityStatement2", "ChargeItemDefinition", "Citation", "CodeSystem", "CompartmentDefinition", "ConceptMap", "ConditionDefinition", "EventDefinition", "Evidence", "EvidenceReport", "EvidenceVariable", "ExampleScenario", "GraphDefinition", "ImplementationGuide", "Library", "Measure", "MessageDefinition", "NamingSystem", "PlanDefinition"))
        return true;
    return sd.getBaseDefinitionElement().hasExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-codegen-super");
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition)

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