Search in sources :

Example 1 with Enumerations

use of org.hl7.fhir.r4.model.Enumerations in project org.hl7.fhir.core by hapifhir.

the class JavaEnumerationsGenerator method generate.

public void generate() throws Exception {
    write("package org.hl7.fhir." + jid + ".model;\r\n");
    startMark(version, genDate);
    write("\r\n");
    write("import org.hl7.fhir.instance.model.api.*;\r\n");
    write("import org.hl7.fhir.exceptions.FHIRException;\r\n");
    write("\r\n");
    write("public class Enumerations {\r\n");
    write("\r\n");
    write("// In here: \r\n");
    Map<String, ValueSet> enums = scanForEnums();
    List<String> names = new ArrayList<String>();
    names.addAll(enums.keySet());
    Collections.sort(names);
    for (String n : names) {
        ValueSet vs = enums.get(n);
        write("//   " + n + ": " + vs.getDescription());
        if (vs.hasUserData("usages")) {
            write(vs.getUserData("usages").toString());
        } else {
            write("?null?");
        }
        write("\r\n");
    }
    write("\r\n");
    write("\r\n");
    for (String n : names) {
        ValueSet vs = enums.get(n);
        generateEnum(n, (ValueSet) vs.getUserData("expansion"));
    }
    write("\r\n");
    write("}\r\n");
    write("\r\n");
    flush();
}
Also used : ArrayList(java.util.ArrayList) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 2 with Enumerations

use of org.hl7.fhir.r4.model.Enumerations in project org.hl7.fhir.core by hapifhir.

the class JavaParserJsonGenerator method genElementComposer.

