Search in sources :

Example 26 with Timing

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

the class QuestionnaireBuilder method processDataType.

private void processDataType(StructureDefinition profile, QuestionnaireItemComponent group, ElementDefinition element, String path, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups, List<ElementDefinition> parents) throws FHIRException {
    String tc = t.getWorkingCode();
    if (tc.equals("code"))
        addCodeQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "string", "id", "oid", "uuid", "markdown"))
        addStringQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "uri", "url", "canonical"))
        addUriQuestions(group, element, path, answerGroups);
    else if (tc.equals("boolean"))
        addBooleanQuestions(group, element, path, answerGroups);
    else if (tc.equals("decimal"))
        addDecimalQuestions(group, element, path, answerGroups);
    else if (tc.equals("dateTime") || tc.equals("date"))
        addDateTimeQuestions(group, element, path, answerGroups);
    else if (tc.equals("instant"))
        addInstantQuestions(group, element, path, answerGroups);
    else if (tc.equals("time"))
        addTimeQuestions(group, element, path, answerGroups);
    else if (tc.equals("CodeableConcept"))
        addCodeableConceptQuestions(group, element, path, answerGroups);
    else if (tc.equals("Period"))
        addPeriodQuestions(group, element, path, answerGroups);
    else if (tc.equals("Ratio"))
        addRatioQuestions(group, element, path, answerGroups);
    else if (tc.equals("HumanName"))
        addHumanNameQuestions(group, element, path, answerGroups);
    else if (tc.equals("Address"))
        addAddressQuestions(group, element, path, answerGroups);
    else if (tc.equals("ContactPoint"))
        addContactPointQuestions(group, element, path, answerGroups);
    else if (tc.equals("Identifier"))
        addIdentifierQuestions(group, element, path, answerGroups);
    else if (tc.equals("integer") || tc.equals("positiveInt") || tc.equals("unsignedInt"))
        addIntegerQuestions(group, element, path, answerGroups);
    else if (tc.equals("Coding"))
        addCodingQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "Quantity", "Count", "Age", "Duration", "Distance", "Money"))
        addQuantityQuestions(group, element, path, answerGroups);
    else if (tc.equals("Money"))
        addMoneyQuestions(group, element, path, answerGroups);
    else if (tc.equals("Reference"))
        addReferenceQuestions(group, element, path, t.getTargetProfile(), answerGroups);
    else if (tc.equals("Duration"))
        addDurationQuestions(group, element, path, answerGroups);
    else if (tc.equals("base64Binary"))
        addBinaryQuestions(group, element, path, answerGroups);
    else if (tc.equals("Attachment"))
        addAttachmentQuestions(group, element, path, answerGroups);
    else if (tc.equals("Age"))
        addAgeQuestions(group, element, path, answerGroups);
    else if (tc.equals("Range"))
        addRangeQuestions(group, element, path, answerGroups);
    else if (tc.equals("Timing"))
        addTimingQuestions(group, element, path, answerGroups);
    else if (tc.equals("Annotation"))
        addAnnotationQuestions(group, element, path, answerGroups);
    else if (tc.equals("SampledData"))
        addSampledDataQuestions(group, element, path, answerGroups);
    else if (tc.equals("Extension")) {
        if (t.hasProfile())
            addExtensionQuestions(profile, group, element, path, t.getProfile().get(0).getValue(), answerGroups, parents);
    } else if (tc.equals("SampledData"))
        addSampledDataQuestions(group, element, path, answerGroups);
    else if (!tc.equals("Narrative") && !tc.equals("Resource") && !tc.equals("Meta") && !tc.equals("Signature")) {
        StructureDefinition sd = context.fetchTypeDefinition(tc);
        if (sd == null)
            throw new NotImplementedException("Unhandled Data Type: " + tc + " on element " + element.getPath());
        buildGroup(group, sd, sd.getSnapshot().getElementFirstRep(), parents, answerGroups);
    }
}
Also used : StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Example 27 with Timing

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

the class NarrativeGenerator method displayTiming.

