Search in sources :

Example 26 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method participantRow.

private void participantRow(XhtmlNode t, String label, ContactDetail cd, boolean email, boolean phone, boolean url) {
    XhtmlNode tr = t.tr();
    tr.td().tx(label);
    tr.td().tx(cd.getName());
    if (email) {
        renderContactPoint(tr.td(), cd.getEmail());
    }
    if (phone) {
        renderContactPoint(tr.td(), cd.getPhone());
    }
    if (url) {
        renderContactPoint(tr.td(), cd.getUrl());
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 27 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method render.

public boolean render(XhtmlNode x, Library lib) throws FHIRFormatError, DefinitionException, IOException {
    if (lib.hasAuthor() || lib.hasEditor() || lib.hasReviewer() || lib.hasEndorser()) {
        boolean email = hasCT(lib.getAuthor(), "email") || hasCT(lib.getEditor(), "email") || hasCT(lib.getReviewer(), "email") || hasCT(lib.getEndorser(), "email");
        boolean phone = hasCT(lib.getAuthor(), "phone") || hasCT(lib.getEditor(), "phone") || hasCT(lib.getReviewer(), "phone") || hasCT(lib.getEndorser(), "phone");
        boolean url = hasCT(lib.getAuthor(), "url") || hasCT(lib.getEditor(), "url") || hasCT(lib.getReviewer(), "url") || hasCT(lib.getEndorser(), "url");
        x.h2().tx("Participants");
        XhtmlNode t = x.table("grid");
        for (ContactDetail cd : lib.getAuthor()) {
            participantRow(t, "Author", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEditor()) {
            participantRow(t, "Editor", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getReviewer()) {
            participantRow(t, "Reviewer", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEndorser()) {
            participantRow(t, "Endorser", cd, email, phone, url);
        }
    }
    if (lib.hasRelatedArtifact()) {
        x.h2().tx("Related Artifacts");
        XhtmlNode t = x.table("grid");
        boolean label = false;
        boolean display = false;
        boolean citation = false;
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            label = label || ra.hasLabel();
            display = display || ra.hasDisplay();
            citation = citation || ra.hasCitation();
        }
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            renderArtifact(t, ra, lib, label, display, citation);
        }
    }
    if (lib.hasParameter()) {
        x.h2().tx("Parameters");
        XhtmlNode t = x.table("grid");
        boolean doco = false;
        for (ParameterDefinition p : lib.getParameter()) {
            doco = doco || p.hasDocumentation();
        }
        for (ParameterDefinition p : lib.getParameter()) {
            renderParameter(t, p, doco);
        }
    }
    if (lib.hasDataRequirement()) {
        x.h2().tx("Data Requirements");
        for (DataRequirement p : lib.getDataRequirement()) {
            renderDataRequirement(x, p);
        }
    }
    if (lib.hasContent()) {
        x.h2().tx("Contents");
        boolean isCql = false;
        int counter = 0;
        for (Attachment att : lib.getContent()) {
            renderAttachment(x, att, isCql, counter, lib.getId());
            isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
            counter++;
        }
    }
    return false;
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) Attachment(org.hl7.fhir.r5.model.Attachment) DataRequirement(org.hl7.fhir.r5.model.DataRequirement) RelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition)

Example 28 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class OpenApiGenerator method generate.

public void generate(String license, String url) {
    dest.info().title(source.present()).description(source.getDescription()).license(license, url).version(source.getVersion());
    for (ContactDetail cd : source.getContact()) {
        dest.info().contact(cd.getName(), email(cd.getTelecom()), url(cd.getTelecom()));
    }
    if (source.hasPublisher())
        dest.info().contact(source.getPublisher(), null, null);
    if (source.hasImplementation()) {
        dest.server(source.getImplementation().getUrl()).description(source.getImplementation().getDescription());
    }
    dest.externalDocs().url(source.getUrl()).description("FHIR CapabilityStatement");
    for (CapabilityStatementRestComponent csr : source.getRest()) {
        if (csr.getMode() == RestfulCapabilityMode.SERVER) {
            generatePaths(csr);
        }
    }
    writeBaseParameters(dest.components());
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) CapabilityStatementRestComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent)

Example 29 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class NPMPackageGenerator method buildPackageJson.

private void buildPackageJson(String canonical, PackageType kind, String web, Date date, ImplementationGuide ig, List<String> fhirVersion, boolean notForPublication) throws FHIRException, IOException {
    String dtHuman = new SimpleDateFormat("EEE, MMM d, yyyy HH:mmZ", new Locale("en", "US")).format(date);
    String dt = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    if (!ig.hasPackageId()) {
        b.append("packageId");
    }
    if (!ig.hasVersion()) {
        b.append("version");
    }
    if (!ig.hasFhirVersion()) {
        b.append("fhirVersion");
    }
    if (!ig.hasLicense()) {
        b.append("license");
    }
    for (ImplementationGuideDependsOnComponent d : ig.getDependsOn()) {
        if (!d.hasVersion()) {
            b.append("dependsOn.version(" + d.getUri() + ")");
        }
    }
    JsonObject npm = new JsonObject();
    npm.addProperty("name", ig.getPackageId());
    npm.addProperty("version", ig.getVersion());
    igVersion = ig.getVersion();
    npm.addProperty("tools-version", ToolsVersion.TOOLS_VERSION);
    npm.addProperty("type", kind.getCode());
    npm.addProperty("date", dt);
    if (ig.hasLicense()) {
        npm.addProperty("license", ig.getLicense().toCode());
    }
    npm.addProperty("canonical", canonical);
    if (notForPublication) {
        npm.addProperty("notForPublication", true);
    }
    npm.addProperty("url", web);
    if (ig.hasTitle()) {
        npm.addProperty("title", ig.getTitle());
    }
    if (ig.hasDescription()) {
        npm.addProperty("description", ig.getDescription() + " (built " + dtHuman + timezone() + ")");
    }
    JsonArray vl = new JsonArray();
    npm.add("fhirVersions", vl);
    for (String v : fhirVersion) {
        vl.add(new JsonPrimitive(v));
    }
    if (kind != PackageType.CORE) {
        JsonObject dep = new JsonObject();
        npm.add("dependencies", dep);
        for (String v : fhirVersion) {
            String vp = packageForVersion(v);
            if (vp != null) {
                dep.addProperty(vp, v);
            }
        }
        for (ImplementationGuideDependsOnComponent d : ig.getDependsOn()) {
            dep.addProperty(d.getPackageId(), d.getVersion());
        }
    }
    if (ig.hasPublisher()) {
        npm.addProperty("author", ig.getPublisher());
    }
    JsonArray m = new JsonArray();
    for (ContactDetail t : ig.getContact()) {
        String email = email(t.getTelecom());
        String url = url(t.getTelecom());
        if (t.hasName() & (email != null || url != null)) {
            JsonObject md = new JsonObject();
            m.add(md);
            md.addProperty("name", t.getName());
            if (email != null)
                md.addProperty("email", email);
            if (url != null)
                md.addProperty("url", url);
        }
    }
    if (m.size() > 0)
        npm.add("maintainers", m);
    if (ig.getManifest().hasRendering())
        npm.addProperty("homepage", ig.getManifest().getRendering());
    JsonObject dir = new JsonObject();
    npm.add("directories", dir);
    dir.addProperty("lib", "package");
    dir.addProperty("example", "example");
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    String json = gson.toJson(npm);
    try {
        addFile(Category.RESOURCE, "package.json", json.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
    }
    packageJ = npm;
    packageManifest = new JsonObject();
    packageManifest.addProperty("version", ig.getVersion());
    JsonArray fv = new JsonArray();
    for (String v : fhirVersion) {
        fv.add(v);
    }
    packageManifest.add("fhirVersion", fv);
    packageManifest.addProperty("date", dt);
    packageManifest.addProperty("name", ig.getPackageId());
}
Also used : Locale(java.util.Locale) JsonArray(com.google.gson.JsonArray) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ImplementationGuideDependsOnComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDependsOnComponent) JsonPrimitive(com.google.gson.JsonPrimitive) GsonBuilder(com.google.gson.GsonBuilder) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 30 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generate.

public boolean generate(ResourceContext rcontext, ConceptMap cm) throws FHIRFormatError, DefinitionException, IOException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    x.h2().addText(cm.getName() + " (" + cm.getUrl() + ")");
    XhtmlNode p = x.para();
    if (cm.hasSource() || cm.hasTarget())
        p.tx("Mapping from ");
    if (!cm.hasSource())
        p.tx("(unspecified)");
    else
        AddVsRef(rcontext, cm.getSource() instanceof Reference ? ((Reference) cm.getSource()).getReference() : ((UriType) cm.getSource()).asStringValue(), p);
    p.tx(" to ");
    if (!cm.hasTarget())
        p.tx("(unspecified)");
    else
        AddVsRef(rcontext, cm.getTarget() instanceof Reference ? ((Reference) cm.getTarget()).getReference() : ((UriType) cm.getTarget()).asStringValue(), p);
    p = x.para();
    if (cm.getExperimental())
        p.addText(Utilities.capitalize(cm.getStatus().toString()) + " (not intended for production usage). ");
    else
        p.addText(Utilities.capitalize(cm.getStatus().toString()) + ". ");
    p.tx("Published on " + (cm.hasDate() ? cm.getDateElement().toHumanDisplay() : "??") + " by " + cm.getPublisher());
    if (!cm.getContact().isEmpty()) {
        p.tx(" (");
        boolean firsti = true;
        for (ContactDetail ci : cm.getContact()) {
            if (firsti)
                firsti = false;
            else
                p.tx(", ");
            if (ci.hasName())
                p.addText(ci.getName() + ": ");
            boolean first = true;
            for (ContactPoint c : ci.getTelecom()) {
                if (first)
                    first = false;
                else
                    p.tx(", ");
                addTelecom(p, c);
            }
        }
        p.tx(")");
    }
    p.tx(". ");
    p.addText(cm.getCopyright());
    if (!Utilities.noString(cm.getDescription()))
        addMarkdown(x, cm.getDescription());
    x.br();
    for (ConceptMapGroupComponent grp : cm.getGroup()) {
        String src = grp.getSource();
        boolean comment = false;
        boolean ok = true;
        Map<String, HashSet<String>> sources = new HashMap<String, HashSet<String>>();
        Map<String, HashSet<String>> targets = new HashMap<String, HashSet<String>>();
        sources.put("code", new HashSet<String>());
        targets.put("code", new HashSet<String>());
        SourceElementComponent cc = grp.getElement().get(0);
        String dst = grp.getTarget();
        sources.get("code").add(grp.getSource());
        targets.get("code").add(grp.getTarget());
        for (SourceElementComponent ccl : grp.getElement()) {
            ok = ok && ccl.getTarget().size() == 1 && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty();
            for (TargetElementComponent ccm : ccl.getTarget()) {
                comment = comment || !Utilities.noString(ccm.getComment());
                for (OtherElementComponent d : ccm.getDependsOn()) {
                    if (!sources.containsKey(d.getProperty()))
                        sources.put(d.getProperty(), new HashSet<String>());
                    sources.get(d.getProperty()).add(d.getSystem());
                }
                for (OtherElementComponent d : ccm.getProduct()) {
                    if (!targets.containsKey(d.getProperty()))
                        targets.put(d.getProperty(), new HashSet<String>());
                    targets.get(d.getProperty()).add(d.getSystem());
                }
            }
        }
        String display;
        if (ok) {
            // simple
            XhtmlNode tbl = x.table("grid");
            XhtmlNode tr = tbl.tr();
            tr.td().b().tx("Source Code");
            tr.td().b().tx("Equivalence");
            tr.td().b().tx("Destination Code");
            if (comment)
                tr.td().b().tx("Comment");
            for (SourceElementComponent ccl : grp.getElement()) {
                tr = tbl.tr();
                XhtmlNode td = tr.td();
                td.addText(ccl.getCode());
                display = getDisplayForConcept(grp.getSource(), ccl.getCode());
                if (display != null)
                    td.tx(" (" + display + ")");
                TargetElementComponent ccm = ccl.getTarget().get(0);
                tr.td().addText(!ccm.hasEquivalence() ? "" : ccm.getEquivalence().toCode());
                td = tr.td();
                td.addText(ccm.getCode());
                display = getDisplayForConcept(grp.getTarget(), ccm.getCode());
                if (display != null)
                    td.tx(" (" + display + ")");
                if (comment)
                    tr.td().addText(ccm.getComment());
            }
        } else {
            XhtmlNode tbl = x.table("grid");
            XhtmlNode tr = tbl.tr();
            XhtmlNode td;
            tr.td().colspan(Integer.toString(sources.size())).b().tx("Source Concept");
            tr.td().b().tx("Equivalence");
            tr.td().colspan(Integer.toString(targets.size())).b().tx("Destination Concept");
            if (comment)
                tr.td().b().tx("Comment");
            tr = tbl.tr();
            if (sources.get("code").size() == 1)
                tr.td().b().tx("Code " + sources.get("code").toString() + "");
            else
                tr.td().b().tx("Code");
            for (String s : sources.keySet()) {
                if (!s.equals("code")) {
                    if (sources.get(s).size() == 1)
                        tr.td().b().addText(getDescForConcept(s) + " " + sources.get(s).toString());
                    else
                        tr.td().b().addText(getDescForConcept(s));
                }
            }
            tr.td();
            if (targets.get("code").size() == 1)
                tr.td().b().tx("Code " + targets.get("code").toString());
            else
                tr.td().b().tx("Code");
            for (String s : targets.keySet()) {
                if (!s.equals("code")) {
                    if (targets.get(s).size() == 1)
                        tr.td().b().addText(getDescForConcept(s) + " " + targets.get(s).toString() + "");
                    else
                        tr.td().b().addText(getDescForConcept(s));
                }
            }
            if (comment)
                tr.td();
            for (SourceElementComponent ccl : grp.getElement()) {
                tr = tbl.tr();
                td = tr.td();
                if (sources.get("code").size() == 1)
                    td.addText(ccl.getCode());
                else
                    td.addText(grp.getSource() + " / " + ccl.getCode());
                display = getDisplayForConcept(grp.getSource(), ccl.getCode());
                if (display != null)
                    td.tx(" (" + display + ")");
                TargetElementComponent ccm = ccl.getTarget().get(0);
                for (String s : sources.keySet()) {
                    if (!s.equals("code")) {
                        td = tr.td();
                        td.addText(getCode(ccm.getDependsOn(), s, sources.get(s).size() != 1));
                        display = getDisplay(ccm.getDependsOn(), s);
                        if (display != null)
                            td.tx(" (" + display + ")");
                    }
                }
                if (!ccm.hasEquivalence())
                    tr.td().tx(":" + "(" + ConceptMapEquivalence.EQUIVALENT.toCode() + ")");
                else
                    tr.td().tx(":" + ccm.getEquivalence().toCode());
                td = tr.td();
                if (targets.get("code").size() == 1)
                    td.addText(ccm.getCode());
                else
                    td.addText(grp.getTarget() + " / " + ccm.getCode());
                display = getDisplayForConcept(grp.getTarget(), ccm.getCode());
                if (display != null)
                    td.tx(" (" + display + ")");
                for (String s : targets.keySet()) {
                    if (!s.equals("code")) {
                        td = tr.td();
                        td.addText(getCode(ccm.getProduct(), s, targets.get(s).size() != 1));
                        display = getDisplay(ccm.getProduct(), s);
                        if (display != null)
                            td.tx(" (" + display + ")");
                    }
                }
                if (comment)
                    tr.td().addText(ccm.getComment());
            }
        }
    }
    inject(cm, x, NarrativeStatus.GENERATED);
    return true;
}
Also used : HashMap(java.util.HashMap) Reference(org.hl7.fhir.dstu3.model.Reference) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ContactDetail(org.hl7.fhir.dstu3.model.ContactDetail) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) OtherElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent) TargetElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent) ConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent) SourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent) HashSet(java.util.HashSet)

Aggregations

ContactDetail (org.hl7.fhir.dstu3.model.ContactDetail)15 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)15 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)9 ContactDetail (org.hl7.fhir.r4b.model.ContactDetail)7 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 CodeType (org.hl7.fhir.r5.model.CodeType)6 NotImplementedException (org.apache.commons.lang3.NotImplementedException)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 HashSet (java.util.HashSet)4 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)4 ContactPoint (org.hl7.fhir.r4b.model.ContactPoint)4 Gson (com.google.gson.Gson)3 GsonBuilder (com.google.gson.GsonBuilder)3 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 FileOutputStream (java.io.FileOutputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HashMap (java.util.HashMap)3 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)3 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)3