Search in sources :

Example 1 with DataElement

use of org.hl7.fhir.dstu2016may.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(ConformanceResourceStatus.DRAFT);
        else
            de.setStatus(ConformanceResourceStatus.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.setComments(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");
}
Also used : DataElement(org.hl7.fhir.dstu2.model.DataElement) Meta(org.hl7.fhir.dstu2.model.Meta) BundleEntryComponent(org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.dstu2.model.Identifier) Element(org.w3c.dom.Element) DataElement(org.hl7.fhir.dstu2.model.DataElement) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition)

Example 2 with DataElement

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.hasDateElement())
        composeDateTime(t, "DataElement", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "DataElement", "publisher", element.getPublisherElement(), -1);
    if (element.hasNameElement())
        composeString(t, "DataElement", "name", element.getNameElement(), -1);
    if (element.hasTitleElement())
        composeString(t, "DataElement", "title", element.getTitleElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "DataElement", "contact", element.getContact().get(i), i);
    for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "DataElement", "useContext", element.getUseContext().get(i), i);
    for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "DataElement", "jurisdiction", element.getJurisdiction().get(i), i);
    if (element.hasCopyrightElement())
        composeMarkdown(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);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 3 with DataElement

use of org.hl7.fhir.dstu2016may.model.DataElement in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDataElementDataElementMappingComponent.

protected void composeDataElementDataElementMappingComponent(Complex parent, String parentType, String name, DataElement.DataElementMappingComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "mapping", name, element, index);
    if (element.hasIdentityElement())
        composeId(t, "DataElement", "identity", element.getIdentityElement(), -1);
    if (element.hasUriElement())
        composeUri(t, "DataElement", "uri", element.getUriElement(), -1);
    if (element.hasNameElement())
        composeString(t, "DataElement", "name", element.getNameElement(), -1);
    if (element.hasCommentElement())
        composeString(t, "DataElement", "comment", element.getCommentElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 4 with DataElement

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();
}
Also used : DataElement(org.hl7.fhir.dstu2.model.DataElement) BundleEntryComponent(org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 5 with DataElement

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;
}
Also used : DataElement(org.hl7.fhir.dstu2.model.DataElement) ContactPoint(org.hl7.fhir.dstu2.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent) DataElementContactComponent(org.hl7.fhir.dstu2.model.DataElement.DataElementContactComponent)

Aggregations

BundleEntryComponent (org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent)3 DataElement (org.hl7.fhir.dstu2.model.DataElement)3 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)3 BundleEntryComponent (org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent)3 DataElement (org.hl7.fhir.dstu2016may.model.DataElement)3 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)3 DataElement (org.hl7.fhir.dstu3.model.DataElement)3 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)3 Element (org.w3c.dom.Element)3 FileOutputStream (java.io.FileOutputStream)2 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)2 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)2 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)2 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)2 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)2 Test (org.junit.jupiter.api.Test)2 File (java.io.File)1 ContactPoint (org.hl7.fhir.dstu2.model.ContactPoint)1 DataElementContactComponent (org.hl7.fhir.dstu2.model.DataElement.DataElementContactComponent)1 Identifier (org.hl7.fhir.dstu2.model.Identifier)1