You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've run into a case where a user would like to conditionally enable fields based on wether some date-type field makes the patient older or younger than 18. This is a very reasonable use case that we should support. Currently we've only implemented the enableWhen handling on form values with string or boolean types. We can follow the existing pattern and extend the behavior to cover the date case (and dateTime case, for that matter) without much trouble. Let's do that.
(Note: we have actually implemented this sort of feature already, but in doing so took advantage of the fact that the Patient's dob was known prior to creating the QR, and simply pre-populated a hidden field with a boolean value (patient-over-18) to drive the conditional logic in the form component. This is a clever hack but doesn't really solve the legitimate case where the dob isn't known until some other field within the form is populated.)
The text was updated successfully, but these errors were encountered:
This functionality has been added but isn't leveraged in any of the default paperwork at the moment. Instead of modifying the default paperwork I added a unit test suite covering the conditional behaviors defined in the paperwork between the built-in enableWhen prop and the custom Ottehr extensions.
In addition to enableWhen, a date-type condition can be used for any of the other existing conditional behaviors (requireWhen, textWhen, etc).
There are two ways a condition targeting a date field can be defined:
using answerInteger - this will be interpreted as expressing a value in years, and the date value on the 'question' field will be evaluated by comparing the operator and a date {answerInteger} years from now. So given the example below, if the KEYS.triggers.date.primary field contains a date that is less than 18 years ago, the condition is satisfied, otherwise it is not satisfied.
using answerDate - this will be a straightforward comparison (using the operator in the operator field) of the trigger date and the date specified in answerDate. For instance, this condition will be true if the date store in KEYS.triggers.date.primary comes before Jan 1, 2021:
We've run into a case where a user would like to conditionally enable fields based on wether some date-type field makes the patient older or younger than 18. This is a very reasonable use case that we should support. Currently we've only implemented the enableWhen handling on form values with string or boolean types. We can follow the existing pattern and extend the behavior to cover the date case (and dateTime case, for that matter) without much trouble. Let's do that.
(Note: we have actually implemented this sort of feature already, but in doing so took advantage of the fact that the Patient's dob was known prior to creating the QR, and simply pre-populated a hidden field with a boolean value (patient-over-18) to drive the conditional logic in the form component. This is a clever hack but doesn't really solve the legitimate case where the dob isn't known until some other field within the form is populated.)
The text was updated successfully, but these errors were encountered: