Search in sources :

Example 11 with DataElement

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

the class TurtleTests method test_dataelement_labtestmaster_example.

@Test
public void test_dataelement_labtestmaster_example() throws FileNotFoundException, IOException, Exception {
    System.out.println("dataelement-labtestmaster-example.ttl");
    new Turtle().parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\dataelement-labtestmaster-example.ttl"));
}
Also used : Turtle(org.hl7.fhir.dstu3.utils.formats.Turtle) Test(org.junit.jupiter.api.Test)

Example 12 with DataElement

use of org.hl7.fhir.dstu2016may.model.DataElement in project kindling by HL7.

the class ProfileGenerator method generateElementDefinition.

private void generateElementDefinition(StructureDefinition source, ElementDefinition ed, ElementDefinition parent) throws Exception {
    String id = ed.getPath().replace("[x]", "X");
    if (id.length() > 64)
        id = id.substring(0, 64);
    if (!id.contains("."))
        // throw new Exception("Don't generate data element for root of resources or types");
        return;
    if (!ed.hasType())
        // throw new Exception("Don't generate data element for reference elements");
        return;
    if (Utilities.existsInList(ed.getType().get(0).getCode(), "Element", "BackboneElement"))
        // throw new Exception("Don't generate data element for elements that are not leaves");
        return;
    StructureDefinition de;
    if (des.containsKey(id)) {
        de = des.get("de-" + id);
        // do it again because we now have more information to generate with
        de.getSnapshot().getElement().clear();
        de.getExtension().clear();
    } else {
        de = new StructureDefinition();
        de.setId("de-" + id);
        des.put(id, de);
        de.setUrl("http://hl7.org/fhir/StructureDefinition/" + de.getId());
        if (de.getId().contains("."))
            definitions.addNs(de.getUrl(), "Data Element " + ed.getPath(), definitions.getSrcFile(id.substring(0, id.indexOf("."))) + "-definitions.html#" + id);
        if (dataElements != null)
            dataElements.addEntry().setResource(de).setFullUrl(de.getUrl());
    }
    if (!de.hasMeta())
        de.setMeta(new Meta());
    de.getMeta().setLastUpdatedElement(new InstantType(genDate));
    de.setVersion(version.toCode());
    de.setName(ed.getPath());
    de.setStatus(PublicationStatus.DRAFT);
    de.setExperimental(true);
    de.setTitle(de.getName());
    de.setDate(genDate.getTime());
    de.setPublisher("HL7 FHIR Standard");
    de.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
    de.setDescription("Data Element for " + ed.getPath());
    de.setPurpose("Data Elements are defined for each element to assist in questionnaire construction etc");
    de.setFhirVersion(version);
    de.setKind(StructureDefinitionKind.LOGICAL);
    de.setType("DataElement");
    de.setAbstract(false);
    de.setType(de.getName());
    de.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
    de.setDerivation(TypeDerivationRule.SPECIALIZATION);
    de.getMapping().addAll(source.getMapping());
    ElementDefinition ted = ed.copy();
    de.getSnapshot().addElement(ted);
    ted.makeBase();
}
Also used : Meta(org.hl7.fhir.r5.model.Meta) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) InstantType(org.hl7.fhir.r5.model.InstantType)

Example 13 with DataElement

use of org.hl7.fhir.dstu2016may.model.DataElement in project kindling by HL7.

the class Publisher method produceDictionary.

private void produceDictionary(Dictionary d) throws Exception {
    if (web)
        return;
    String src = TextFile.fileToString(page.getFolders().templateDir + "template-dictionary.html");
    String file = d.getSource();
    String prefix = d.getIg() != null ? d.getIg().getCode() + File.separator : "";
    String filename = prefix + d.getId();
    XmlParser xml = new XmlParser();
    Bundle dict = (Bundle) xml.parse(new CSFileInputStream(file));
    src = page.processPageIncludes(filename + ".html", src, "page", null, dict, null, "Dictionary", null, null, null);
    // before we save this page out, we're going to figure out what it's index
    // is, and number the headers if we can
    TextFile.stringToFile(src, page.getFolders().dstDir + filename + ".html");
    src = addSectionNumbers(filename + ".html", filename, src, null, d.getIg() != null ? 1 : 0, null, d.getIg());
    TextFile.stringToFile(src, page.getFolders().dstDir + filename + ".html");
    src = TextFile.fileToString(page.getFolders().templateDir + "template-dictionary.html").replace("<body>", "<body style=\"margin: 10px\">");
    src = page.processPageIncludesForBook(filename + ".html", src, "page", dict, null, null);
    cachePage(filename + ".html", src, d.getId(), true);
    xml.setOutputStyle(OutputStyle.PRETTY);
    FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + filename + ".xml");
    xml.compose(s, dict);
    s.close();
    xml.setOutputStyle(OutputStyle.CANONICAL);
    s = new FileOutputStream(page.getFolders().dstDir + filename + ".canonical.xml");
    xml.compose(s, dict);
    s.close();
    cloneToXhtml(filename, "Source for Dictionary" + d.getName(), false, "dict-instance", "Dictionary", null, null);
    IParser json = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
    s = new FileOutputStream(page.getFolders().dstDir + filename + ".json");
    json.compose(s, dict);
    s.close();
    json = new JsonParser().setOutputStyle(OutputStyle.CANONICAL);
    s = new FileOutputStream(page.getFolders().dstDir + filename + ".canonical.json");
    json.compose(s, dict);
    s.close();
    jsonToXhtml(filename, "Source for Dictionary" + d.getName(), resource2Json(dict), "dict-instance", "Dictionary", null, null);
    ttlToXhtml(filename, "Source for Dictionary" + d.getName(), resource2Ttl(dict), "dict-instance", "Dictionary", null, null);
    throw new Error("must be redone");
// for (BundleEntryComponent e : dict.getEntry()) {
// produceDictionaryProfile(d, file, filename, (DataElement) e.getResource(), d.getIg());
// }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) Bundle(org.hl7.fhir.r5.model.Bundle) FileOutputStream(java.io.FileOutputStream) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) IParser(org.hl7.fhir.r5.formats.IParser) JsonParser(org.hl7.fhir.r5.formats.JsonParser)

Example 14 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.dstu2016may.formats.RdfGenerator.Complex)

Example 15 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.dstu2016may.model.DataElement) Meta(org.hl7.fhir.dstu2016may.model.Meta) BundleEntryComponent(org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.dstu2016may.model.Identifier) DataElement(org.hl7.fhir.dstu2016may.model.DataElement) Element(org.w3c.dom.Element) ElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition)

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