Search in sources :

Example 21 with Compartment

use of org.hl7.fhir.definitions.model.Compartment in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeGraphDefinitionGraphDefinitionLinkTargetComponent.

protected void composeGraphDefinitionGraphDefinitionLinkTargetComponent(Complex parent, String parentType, String name, GraphDefinition.GraphDefinitionLinkTargetComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "target", name, element, index);
    if (element.hasTypeElement())
        composeCode(t, "GraphDefinition", "type", element.getTypeElement(), -1);
    if (element.hasParamsElement())
        composeString(t, "GraphDefinition", "params", element.getParamsElement(), -1);
    if (element.hasProfileElement())
        composeCanonical(t, "GraphDefinition", "profile", element.getProfileElement(), -1);
    for (int i = 0; i < element.getCompartment().size(); i++) composeGraphDefinitionGraphDefinitionLinkTargetCompartmentComponent(t, "GraphDefinition", "compartment", element.getCompartment().get(i), i);
    for (int i = 0; i < element.getLink().size(); i++) composeGraphDefinitionGraphDefinitionLinkComponent(t, "GraphDefinition", "link", element.getLink().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 22 with Compartment

use of org.hl7.fhir.definitions.model.Compartment in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeConformanceConformanceRestComponent.

protected void composeConformanceConformanceRestComponent(Complex parent, String parentType, String name, Conformance.ConformanceRestComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "rest", name, element, index);
    if (element.hasModeElement())
        composeEnum(t, "Conformance", "mode", element.getModeElement(), -1);
    if (element.hasDocumentationElement())
        composeString(t, "Conformance", "documentation", element.getDocumentationElement(), -1);
    if (element.hasSecurity())
        composeConformanceConformanceRestSecurityComponent(t, "Conformance", "security", element.getSecurity(), -1);
    for (int i = 0; i < element.getResource().size(); i++) composeConformanceConformanceRestResourceComponent(t, "Conformance", "resource", element.getResource().get(i), i);
    for (int i = 0; i < element.getInteraction().size(); i++) composeConformanceSystemInteractionComponent(t, "Conformance", "interaction", element.getInteraction().get(i), i);
    if (element.hasTransactionModeElement())
        composeEnum(t, "Conformance", "transactionMode", element.getTransactionModeElement(), -1);
    for (int i = 0; i < element.getSearchParam().size(); i++) composeConformanceConformanceRestResourceSearchParamComponent(t, "Conformance", "searchParam", element.getSearchParam().get(i), i);
    for (int i = 0; i < element.getOperation().size(); i++) composeConformanceConformanceRestOperationComponent(t, "Conformance", "operation", element.getOperation().get(i), i);
    for (int i = 0; i < element.getCompartment().size(); i++) composeUri(t, "Conformance", "compartment", element.getCompartment().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 23 with Compartment

use of org.hl7.fhir.definitions.model.Compartment in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareRests.

private void compareRests(List<CapabilityStatementRestComponent> left, List<CapabilityStatementRestComponent> right, StructuralMatch<Element> combined, List<CapabilityStatementRestComponent> union, List<CapabilityStatementRestComponent> intersection, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
    List<CapabilityStatementRestComponent> matchR = new ArrayList<>();
    for (CapabilityStatementRestComponent l : left) {
        CapabilityStatementRestComponent r = findInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
        } else {
            matchR.add(r);
            CapabilityStatementRestComponent cdM = merge(l, r, res);
            CapabilityStatementRestComponent cdI = intersect(l, r, res);
            union.add(cdM);
            intersection.add(cdI);
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            compare(sm, l, r, path + ".where(mode='" + l.getMode() + "')", res);
            combined.getChildren().add(sm);
            compareRestSecurity(l, r, sm, cdM.getSecurity(), cdI.getSecurity(), csU, csI, res, path + ".security");
            compareRestResources(l, r, sm, cdM, cdI, csU, csI, res, path + ".resource");
            compareSearchParams(combined, l.getSearchParam(), r.getSearchParam(), path, res, cdM.getSearchParam(), cdI.getSearchParam());
            compareOperations(combined, l.getOperation(), r.getOperation(), path, res, cdM.getOperation(), cdI.getOperation());
            compareItemPropertyList(sm, "compartment", l.getCompartment(), r.getCompartment(), path, res, cdM.getCompartment(), cdI.getCompartment(), IssueSeverity.ERROR);
        }
    }
    for (CapabilityStatementRestComponent r : right) {
        if (!matchR.contains(r)) {
            union.add(r);
            combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this concept", path), r));
        }
    }
}
Also used : BackboneElement(org.hl7.fhir.r4b.model.BackboneElement) Element(org.hl7.fhir.r4b.model.Element) ArrayList(java.util.ArrayList) CapabilityStatementRestComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent)

