use of org.hl7.fhir.r5.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;
}
use of org.hl7.fhir.r5.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;
}
use of org.hl7.fhir.r5.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;
}
use of org.hl7.fhir.r5.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);
}
use of org.hl7.fhir.r5.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);
}
Aggregations