Search in sources :

Example 96 with Period

use of org.hl7.fhir.dstu2.model.Period in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeEncounter.

protected void composeEncounter(Complex parent, String parentType, String name, Encounter element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Encounter", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Encounter", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Encounter", "status", element.getStatusElement(), -1);
    for (int i = 0; i < element.getStatusHistory().size(); i++) composeEncounterEncounterStatusHistoryComponent(t, "Encounter", "statusHistory", element.getStatusHistory().get(i), i);
    if (element.hasClass_Element())
        composeEnum(t, "Encounter", "class", element.getClass_Element(), -1);
    for (int i = 0; i < element.getType().size(); i++) composeCodeableConcept(t, "Encounter", "type", element.getType().get(i), i);
    if (element.hasPriority())
        composeCodeableConcept(t, "Encounter", "priority", element.getPriority(), -1);
    if (element.hasPatient())
        composeReference(t, "Encounter", "patient", element.getPatient(), -1);
    for (int i = 0; i < element.getEpisodeOfCare().size(); i++) composeReference(t, "Encounter", "episodeOfCare", element.getEpisodeOfCare().get(i), i);
    for (int i = 0; i < element.getIncomingReferral().size(); i++) composeReference(t, "Encounter", "incomingReferral", element.getIncomingReferral().get(i), i);
    for (int i = 0; i < element.getParticipant().size(); i++) composeEncounterEncounterParticipantComponent(t, "Encounter", "participant", element.getParticipant().get(i), i);
    if (element.hasAppointment())
        composeReference(t, "Encounter", "appointment", element.getAppointment(), -1);
    if (element.hasPeriod())
        composePeriod(t, "Encounter", "period", element.getPeriod(), -1);
    if (element.hasLength())
        composeQuantity(t, "Encounter", "length", element.getLength(), -1);
    for (int i = 0; i < element.getReason().size(); i++) composeCodeableConcept(t, "Encounter", "reason", element.getReason().get(i), i);
    for (int i = 0; i < element.getIndication().size(); i++) composeReference(t, "Encounter", "indication", element.getIndication().get(i), i);
    if (element.hasHospitalization())
        composeEncounterEncounterHospitalizationComponent(t, "Encounter", "hospitalization", element.getHospitalization(), -1);
    for (int i = 0; i < element.getLocation().size(); i++) composeEncounterEncounterLocationComponent(t, "Encounter", "location", element.getLocation().get(i), i);
    if (element.hasServiceProvider())
        composeReference(t, "Encounter", "serviceProvider", element.getServiceProvider(), -1);
    if (element.hasPartOf())
        composeReference(t, "Encounter", "partOf", element.getPartOf(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 97 with Period

use of org.hl7.fhir.dstu2.model.Period in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeRelatedPerson.

protected void composeRelatedPerson(Complex parent, String parentType, String name, RelatedPerson element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "RelatedPerson", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "RelatedPerson", "identifier", element.getIdentifier().get(i), i);
    if (element.hasPatient())
        composeReference(t, "RelatedPerson", "patient", element.getPatient(), -1);
    if (element.hasRelationship())
        composeCodeableConcept(t, "RelatedPerson", "relationship", element.getRelationship(), -1);
    if (element.hasName())
        composeHumanName(t, "RelatedPerson", "name", element.getName(), -1);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "RelatedPerson", "telecom", element.getTelecom().get(i), i);
    if (element.hasGenderElement())
        composeEnum(t, "RelatedPerson", "gender", element.getGenderElement(), -1);
    if (element.hasBirthDateElement())
        composeDate(t, "RelatedPerson", "birthDate", element.getBirthDateElement(), -1);
    for (int i = 0; i < element.getAddress().size(); i++) composeAddress(t, "RelatedPerson", "address", element.getAddress().get(i), i);
    for (int i = 0; i < element.getPhoto().size(); i++) composeAttachment(t, "RelatedPerson", "photo", element.getPhoto().get(i), i);
    if (element.hasPeriod())
        composePeriod(t, "RelatedPerson", "period", element.getPeriod(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 98 with Period

use of org.hl7.fhir.dstu2.model.Period in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeTimingTimingRepeatComponent.

protected void composeTimingTimingRepeatComponent(Complex parent, String parentType, String name, Timing.TimingRepeatComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "repeat", name, element, index);
    if (element.hasBounds())
        composeType(t, "Timing", "bounds", element.getBounds(), -1);
    if (element.hasCountElement())
        composeInteger(t, "Timing", "count", element.getCountElement(), -1);
    if (element.hasCountMaxElement())
        composeInteger(t, "Timing", "countMax", element.getCountMaxElement(), -1);
    if (element.hasDurationElement())
        composeDecimal(t, "Timing", "duration", element.getDurationElement(), -1);
    if (element.hasDurationMaxElement())
        composeDecimal(t, "Timing", "durationMax", element.getDurationMaxElement(), -1);
    if (element.hasDurationUnitElement())
        composeEnum(t, "Timing", "durationUnit", element.getDurationUnitElement(), -1);
    if (element.hasFrequencyElement())
        composeInteger(t, "Timing", "frequency", element.getFrequencyElement(), -1);
    if (element.hasFrequencyMaxElement())
        composeInteger(t, "Timing", "frequencyMax", element.getFrequencyMaxElement(), -1);
    if (element.hasPeriodElement())
        composeDecimal(t, "Timing", "period", element.getPeriodElement(), -1);
    if (element.hasPeriodMaxElement())
        composeDecimal(t, "Timing", "periodMax", element.getPeriodMaxElement(), -1);
    if (element.hasPeriodUnitElement())
        composeEnum(t, "Timing", "periodUnit", element.getPeriodUnitElement(), -1);
    if (element.hasWhenElement())
        composeEnum(t, "Timing", "when", element.getWhenElement(), -1);
    if (element.hasOffsetElement())
        composeUnsignedInt(t, "Timing", "offset", element.getOffsetElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 99 with Period

use of org.hl7.fhir.dstu2.model.Period in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeSampledData.

protected void composeSampledData(Complex parent, String parentType, String name, SampledData element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "SampledData", name, element, index);
    if (element.hasOrigin())
        composeQuantity(t, "SampledData", "origin", element.getOrigin(), -1);
    if (element.hasPeriodElement())
        composeDecimal(t, "SampledData", "period", element.getPeriodElement(), -1);
    if (element.hasFactorElement())
        composeDecimal(t, "SampledData", "factor", element.getFactorElement(), -1);
    if (element.hasLowerLimitElement())
        composeDecimal(t, "SampledData", "lowerLimit", element.getLowerLimitElement(), -1);
    if (element.hasUpperLimitElement())
        composeDecimal(t, "SampledData", "upperLimit", element.getUpperLimitElement(), -1);
    if (element.hasDimensionsElement())
        composePositiveInt(t, "SampledData", "dimensions", element.getDimensionsElement(), -1);
    if (element.hasDataElement())
        composeString(t, "SampledData", "data", element.getDataElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 100 with Period

use of org.hl7.fhir.dstu2.model.Period 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.dstu2016may.model.DateType)
        x.addText(((org.hl7.fhir.dstu2016may.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.dstu2016may.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu2016may.model.IntegerType) e).getValue()));
    } else if (e instanceof org.hl7.fhir.dstu2016may.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu2016may.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.dstu2016may.model.Meta) Base64(org.apache.commons.codec.binary.Base64) Address(org.hl7.fhir.dstu2016may.model.Address) StringType(org.hl7.fhir.dstu2016may.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu2016may.model.Attachment) UriType(org.hl7.fhir.dstu2016may.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HumanName(org.hl7.fhir.dstu2016may.model.HumanName) ContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint) Identifier(org.hl7.fhir.dstu2016may.model.Identifier) Coding(org.hl7.fhir.dstu2016may.model.Coding) Narrative(org.hl7.fhir.dstu2016may.model.Narrative) SampledData(org.hl7.fhir.dstu2016may.model.SampledData) Ratio(org.hl7.fhir.dstu2016may.model.Ratio) ElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition) InstantType(org.hl7.fhir.dstu2016may.model.InstantType) Enumeration(org.hl7.fhir.dstu2016may.model.Enumeration) Reference(org.hl7.fhir.dstu2016may.model.Reference) BooleanType(org.hl7.fhir.dstu2016may.model.BooleanType) Resource(org.hl7.fhir.dstu2016may.model.Resource) DomainResource(org.hl7.fhir.dstu2016may.model.DomainResource) Quantity(org.hl7.fhir.dstu2016may.model.Quantity) Period(org.hl7.fhir.dstu2016may.model.Period) Range(org.hl7.fhir.dstu2016may.model.Range) Base(org.hl7.fhir.dstu2016may.model.Base) Annotation(org.hl7.fhir.dstu2016may.model.Annotation) IdType(org.hl7.fhir.dstu2016may.model.IdType) Extension(org.hl7.fhir.dstu2016may.model.Extension) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) CodeType(org.hl7.fhir.dstu2016may.model.CodeType) EventTiming(org.hl7.fhir.dstu2016may.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu2016may.model.Timing) Base64BinaryType(org.hl7.fhir.dstu2016may.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept)

Aggregations

Period (org.hl7.fhir.r4.model.Period)87 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)44 Date (java.util.Date)42 Test (org.junit.Test)42 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)40 Coding (org.hl7.fhir.r4.model.Coding)34 Test (org.junit.jupiter.api.Test)34 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)32 Period (org.hl7.fhir.dstu3.model.Period)30 ArrayList (java.util.ArrayList)29 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)27 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)20 Encounter (org.hl7.fhir.r4.model.Encounter)20 Reference (org.hl7.fhir.r4.model.Reference)20 Patient (org.hl7.fhir.r4.model.Patient)19 Reference (org.hl7.fhir.dstu3.model.Reference)18 HashMap (java.util.HashMap)17 Identifier (org.hl7.fhir.r4.model.Identifier)17 NotImplementedException (org.apache.commons.lang3.NotImplementedException)15 List (java.util.List)14