use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.
the class XmlSpecGenerator method renderType.
private String renderType(int indent, DataType value) throws Exception {
StringBuilder b = new StringBuilder();
for (int i = 0; i < indent - 2; i++) b.append(" ");
String ind = b.toString();
XmlParser xml = new XmlParser();
ByteArrayOutputStream bs = new ByteArrayOutputStream();
xml.setOutputStyle(OutputStyle.PRETTY);
xml.compose(bs, null, value);
bs.close();
String[] result = bs.toString().split("\\r?\\n");
b = new StringBuilder();
for (String s : result) {
if (// eliminate the wrapper content
s.startsWith(" "))
b.append("\r\n " + ind + Utilities.escapeXml(s));
}
return b.toString() + "\r\n" + ind;
}
use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.
the class XSDGenerator method generateType.
private void generateType(ElementDefn root, String name, ElementDefn struc, boolean isResource) throws IOException, Exception {
write(" <xs:complexType name=\"" + name + "\">\r\n");
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(root.getDefinition()) + "</xs:documentation>\r\n");
if (isResource)
write(" <xs:documentation xml:lang=\"en\">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
write(" <xs:complexContent>\r\n");
if (isResource)
write(" <xs:extension base=\"" + root.typeCode() + "\">\r\n");
else
write(" <xs:extension base=\"BackboneElement\">\r\n");
write(" <xs:sequence>\r\n");
for (ElementDefn e : struc.getElements()) {
if (e.getName().equals("[type]"))
generateAny(root, e);
else
generateElement(root, e);
}
write(" </xs:sequence>\r\n");
write(" </xs:extension>\r\n");
write(" </xs:complexContent>\r\n");
write(" </xs:complexType>\r\n");
}
use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.
the class XSDGenerator method generateEnum.
private void generateEnum(String en) throws IOException {
if (allenums.contains(en))
return;
allenums.add(en);
write(" <xs:simpleType name=\"" + en + "-list\">\r\n");
write(" <xs:restriction base=\"code-primitive\">\r\n");
ValueSet vs = enums.get(en);
vs.setUserData(ToolResourceUtilities.NAME_VS_USE_MARKER, true);
ValueSet ex = workerContext.expandVS(vs, true, false).getValueset();
for (ValueSetExpansionContainsComponent cc : ex.getExpansion().getContains()) {
genIncludedCode(cc);
}
write(" </xs:restriction>\r\n");
write(" </xs:simpleType>\r\n");
write(" <xs:complexType name=\"" + en + "\">\r\n");
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(enumDefs.get(en)) + "</xs:documentation>\r\n");
write(" <xs:documentation xml:lang=\"en\">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
write(" <xs:complexContent>\r\n");
write(" <xs:extension base=\"Element\">\r\n");
write(" <xs:attribute name=\"value\" type=\"" + en + "-list\" use=\"optional\"/>\r\n");
write(" </xs:extension>\r\n");
write(" </xs:complexContent>\r\n");
write(" </xs:complexType>\r\n");
}
use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.
the class JsonLDDefinitionsGenerator method generate.
// private String genDate;
// private String version;
// private BuildWorkerContext workerContext;
public void generate(Definitions definitions, IniFile ini, String tmpResDir, String dstDir, String srcDir, FHIRVersion version, String genDate, BuildWorkerContext workerContext) throws Exception {
// this.genDate = genDate;
// this.version = version;
// this.workerContext = workerContext;
JsonObject defn = new JsonObject();
JsonObject context = new JsonObject();
defn.add("@context", context);
defn.addProperty("@id", "http://hl7.org/fhir/");
context.addProperty("fhir", "http://hl7.org/fhir/");
context.addProperty("xsd", "http://www.w3.org/2001/XMLSchema#");
// properties for primitives, helpers, format features
addProperty(context, "value", "fhir:value", "xsd:string");
addProperty(context, "decimal", "fhir:value", "xsd:decimal");
addProperty(context, "integer", "fhir:value", "xsd:integer");
if (!version.isR4B()) {
addProperty(context, "integer64", "fhir:value", "xsd:string");
}
addProperty(context, "boolean", "fhir:value", "xsd:boolean");
addProperty(context, "binary", "fhir:value", "xsd:base64Binary");
addProperty(context, "date", "fhir:value", "xsd:date");
addProperty(context, "dateTime", "fhir:value", "xsd:dateTime");
addProperty(context, "gYearMonth", "fhir:value", "xsd:gYearMonth");
addProperty(context, "gYear", "fhir:value", "xsd:gYear");
addProperty(context, "link", "fhir:link", "@id");
addProperty(context, "concept", "fhir:concept", "@id");
addProperty(context, "index", "fhir:index", "xsd:integer");
addProperty(context, "role", "fhir:nodeRole", "@id");
// elements defined in FHIR:
for (TypeRef tr : definitions.getKnownTypes()) {
if (!definitions.hasPrimitiveType(tr.getName()) && !tr.getName().equals("SimpleQuantity") && !tr.getName().equals("MoneyQuantity")) {
TypeDefn root = definitions.getElementDefn(tr.getName());
new JsonLDGenerator(definitions, workerContext, definitions.getKnownTypes()).generate(context, root, version, genDate);
}
}
List<String> names = new ArrayList<String>();
names.addAll(definitions.getResources().keySet());
names.addAll(definitions.getBaseResources().keySet());
names.add("Parameters");
Collections.sort(names);
for (String name : names) {
ResourceDefn root = definitions.getResourceByName(name);
new JsonLDGenerator(definitions, workerContext, definitions.getKnownTypes()).generate(context, root.getRoot(), version, genDate);
}
save(defn, dstDir + "fhir.jsonld");
}
use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.
the class XSDBaseGenerator method genInfrastructure.
private void genInfrastructure(ElementDefn elem) throws Exception {
enums.clear();
enumDefs.clear();
String name = elem.getName();
write(" <xs:complexType name=\"" + name + "\">\r\n");
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(elem.getDefinition()) + "</xs:documentation>\r\n");
write(" <xs:documentation xml:lang=\"en\">If the element is present, it must have a value for at least one of the defined elements, an @id referenced from the Narrative, or extensions</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
if (!elem.getName().equals("Base")) {
write(" <xs:complexContent>\r\n");
write(" <xs:extension base=\"" + getParentType(elem) + "\">\r\n");
}
write(" <xs:sequence>\r\n");
for (ElementDefn e : elem.getElements()) {
if (!e.isXmlAttribute()) {
if (e.getName().equals("[type]"))
generateAny(elem, e, null, null);
else
generateElement(elem, e, null, null);
}
}
write(" </xs:sequence>\r\n");
for (ElementDefn e : elem.getElements()) {
if (e.isXmlAttribute()) {
generateAttribute(elem, e, null);
}
}
if (!elem.getName().equals("Base")) {
write(" </xs:extension>\r\n");
write(" </xs:complexContent>\r\n");
}
write(" </xs:complexType>\r\n");
while (!structures.isEmpty()) {
String s = structures.keySet().iterator().next();
generateType(elem, s, structures.get(s));
structures.remove(s);
}
for (BindingSpecification en : enums) {
generateEnum(en);
}
}
Aggregations