Search in sources :

Example 16 with DateTime

use of org.hl7.elm.r1.DateTime in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeNutritionOrder.

protected void composeNutritionOrder(Complex parent, String parentType, String name, NutritionOrder element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "NutritionOrder", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "NutritionOrder", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "NutritionOrder", "status", element.getStatusElement(), -1);
    if (element.hasPatient())
        composeReference(t, "NutritionOrder", "patient", element.getPatient(), -1);
    if (element.hasEncounter())
        composeReference(t, "NutritionOrder", "encounter", element.getEncounter(), -1);
    if (element.hasDateTimeElement())
        composeDateTime(t, "NutritionOrder", "dateTime", element.getDateTimeElement(), -1);
    if (element.hasOrderer())
        composeReference(t, "NutritionOrder", "orderer", element.getOrderer(), -1);
    for (int i = 0; i < element.getAllergyIntolerance().size(); i++) composeReference(t, "NutritionOrder", "allergyIntolerance", element.getAllergyIntolerance().get(i), i);
    for (int i = 0; i < element.getFoodPreferenceModifier().size(); i++) composeCodeableConcept(t, "NutritionOrder", "foodPreferenceModifier", element.getFoodPreferenceModifier().get(i), i);
    for (int i = 0; i < element.getExcludeFoodModifier().size(); i++) composeCodeableConcept(t, "NutritionOrder", "excludeFoodModifier", element.getExcludeFoodModifier().get(i), i);
    if (element.hasOralDiet())
        composeNutritionOrderNutritionOrderOralDietComponent(t, "NutritionOrder", "oralDiet", element.getOralDiet(), -1);
    for (int i = 0; i < element.getSupplement().size(); i++) composeNutritionOrderNutritionOrderSupplementComponent(t, "NutritionOrder", "supplement", element.getSupplement().get(i), i);
    if (element.hasEnteralFormula())
        composeNutritionOrderNutritionOrderEnteralFormulaComponent(t, "NutritionOrder", "enteralFormula", element.getEnteralFormula(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 17 with DateTime

use of org.hl7.elm.r1.DateTime in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method convertType.

@SuppressWarnings("unchecked")
private Type convertType(Base value, QuestionnaireItemType af, ValueSet vs, String path) throws FHIRException {
    switch(af) {
        // simple cases
        case BOOLEAN:
            if (value instanceof BooleanType)
                return (Type) value;
        case DECIMAL:
            if (value instanceof DecimalType)
                return (Type) value;
        case INTEGER:
            if (value instanceof IntegerType)
                return (Type) value;
        case DATE:
            if (value instanceof DateType)
                return (Type) value;
        case DATETIME:
            if (value instanceof DateTimeType)
                return (Type) value;
        case INSTANT:
            if (value instanceof InstantType)
                return (Type) value;
        case TIME:
            if (value instanceof TimeType)
                return (Type) value;
        case STRING:
            if (value instanceof StringType)
                return (Type) value;
            else if (value instanceof UriType)
                return new StringType(((UriType) value).asStringValue());
        case TEXT:
            if (value instanceof StringType)
                return (Type) value;
        case QUANTITY:
            if (value instanceof Quantity)
                return (Type) value;
        // ? QuestionnaireItemTypeAttachment: ...?
        case CHOICE:
        case OPENCHOICE:
            if (value instanceof Coding)
                return (Type) value;
            else if (value instanceof Enumeration) {
                Coding cc = new Coding();
                cc.setCode(((Enumeration<Enum<?>>) value).asStringValue());
                cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
                return cc;
            } else if (value instanceof StringType) {
                Coding cc = new Coding();
                cc.setCode(((StringType) value).asStringValue());
                cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
                return cc;
            }
        case REFERENCE:
            if (value instanceof Reference)
                return (Type) value;
            else if (value instanceof StringType) {
                Reference r = new Reference();
                r.setReference(((StringType) value).asStringValue());
            }
    }
    throw new FHIRException("Unable to convert from '" + value.getClass().toString() + "' for Answer Format " + af.toCode() + ", path = " + path);
}
Also used : Enumeration(org.hl7.fhir.dstu2016may.model.Enumeration) StringType(org.hl7.fhir.dstu2016may.model.StringType) Reference(org.hl7.fhir.dstu2016may.model.Reference) BooleanType(org.hl7.fhir.dstu2016may.model.BooleanType) Quantity(org.hl7.fhir.dstu2016may.model.Quantity) FHIRException(org.hl7.fhir.exceptions.FHIRException) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) TimeType(org.hl7.fhir.dstu2016may.model.TimeType) UriType(org.hl7.fhir.dstu2016may.model.UriType) IntegerType(org.hl7.fhir.dstu2016may.model.IntegerType) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) Coding(org.hl7.fhir.dstu2016may.model.Coding) DecimalType(org.hl7.fhir.dstu2016may.model.DecimalType) InstantType(org.hl7.fhir.dstu2016may.model.InstantType) DateType(org.hl7.fhir.dstu2016may.model.DateType)

Example 18 with DateTime

use of org.hl7.elm.r1.DateTime in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method convertType.

