Search in sources :

Example 56 with QuestionnaireResponse

use of org.hl7.fhir.r4b.model.QuestionnaireResponse 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.getType().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.dstu3.model.Questionnaire.QuestionnaireItemComponent) Questionnaire(org.hl7.fhir.dstu3.model.Questionnaire) ArrayList(java.util.ArrayList) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) QuestionnaireItemComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent)

Example 57 with QuestionnaireResponse

use of org.hl7.fhir.r4b.model.QuestionnaireResponse 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.getType().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.r4.model.Questionnaire.QuestionnaireItemComponent) Questionnaire(org.hl7.fhir.r4.model.Questionnaire) ArrayList(java.util.ArrayList) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ElementDefinition(org.hl7.fhir.r4.model.ElementDefinition) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse) QuestionnaireItemComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent)

Example 58 with QuestionnaireResponse

use of org.hl7.fhir.r4b.model.QuestionnaireResponse 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.getConstrainedType().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.GroupComponent> answerGroups = new ArrayList<QuestionnaireResponse.GroupComponent>();
    if (resource != null)
        answerGroups.add(response.getGroup());
    if (prebuiltQuestionnaire != null) {
        // give it a fake group to build
        Questionnaire.GroupComponent group = new Questionnaire.GroupComponent();
        buildGroup(group, profile, profile.getSnapshot().getElement().get(0), list, answerGroups);
    } else
        buildGroup(questionnaire.getGroup(), profile, profile.getSnapshot().getElement().get(0), list, answerGroups);
// 
// NarrativeGenerator ngen = new NarrativeGenerator(context);
// ngen.generate(result);
// 
// if FResponse <> nil then
// FResponse.collapseAllContained;
}
Also used : Questionnaire(org.hl7.fhir.dstu2.model.Questionnaire) GroupComponent(org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent) GroupComponent(org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent) ArrayList(java.util.ArrayList) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition) QuestionnaireResponse(org.hl7.fhir.dstu2.model.QuestionnaireResponse)

Example 59 with QuestionnaireResponse

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

the class RdfParser method composeQuestionnaireResponseQuestionnaireResponseItemAnswerComponent.

protected void composeQuestionnaireResponseQuestionnaireResponseItemAnswerComponent(Complex parent, String parentType, String name, QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "answer", name, element, index);
    if (element.hasValue())
        composeType(t, "QuestionnaireResponse", "value", element.getValue(), -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.r4.utils.formats.Turtle.Complex)

Example 60 with QuestionnaireResponse

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

the class RdfParser method composeQuestionnaireResponseQuestionnaireResponseItemComponent.

protected void composeQuestionnaireResponseQuestionnaireResponseItemComponent(Complex parent, String parentType, String name, QuestionnaireResponse.QuestionnaireResponseItemComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "item", name, element, index);
    if (element.hasLinkIdElement())
        composeString(t, "QuestionnaireResponse", "linkId", element.getLinkIdElement(), -1);
    if (element.hasDefinitionElement())
        composeUri(t, "QuestionnaireResponse", "definition", element.getDefinitionElement(), -1);
    if (element.hasTextElement())
        composeString(t, "QuestionnaireResponse", "text", element.getTextElement(), -1);
    for (int i = 0; i < element.getAnswer().size(); i++) composeQuestionnaireResponseQuestionnaireResponseItemAnswerComponent(t, "QuestionnaireResponse", "answer", element.getAnswer().get(i), i);
    for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireResponseQuestionnaireResponseItemComponent(t, "QuestionnaireResponse", "item", element.getItem().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)15 ArrayList (java.util.ArrayList)14 Bundle (org.hl7.fhir.r4.model.Bundle)11 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)8 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)8 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)8 Test (org.junit.jupiter.api.Test)8 Reference (org.hl7.fhir.dstu3.model.Reference)7 Reference (org.hl7.fhir.r4.model.Reference)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 Map (java.util.Map)5 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)5 FhirUtil (org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil)5 Coding (org.hl7.fhir.r4.model.Coding)4 Date (java.util.Date)3 Getter (lombok.Getter)3 Bundle (org.hl7.fhir.dstu3.model.Bundle)3