private String displayTiming(Timing s) throws FHIRException {
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    if (s.hasCode())
        b.append("Code: " + displayCodeableConcept(s.getCode()));
    if (s.getEvent().size() > 0) {
        CommaSeparatedStringBuilder c = new CommaSeparatedStringBuilder();
        for (DateTimeType p : s.getEvent()) {
            c.append(p.toHumanDisplay());
        }
        b.append("Events: " + c.toString());
    }
    if (s.hasRepeat()) {
        TimingRepeatComponent rep = s.getRepeat();
        if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasStart())
            b.append("Starting " + rep.getBoundsPeriod().getStartElement().toHumanDisplay());
        if (rep.hasCount())
            b.append("Count " + Integer.toString(rep.getCount()) + " times");
        if (rep.hasDuration())
            b.append("Duration " + rep.getDuration().toPlainString() + displayTimeUnits(rep.getPeriodUnit()));
        if (rep.hasWhen()) {
            String st = "";
            if (rep.hasOffset()) {
                st = Integer.toString(rep.getOffset()) + "min ";
            }
            b.append("Do " + st);
            for (Enumeration<EventTiming> wh : rep.getWhen()) b.append(displayEventCode(wh.getValue()));
        } else {
            String st = "";
            if (!rep.hasFrequency() || (!rep.hasFrequencyMax() && rep.getFrequency() == 1))
                st = "Once";
            else {
                st = Integer.toString(rep.getFrequency());
                if (rep.hasFrequencyMax())
                    st = st + "-" + Integer.toString(rep.getFrequency());
            }
            if (rep.hasPeriod()) {
                st = st + " per " + rep.getPeriod().toPlainString();
                if (rep.hasPeriodMax())
                    st = st + "-" + rep.getPeriodMax().toPlainString();
                st = st + " " + displayTimeUnits(rep.getPeriodUnit());
            }
            b.append("Do " + st);
        }
        if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasEnd())
            b.append("Until " + rep.getBoundsPeriod().getEndElement().toHumanDisplay());
    }
    return b.toString();
}
Also used : EventTiming(org.hl7.fhir.dstu3.model.Timing.EventTiming) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) TimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent)

Example 28 with Timing

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

the class RdfParser method composePlanDefinitionPlanDefinitionActionComponent.

