use of org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project pathling by aehrc.
the class TestData method newQuestionnaireResponse.
/**
* Returns a FHIR QuestionnaireResponse resource for testing purposes.
*/
public static QuestionnaireResponse newQuestionnaireResponse() {
final QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
questionnaireResponse.setId("QuestionnaireResponse/1");
final QuestionnaireResponseItemComponent item = questionnaireResponse.addItem();
final QuestionnaireResponseItemAnswerComponent answer1 = new QuestionnaireResponseItemAnswerComponent();
answer1.setValue(new DecimalType(TEST_VERY_SMALL_DECIMAL_SCALE_6));
final QuestionnaireResponseItemAnswerComponent answer2 = new QuestionnaireResponseItemAnswerComponent();
answer2.setValue(new DecimalType(TEST_VERY_BIG_DECIMAL));
item.addAnswer(answer1);
item.addAnswer(answer2);
return questionnaireResponse;
}
use of org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project pathling by aehrc.
the class TestData method newNestedResponseAnswer.
private static QuestionnaireResponseItemAnswerComponent newNestedResponseAnswer(final int nestingLevel) {
final QuestionnaireResponseItemAnswerComponent answer = new QuestionnaireResponseItemAnswerComponent();
answer.setId("AnswerLevel/" + nestingLevel);
answer.setItem(Collections.singletonList(newNestedResponseItem(nestingLevel - 1)));
return answer;
}
use of org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method selectTypes.
private void selectTypes(StructureDefinition profile, QuestionnaireItemComponent sub, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> source, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> dest) throws FHIRFormatError {
List<QuestionnaireResponse.QuestionnaireResponseItemComponent> temp = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : source) if (instanceOf(t, (Element) g.getUserData("object")))
temp.add(g);
for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) source.remove(g);
for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) {
// it should be empty
assert (g.getItem().size() == 0);
QuestionnaireResponse.QuestionnaireResponseItemComponent q = g.addItem();
q.setLinkId(g.getLinkId() + "._type");
q.setText("type");
QuestionnaireResponseItemAnswerComponent a = q.addAnswer();
if (t.hasTarget()) {
for (UriType u : t.getTargetProfile()) {
if (u.getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
Coding cc = new Coding();
a.setValue(cc);
cc.setCode(u.getValue().substring(40));
cc.setSystem("http://hl7.org/fhir/resource-types");
}
}
} else {
Coding cc = new Coding();
a.setValue(cc);
ProfileUtilities pu = new ProfileUtilities(context, null, null);
StructureDefinition ps = null;
if (t.hasProfile())
ps = pu.getProfile(profile, t.getProfile().get(0).getValue());
if (ps != null) {
cc.setCode(t.getProfile().get(0).getValue());
cc.setSystem("http://hl7.org/fhir/resource-types");
} else {
cc.setCode(t.getWorkingCode());
cc.setSystem("http://hl7.org/fhir/data-types");
}
}
// 1st: create the subgroup
QuestionnaireResponse.QuestionnaireResponseItemComponent subg = a.addItem();
dest.add(subg);
subg.setLinkId(sub.getLinkId());
subg.setText(sub.getText());
subg.setUserData("object", g.getUserData("object"));
}
}
use of org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method selectTypes.
private void selectTypes(StructureDefinition profile, QuestionnaireItemComponent sub, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> source, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> dest) {
List<QuestionnaireResponse.QuestionnaireResponseItemComponent> temp = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : source) if (instanceOf(t, (Element) g.getUserData("object")))
temp.add(g);
for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) source.remove(g);
for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) {
// it should be empty
assert (g.getItem().size() == 0);
QuestionnaireResponse.QuestionnaireResponseItemComponent q = g.addItem();
q.setLinkId(g.getLinkId() + "._type");
q.setText("type");
Coding cc = new Coding();
QuestionnaireResponseItemAnswerComponent a = q.addAnswer();
a.setValue(cc);
if (t.getCode().equals("Reference") && t.hasProfile() && t.getProfile().get(0).getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
cc.setCode(t.getProfile().get(0).getValue().substring(40));
cc.setSystem("http://hl7.org/fhir/resource-types");
} else {
ProfileUtilities pu = new ProfileUtilities(context, null, null);
StructureDefinition ps = null;
if (t.hasProfile())
ps = pu.getProfile(profile, t.getProfile().get(0).getValue());
if (ps != null) {
cc.setCode(t.getProfile().get(0).getValue());
cc.setSystem("http://hl7.org/fhir/resource-types");
} else {
cc.setCode(t.getCode());
cc.setSystem("http://hl7.org/fhir/data-types");
}
}
// 1st: create the subgroup
QuestionnaireResponse.QuestionnaireResponseItemComponent subg = a.addItem();
dest.add(subg);
subg.setLinkId(sub.getLinkId());
subg.setText(sub.getText());
subg.setUserData("object", g.getUserData("object"));
}
}
use of org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireResponseRenderer method renderTreeItem.
private boolean renderTreeItem(HierarchicalTableGenerator gen, List<Row> rows, QuestionnaireResponse q, QuestionnaireResponseItemComponent i) throws IOException {
Row r = gen.new Row();
rows.add(r);
boolean hasExt = false;
boolean hasItem = i.hasItem();
for (QuestionnaireResponseItemAnswerComponent a : i.getAnswer()) {
hasItem = a.hasItem();
}
if (hasItem) {
r.setIcon("icon-q-group.png", "Group");
} else {
r.setIcon("icon-q-string.png", "Item");
}
r.getCells().add(gen.new Cell(null, context.getDefinitionsTarget() == null ? "" : context.getDefinitionsTarget() + "#item." + i.getLinkId(), i.getLinkId(), null, null));
r.getCells().add(gen.new Cell(null, null, i.getText(), null, null));
r.getCells().add(gen.new Cell(null, null, null, null, null));
r.getCells().add(gen.new Cell(null, null, null, null, null));
return hasExt;
}
Aggregations