Example 24 with Compartment

use of org.hl7.fhir.definitions.model.Compartment in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generate.

public boolean generate(ResourceContext rcontext, CompartmentDefinition cpd) {
    StringBuilder in = new StringBuilder();
    StringBuilder out = new StringBuilder();
    for (CompartmentDefinitionResourceComponent cc : cpd.getResource()) {
        CommaSeparatedStringBuilder rules = new CommaSeparatedStringBuilder();
        if (!cc.hasParam()) {
            out.append(" <li><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></li>\r\n");
        } else if (!rules.equals("{def}")) {
            for (StringType p : cc.getParam()) rules.append(p.asStringValue());
            in.append(" <tr><td><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></td><td>").append(rules.toString()).append("</td></tr>\r\n");
        }
    }
    XhtmlNode x;
    try {
        x = new XhtmlParser().parseFragment("<div><p>\r\nThe following resources may be in this compartment:\r\n</p>\r\n" + "<table class=\"grid\">\r\n" + " <tr><td><b>Resource</b></td><td><b>Inclusion Criteria</b></td></tr>\r\n" + in.toString() + "</table>\r\n" + "<p>\r\nA resource is in this compartment if the nominated search parameter (or chain) refers to the patient resource that defines the compartment.\r\n</p>\r\n" + "<p>\r\n\r\n</p>\r\n" + "<p>\r\nThe following resources are never in this compartment:\r\n</p>\r\n" + "<ul>\r\n" + out.toString() + "</ul></div>\r\n");
        inject(cpd, x, NarrativeStatus.GENERATED);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) XhtmlParser(org.hl7.fhir.utilities.xhtml.XhtmlParser) CompartmentDefinitionResourceComponent(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent) StringType(org.hl7.fhir.dstu3.model.StringType) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) ParseException(java.text.ParseException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 25 with Compartment

use of org.hl7.fhir.definitions.model.Compartment in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generate.

public boolean generate(ResourceContext rcontext, CompartmentDefinition cpd) {
    StringBuilder in = new StringBuilder();
    StringBuilder out = new StringBuilder();
    for (CompartmentDefinitionResourceComponent cc : cpd.getResource()) {
        CommaSeparatedStringBuilder rules = new CommaSeparatedStringBuilder();
        if (!cc.hasParam()) {
            out.append(" <li><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></li>\r\n");
        } else if (!rules.equals("{def}")) {
            for (StringType p : cc.getParam()) rules.append(p.asStringValue());
            in.append(" <tr><td><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></td><td>").append(rules.toString()).append("</td></tr>\r\n");
        }
    }
    XhtmlNode x;
    try {
        x = new XhtmlParser().parseFragment("<div><p>\r\nThe following resources may be in this compartment:\r\n</p>\r\n" + "<table class=\"grid\">\r\n" + " <tr><td><b>Resource</b></td><td><b>Inclusion Criteria</b></td></tr>\r\n" + in.toString() + "</table>\r\n" + "<p>\r\nA resource is in this compartment if the nominated search parameter (or chain) refers to the patient resource that defines the compartment.\r\n</p>\r\n" + "<p>\r\n\r\n</p>\r\n" + "<p>\r\nThe following resources are never in this compartment:\r\n</p>\r\n" + "<ul>\r\n" + out.toString() + "</ul></div>\r\n");
        inject(cpd, x, NarrativeStatus.GENERATED);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) XhtmlParser(org.hl7.fhir.utilities.xhtml.XhtmlParser) CompartmentDefinitionResourceComponent(org.hl7.fhir.r4.model.CompartmentDefinition.CompartmentDefinitionResourceComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ParseException(java.text.ParseException) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)9 Compartment (org.hl7.fhir.definitions.model.Compartment)6 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)5 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)5 XhtmlParser (org.hl7.fhir.utilities.xhtml.XhtmlParser)5 IOException (java.io.IOException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 ArrayList (java.util.ArrayList)4 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 NotImplementedException (org.apache.commons.lang3.NotImplementedException)3 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 FileOutputStream (java.io.FileOutputStream)2 ParseException (java.text.ParseException)2 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)2 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)2 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)2 JsonParser (org.hl7.fhir.r5.formats.JsonParser)2 XmlParser (org.hl7.fhir.r5.formats.XmlParser)2 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)2