private void genElementComposer(Analysis analysis, TypeInfo ti, ElementDefinition ed, ElementDefinition inh) throws Exception {
    String name = ed.getName();
    if (name.endsWith("[x]") || name.equals("[type]")) {
        String en = name.endsWith("[x]") && !name.equals("[x]") ? name.replace("[x]", "") : "value";
        String pfx = name.endsWith("[x]") ? name.replace("[x]", "") : "";
        composer.append("      if (element.has" + upFirst(en) + "()) {\r\n");
        composer.append("        composeType(\"" + pfx + "\", element.get" + upFirst(en) + "());\r\n");
        composer.append("      }\r\n");
    } else {
        String tn = ed.getUserString("java.type");
        String comp = null;
        String en = null;
        boolean enShared = false;
        if (ed.hasUserData("java.enum")) {
            // getCodeListType(cd.getBinding());
            EnumInfo ei = (EnumInfo) ed.getUserData("java.enum");
            ValueSet vs = ei.getValueSet();
            enShared = vs.hasUserData("shared");
            if (enShared) {
                en = "Enumerations." + ei.getName();
            } else {
                en = analysis.getClassName() + "." + ei.getName();
            }
        } else {
            if (name.equals("extension")) {
                name = "extension";
                tn = "Extension";
            }
            if (tn.equals("XhtmlNode")) {
                tn = "xhtml";
                comp = "composeXhtml";
            } else if (tn.equals("code")) {
                tn = "Code";
                comp = "composeCode";
            } else if (tn.equals("instant")) {
                tn = "Instant";
            } else if (tn.contains("Reference(")) {
                comp = "composeReference";
                tn = "Reference";
            } else if (tn.contains("canonical(")) {
                comp = "composeCanonical";
                tn = "CanonicalType";
            } else if (tn.contains("(")) {
                comp = "compose" + tn;
            } else if (tn.startsWith(analysis.getName()) && !tn.equals(analysis.getClassName())) {
                comp = "compose" + leaf(tn);
            } else if (isPrimitive(ed)) {
                comp = "compose" + leaf(tn);
                // remove Type"
                comp = comp.substring(0, comp.length() - 4);
            } else {
                comp = "compose" + leaf(tn);
            }
        }
        if (ed.unbounded()) {
            tn = ed.getUserString("java.type");
            if (tn.contains("Reference(")) {
                comp = "composeReference";
                tn = "Reference";
            } else if (tn.contains("canonical(")) {
                comp = "composeCanonical";
                tn = "CanonicalType";
            }
            String stn = tn;
            if (ed.isInlineType() || ed.hasContentReference()) {
                stn = analysis.getClassName() + "." + tn;
            }
            composer.append("      if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            if (en == null) {
                if (tn.equals("String"))
                    tn = "StringType";
                if (definitions.hasPrimitiveType(tn)) {
                    tn = upFirst(tn) + "Type";
                }
                if (isPrimitive(ed) || ed.typeSummary().startsWith("canonical(")) {
                    composer.append("        if (anyHasValue(element.get" + upFirst(getElementName(name, false)) + "())) {\r\n");
                    composer.append("          openArray(\"" + name + "\");\r\n");
                    composer.append("          for (" + (tn.contains("(") ? stn : upFirst(tn)) + " e : element.get" + upFirst(getElementName(name, false)) + "()) \r\n");
                    composer.append("            " + comp + "Core(null, e, e != element.get" + upFirst(getElementName(name, false)) + "().get(element.get" + upFirst(getElementName(name, false)) + "().size()-1));\r\n");
                    composer.append("          closeArray();\r\n");
                    composer.append("        }\r\n");
                    composer.append("        if (anyHasExtras(element.get" + upFirst(getElementName(name, false)) + "())) {\r\n");
                    composer.append("          openArray(\"_" + name + "\");\r\n");
                    composer.append("          for (" + (stn.contains("(") ? stn : upFirst(stn)) + " e : element.get" + upFirst(getElementName(name, false)) + "()) \r\n");
                    composer.append("            " + comp + "Extras(null, e, true);\r\n");
                    composer.append("          closeArray();\r\n");
                    composer.append("        }\r\n");
                } else if (ed.typeSummary().equals("Resource")) {
                    composer.append("        openArray(\"" + name + "\");\r\n");
                    composer.append("        for (" + (stn.contains("(") ? tn : upFirst(tn)) + " e : element.get" + upFirst(getElementName(name, false)) + "()) {\r\n");
                    composer.append("          open(null);\r\n");
                    composer.append("          " + comp + "(e);\r\n");
                    composer.append("          close();\r\n");
                    composer.append("        }\r\n");
                    composer.append("        closeArray();\r\n");
                } else {
                    composer.append("        openArray(\"" + name + "\");\r\n");
                    composer.append("        for (" + (stn.contains("(") ? stn : upFirst(stn)) + " e : element.get" + upFirst(getElementName(name, false)) + "()) \r\n");
                    composer.append("          " + comp + "(null, e);\r\n");
                    composer.append("        closeArray();\r\n");
                }
            } else {
                composer.append("        openArray(\"" + name + "\");\r\n");
                composer.append("        for (Enumeration<" + prepEnumName(en) + "> e : element.get" + upFirst(getElementName(name, false)) + "()) \r\n");
                composer.append("          composeEnumerationCore(null, e, new " + prepEnumName(en) + "EnumFactory(), true);\r\n");
                composer.append("        closeArray();\r\n");
                composer.append("        if (anyHasExtras(element.get" + upFirst(getElementName(name, false)) + "())) {\r\n");
                composer.append("          openArray(\"_" + name + "\");\r\n");
                composer.append("          for (Enumeration<" + prepEnumName(en) + "> e : element.get" + upFirst(getElementName(name, false)) + "()) \r\n");
                composer.append("            composeEnumerationExtras(null, e, new " + prepEnumName(en) + "EnumFactory(), true);\r\n");
                composer.append("          closeArray();\r\n");
                composer.append("        }\r\n");
            }
            composer.append("      };\r\n");
        } else if (en != null) {
            composer.append("      if (element.has" + upFirst(getElementName(name, false)) + "Element()) {\r\n");
            if (enShared) {
                composer.append("        composeEnumerationCore(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element(), new " + prepEnumName(en) + "EnumFactory(), false);\r\n");
                composer.append("        composeEnumerationExtras(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element(), new " + prepEnumName(en) + "EnumFactory(), false);\r\n");
            } else {
                composer.append("        composeEnumerationCore(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element(), new " + prepEnumName(en) + "EnumFactory(), false);\r\n");
                composer.append("        composeEnumerationExtras(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element(), new " + prepEnumName(en) + "EnumFactory(), false);\r\n");
            }
            composer.append("      }\r\n");
        // composer.append("        composeString(\""+name+"\", element.get"+upFirst(getElementName(name, false))+"().toCode());\r\n");
        } else if (ed.typeSummary().equals("Resource")) {
            composer.append("        if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            composer.append("          open(\"" + name + "\");\r\n");
            composer.append("          " + comp + "(element.get" + upFirst(getElementName(name, false)) + "());\r\n");
            composer.append("          close();\r\n");
            composer.append("        }\r\n");
        } else if (!"xhtml".equals(ed.typeSummary()) && (isPrimitive(ed) || ed.typeSummary().startsWith("canonical("))) {
            composer.append("      if (element.has" + upFirst(getElementName(name, false)) + "Element()) {\r\n");
            composer.append("        " + comp + "Core(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element(), false);\r\n");
            composer.append("        " + comp + "Extras(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element(), false);\r\n");
            composer.append("      }\r\n");
        } else if (tn.equals("xhtml")) {
            composer.append("      if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            composer.append("        XhtmlNode node = element.getDiv();\r\n");
            composer.append("        if (node.getNsDecl() == null) {\r\n");
            composer.append("          node.attribute(\"xmlns\", XHTML_NS);\r\n");
            composer.append("        }\r\n");
            composer.append("        " + comp + "(\"" + name + "\", node);\r\n");
            composer.append("      }\r\n");
        } else if (inh != null && inh.unbounded()) {
            composer.append("      if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            composer.append("        " + comp + "(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "FirstRep());\r\n");
            composer.append("      }\r\n");
        } else {
            composer.append("      if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            composer.append("        " + comp + "(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "());\r\n");
            composer.append("      }\r\n");
        }
    }
}
Also used : EnumInfo(org.hl7.fhir.core.generator.analysis.EnumInfo) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 3 with Enumerations

use of org.hl7.fhir.r4.model.Enumerations in project org.hl7.fhir.core by hapifhir.

the class JavaParserXmlGenerator method genElementCompose.

private void genElementCompose(Analysis analysis, TypeInfo ti, ElementDefinition ed, ElementDefinition inh) throws Exception {
    String name = ed.getName();
    if (name.endsWith("[x]") || name.equals("[type]")) {
        String en = name.endsWith("[x]") && !name.equals("[x]") ? name.replace("[x]", "") : "value";
        String pfx = name.endsWith("[x]") ? name.replace("[x]", "") : "";
        composer.append("    if (element.has" + upFirst(getElementName(en, false)) + "()) {\r\n");
        composer.append("      composeType(\"" + pfx + "\", element.get" + upFirst(getElementName(en, false)) + "());\r\n");
        composer.append("    }");
    } else {
        String comp = null;
        String en = null;
        String tn = ed.getUserString("java.type");
        if (ed.hasUserData("java.enum")) {
            EnumInfo ei = (EnumInfo) ed.getUserData("java.enum");
            ValueSet vs = ei.getValueSet();
            boolean enShared = vs.hasUserData("shared");
            if (enShared) {
                en = "Enumerations." + ei.getName();
            } else {
                en = analysis.getClassName() + "." + ei.getName();
            }
        } else {
            if (name.equals("extension")) {
                name = "extension";
                tn = "Extension";
            }
            if (tn.equals("XhtmlNode")) {
                tn = "xhtml";
                comp = "composeXhtml";
            } else if (isPrimitive(ed)) {
                comp = "compose" + tn.substring(0, tn.length() - 4);
            } else if (tn.contains("Reference(")) {
                comp = "composeReference";
                tn = "Reference";
            } else if (tn.contains("canonical(")) {
                comp = "composeCanonical";
                tn = "CanonicalType";
            } else if (tn.contains("(")) {
                comp = "compose" + tn;
            } else if ((ed.hasContentReference() || ed.isInlineType()) && !tn.startsWith(analysis.getClassName())) {
                comp = "compose" + analysis.getClassName() + tn;
            } else {
                comp = "compose" + tn;
            }
        }
        if (ed.unbounded()) {
            if (en != null) {
                composer.append("      if (element.has" + upFirst(getElementName(name, false)) + "()) \r\n");
                composer.append("        for (Enumeration<" + en + "> e : element.get" + upFirst(getElementName(name, false)) + "()) \r\n");
                composer.append("          composeEnumeration(\"" + name + "\", e, new " + en + "EnumFactory());\r\n");
            } else {
                String stn = ed.isInlineType() || ed.hasContentReference() ? analysis.getClassName() + "." + tn : tn;
                // String pfx = ed.isInlineType() || ed.hasContentReference() ? analysis.getClassName() : "";
                composer.append("    if (element.has" + upFirst(getElementName(name, false)) + "()) { \r\n");
                composer.append("      for (" + stn + " e : element.get" + upFirst(getElementName(name, false)) + "()) \r\n");
                if (ed.typeSummary().equals("Resource")) {
                    composer.append("        {\r\n");
                    composer.append("          xml.enter(FHIR_NS, \"" + name + "\");\r\n");
                    composer.append("          " + comp + "(e);\r\n");
                    composer.append("          xml.exit(FHIR_NS, \"" + name + "\");\r\n");
                    composer.append("        }\r\n");
                } else {
                    composer.append("          " + comp + "(\"" + name + "\", e);\r\n");
                }
                composer.append("    }\r\n");
            }
        } else if (en != null) {
            composer.append("    if (element.has" + upFirst(getElementName(name, false)) + "Element())\r\n");
            composer.append("      composeEnumeration(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element(), new " + en + "EnumFactory());\r\n");
        } else if (!"xhtml".equals(ed.typeSummary()) && (isJavaPrimitive(ed) || ed.typeSummary().startsWith("canonical("))) {
            composer.append("    if (element.has" + upFirst(getElementName(name, false)) + "Element()) {\r\n");
            composer.append("      " + comp + "(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "Element());\r\n");
            composer.append("    }\r\n");
        } else if (ed.typeSummary().equals("Resource")) {
            composer.append("    if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            composer.append("      xml.enter(FHIR_NS, \"" + name + "\");\r\n");
            composer.append("      " + comp + "(element.get" + upFirst(getElementName(name, false)) + "());\r\n");
            composer.append("      xml.exit(FHIR_NS, \"" + name + "\");\r\n");
            composer.append("    }\r\n");
        } else if (inh != null && inh.unbounded()) {
            composer.append("    if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            composer.append("      " + comp + "(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "FirstRep());\r\n");
            composer.append("    }\r\n");
        } else {
            composer.append("    if (element.has" + upFirst(getElementName(name, false)) + "()) {\r\n");
            composer.append("      " + comp + "(\"" + name + "\", element.get" + upFirst(getElementName(name, false)) + "());\r\n");
            composer.append("    }\r\n");
        }
    }
}
Also used : EnumInfo(org.hl7.fhir.core.generator.analysis.EnumInfo) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 4 with Enumerations

use of org.hl7.fhir.r4.model.Enumerations in project org.hl7.fhir.core by hapifhir.

the class JavaParserXmlGenerator method genElement.

private void genElement(Analysis analysis, TypeInfo ti, ElementDefinition ed, ElementDefinition inh, boolean first) throws Exception {
    String name = ed.getName();
    if (name.endsWith("[x]") || name.equals("[type]")) {
        String en = name.endsWith("[x]") && !name.equals("[x]") ? name.replace("[x]", "") : "value";
        String pfx = name.endsWith("[x]") && !name.equals("[x]") ? name.replace("[x]", "") : "";
        parser.append("    " + (!first ? "} else " : "") + "if (eventType == XmlPullParser.START_TAG && nameIsTypeName(xpp, \"" + pfx + "\")) {\r\n");
        parser.append("      res.set" + upFirst(getElementName(en, false)) + "(parseType(\"" + en + "\", xpp));\r\n");
    } else {
        String prsr = null;
        if (ed.hasUserData("java.enum")) {
            // getCodeListType(cd.getBinding());
            EnumInfo ei = (EnumInfo) ed.getUserData("java.enum");
            ValueSet vs = ei.getValueSet();
            boolean enShared = vs.hasUserData("shared");
            String en;
            if (enShared) {
                en = "Enumerations." + ei.getName();
            } else {
                en = analysis.getClassName() + "." + ei.getName();
            }
            // en+".fromCode(parseString(xpp))";
            prsr = "parseEnumeration(xpp, " + en + ".NULL, new " + en.substring(0, en.indexOf(".")) + "." + en.substring(en.indexOf(".") + 1) + "EnumFactory())";
        // parseEnumeration(xpp, Narrative.NarrativeStatus.additional, new Narrative.NarrativeStatusEnumFactory())
        } else {
            String tn = ed.getUserString("java.type");
            if (name.equals("extension")) {
                name = "extension";
                tn = "Extension";
            }
            if (tn.contains("Reference("))
                prsr = "parseReference(xpp)";
            else if (tn.contains("canonical("))
                prsr = "parseCanonical(xpp)";
            else if (tn.contains("("))
                prsr = "parse" + tn + "(xpp)";
            else if (tn.startsWith(analysis.getName()) && !tn.equals(analysis.getClassName())) /* && !definitions.hasType(tn)*/
            {
                prsr = "parse" + upFirst(tn) + "(xpp)";
            } else if (tn.equals("Resource") || tn.equals("DomainResource"))
                prsr = "parse" + upFirst(tn) + "Contained(xpp)";
            else if (isPrimitive(ed)) {
                prsr = "parse" + upFirst(tn.substring(0, tn.length() - 4)) + "(xpp)";
            } else if ((ed.hasContentReference() || ed.isInlineType()) && !tn.startsWith(analysis.getClassName())) {
                prsr = "parse" + analysis.getClassName() + upFirst(tn) + "(xpp)";
            } else {
                prsr = "parse" + upFirst(tn) + "(xpp)";
            }
        }
        if (ed.unbounded()) {
            parser.append("    " + (!first ? "} else " : "") + "if (eventType == XmlPullParser.START_TAG && xpp.getName().equals(\"" + name + "\")) {\r\n");
            parser.append("      res.get" + upFirst(getElementName(name, false)) + "().add(" + prsr + ");\r\n");
        } else if (inh != null && inh.unbounded()) {
            parser.append("    " + (!first ? "} else " : "") + "if (eventType == XmlPullParser.START_TAG && xpp.getName().equals(\"" + name + "\")) {\r\n");
            parser.append("      res.add" + upFirst(getElementName(name, false)) + (!ed.typeSummary().equals("xhtml") && (isPrimitive(ed) || ed.typeSummary().startsWith("canonical(")) ? "Element" : "") + "(" + prsr + ");\r\n");
        } else {
            parser.append("    " + (!first ? "} else " : "") + "if (eventType == XmlPullParser.START_TAG && xpp.getName().equals(\"" + name + "\")) {\r\n");
            parser.append("      res.set" + upFirst(getElementName(name, false)) + (!ed.typeSummary().equals("xhtml") && (isPrimitive(ed) || ed.typeSummary().startsWith("canonical(")) ? "Element" : "") + "(" + prsr + ");\r\n");
        }
    }
}
Also used : EnumInfo(org.hl7.fhir.core.generator.analysis.EnumInfo) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 5 with Enumerations

use of org.hl7.fhir.r4.model.Enumerations in project org.hl7.fhir.core by hapifhir.

the class JavaCoreGenerator method generate.

private void generate(String version, String src, String dest) throws Exception {
    long start = System.currentTimeMillis();
    Date date = new Date();
    String ap = Utilities.path(src);
    System.out.println("Load Configuration from " + ap);
    Configuration config = new Configuration(ap);
    String pid = VersionUtilities.isR4BVer(version) ? "r4b" : "r5";
    String jid = VersionUtilities.isR4BVer(version) ? "r4b" : "r5";
    FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
    System.out.println("Cache: " + pcm.getFolder());
    System.out.println("Load hl7.fhir." + pid + ".core");
    NpmPackage npm = pcm.loadPackage("hl7.fhir." + pid + ".core", version);
    Definitions master = VersionUtilities.isR4BVer(version) ? DefinitionsLoaderR4B.load(npm) : DefinitionsLoaderR5.load(npm);
    master.fix();
    markValueSets(master, config);
    System.out.println("Load hl7.fhir." + pid + ".expansions");
    Definitions expansions = DefinitionsLoaderR5.load(pcm.loadPackage("hl7.fhir." + pid + ".expansions", version));
    System.out.println("Process Expansions");
    updateExpansions(master, expansions);
    System.out.println("Generate Model");
    System.out.println(" .. Constants");
    JavaConstantsGenerator cgen = new JavaConstantsGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "Constants.java")), master, config, date, npm.version(), jid);
    cgen.generate();
    cgen.close();
    System.out.println(" .. Enumerations");
    JavaEnumerationsGenerator egen = new JavaEnumerationsGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "Enumerations.java")), master, config, date, npm.version(), jid);
    egen.generate();
    egen.close();
    JavaFactoryGenerator fgen = new JavaFactoryGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "ResourceFactory.java")), master, config, date, npm.version(), jid);
    JavaTypeGenerator tgen = new JavaTypeGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "ResourceType.java")), master, config, date, npm.version(), jid);
    JavaParserJsonGenerator jgen = new JavaParserJsonGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "JsonParser.java")), master, config, date, npm.version(), jid);
    JavaParserXmlGenerator xgen = new JavaParserXmlGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "XmlParser.java")), master, config, date, npm.version(), jid);
    JavaParserRdfGenerator rgen = new JavaParserRdfGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "RdfParser.java")), master, config, date, npm.version(), jid);
    if (VersionUtilities.isR4BVer(version)) {
        StructureDefinition sd = master.getStructures().get("http://hl7.org/fhir/StructureDefinition/Element");
        genClass(version, dest, date, config, jid, npm, master, jgen, xgen, rgen, sd);
    }
    for (StructureDefinition sd : master.getStructures().getList()) {
        if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && sd.getKind() == StructureDefinitionKind.COMPLEXTYPE) {
            if (!Utilities.existsInList(sd.getName(), "Base", "PrimitiveType") && !sd.getName().contains(".") && sd.getAbstract()) {
                genClass(version, dest, date, config, jid, npm, master, jgen, xgen, rgen, sd);
            }
        }
    }
    for (StructureDefinition sd : master.getStructures().getList()) {
        if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && sd.getKind() == StructureDefinitionKind.COMPLEXTYPE) {
            if (!Utilities.existsInList(sd.getName(), "Base", "PrimitiveType") && !sd.getName().contains(".") && !sd.getAbstract()) {
                genClass(version, dest, date, config, jid, npm, master, jgen, xgen, rgen, sd);
            }
        }
    }
    if (VersionUtilities.isR4BVer(version)) {
        StructureDefinition sd = master.getStructures().get("http://hl7.org/fhir/StructureDefinition/Resource");
        genClass(version, dest, date, config, jid, npm, master, jgen, xgen, rgen, sd);
    }
    for (StructureDefinition sd : master.getStructures().getList()) {
        if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && sd.getKind() == StructureDefinitionKind.RESOURCE) {
            if (!Utilities.existsInList(sd.getName(), "Base", "PrimitiveType") && !sd.getName().contains(".") && sd.getAbstract()) {
                genClass(version, dest, date, config, jid, npm, master, jgen, xgen, rgen, sd);
            }
        }
    }
    for (StructureDefinition sd : master.getStructures().getList()) {
        if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && sd.getKind() == StructureDefinitionKind.RESOURCE) {
            if (!Utilities.existsInList(sd.getName(), "Base", "PrimitiveType") && !sd.getName().contains(".") && !sd.getAbstract()) {
                genClass(version, dest, date, config, jid, npm, master, jgen, xgen, rgen, sd);
            }
        }
    }
    System.out.println(" .. Factory");
    fgen.generate();
    fgen.close();
    System.out.println(" .. Types");
    tgen.generate();
    tgen.close();
    System.out.println(" .. JsonParser");
    jgen.generate();
    jgen.close();
    System.out.println(" .. XmlParser");
    xgen.generate();
    xgen.close();
    System.out.println(" .. RdfParser");
    rgen.generate();
    rgen.close();
    System.out.println("Done (" + Long.toString(System.currentTimeMillis() - start) + "ms)");
}
Also used : JavaEnumerationsGenerator(org.hl7.fhir.core.generator.codegen.JavaEnumerationsGenerator) FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager) JavaTypeGenerator(org.hl7.fhir.core.generator.codegen.JavaTypeGenerator) Configuration(org.hl7.fhir.core.generator.codegen.Configuration) JavaParserRdfGenerator(org.hl7.fhir.core.generator.codegen.JavaParserRdfGenerator) JavaParserJsonGenerator(org.hl7.fhir.core.generator.codegen.JavaParserJsonGenerator) JavaParserXmlGenerator(org.hl7.fhir.core.generator.codegen.JavaParserXmlGenerator) Date(java.util.Date) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) NpmPackage(org.hl7.fhir.utilities.npm.NpmPackage) JavaFactoryGenerator(org.hl7.fhir.core.generator.codegen.JavaFactoryGenerator) FileOutputStream(java.io.FileOutputStream) JavaConstantsGenerator(org.hl7.fhir.core.generator.codegen.JavaConstantsGenerator)

Aggregations

ValueSet (org.hl7.fhir.r5.model.ValueSet)5 EnumInfo (org.hl7.fhir.core.generator.analysis.EnumInfo)4 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Configuration (org.hl7.fhir.core.generator.codegen.Configuration)1 JavaConstantsGenerator (org.hl7.fhir.core.generator.codegen.JavaConstantsGenerator)1 JavaEnumerationsGenerator (org.hl7.fhir.core.generator.codegen.JavaEnumerationsGenerator)1 JavaFactoryGenerator (org.hl7.fhir.core.generator.codegen.JavaFactoryGenerator)1 JavaParserJsonGenerator (org.hl7.fhir.core.generator.codegen.JavaParserJsonGenerator)1 JavaParserRdfGenerator (org.hl7.fhir.core.generator.codegen.JavaParserRdfGenerator)1 JavaParserXmlGenerator (org.hl7.fhir.core.generator.codegen.JavaParserXmlGenerator)1 JavaTypeGenerator (org.hl7.fhir.core.generator.codegen.JavaTypeGenerator)1 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)1 FilesystemPackageCacheManager (org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager)1 NpmPackage (org.hl7.fhir.utilities.npm.NpmPackage)1