Search in sources :

Example 16 with PackageInfo

use of org.hl7.fhir.utilities.npm.PackageInfo in project org.hl7.fhir.core by hapifhir.

the class CachingPackageClientTests method testSearch2.

@Test
public void testSearch2() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2);
    List<PackageInfo> matches = client.search("core", null, null, false);
    for (PackageInfo pi : matches) {
        System.out.println(pi.toString());
    }
    Assertions.assertTrue(matches.size() > 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 17 with PackageInfo

use of org.hl7.fhir.utilities.npm.PackageInfo in project org.hl7.fhir.core by hapifhir.

the class CachingPackageClientTests method testVersionsNone2.

@Test
public void testVersionsNone2() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2);
    List<PackageInfo> matches = client.getVersions("Simplifier.Core.STU3X");
    Assertions.assertTrue(matches.size() == 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 18 with PackageInfo

use of org.hl7.fhir.utilities.npm.PackageInfo in project kindling by HL7.

the class PageProcessor method genValueSetsTable.

private String genValueSetsTable(ImplementationGuideDefn ig) throws Exception {
    StringBuilder s = new StringBuilder();
    s.append("<table class=\"codes\">\r\n");
    s.append(" <tr><td><b>Name</b></td><td><b>Definition</b></td><td><b>Source</b></td><td><b>Id</b></td></tr>\r\n");
    List<String> namespaces = new ArrayList<String>();
    CanonicalResourceManager<ValueSet> vslist = new CanonicalResourceManager<ValueSet>(false);
    for (String sn : definitions.getValuesets().keys()) {
        ValueSet vs = definitions.getValuesets().get(sn);
        if (vs.hasUrl() && !vs.getUrl().startsWith("http://terminology.hl7.org")) {
            vslist.see(vs, packageInfo());
            String n = getNamespace(sn);
            if (!n.equals("http://hl7.org/fhir/ValueSet") && !namespaces.contains(n) && !sn.startsWith("http://terminology.hl7.org/ValueSet/v2-") && !sn.startsWith("http://terminology.hl7.org/ValueSet/v3-"))
                namespaces.add(n);
        }
    }
    for (String sn : definitions.getExtraValuesets().keySet()) {
        ValueSet vs = definitions.getExtraValuesets().get(sn);
        vslist.see(vs, packageInfo());
    }
    Collections.sort(namespaces);
    generateVSforNS(s, "http://hl7.org/fhir/ValueSet", vslist, true, ig);
    for (String n : namespaces) generateVSforNS(s, n, definitions.getValuesets(), true, ig);
    s.append("</table>\r\n");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CanonicalResourceManager(org.hl7.fhir.r5.context.CanonicalResourceManager) ArrayList(java.util.ArrayList) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 19 with PackageInfo

use of org.hl7.fhir.utilities.npm.PackageInfo in project kindling by HL7.

the class CodeListToValueSetParser method generateConceptMapV3.

private void generateConceptMapV3(String v3map, ValueSet vs, CodeSystem cs) throws Exception {
    if (!v3map.startsWith("http://terminology.hl7.org/ValueSet/v3-"))
        v3map = "http://terminology.hl7.org/ValueSet/v3-" + v3map;
    ConceptMap cm = new ConceptMap();
    cm.setVersion(version);
    cm.setId("cm-" + vs.getId() + "-v3");
    cm.setUserData("path", cm.getId() + ".html");
    cm.setUserData("generate", true);
    cm.setUrl("http://hl7.org/fhir/ConceptMap/" + cm.getId());
    cm.setName("v3." + vs.getName());
    cm.setTitle("v3 map for " + vs.present());
    cm.setPublisher("HL7 (FHIR Project)");
    for (ContactDetail cc : vs.getContact()) {
        ContactDetail cd = cm.addContact();
        cd.setName(cc.getName());
        for (ContactPoint ccs : cc.getTelecom()) cd.addTelecom(ccs.copy());
    }
    cm.setCopyright(vs.getCopyright());
    // until we publish DSTU, then .review
    cm.setStatus(vs.getStatus());
    cm.setDate(vs.getDate());
    cm.setSource(Factory.newCanonical(vs.getUrl()));
    cm.setTarget(Factory.newCanonical(v3map));
    if (cs != null)
        processV3ConceptDefs(cm, cs.getUrl(), cs.getConcept());
    for (ConceptSetComponent cc : vs.getCompose().getInclude()) for (ConceptReferenceComponent c : cc.getConcept()) {
        processV3Map(cm, cc.getSystem(), c.getCode(), c.getUserString("v2"));
    }
    maps.see(cm, packageInfo);
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)

Example 20 with PackageInfo

use of org.hl7.fhir.utilities.npm.PackageInfo in project kindling by HL7.

the class CodeListToValueSetParser method execute.

public void execute(String v2map, String v3map, boolean utg) throws Exception {
    boolean hasDefine = false;
    for (int row = 0; row < sheet.rows.size(); row++) {
        hasDefine = hasDefine || Utilities.noString(sheet.getColumn(row, "System"));
    }
    Map<String, ConceptDefinitionComponent> codes = new HashMap<String, ConceptDefinitionComponent>();
    Map<String, ConceptDefinitionComponent> codesById = new HashMap<String, ConceptDefinitionComponent>();
    Map<String, ConceptSetComponent> includes = new HashMap<String, ConceptSetComponent>();
    CodeSystem cs = null;
    if (hasDefine) {
        cs = new CodeSystem();
        if (utg)
            cs.setUrl("http://terminology.hl7.org/CodeSystem/" + sheetName);
        else
            cs.setUrl("http://hl7.org/fhir/" + sheetName);
        if (!valueSet.hasCompose())
            valueSet.setCompose(new ValueSetComposeComponent());
        valueSet.getCompose().addInclude().setSystem(cs.getUrl());
        cs.setVersion(version);
        cs.setCaseSensitive(true);
        cs.setContent(CodeSystemContentMode.COMPLETE);
        codeSystems.see(cs, packageInfo);
        for (int row = 0; row < sheet.rows.size(); row++) {
            if (Utilities.noString(sheet.getColumn(row, "System"))) {
                ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
                cc.setUserData("id", sheet.getColumn(row, "Id"));
                cc.setCode(sheet.getColumn(row, "Code"));
                if (codes.containsKey(cc.getCode()))
                    throw new Exception("Duplicate Code " + cc.getCode());
                codes.put(cc.getCode(), cc);
                codesById.put(cc.getUserString("id"), cc);
                cc.setDisplay(sheet.getColumn(row, "Display"));
                if (sheet.getColumn(row, "Abstract").toUpperCase().equals("Y"))
                    CodeSystemUtilities.setNotSelectable(cs, cc);
                if (cc.hasCode() && !cc.hasDisplay())
                    cc.setDisplay(Utilities.humanize(cc.getCode()));
                cc.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Definition")));
                if (!Utilities.noString(sheet.getColumn(row, "Comment")))
                    ToolingExtensions.addCSComment(cc, sheet.getColumn(row, "Comment"));
                cc.setUserData("v2", sheet.getColumn(row, "v2"));
                cc.setUserData("v3", sheet.getColumn(row, "v3"));
                for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
                    cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
                String parent = sheet.getColumn(row, "Parent");
                if (Utilities.noString(parent))
                    cs.addConcept(cc);
                else if (parent.startsWith("#") && codesById.containsKey(parent.substring(1)))
                    codesById.get(parent.substring(1)).addConcept(cc);
                else if (codes.containsKey(parent))
                    codes.get(parent).addConcept(cc);
                else
                    throw new Exception("Parent " + parent + " not resolved in " + sheetName);
            }
        }
    }
    for (int row = 0; row < sheet.rows.size(); row++) {
        if (!Utilities.noString(sheet.getColumn(row, "System"))) {
            String system = sheet.getColumn(row, "System");
            ConceptSetComponent t = includes.get(system);
            if (t == null) {
                if (!valueSet.hasCompose())
                    valueSet.setCompose(new ValueSetComposeComponent());
                t = valueSet.getCompose().addInclude();
                t.setSystem(system);
                includes.put(system, t);
            }
            ConceptReferenceComponent cc = t.addConcept();
            cc.setCode(sheet.getColumn(row, "Code"));
            if (codes.containsKey(cc.getCode()))
                throw new Exception("Duplicate Code " + cc.getCode());
            codes.put(cc.getCode(), null);
            cc.setDisplay(sheet.getColumn(row, "Display"));
            if (!Utilities.noString(sheet.getColumn(row, "Definition")))
                ToolingExtensions.addDefinition(cc, sheet.getColumn(row, "Definition"));
            if (!Utilities.noString(sheet.getColumn(row, "Comment")))
                ToolingExtensions.addVSComment(cc, sheet.getColumn(row, "Comment"));
            cc.setUserDataINN("v2", sheet.getColumn(row, "v2"));
            cc.setUserDataINN("v3", sheet.getColumn(row, "v3"));
            for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
                cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
        }
    }
    if (!Utilities.noString(v2map)) {
        generateConceptMapV2(v2map, valueSet, cs);
    }
    if (!Utilities.noString(v3map)) {
        generateConceptMapV3(v3map, valueSet, cs);
    }
    if (cs != null)
        CodeSystemConvertor.populate(cs, valueSet);
}
Also used : ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) HashMap(java.util.HashMap) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Aggregations

PackageInfo (org.hl7.fhir.utilities.npm.PackageInfo)12 CachingPackageClient (org.hl7.fhir.utilities.npm.CachingPackageClient)11 CodeType (org.hl7.fhir.r5.model.CodeType)10 Test (org.junit.jupiter.api.Test)10 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)8 ValueSet (org.hl7.fhir.r5.model.ValueSet)8 ArrayList (java.util.ArrayList)6 ValueSetComposeComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent)5 File (java.io.File)4 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)4 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)4 FileInputStream (java.io.FileInputStream)3 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 XmlParser (org.hl7.fhir.r5.formats.XmlParser)3 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)3 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2