@SuppressWarnings("unchecked")
private Type convertType(Base value, QuestionnaireItemType af, ValueSet vs, String path) throws FHIRException {
    switch(af) {
        // simple cases
        case BOOLEAN:
            if (value instanceof BooleanType)
                return (Type) value;
        case DECIMAL:
            if (value instanceof DecimalType)
                return (Type) value;
        case INTEGER:
            if (value instanceof IntegerType)
                return (Type) value;
        case DATE:
            if (value instanceof DateType)
                return (Type) value;
        case DATETIME:
            if (value instanceof DateTimeType)
                return (Type) value;
        case TIME:
            if (value instanceof TimeType)
                return (Type) value;
        case STRING:
            if (value instanceof StringType)
                return (Type) value;
            else if (value instanceof UriType)
                return new StringType(((UriType) value).asStringValue());
        case TEXT:
            if (value instanceof StringType)
                return (Type) value;
        case QUANTITY:
            if (value instanceof Quantity)
                return (Type) value;
        // ? QuestionnaireItemTypeAttachment: ...?
        case CHOICE:
        case OPENCHOICE:
            if (value instanceof Coding)
                return (Type) value;
            else if (value instanceof Enumeration) {
                Coding cc = new Coding();
                cc.setCode(((Enumeration<Enum<?>>) value).asStringValue());
                cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
                return cc;
            } else if (value instanceof StringType) {
                Coding cc = new Coding();
                cc.setCode(((StringType) value).asStringValue());
                cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
                return cc;
            }
        case REFERENCE:
            if (value instanceof Reference)
                return (Type) value;
            else if (value instanceof StringType) {
                Reference r = new Reference();
                r.setReference(((StringType) value).asStringValue());
            }
    }
    throw new FHIRException("Unable to convert from '" + value.getClass().toString() + "' for Answer Format " + af.toCode() + ", path = " + path);
}
Also used : Enumeration(org.hl7.fhir.dstu3.model.Enumeration) StringType(org.hl7.fhir.dstu3.model.StringType) Reference(org.hl7.fhir.dstu3.model.Reference) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Quantity(org.hl7.fhir.dstu3.model.Quantity) FHIRException(org.hl7.fhir.exceptions.FHIRException) TimeType(org.hl7.fhir.dstu3.model.TimeType) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) UriType(org.hl7.fhir.dstu3.model.UriType) IntegerType(org.hl7.fhir.dstu3.model.IntegerType) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Coding(org.hl7.fhir.dstu3.model.Coding) DecimalType(org.hl7.fhir.dstu3.model.DecimalType) DateType(org.hl7.fhir.dstu3.model.DateType)

Example 19 with DateTime

use of org.hl7.elm.r1.DateTime in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeConsent.

protected void composeConsent(Complex parent, String parentType, String name, Consent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Consent", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Consent", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Consent", "status", element.getStatusElement(), -1);
    if (element.hasScope())
        composeCodeableConcept(t, "Consent", "scope", element.getScope(), -1);
    for (int i = 0; i < element.getCategory().size(); i++) composeCodeableConcept(t, "Consent", "category", element.getCategory().get(i), i);
    if (element.hasPatient())
        composeReference(t, "Consent", "patient", element.getPatient(), -1);
    if (element.hasDateTimeElement())
        composeDateTime(t, "Consent", "dateTime", element.getDateTimeElement(), -1);
    for (int i = 0; i < element.getPerformer().size(); i++) composeReference(t, "Consent", "performer", element.getPerformer().get(i), i);
    for (int i = 0; i < element.getOrganization().size(); i++) composeReference(t, "Consent", "organization", element.getOrganization().get(i), i);
    if (element.hasSource())
        composeType(t, "Consent", "source", element.getSource(), -1);
    for (int i = 0; i < element.getPolicy().size(); i++) composeConsentConsentPolicyComponent(t, "Consent", "policy", element.getPolicy().get(i), i);
    if (element.hasPolicyRule())
        composeCodeableConcept(t, "Consent", "policyRule", element.getPolicyRule(), -1);
    for (int i = 0; i < element.getVerification().size(); i++) composeConsentConsentVerificationComponent(t, "Consent", "verification", element.getVerification().get(i), i);
    if (element.hasProvision())
        composeConsentprovisionComponent(t, "Consent", "provision", element.getProvision(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 20 with DateTime

use of org.hl7.elm.r1.DateTime 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)

Aggregations

ArrayList (java.util.ArrayList)30 List (java.util.List)21 LinkedHashSet (java.util.LinkedHashSet)20 Test (org.junit.Test)18 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)16 FHIRException (org.hl7.fhir.exceptions.FHIRException)15 Before (org.junit.Before)11 Set (java.util.Set)10 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 Condition (org.hl7.fhir.r4.model.Condition)8 MergedList (org.hl7.fhir.utilities.MergedList)8 Date (java.util.Date)5 HashMap (java.util.HashMap)4 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)4 Period (org.hl7.fhir.r4.model.Period)4 Procedure (org.hl7.fhir.r4.model.Procedure)4 CodeType (org.hl7.fhir.r5.model.CodeType)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)4