use of org.hl7.fhir.r5.model.QuestionnaireResponse in project integration-adaptor-111 by nhsconnect.
the class ConditionMapperTest method setUp.
@BeforeEach
public void setUp() {
POCDMT000002UK01Component3[] component3Array = new POCDMT000002UK01Component3[1];
component3Array[0] = component3;
POCDMT000002UK01Component5[] component5Array = new POCDMT000002UK01Component5[1];
component5Array[0] = component5;
questionnaireResponseList = new ArrayList<>();
questionnaireResponseList.add(questionnaireResponse);
when(encounter.getSubject()).thenReturn(patient);
when(clinicalDocument.getComponent()).thenReturn(component2);
when(component2.isSetStructuredBody()).thenReturn(true);
when(component2.getStructuredBody()).thenReturn(structuredBody);
when(structuredBody.getComponentArray()).thenReturn(component3Array);
when(component3.getSection()).thenReturn(section);
POCDMT000002UK01Entry[] entries = new POCDMT000002UK01Entry[] { entry };
when(section.getEntryArray()).thenReturn(entries);
when(entry.isSetEncounter()).thenReturn(true);
when(entry.getEncounter()).thenReturn(itkEncounter);
when(itkEncounter.isSetEffectiveTime()).thenReturn(true);
when(itkEncounter.getEffectiveTime()).thenReturn(time);
when(time.getValue()).thenReturn(EFFECTIVE_TIME_STRING);
when(itkEncounter.isSetText()).thenReturn(true);
when(itkEncounter.getText()).thenReturn(ed);
when(ed.getDomNode()).thenReturn(node);
when(nodeUtil.getAllText(node)).thenReturn(CONIDITION_TEXT);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
when(resourceUtil.createReference(encounter)).thenReturn(new Reference(encounter));
when(resourceUtil.createReference(questionnaireResponse)).thenReturn(new Reference(QUESTIONNAIRE_RESPONSE_ID));
when(section.getComponentArray()).thenReturn(component5Array);
when(component5.getSection()).thenReturn(section);
when(section.isSetLanguageCode()).thenReturn(true);
when(section.getLanguageCode()).thenReturn(cs);
when(cs.isSetCode()).thenReturn(true);
when(cs.getCode()).thenReturn(LANGUAGE_CODE);
when(questionnaireResponse.hasId()).thenReturn(true);
}
use of org.hl7.fhir.r5.model.QuestionnaireResponse 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.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.hasTextElement())
composeString(t, "QuestionnaireResponse", "text", element.getTextElement(), -1);
if (element.hasSubject())
composeReference(t, "QuestionnaireResponse", "subject", element.getSubject(), -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);
}
use of org.hl7.fhir.r5.model.QuestionnaireResponse in project org.hl7.fhir.core by hapifhir.
the class EnableWhenEvaluator method isQuestionEnabled.
/**
* the stack contains a set of QR items that represent the tree of the QR being validated, each tagged with the definition of the item from the Q for the QR being validated
* <p>
* the itembeing validated is in the context of the stack. For root items, the stack is empty.
* <p>
* The context Questionnaire and QuestionnaireResponse are always available
*/
public boolean isQuestionEnabled(ValidatorHostContext hostContext, QuestionnaireItemComponent qitem, QStack qstack, FHIRPathEngine engine) {
if (hasExpressionExtension(qitem)) {
String expr = getExpression(qitem);
ExpressionNode node = engine.parse(expr);
return engine.evaluateToBoolean(hostContext, qstack.a, qstack.a, qstack.a, node);
}
if (!qitem.hasEnableWhen()) {
return true;
}
List<EnableWhenResult> evaluationResults = new ArrayList<>();
for (QuestionnaireItemEnableWhenComponent enableCondition : qitem.getEnableWhen()) {
evaluationResults.add(evaluateCondition(enableCondition, qitem, qstack));
}
return checkConditionResults(evaluationResults, qitem);
}
use of org.hl7.fhir.r5.model.QuestionnaireResponse 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);
for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "QuestionnaireResponse", "basedOn", element.getBasedOn().get(i), i);
for (int i = 0; i < element.getParent().size(); i++) composeReference(t, "QuestionnaireResponse", "parent", element.getParent().get(i), i);
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.hasContext())
composeReference(t, "QuestionnaireResponse", "context", element.getContext(), -1);
if (element.hasAuthoredElement())
composeDateTime(t, "QuestionnaireResponse", "authored", element.getAuthoredElement(), -1);
if (element.hasAuthor())
composeReference(t, "QuestionnaireResponse", "author", element.getAuthor(), -1);
if (element.hasSource())
composeReference(t, "QuestionnaireResponse", "source", element.getSource(), -1);
for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireResponseQuestionnaireResponseItemComponent(t, "QuestionnaireResponse", "item", element.getItem().get(i), i);
}
Aggregations