Search in sources :

Example 26 with CanonicalResource

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

the class ResourceRenderer method generateCopyright.

protected void generateCopyright(XhtmlNode x, CanonicalResource cs) {
    XhtmlNode p = x.para();
    p.b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Copyright Statement:", context.getLang()));
    smartAddText(p, " " + cs.getCopyright());
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 27 with CanonicalResource

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

the class ResourceRenderer method renderCommitteeLink.

protected void renderCommitteeLink(XhtmlNode x, CanonicalResource cr) {
    String code = ToolingExtensions.readStringExtension(cr, ToolingExtensions.EXT_WORKGROUP);
    CodeSystem cs = context.getWorker().fetchCodeSystem("http://terminology.hl7.org/CodeSystem/hl7-work-group");
    if (cs == null || !cs.hasUserData("path"))
        x.tx(code);
    else {
        ConceptDefinitionComponent cd = CodeSystemUtilities.findCode(cs.getConcept(), code);
        if (cd == null) {
            x.tx(code);
        } else {
            x.ah(cs.getUserString("path") + "#" + cs.getId() + "-" + cd.getCode()).tx(cd.getDisplay());
        }
    }
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem)

Example 28 with CanonicalResource

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

the class TerminologyRenderer method AddVsRef.

protected void AddVsRef(String value, XhtmlNode li) {
    Resource res = null;
    if (rcontext != null) {
        BundleEntryComponent be = rcontext.resolve(value);
        if (be != null) {
            res = be.getResource();
        }
    }
    if (res != null && !(res instanceof CanonicalResource)) {
        li.addText(value);
        return;
    }
    CanonicalResource vs = (CanonicalResource) res;
    if (vs == null)
        vs = getContext().getWorker().fetchResource(ValueSet.class, value);
    if (vs == null)
        vs = getContext().getWorker().fetchResource(StructureDefinition.class, value);
    // vs = context.getWorker().fetchResource(DataElement.class, value);
    if (vs == null)
        vs = getContext().getWorker().fetchResource(Questionnaire.class, value);
    if (vs != null) {
        String ref = (String) vs.getUserData("path");
        ref = context.fixReference(ref);
        XhtmlNode a = li.ah(ref == null ? "?ngen-11?" : ref.replace("\\", "/"));
        a.addText(value);
    } else {
        CodeSystem cs = getContext().getWorker().fetchCodeSystem(value);
        if (cs != null) {
            String ref = (String) cs.getUserData("path");
            ref = context.fixReference(ref);
            XhtmlNode a = li.ah(ref == null ? "?ngen-12?" : ref.replace("\\", "/"));
            a.addText(value);
        } else if (value.equals("http://snomed.info/sct") || value.equals("http://snomed.info/id")) {
            XhtmlNode a = li.ah(value);
            a.tx("SNOMED-CT");
        } else {
            if (value.startsWith("http://hl7.org") && !Utilities.existsInList(value, "http://hl7.org/fhir/sid/icd-10-us"))
                System.out.println("Unable to resolve value set " + value);
            li.addText(value);
        }
    }
}
Also used : BundleEntryComponent(org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent) CanonicalResource(org.hl7.fhir.r4b.model.CanonicalResource) Resource(org.hl7.fhir.r4b.model.Resource) DomainResource(org.hl7.fhir.r4b.model.DomainResource) CanonicalResource(org.hl7.fhir.r4b.model.CanonicalResource) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 29 with CanonicalResource

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

the class ValueSetRenderer method findReleventMaps.

private List<UsedConceptMap> findReleventMaps(ValueSet vs) throws FHIRException {
    List<UsedConceptMap> res = new ArrayList<UsedConceptMap>();
    for (CanonicalResource md : getContext().getWorker().allConformanceResources()) {
        if (md instanceof ConceptMap) {
            ConceptMap cm = (ConceptMap) md;
            if (isSource(vs, cm.getSource())) {
                ConceptMapRenderInstructions re = findByTarget(cm.getTarget());
                if (re != null) {
                    ValueSet vst = cm.hasTarget() ? getContext().getWorker().fetchResource(ValueSet.class, cm.hasTargetCanonicalType() ? cm.getTargetCanonicalType().getValue() : cm.getTargetUriType().asStringValue()) : null;
                    res.add(new UsedConceptMap(re, vst == null ? cm.getUserString("path") : vst.getUserString("path"), cm));
                }
            }
        }
    }
    return res;
// Map<ConceptMap, String> mymaps = new HashMap<ConceptMap, String>();
// for (ConceptMap a : context.getWorker().findMapsForSource(vs.getUrl())) {
// String url = "";
// ValueSet vsr = context.getWorker().fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference());
// if (vsr != null)
// url = (String) vsr.getUserData("filename");
// mymaps.put(a, url);
// }
// Map<ConceptMap, String> mymaps = new HashMap<ConceptMap, String>();
// for (ConceptMap a : context.getWorker().findMapsForSource(cs.getValueSet())) {
// String url = "";
// ValueSet vsr = context.getWorker().fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference());
// if (vsr != null)
// url = (String) vsr.getUserData("filename");
// mymaps.put(a, url);
// }
// also, look in the contained resources for a concept map
// for (Resource r : cs.getContained()) {
// if (r instanceof ConceptMap) {
// ConceptMap cm = (ConceptMap) r;
// if (((Reference) cm.getSource()).getReference().equals(cs.getValueSet())) {
// String url = "";
// ValueSet vsr = context.getWorker().fetchResource(ValueSet.class, ((Reference) cm.getTarget()).getReference());
// if (vsr != null)
// url = (String) vsr.getUserData("filename");
// mymaps.put(cm, url);
// }
// }
// }
}
Also used : ArrayList(java.util.ArrayList) ConceptMap(org.hl7.fhir.r4b.model.ConceptMap) CanonicalResource(org.hl7.fhir.r4b.model.CanonicalResource) ValueSet(org.hl7.fhir.r4b.model.ValueSet)

Example 30 with CanonicalResource

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

the class CapabilityStatementComparer method addPrimitiveTypeRow.

@SuppressWarnings("rawtypes")
private Row addPrimitiveTypeRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t, CapabilityStatementComparison comparison) {
    Row r = gen.new Row();
    rows.add(r);
    r.getCells().add(gen.new Cell(null, null, t.getName(), null, null));
    PrimitiveType left = t.hasLeft() ? (PrimitiveType) t.getLeft() : null;
    PrimitiveType right = t.hasRight() ? (PrimitiveType) t.getRight() : null;
    CanonicalResource crL = left == null ? null : (CanonicalResource) session.getContextLeft().fetchResource(Resource.class, left.primitiveValue());
    CanonicalResource crR = right == null ? null : (CanonicalResource) session.getContextRight().fetchResource(Resource.class, right.primitiveValue());
    String refL = crL != null && crL.hasUserData("path") ? crL.getUserString("path") : null;
    String dispL = crL != null && refL != null ? crL.present() : left == null ? "" : left.primitiveValue();
    String refR = crR != null && crR.hasUserData("path") ? crR.getUserString("path") : null;
    String dispR = crR != null && refR != null ? crR.present() : right == null ? "" : right.primitiveValue();
    r.getCells().add(style(gen.new Cell(null, refL, dispL, null, null), left != null ? left.primitiveValue() : null, right != null ? right.primitiveValue() : null, true));
    r.getCells().add(gen.new Cell(null, null, "", null, null));
    r.getCells().add(style(gen.new Cell(null, refR, dispR, null, null), left != null ? left.primitiveValue() : null, right != null ? right.primitiveValue() : null, false));
    r.getCells().add(gen.new Cell(null, null, "", null, null));
    r.getCells().add(cellForMessages(gen, t.getMessages()));
    return r;
}
Also used : PrimitiveType(org.hl7.fhir.r5.model.PrimitiveType) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)20 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)19 ArrayList (java.util.ArrayList)17 File (java.io.File)11 CanonicalResource (org.hl7.fhir.r4b.model.CanonicalResource)10 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)10 XmlParser (org.hl7.fhir.r5.formats.XmlParser)9 org.hl7.fhir.r5.model (org.hl7.fhir.r5.model)9 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)9 FileOutputStream (java.io.FileOutputStream)8 IOException (java.io.IOException)8 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)8 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)8 Resource (org.hl7.fhir.r5.model.Resource)8 ValueSet (org.hl7.fhir.r5.model.ValueSet)8 FileNotFoundException (java.io.FileNotFoundException)7 Resource (org.hl7.fhir.r4b.model.Resource)7 CodeSystem (org.hl7.fhir.r4b.model.CodeSystem)5 SearchParameter (org.hl7.fhir.r5.model.SearchParameter)5 FileInputStream (java.io.FileInputStream)4