use of org.hl7.fhir.dstu2016may.model.DataElement in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeDataElement.
protected void composeDataElement(Complex parent, String parentType, String name, DataElement element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "DataElement", name, element, index);
if (element.hasUrlElement())
composeUri(t, "DataElement", "url", element.getUrlElement(), -1);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "DataElement", "identifier", element.getIdentifier().get(i), i);
if (element.hasVersionElement())
composeString(t, "DataElement", "version", element.getVersionElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "DataElement", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "DataElement", "experimental", element.getExperimentalElement(), -1);
if (element.hasPublisherElement())
composeString(t, "DataElement", "publisher", element.getPublisherElement(), -1);
if (element.hasDateElement())
composeDateTime(t, "DataElement", "date", element.getDateElement(), -1);
if (element.hasNameElement())
composeString(t, "DataElement", "name", element.getNameElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeDataElementDataElementContactComponent(t, "DataElement", "contact", element.getContact().get(i), i);
for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "DataElement", "useContext", element.getUseContext().get(i), i);
if (element.hasCopyrightElement())
composeString(t, "DataElement", "copyright", element.getCopyrightElement(), -1);
if (element.hasStringencyElement())
composeEnum(t, "DataElement", "stringency", element.getStringencyElement(), -1);
for (int i = 0; i < element.getMapping().size(); i++) composeDataElementDataElementMappingComponent(t, "DataElement", "mapping", element.getMapping().get(i), i);
for (int i = 0; i < element.getElement().size(); i++) composeElementDefinition(t, "DataElement", "element", element.getElement().get(i), i);
}
use of org.hl7.fhir.dstu2016may.model.DataElement in project org.hl7.fhir.core by hapifhir.
the class ResourceUtilities method renderDE.
private static void renderDE(DataElement de, List<String> cols, StringBuilder b, boolean profileLink, String linkBase) {
b.append("<tr>");
for (String col : cols) {
String v;
ElementDefinition dee = de.getElement().get(0);
if (col.equals("DataElement.name")) {
v = de.hasName() ? Utilities.escapeXml(de.getName()) : "";
} else if (col.equals("DataElement.status")) {
v = de.hasStatusElement() ? de.getStatusElement().asStringValue() : "";
} else if (col.equals("DataElement.code")) {
v = renderCoding(dee.getCode());
} else if (col.equals("DataElement.type")) {
v = dee.hasType() ? Utilities.escapeXml(dee.getType().get(0).getCode()) : "";
} else if (col.equals("DataElement.units")) {
v = renderDEUnits(ToolingExtensions.getAllowedUnits(dee));
} else if (col.equals("DataElement.binding")) {
v = renderBinding(dee.getBinding());
} else if (col.equals("DataElement.minValue")) {
v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/minValue") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/minValue").asStringValue()) : "";
} else if (col.equals("DataElement.maxValue")) {
v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/maxValue") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/maxValue").asStringValue()) : "";
} else if (col.equals("DataElement.maxLength")) {
v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/maxLength") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/maxLength").asStringValue()) : "";
} else if (col.equals("DataElement.mask")) {
v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/mask") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/mask").asStringValue()) : "";
} else
throw new Error("Unknown column name: " + col);
b.append("<td>" + v + "</td>");
}
if (profileLink) {
b.append("<td><a href=\"" + linkBase + "-" + de.getId() + ".html\">Profile</a>, <a href=\"http://www.opencem.org/#/20140917/Intermountain/" + de.getId() + "\">CEM</a>");
if (ToolingExtensions.hasExtension(de, ToolingExtensions.EXT_CIMI_REFERENCE))
b.append(", <a href=\"" + ToolingExtensions.readStringExtension(de, ToolingExtensions.EXT_CIMI_REFERENCE) + "\">CIMI</a>");
b.append("</td>");
}
b.append("</tr>\r\n");
}
use of org.hl7.fhir.dstu2016may.model.DataElement in project org.hl7.fhir.core by hapifhir.
the class ResourceUtilities method showDECHeader.
private static DataElement showDECHeader(StringBuilder b, Bundle bundle) {
DataElement meta = new DataElement();
DataElement prototype = (DataElement) bundle.getEntry().get(0).getResource();
meta.setPublisher(prototype.getPublisher());
meta.getContact().addAll(prototype.getContact());
meta.setStatus(prototype.getStatus());
meta.setDate(prototype.getDate());
meta.addElement().getType().addAll(prototype.getElement().get(0).getType());
for (BundleEntryComponent e : bundle.getEntry()) {
DataElement de = (DataElement) e.getResource();
if (!Base.compareDeep(de.getPublisherElement(), meta.getPublisherElement(), false))
meta.setPublisherElement(null);
if (!Base.compareDeep(de.getContact(), meta.getContact(), false))
meta.getContact().clear();
if (!Base.compareDeep(de.getStatusElement(), meta.getStatusElement(), false))
meta.setStatusElement(null);
if (!Base.compareDeep(de.getDateElement(), meta.getDateElement(), false))
meta.setDateElement(null);
if (!Base.compareDeep(de.getElement().get(0).getType(), meta.getElement().get(0).getType(), false))
meta.getElement().get(0).getType().clear();
}
if (meta.hasPublisher() || meta.hasContact() || meta.hasStatus() || meta.hasDate()) /* || meta.hasType() */
{
b.append("<table class=\"grid\">\r\n");
if (meta.hasPublisher())
b.append("<tr><td>Publisher:</td><td>" + meta.getPublisher() + "</td></tr>\r\n");
if (meta.hasContact()) {
b.append("<tr><td>Contacts:</td><td>");
boolean firsti = true;
for (DataElementContactComponent c : meta.getContact()) {
if (firsti)
firsti = false;
else
b.append("<br/>");
if (c.hasName())
b.append(Utilities.escapeXml(c.getName()) + ": ");
boolean first = true;
for (ContactPoint cp : c.getTelecom()) {
if (first)
first = false;
else
b.append(", ");
renderContactPoint(b, cp);
}
}
b.append("</td></tr>\r\n");
}
if (meta.hasStatus())
b.append("<tr><td>Status:</td><td>" + meta.getStatus().toString() + "</td></tr>\r\n");
if (meta.hasDate())
b.append("<tr><td>Date:</td><td>" + meta.getDateElement().asStringValue() + "</td></tr>\r\n");
if (meta.getElement().get(0).hasType())
b.append("<tr><td>Type:</td><td>" + renderType(meta.getElement().get(0).getType()) + "</td></tr>\r\n");
b.append("</table>\r\n");
}
return meta;
}
use of org.hl7.fhir.dstu2016may.model.DataElement in project org.hl7.fhir.core by hapifhir.
the class ResourceUtilities method representDataElementCollection.
public static String representDataElementCollection(IWorkerContext context, Bundle bundle, boolean profileLink, String linkBase) {
StringBuilder b = new StringBuilder();
DataElement common = showDECHeader(b, bundle);
b.append("<table class=\"grid\">\r\n");
List<String> cols = chooseColumns(bundle, common, b, profileLink);
for (BundleEntryComponent e : bundle.getEntry()) {
DataElement de = (DataElement) e.getResource();
renderDE(de, cols, b, profileLink, linkBase);
}
b.append("</table>\r\n");
return b.toString();
}
use of org.hl7.fhir.dstu2016may.model.DataElement in project org.hl7.fhir.core by hapifhir.
the class R3TEchnicalCorrectionProcessor method extractToPackageMaster.
private void extractToPackageMaster(List<Resource> list, String root) throws IOException, FHIRFormatError {
System.out.println("Updating Packages Master");
String corePath = Utilities.path(root, "hl7.fhir.r3.core", "package");
String examplesPath = Utilities.path(root, "hl7.fhir.r3.examples", "package");
String elementsPath = Utilities.path(root, "hl7.fhir.r3.elements", "package");
int coreTotal = new File(corePath).list().length - 1;
int examplesTotal = new File(examplesPath).list().length - 1;
int elementsTotal = new File(elementsPath).list().length - 1;
int coreCount = 0;
int examplesCount = 0;
int elementsCount = 0;
for (Resource r : list) {
String n = r.fhirType() + "-" + r.getId() + ".json";
FileOutputStream dst = null;
if (n.startsWith("DataElement-")) {
elementsCount++;
dst = new FileOutputStream(Utilities.path(elementsPath, n));
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(dst, r);
} else {
dst = new FileOutputStream(Utilities.path(examplesPath, n));
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(dst, r);
examplesCount++;
if (isCoreResource(r.fhirType())) {
coreCount++;
DomainResource dr = (DomainResource) r;
dr.setText(null);
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(new FileOutputStream(Utilities.path(corePath, n)), r);
}
}
}
System.out.println(" Core @ " + corePath + ": Replaced " + coreCount + " of " + coreTotal);
System.out.println(" Examples @ " + examplesPath + ": Replaced " + examplesCount + " of " + examplesTotal);
System.out.println(" Elements @ " + elementsPath + ": Replaced " + elementsCount + " of " + elementsTotal);
}
Aggregations