Search in sources :

Example 31 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method listByApprovalStatus.

private void listByApprovalStatus(StringBuilder b, List<String> res, FMGApproval state, String title) throws FHIRException {
    b.append("<p><b>" + title + "</b></p>\r\n");
    b.append("<ul style=\"width: 90%; -moz-column-count: 4; -moz-column-gap: 10px; -webkit-column-count: 4; -webkit-column-gap: 10px; column-count: 4; column-gap: 10px\">\r\n");
    for (String rn : res) {
        ResourceDefn rd = definitions.getResourceByName(rn);
        if (rd.getApproval() == state)
            if (rd.getNormativePackage() != null || rd.getNormativeVersion() != null)
                b.append("  <li><a title=\"[%resdesc " + rn + "%]\" href=\"" + rn.toLowerCase() + ".html\">" + rn + "</a> <a href=\"versions.html#std-process\"  title=\"Normative Content\" class=\"normative-flag\">N</a></li>\r\n");
            else
                b.append("  <li><a title=\"[%resdesc " + rn + "%]\" href=\"" + rn.toLowerCase() + ".html\">" + rn + "</a></li>\r\n");
    }
    b.append("</ul>\r\n");
}
Also used : ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 32 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method genImplementationList.

private String genImplementationList(ResourceDefn logical) throws FHIRException {
    String url = logical.getMappingUrl();
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"lines\">\r\n");
    for (String s : sorted(definitions.getResources().keySet())) {
        ResourceDefn rd = definitions.getResourceByName(s);
        StructureDefinition sd = rd.getProfile();
        String code = null;
        for (StructureDefinitionMappingComponent m : sd.getMapping()) {
            if (m.getUri().equals(url))
                code = m.getIdentity();
        }
        if (code != null) {
            if (hasLogicalMapping(sd, logical, code)) {
                b.append(" <tr>\r\n");
                b.append("  <td><a href=\"" + rd.getName().toLowerCase() + ".html\">" + rd.getName() + "</a>&nbsp;&nbsp;&nbsp;&nbsp;</td>\r\n");
                b.append("  <td><a href=\"" + rd.getName().toLowerCase() + "-mappings.html#" + url + "\">Mappings</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\r\n");
                b.append("  <td><a href=\"" + rd.getName().toLowerCase() + "-examples.html\">Examples</a></td>\r\n");
                b.append(" </tr>\r\n");
            }
        }
    }
    b.append("</table>");
    return b.toString();
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) StructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 33 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method buildResListByFMG.

private String buildResListByFMG() throws FHIRException {
    List<String> res = new ArrayList<String>();
    for (ResourceDefn rd : definitions.getBaseResources().values()) res.add(rd.getName());
    for (ResourceDefn rd : definitions.getResources().values()) res.add(rd.getName());
    Collections.sort(res);
    StringBuilder b = new StringBuilder();
    listByApprovalStatus(b, res, FMGApproval.NOPROPOSAL, "Not yet proposed");
    listByApprovalStatus(b, res, FMGApproval.PENDING, "Pending");
    listByApprovalStatus(b, res, FMGApproval.APPROVED, "Approved");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 34 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method buildShortParameterList.

private String buildShortParameterList(String param) throws Exception {
    String[] p1 = param.split("\\:");
    String[] op = p1[0].split("\\/");
    String[] p = p1[1].split("\\,");
    ResourceDefn rd = definitions.getResourceByName(op[0]);
    Operation od = rd.getOperationByName(op[1].substring(1));
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"grid\">\r\n");
    for (OperationParameter pd : od.getParameters()) {
        if (Utilities.existsInList(pd.getName(), p))
            b.append("<tr><td><code>" + pd.getName() + "</code></td><td>" + processMarkdown("short param list", pd.getDoc(), "") + "</td></tr>\r\n");
    }
    b.append("</table>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) OperationParameter(org.hl7.fhir.definitions.model.OperationParameter) Operation(org.hl7.fhir.definitions.model.Operation) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 35 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class ExampleInspector method fetch.

@Override
public Element fetch(IResourceValidator validator, Object appContext, String url) throws IOException, FHIRException {
    String[] parts = url.split("\\/");
    if (parts.length == 2 && definitions.hasResource(parts[0])) {
        ResourceDefn r = definitions.getResourceByName(parts[0]);
        for (Example e : r.getExamples()) {
            if (e.getElement() == null && e.hasXml()) {
                e.setElement(new org.hl7.fhir.r5.elementmodel.XmlParser(context).parse(e.getXml()));
                if (e.getElement().getProperty().getStructure().getBaseDefinition().contains("MetadataResource")) {
                    String urle = e.getElement().getChildValue("url");
                    String v = e.getElement().getChildValue("url");
                    if (urle != null && urle.startsWith("http://hl7.org/fhir") && !version.toCode().equals(v)) {
                        e.getElement().setChildValue("version", version.toCode());
                    }
                }
            }
            if (e.getElement() != null) {
                if (e.getElement().fhirType().equals("Bundle")) {
                    for (Base b : e.getElement().listChildrenByName("entry")) {
                        if (b.getChildByName("resource").hasValues()) {
                            Element res = (Element) b.getChildByName("resource").getValues().get(0);
                            if (res.fhirType().equals(parts[0]) && parts[1].equals(res.getChildValue("id"))) {
                                return res;
                            }
                        }
                    }
                } else if (e.getElement().fhirType().equals(parts[0]) && e.getId().equals(parts[1])) {
                    return e.getElement();
                }
            }
        }
        try {
            if (parts[0].equals("StructureDefinition"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(StructureDefinition.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("OperationDefinition"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(OperationDefinition.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("SearchParameter"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(SearchParameter.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("ValueSet"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(ValueSet.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("CodeSystem"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(CodeSystem.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
        } catch (Exception e) {
            return null;
        }
        return null;
    } else
        return null;
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ObjectConverter(org.hl7.fhir.r5.elementmodel.ObjectConverter) Example(org.hl7.fhir.definitions.model.Example) Element(org.hl7.fhir.r5.elementmodel.Element) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) Base(org.hl7.fhir.r5.model.Base) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) ValidationException(org.everit.json.schema.ValidationException) MalformedURLException(java.net.MalformedURLException) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Aggregations

ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)75 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)42 ArrayList (java.util.ArrayList)38 FHIRException (org.hl7.fhir.exceptions.FHIRException)36 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)31 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)28 File (java.io.File)26 FileOutputStream (java.io.FileOutputStream)25 CSFile (org.hl7.fhir.utilities.CSFile)24 XmlParser (org.hl7.fhir.r5.formats.XmlParser)22 FileNotFoundException (java.io.FileNotFoundException)20 IOException (java.io.IOException)20 Example (org.hl7.fhir.definitions.model.Example)20 Profile (org.hl7.fhir.definitions.model.Profile)20 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)18 IniFile (org.hl7.fhir.utilities.IniFile)18 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)16 TransformerException (javax.xml.transform.TransformerException)15 TextFile (org.hl7.fhir.utilities.TextFile)15 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)14