protected void composePlanDefinitionPlanDefinitionActionComponent(Complex parent, String parentType, String name, PlanDefinition.PlanDefinitionActionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "action", name, element, index);
    if (element.hasPrefixElement())
        composeString(t, "PlanDefinition", "prefix", element.getPrefixElement(), -1);
    if (element.hasTitleElement())
        composeString(t, "PlanDefinition", "title", element.getTitleElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "PlanDefinition", "description", element.getDescriptionElement(), -1);
    if (element.hasTextEquivalentElement())
        composeString(t, "PlanDefinition", "textEquivalent", element.getTextEquivalentElement(), -1);
    if (element.hasPriorityElement())
        composeEnum(t, "PlanDefinition", "priority", element.getPriorityElement(), -1);
    for (int i = 0; i < element.getCode().size(); i++) composeCodeableConcept(t, "PlanDefinition", "code", element.getCode().get(i), i);
    for (int i = 0; i < element.getReason().size(); i++) composeCodeableConcept(t, "PlanDefinition", "reason", element.getReason().get(i), i);
    for (int i = 0; i < element.getDocumentation().size(); i++) composeRelatedArtifact(t, "PlanDefinition", "documentation", element.getDocumentation().get(i), i);
    for (int i = 0; i < element.getGoalId().size(); i++) composeId(t, "PlanDefinition", "goalId", element.getGoalId().get(i), i);
    if (element.hasSubject())
        composeType(t, "PlanDefinition", "subject", element.getSubject(), -1);
    for (int i = 0; i < element.getTrigger().size(); i++) composeTriggerDefinition(t, "PlanDefinition", "trigger", element.getTrigger().get(i), i);
    for (int i = 0; i < element.getCondition().size(); i++) composePlanDefinitionPlanDefinitionActionConditionComponent(t, "PlanDefinition", "condition", element.getCondition().get(i), i);
    for (int i = 0; i < element.getInput().size(); i++) composeDataRequirement(t, "PlanDefinition", "input", element.getInput().get(i), i);
    for (int i = 0; i < element.getOutput().size(); i++) composeDataRequirement(t, "PlanDefinition", "output", element.getOutput().get(i), i);
    for (int i = 0; i < element.getRelatedAction().size(); i++) composePlanDefinitionPlanDefinitionActionRelatedActionComponent(t, "PlanDefinition", "relatedAction", element.getRelatedAction().get(i), i);
    if (element.hasTiming())
        composeType(t, "PlanDefinition", "timing", element.getTiming(), -1);
    for (int i = 0; i < element.getParticipant().size(); i++) composePlanDefinitionPlanDefinitionActionParticipantComponent(t, "PlanDefinition", "participant", element.getParticipant().get(i), i);
    if (element.hasType())
        composeCodeableConcept(t, "PlanDefinition", "type", element.getType(), -1);
    if (element.hasGroupingBehaviorElement())
        composeEnum(t, "PlanDefinition", "groupingBehavior", element.getGroupingBehaviorElement(), -1);
    if (element.hasSelectionBehaviorElement())
        composeEnum(t, "PlanDefinition", "selectionBehavior", element.getSelectionBehaviorElement(), -1);
    if (element.hasRequiredBehaviorElement())
        composeEnum(t, "PlanDefinition", "requiredBehavior", element.getRequiredBehaviorElement(), -1);
    if (element.hasPrecheckBehaviorElement())
        composeEnum(t, "PlanDefinition", "precheckBehavior", element.getPrecheckBehaviorElement(), -1);
    if (element.hasCardinalityBehaviorElement())
        composeEnum(t, "PlanDefinition", "cardinalityBehavior", element.getCardinalityBehaviorElement(), -1);
    if (element.hasDefinition())
        composeType(t, "PlanDefinition", "definition", element.getDefinition(), -1);
    if (element.hasTransformElement())
        composeCanonical(t, "PlanDefinition", "transform", element.getTransformElement(), -1);
    for (int i = 0; i < element.getDynamicValue().size(); i++) composePlanDefinitionPlanDefinitionActionDynamicValueComponent(t, "PlanDefinition", "dynamicValue", element.getDynamicValue().get(i), i);
    for (int i = 0; i < element.getAction().size(); i++) composePlanDefinitionPlanDefinitionActionComponent(t, "PlanDefinition", "action", element.getAction().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 29 with Timing

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

the class RdfParser method composeClaimSupportingInformationComponent.

protected void composeClaimSupportingInformationComponent(Complex parent, String parentType, String name, Claim.SupportingInformationComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "supportingInfo", name, element, index);
    if (element.hasSequenceElement())
        composePositiveInt(t, "Claim", "sequence", element.getSequenceElement(), -1);
    if (element.hasCategory())
        composeCodeableConcept(t, "Claim", "category", element.getCategory(), -1);
    if (element.hasCode())
        composeCodeableConcept(t, "Claim", "code", element.getCode(), -1);
    if (element.hasTiming())
        composeType(t, "Claim", "timing", element.getTiming(), -1);
    if (element.hasValue())
        composeType(t, "Claim", "value", element.getValue(), -1);
    if (element.hasReason())
        composeCodeableConcept(t, "Claim", "reason", element.getReason(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 30 with Timing

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

the class RdfParser method composeTiming.

protected void composeTiming(Complex parent, String parentType, String name, Timing element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "Timing", name, element, index);
    for (int i = 0; i < element.getEvent().size(); i++) composeDateTime(t, "Timing", "event", element.getEvent().get(i), i);
    if (element.hasRepeat())
        composeTimingTimingRepeatComponent(t, "Timing", "repeat", element.getRepeat(), -1);
    if (element.hasCode())
        composeCodeableConcept(t, "Timing", "code", element.getCode(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 Timing (org.hl7.fhir.r4.model.Timing)11 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)10 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)9 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)8 Base64 (org.apache.commons.codec.binary.Base64)6 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 Timing (org.hl7.fhir.dstu3.model.Timing)5 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)5 Reference (org.hl7.fhir.dstu3.model.Reference)4 EventTiming (org.hl7.fhir.dstu3.model.Timing.EventTiming)4 TimingRepeatComponent (org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent)4 BigDecimal (java.math.BigDecimal)3 Dosage (org.hl7.fhir.r4.model.Dosage)3 Period (org.hl7.fhir.r4.model.Period)3 Quantity (org.hl7.fhir.r4.model.Quantity)3 TimingRepeatComponent (org.hl7.fhir.r4.model.Timing.TimingRepeatComponent)3 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)3