use of org.hl7.fhir.r5.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.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.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.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.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method processMetadata.
private void processMetadata() {
// todo: can we derive a more informative identifier from the questionnaire if we have a profile
if (prebuiltQuestionnaire == null) {
questionnaire.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue(questionnaireId);
questionnaire.setVersion(profile.getVersion());
questionnaire.setStatus(profile.getStatus());
questionnaire.setDate(profile.getDate());
questionnaire.setPublisher(profile.getPublisher());
Questionnaire.QuestionnaireItemComponent item = new Questionnaire.QuestionnaireItemComponent();
questionnaire.addItem(item);
item.setLinkId("meta");
item.getCode().addAll(profile.getKeyword());
questionnaire.setId(nextId("qs"));
}
if (response != null) {
// no identifier - this is transient
response.setQuestionnaire("#" + questionnaire.getId());
response.getContained().add(questionnaire);
response.setStatus(QuestionnaireResponseStatus.INPROGRESS);
QuestionnaireResponse.QuestionnaireResponseItemComponent item = new QuestionnaireResponse.QuestionnaireResponseItemComponent();
response.addItem(item);
item.setLinkId("meta");
item.setUserData("object", resource);
}
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class ToolingExtensions method addFlyOver.
// public static boolean hasDeprecated(Element c) {
// return findBooleanExtension(c, EXT_DEPRECATED);
// }
public static void addFlyOver(QuestionnaireItemComponent item, String text, String linkId) {
if (!StringUtils.isBlank(text)) {
QuestionnaireItemComponent display = item.addItem();
display.setType(QuestionnaireItemType.DISPLAY);
display.setText(text);
display.setLinkId(linkId);
display.getExtension().add(Factory.newExtension(EXT_CONTROL, Factory.newCodeableConcept("flyover", "http://hl7.org/fhir/questionnaire-item-control", "Fly-over"), true));
}
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method renderRootDefinition.
private boolean renderRootDefinition(XhtmlNode tbl, Questionnaire q, List<QuestionnaireItemComponent> parents) throws IOException {
boolean ext = false;
XhtmlNode td = tbl.tr().td("structure").colspan("2").span(null, null).attribute("class", "self-link-parent");
td.an(q.getId());
td.img(Utilities.path(context.getLocalPrefix(), "icon_q_root.gif"));
td.tx(" Questionnaire ");
td.b().tx(q.getId());
// general information
defn(tbl, "URL", q.getUrl());
defn(tbl, "Version", q.getVersion());
defn(tbl, "Name", q.getName());
defn(tbl, "Title", q.getTitle());
if (q.hasDerivedFrom()) {
td = defn(tbl, "Derived From");
boolean first = true;
for (CanonicalType c : q.getDerivedFrom()) {
if (first)
first = false;
else
td.tx(", ");
// todo: make these a reference
td.tx(c.asStringValue());
}
}
defn(tbl, "Status", q.getStatus().getDisplay());
defn(tbl, "Experimental", q.getExperimental());
defn(tbl, "Publication Date", q.getDateElement().primitiveValue());
defn(tbl, "Approval Date", q.getApprovalDateElement().primitiveValue());
defn(tbl, "Last Review Date", q.getLastReviewDateElement().primitiveValue());
if (q.hasEffectivePeriod()) {
renderPeriod(defn(tbl, "Effective Period"), q.getEffectivePeriod());
}
if (q.hasSubjectType()) {
td = defn(tbl, "Subject Type");
boolean first = true;
for (CodeType c : q.getSubjectType()) {
if (first)
first = false;
else
td.tx(", ");
td.tx(c.asStringValue());
}
}
defn(tbl, "Description", q.getDescription());
defn(tbl, "Purpose", q.getPurpose());
defn(tbl, "Copyright", q.getCopyright());
if (q.hasCode()) {
td = defn(tbl, Utilities.pluralize("Code", q.getCode().size()));
boolean first = true;
for (Coding c : q.getCode()) {
if (first)
first = false;
else
td.tx(", ");
renderCodingWithDetails(td, c);
}
}
return false;
}
Aggregations