Search in sources :

Example 96 with Identifier

use of io.adminshell.aas.v3.model.Identifier in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        x.addText("Extensions: Todo");
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType)
        x.addText(((DateTimeType) e).toHumanDisplay());
    else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.dstu2.model.DateType)
        x.addText(((org.hl7.fhir.dstu2.model.DateType) e).toHumanDisplay());
    else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType)
        x.addText(((BooleanType) e).getValue().toString());
    else if (e instanceof CodeableConcept) {
        renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding((Coding) e, x, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation((Annotation) e, x);
    } else if (e instanceof Identifier) {
        renderIdentifier((Identifier) e, x);
    } else if (e instanceof org.hl7.fhir.dstu2.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu2.model.IntegerType) e).getValue()));
    } else if (e instanceof org.hl7.fhir.dstu2.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu2.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName((HumanName) e, x);
    } else if (e instanceof SampledData) {
        renderSampledData((SampledData) e, x);
    } else if (e instanceof Address) {
        renderAddress((Address) e, x);
    } else if (e instanceof ContactPoint) {
        renderContactPoint((ContactPoint) e, x);
    } else if (e instanceof UriType) {
        renderUri((UriType) e, x);
    } else if (e instanceof Timing) {
        renderTiming((Timing) e, x);
    } else if (e instanceof Range) {
        renderRange((Range) e, x);
    } else if (e instanceof Quantity) {
        renderQuantity((Quantity) e, x, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
        x.addText("/");
        renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
        x.addText(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        XhtmlNode c = x;
        ResourceWithReference tr = null;
        if (r.hasReferenceElement()) {
            tr = resolveReference(res, r.getReference());
            if (!r.getReference().startsWith("#")) {
                if (tr != null && tr.getReference() != null)
                    c = x.addTag("a").attribute("href", tr.getReference());
                else
                    c = x.addTag("a").attribute("href", r.getReference());
            }
        }
        // what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
        if (r.hasDisplayElement()) {
            c.addText(r.getDisplay());
            if (tr != null) {
                c.addText(". Generated Summary: ");
                generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
            }
        } else if (tr != null) {
            generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
        } else {
            c.addText(r.getReference());
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof ElementDefinition) {
        x.addText("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta))
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
}
Also used : Meta(org.hl7.fhir.dstu2.model.Meta) Base64(org.apache.commons.codec.binary.Base64) Address(org.hl7.fhir.dstu2.model.Address) StringType(org.hl7.fhir.dstu2.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu2.model.Attachment) UriType(org.hl7.fhir.dstu2.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HumanName(org.hl7.fhir.dstu2.model.HumanName) ContactPoint(org.hl7.fhir.dstu2.model.ContactPoint) Identifier(org.hl7.fhir.dstu2.model.Identifier) Coding(org.hl7.fhir.dstu2.model.Coding) Narrative(org.hl7.fhir.dstu2.model.Narrative) SampledData(org.hl7.fhir.dstu2.model.SampledData) Ratio(org.hl7.fhir.dstu2.model.Ratio) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition) InstantType(org.hl7.fhir.dstu2.model.InstantType) Enumeration(org.hl7.fhir.dstu2.model.Enumeration) Reference(org.hl7.fhir.dstu2.model.Reference) BooleanType(org.hl7.fhir.dstu2.model.BooleanType) Resource(org.hl7.fhir.dstu2.model.Resource) DomainResource(org.hl7.fhir.dstu2.model.DomainResource) Quantity(org.hl7.fhir.dstu2.model.Quantity) Period(org.hl7.fhir.dstu2.model.Period) Range(org.hl7.fhir.dstu2.model.Range) Base(org.hl7.fhir.dstu2.model.Base) Annotation(org.hl7.fhir.dstu2.model.Annotation) IdType(org.hl7.fhir.dstu2.model.IdType) Extension(org.hl7.fhir.dstu2.model.Extension) DateTimeType(org.hl7.fhir.dstu2.model.DateTimeType) CodeType(org.hl7.fhir.dstu2.model.CodeType) EventTiming(org.hl7.fhir.dstu2.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu2.model.Timing) Base64BinaryType(org.hl7.fhir.dstu2.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept)

Example 97 with Identifier

use of io.adminshell.aas.v3.model.Identifier 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 98 with Identifier

use of io.adminshell.aas.v3.model.Identifier in project org.hl7.fhir.core by hapifhir.

the class DicomPackageBuilder method buildCodeSystem.

private CodeSystem buildCodeSystem() throws ParserConfigurationException, FileNotFoundException, SAXException, IOException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(new FileInputStream(Utilities.path(source, "Resources", "Ontology", "DCM", "dcm.owl")));
    Element rdf = doc.getDocumentElement();
    Element d = XMLUtil.getFirstChild(rdf);
    version = processVersion(XMLUtil.getNamedChildText(d, "versionInfo"));
    CodeSystem cs = new CodeSystem();
    cs.setId("DCM");
    cs.setUrl("http://dicom.nema.org/resources/ontology/DCM");
    cs.setVersion(version);
    cs.setName("DICOMTerminologyDefinitions");
    cs.setTitle("DICOM Controlled Terminology Definitions");
    cs.getIdentifier().add(new Identifier().setSystem("urn:ietf:rfc:3986").setValue("urn:oid:1.2.840.10008.2.16.4"));
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setExperimental(false);
    cs.setPublisher("FHIR Project on behalf of DICOM");
    cs.setDate(new Date());
    cs.setDescription("DICOM Code Definitions (Coding Scheme Designator \"DCM\" Coding Scheme Version " + version);
    cs.setPurpose("This code system is published as part of FHIR in order to make the codes available to FHIR terminology services and so implementers can easily leverage the codes");
    cs.setCopyright("These codes are excerpted from Digital Imaging and Communications in Medicine (DICOM) Standard, Part 16: Content Mapping Resource, Copyright © 2011 by the National Electrical Manufacturers Association.");
    cs.setCaseSensitive(true);
    cs.setValueSet("http://dicom.nema.org/resources/ValueSet/all");
    cs.setContent(CodeSystemContentMode.COMPLETE);
    d = XMLUtil.getNextSibling(d);
    while (d != null) {
        String code = XMLUtil.getNamedChildText(d, "notation");
        String display = XMLUtil.getNamedChildText(d, "prefLabel");
        String definition = XMLUtil.getNamedChildText(d, "definition");
        ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
        cs.getConcept().add(cc);
        cc.setCode(code);
        cc.setDisplay(display);
        cc.setDefinition(definition);
        d = XMLUtil.getNextSibling(d);
    }
    return cs;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Identifier(org.hl7.fhir.r4.model.Identifier) ConceptDefinitionComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) CodeSystem(org.hl7.fhir.r4.model.CodeSystem) FileInputStream(java.io.FileInputStream) Date(java.util.Date)

Example 99 with Identifier

use of io.adminshell.aas.v3.model.Identifier in project org.hl7.fhir.core by hapifhir.

the class ObjectConverter method readAsIdentifier.

public static Identifier readAsIdentifier(Element item) {
    Identifier r = new Identifier();
    r.setSystem(item.getNamedChildValue("system"));
    r.setValue(item.getNamedChildValue("value"));
    return r;
}
Also used : Identifier(org.hl7.fhir.r5.model.Identifier)

Example 100 with Identifier

use of io.adminshell.aas.v3.model.Identifier in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints, String path) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        return;
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType)
        x.addText(((DateTimeType) e).toHumanDisplay());
    else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.dstu3.model.DateType)
        x.addText(((org.hl7.fhir.dstu3.model.DateType) e).toHumanDisplay());
    else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType)
        x.addText(((BooleanType) e).getValue().toString());
    else if (e instanceof CodeableConcept) {
        renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding((Coding) e, x, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation((Annotation) e, x);
    } else if (e instanceof Identifier) {
        renderIdentifier((Identifier) e, x);
    } else if (e instanceof org.hl7.fhir.dstu3.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu3.model.IntegerType) e).getValue()));
    } else if (e instanceof org.hl7.fhir.dstu3.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu3.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName((HumanName) e, x);
    } else if (e instanceof SampledData) {
        renderSampledData((SampledData) e, x);
    } else if (e instanceof Address) {
        renderAddress((Address) e, x);
    } else if (e instanceof ContactPoint) {
        renderContactPoint((ContactPoint) e, x);
    } else if (e instanceof UriType) {
        renderUri((UriType) e, x);
    } else if (e instanceof Timing) {
        renderTiming((Timing) e, x);
    } else if (e instanceof Range) {
        renderRange((Range) e, x);
    } else if (e instanceof Quantity) {
        renderQuantity((Quantity) e, x, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
        x.tx("/");
        renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
        x.tx(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        XhtmlNode c = x;
        ResourceWithReference tr = null;
        if (r.hasReferenceElement()) {
            tr = resolveReference(res, r.getReference());
            if (!r.getReference().startsWith("#")) {
                if (tr != null && tr.getReference() != null)
                    c = x.ah(tr.getReference());
                else
                    c = x.ah(r.getReference());
            }
        }
        // what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
        if (r.hasDisplayElement()) {
            c.addText(r.getDisplay());
            if (tr != null && tr.getResource() != null) {
                c.tx(". Generated Summary: ");
                generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
            }
        } else if (tr != null && tr.getResource() != null) {
            generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
        } else {
            c.addText(r.getReference());
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof ElementDefinition) {
        x.tx("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
        StructureDefinition sd = context.fetchTypeDefinition(e.fhirType());
        if (sd == null)
            throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet, and no structure found");
        else
            generateByProfile(res, sd, ew, sd.getSnapshot().getElement(), sd.getSnapshot().getElementFirstRep(), getChildrenForPath(sd.getSnapshot().getElement(), sd.getSnapshot().getElementFirstRep().getPath()), x, path, showCodeDetails);
    }
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) Base64(org.apache.commons.codec.binary.Base64) Address(org.hl7.fhir.dstu3.model.Address) StringType(org.hl7.fhir.dstu3.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu3.model.Attachment) UriType(org.hl7.fhir.dstu3.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HumanName(org.hl7.fhir.dstu3.model.HumanName) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) Narrative(org.hl7.fhir.dstu3.model.Narrative) SampledData(org.hl7.fhir.dstu3.model.SampledData) Ratio(org.hl7.fhir.dstu3.model.Ratio) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition) InstantType(org.hl7.fhir.dstu3.model.InstantType) Enumeration(org.hl7.fhir.dstu3.model.Enumeration) Reference(org.hl7.fhir.dstu3.model.Reference) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) MetadataResource(org.hl7.fhir.dstu3.model.MetadataResource) Resource(org.hl7.fhir.dstu3.model.Resource) Quantity(org.hl7.fhir.dstu3.model.Quantity) Period(org.hl7.fhir.dstu3.model.Period) Range(org.hl7.fhir.dstu3.model.Range) Base(org.hl7.fhir.dstu3.model.Base) Annotation(org.hl7.fhir.dstu3.model.Annotation) IdType(org.hl7.fhir.dstu3.model.IdType) Extension(org.hl7.fhir.dstu3.model.Extension) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) CodeType(org.hl7.fhir.dstu3.model.CodeType) EventTiming(org.hl7.fhir.dstu3.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu3.model.Timing) Base64BinaryType(org.hl7.fhir.dstu3.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

Identifier (org.hl7.fhir.r4.model.Identifier)212 Test (org.junit.Test)94 Test (org.junit.jupiter.api.Test)69 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)58 Identifier (org.hl7.fhir.dstu3.model.Identifier)55 Reference (org.hl7.fhir.r4.model.Reference)45 List (java.util.List)40 Coding (org.hl7.fhir.r4.model.Coding)39 Patient (org.hl7.fhir.r4.model.Patient)36 ArrayList (java.util.ArrayList)34 Date (java.util.Date)33 Collectors (java.util.stream.Collectors)32 Practitioner (org.hl7.fhir.r4.model.Practitioner)28 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)27 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)26 Resource (org.hl7.fhir.r4.model.Resource)25 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)23 HumanName (org.hl7.fhir.r4.model.HumanName)22 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)21 Identifier (io.adminshell.aas.v3.model.Identifier)21