Search in sources :

Example 16 with Questionnaire

use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeQuestionnaire.

protected void composeQuestionnaire(Complex parent, String parentType, String name, Questionnaire element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Questionnaire", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "Questionnaire", "url", element.getUrlElement(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Questionnaire", "identifier", element.getIdentifier().get(i), i);
    if (element.hasVersionElement())
        composeString(t, "Questionnaire", "version", element.getVersionElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "Questionnaire", "status", element.getStatusElement(), -1);
    if (element.hasDateElement())
        composeDateTime(t, "Questionnaire", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "Questionnaire", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "Questionnaire", "telecom", element.getTelecom().get(i), i);
    for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "Questionnaire", "useContext", element.getUseContext().get(i), i);
    if (element.hasTitleElement())
        composeString(t, "Questionnaire", "title", element.getTitleElement(), -1);
    for (int i = 0; i < element.getConcept().size(); i++) composeCoding(t, "Questionnaire", "concept", element.getConcept().get(i), i);
    for (int i = 0; i < element.getSubjectType().size(); i++) composeCode(t, "Questionnaire", "subjectType", element.getSubjectType().get(i), i);
    for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireQuestionnaireItemComponent(t, "Questionnaire", "item", element.getItem().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 17 with Questionnaire

use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeQuestionnaireQuestionnaireItemEnableWhenComponent.

protected void composeQuestionnaireQuestionnaireItemEnableWhenComponent(Complex parent, String parentType, String name, Questionnaire.QuestionnaireItemEnableWhenComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "enableWhen", name, element, index);
    if (element.hasQuestionElement())
        composeString(t, "Questionnaire", "question", element.getQuestionElement(), -1);
    if (element.hasAnsweredElement())
        composeBoolean(t, "Questionnaire", "answered", element.getAnsweredElement(), -1);
    if (element.hasAnswer())
        composeType(t, "Questionnaire", "answer", element.getAnswer(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 18 with Questionnaire

use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeQuestionnaireResponse.

protected void composeQuestionnaireResponse(Complex parent, String parentType, String name, QuestionnaireResponse element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "QuestionnaireResponse", name, element, index);
    if (element.hasIdentifier())
        composeIdentifier(t, "QuestionnaireResponse", "identifier", element.getIdentifier(), -1);
    if (element.hasQuestionnaire())
        composeReference(t, "QuestionnaireResponse", "questionnaire", element.getQuestionnaire(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "QuestionnaireResponse", "status", element.getStatusElement(), -1);
    if (element.hasSubject())
        composeReference(t, "QuestionnaireResponse", "subject", element.getSubject(), -1);
    if (element.hasAuthor())
        composeReference(t, "QuestionnaireResponse", "author", element.getAuthor(), -1);
    if (element.hasAuthoredElement())
        composeDateTime(t, "QuestionnaireResponse", "authored", element.getAuthoredElement(), -1);
    if (element.hasSource())
        composeReference(t, "QuestionnaireResponse", "source", element.getSource(), -1);
    if (element.hasEncounter())
        composeReference(t, "QuestionnaireResponse", "encounter", element.getEncounter(), -1);
    for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireResponseQuestionnaireResponseItemComponent(t, "QuestionnaireResponse", "item", element.getItem().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 19 with Questionnaire

use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method build.

public void build() throws FHIRException {
    if (profile == null)
        throw new DefinitionException("QuestionnaireBuilder.build: no profile found");
    if (resource != null)
        if (!profile.getBaseType().equals(resource.getResourceType().toString()))
            throw new DefinitionException("Wrong Type");
    if (prebuiltQuestionnaire != null)
        questionnaire = prebuiltQuestionnaire;
    else
        questionnaire = new Questionnaire();
    if (resource != null)
        response = new QuestionnaireResponse();
    processMetadata();
    List<ElementDefinition> list = new ArrayList<ElementDefinition>();
    List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
    if (resource != null)
        answerGroups.addAll(response.getItem());
    if (prebuiltQuestionnaire != null) {
        // give it a fake group to build
        Questionnaire.QuestionnaireItemComponent group = new Questionnaire.QuestionnaireItemComponent();
        group.setType(QuestionnaireItemType.GROUP);
        buildGroup(group, profile, profile.getSnapshot().getElement().get(0), list, answerGroups);
    } else
        buildGroup(questionnaire.getItem().get(0), profile, profile.getSnapshot().getElement().get(0), list, answerGroups);
// 
// NarrativeGenerator ngen = new NarrativeGenerator(context);
// ngen.generate(result);
// 
// if FResponse <> nil then
// FResponse.collapseAllContained;
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent) Questionnaire(org.hl7.fhir.dstu2016may.model.Questionnaire) ArrayList(java.util.ArrayList) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition) QuestionnaireResponse(org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) QuestionnaireItemComponent(org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent)

Example 20 with Questionnaire

use of org.hl7.fhir.r4b.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class ToolingExtensions method addFlyOver.

public static void addFlyOver(QuestionnaireItemComponent item, String text) {
    if (!StringUtils.isBlank(text)) {
        QuestionnaireItemComponent display = item.addItem();
        display.setType(QuestionnaireItemType.DISPLAY);
        display.setText(text);
        display.getExtension().add(Factory.newExtension(EXT_CONTROL, Factory.newCodeableConcept("flyover", "http://hl7.org/fhir/questionnaire-item-control", "Fly-over"), true));
    }
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)18 ArrayList (java.util.ArrayList)15 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)14 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)13 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)12 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)11 QuestionnaireItemComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent)11 File (java.io.File)10 TextFile (org.hl7.fhir.utilities.TextFile)10 Test (org.junit.jupiter.api.Test)10 FileOutputStream (java.io.FileOutputStream)9 Questionnaire (org.hl7.fhir.dstu3.model.Questionnaire)9 FHIRException (org.hl7.fhir.exceptions.FHIRException)8 QuestionnaireItemComponent (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent)8 IOException (java.io.IOException)7 Bundle (org.hl7.fhir.r4.model.Bundle)7 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)7 ValueSet (org.hl7.fhir.r5.model.ValueSet)7 FileNotFoundException (java.io.FileNotFoundException)6 Extension (org.hl7.fhir.r4.model.Extension)6