Search in sources :

Example 46 with QuestionnaireResponse

use of org.hl7.fhir.r4b.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);
}
Also used : POCDMT000002UK01Component3(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component3) POCDMT000002UK01Entry(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Entry) Reference(org.hl7.fhir.dstu3.model.Reference) POCDMT000002UK01Component5(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component5) IdType(org.hl7.fhir.dstu3.model.IdType) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 47 with QuestionnaireResponse

use of org.hl7.fhir.r4b.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;
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) QuestionnaireResponseItemComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)

Example 48 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.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);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 49 with QuestionnaireResponse

use of org.hl7.fhir.r4b.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);
}
Also used : ExpressionNode(org.hl7.fhir.r5.model.ExpressionNode) ArrayList(java.util.ArrayList) QuestionnaireItemEnableWhenComponent(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent)

Example 50 with QuestionnaireResponse

use of org.hl7.fhir.r4b.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);
}
Also used : Complex(org.hl7.fhir.dstu3.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