Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CARDS-2509: Reference question should support conditions based on sou… #1791

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Utilities/FormImport/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,12 @@ def range_value_handler(self, questionnaire, row, datetime_limit):
DefaultHeaders["TYPE_PROPERTY"] = HeaderColumn("type", "type")
DefaultHeaders["VALIDATION_ERROR_TEXT"] = HeaderColumn("validationErrorText", "validationErrorText")
DefaultHeaders["IS_RANGE"] = HeaderColumn("isRange", "isRange", boolean_handler)
DefaultHeaders["CONDITIONAL_PROPERTY"] = HeaderColumn("conditionalProperty", "conditionalProperty")
DefaultHeaders["CONDITIONAL_OPERATOR"] = HeaderColumn("conditionalOperator", "conditionalOperator")
DefaultHeaders["CONDITIONAL_VALUE"] = HeaderColumn("conditionalValue", "conditionalValue")
DefaultHeaders["CONDITIONAL_INVALID_SRC_MSG"] = HeaderColumn("conditionalInvalidSourceMessage", "conditionalInvalidSourceMessage")
DefaultHeaders["CONDITIONAL_FALLBACK"] = HeaderColumn("conditionalFallback", "conditionalFallback")
DefaultHeaders["CONDITIONAL_TYPE"] = HeaderColumn("conditionalType", "conditionalType")

#==================
# Utility functions
Expand Down
2 changes: 1 addition & 1 deletion modules/data-entry/src/main/features/feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"io.uhndata.cards.data-model-links-impl=[cards-links-manager]",
"io.uhndata.cards.data-model-forms-impl:createMissingAnswers=[cards-answer-editor]",
"io.uhndata.cards.data-model-forms-impl:computedAnswers=[cards-answer-editor]",
"io.uhndata.cards.data-model-forms-impl:referenceAnswers=[cards-answer-editor]",
"io.uhndata.cards.data-model-forms-impl:referenceAnswers=[cards-reference-answer-editor]",
"io.uhndata.cards.data-model-forms-impl:sortChildren=[cards-answer-editor]",
"io.uhndata.cards.data-model-forms-impl:maxFormsOfTypePerSubjectValidator=[sling-readall]",
"io.uhndata.cards.data-model-forms-impl:requiredSubjectTypesValidator=[sling-readall]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ import { useFormWriterContext } from "./FormContext";
// Other options are passed to the <question> widget
let AutocreatedQuestion = (props) => {
const { isEdit, ...rest } = props;
const { existingAnswer, classes, pageActive, questionName} = rest;
const { unitOfMeasurement, displayMode } = {...props.questionDefinition, ...rest};
const { existingAnswer, questionName} = rest;
const { displayMode } = {...props.questionDefinition, ...rest};

const [muiInputProps, changeMuiInputProps] = useState({});
const [isFormatted, changeIsFormatted] = useState(false);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,32 @@
// under the License.
//

import React from "react";

import { Typography } from "@mui/material";

import AnswerComponentManager from "./AnswerComponentManager";
import AutocreatedQuestion from './AutocreatedQuestion';

let ReferenceQuestion = (props) => {
const { existingAnswer, ...rest } = props;
const { conditionalInvalidSourceMessage } = {...props.questionDefinition, ...rest};

const INVALID_SOURCE_FLAG = "INVALID SOURCE";
let hasInvalidSourceMessage = (existingAnswer?.[1]?.["statusFlags"]?.includes(INVALID_SOURCE_FLAG)
&& conditionalInvalidSourceMessage)

return <AutocreatedQuestion
{...props}
preventDefaultView={hasInvalidSourceMessage}>
{(hasInvalidSourceMessage)
? <Typography color='error'>{conditionalInvalidSourceMessage}</Typography>
: <></>}
</AutocreatedQuestion>
}

AnswerComponentManager.registerAnswerComponent((definition) => {
if (definition.entryMode === "reference") {
return [AutocreatedQuestion, 80];
return [ReferenceQuestion, 80];
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down Expand Up @@ -106,6 +112,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down Expand Up @@ -168,6 +180,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down Expand Up @@ -230,6 +248,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down Expand Up @@ -278,6 +302,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down Expand Up @@ -349,6 +379,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down Expand Up @@ -399,6 +435,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down Expand Up @@ -433,6 +475,12 @@
},
"reference": {
"question": "string",
"conditionalProperty": "string",
"conditionalOperator": "string",
"conditionalValue": "string",
"conditionalFallback": "string",
"conditionalType": "string",
"conditionalInvalidSourceMessage": "string",
"displayMode" : {
"plain" : {},
"formatted" : {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public interface FormUtils
/** The name of the property of a Form node that links to other Subjects the form relates to. */
String RELATED_SUBJECTS_PROPERTY = "relatedSubjects";

/** The name of a property on an Answer, Section or Form node that holds the status flags for that node.*/
String STATUS_FLAGS = "statusFlags";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String STATUS_FLAGS = "statusFlags";
String STATUS_FLAGS_PROPERTY = "statusFlags";


/**
* The primary node type for an Answer Section, a group of related answers and subsections in a Form, corresponding
* to a Section in the answered Questionnaire.
Expand Down
Loading