use of org.hl7.fhir.dstu2.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 (ContactDetail 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.dstu2.model.DataElement in project org.hl7.fhir.core by hapifhir.
the class LoincToDEConvertor method processLoincCodes.
private void processLoincCodes() {
Element row = XMLUtil.getFirstChild(xml.getDocumentElement());
int i = 0;
while (row != null) {
i++;
if (i % 1000 == 0)
System.out.print(".");
String code = col(row, "LOINC_NUM");
String comp = col(row, "COMPONENT");
DataElement de = new DataElement();
de.setId("loinc-" + code);
de.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
bundle.getEntry().add(new BundleEntryComponent().setResource(de));
Identifier id = new Identifier();
id.setSystem("http://hl7.org/fhir/commondataelement/loinc");
id.setValue(code);
de.addIdentifier(id);
de.setPublisher("Regenstrief + FHIR Project Team");
if (!col(row, "STATUS").equals("ACTIVE"))
// till we get good at this
de.setStatus(PublicationStatus.DRAFT);
else
de.setStatus(PublicationStatus.RETIRED);
de.setDateElement(DateTimeType.now());
de.setName(comp);
ElementDefinition dee = de.addElement();
// PROPERTY ignore
// TIME_ASPCT
// SYSTEM
// SCALE_TYP
// METHOD_TYP
// dee.getCategory().add(new CodeableConcept().setText(col(row, "CLASS")));
// SOURCE
// DATE_LAST_CHANGED - should be in ?
// CHNG_TYPE
dee.setComment(col(row, "COMMENTS"));
if (hasCol(row, "CONSUMER_NAME"))
dee.addAlias(col(row, "CONSUMER_NAME"));
// SURVEY_QUEST_SRC
if (hasCol(row, "RELATEDNAMES2")) {
String n = col(row, "RELATEDNAMES2");
for (String s : n.split("\\;")) {
if (!Utilities.noString(s))
dee.addAlias(s);
}
}
dee.addAlias(col(row, "SHORTNAME"));
// ORDER_OBS
// CDISC Code
// HL7_FIELD_SUBFIELD_ID
// ------------------ EXTERNAL_COPYRIGHT_NOTICE todo
dee.setDefinition(col(row, "LONG_COMMON_NAME"));
// HL7_V2_DATATYPE
String cc = makeType(col(row, "HL7_V3_DATATYPE"), code);
if (cc != null)
dee.addType().setCode(cc);
// todo... CURATED_RANGE_AND_UNITS
// todo: DOCUMENT_SECTION
// STATUS_REASON
// STATUS_TEXT
// CHANGE_REASON_PUBLIC
// COMMON_TEST_RANK
// COMMON_ORDER_RANK
// COMMON_SI_TEST_RANK
// HL7_ATTACHMENT_STRUCTURE
// units:
// UNITSREQUIRED
// SUBMITTED_UNITS
ToolingExtensions.setAllowableUnits(dee, makeUnits(col(row, "EXAMPLE_UNITS"), col(row, "EXAMPLE_UCUM_UNITS")));
// EXAMPLE_SI_UCUM_UNITS
row = XMLUtil.getNextSibling(row);
}
System.out.println("done");
}
use of org.hl7.fhir.dstu2.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.dstu2.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();
}
Aggregations