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
I'm writing my first form in medic/cht-core#6727 and think it'd be helpful to new app builders if we documented some top used tricks when building an xlsx
only show a field when prior select_one or multi_select field is filled out a specific way: set relevent to selected(${attend_clinic}, 'yes')
only show a field when prior value is not selected: set relevent to not(selected(${attend_clinic}, 'yes'))
require a date to be in the future (invert > to be in past): constraint to decimal-date-time(.) >= floor(decimal-date-time(today()))
make patient's age in available in the form:
ensure there's a type/name/appearance entry of: db:person/ _id/db-object
and another of type/name entry of: hidden/date_of_birth
Make patient's age avail in years: type/name/calculation of calculate/patient_age_in_years/floor( difference-in-months( ${date_of_birth}, today() ) div 12 )
Make patient's age avail in months: type/name/calculation of calculate/patient_age_in_months/difference-in-months( ${date_of_birth}, today() )
Make patient's age avail in days: type/name/calculation of calculate/patient_age_in_days/floor(decimal-date-time(today()) - decimal-date-time(${date_of_birth}) )
group a set of fields together on a page: appearance to field-list
how to debug a field's current values: in dev console paste window.debugFormModel(). also see forum post
tips on how to format a summary page:
multiple formatting h1 yellow center
use of raw HTML including font awesome
which icons you can use - list is here, but how to actually use those icons? use font awesome or include .svg? (answer - it's always use FA in headers - see
show appropriate formatted age:
if(${patient_age_in_days} < 31,
concat(${patient_age_in_days}, ' days old'),
if(${patient_age_in_months} < 12,
concat(${patient_age_in_months}, ' months old'),
concat(${patient_age_in_years}, ' years old')))
get 1 day from today() (or from a user input date with ${input}): format-date-time(date-time(floor(decimal-date-time(today())) + 1), "%Y-%m-%d")
require a date input to be within next 7 days, set constraint to decimal-date-time(.) >= floor(decimal-date-time(today())) and decimal-date-time(.) <= floor(decimal-date-time(today() + 7))
show values of form in JS console: window.debugFormModel();
remind folks of the use of numbers for choices instead ascii text names. this allows you to use both selected() logic as well as < operators
Tasks can't be assigned to admin users, "Tasks are available only for users of type “restricted to their place"" - per our docs.
Offline users won't work on http (non SSL) connections unless you're on localhost. Either user Admin user to be an online user or use ngrok or DIY to enable SSL.
You want to have a multi-select (select_multiple) with a "none of the above" option that doesn't allow them to select any other options. Set constraint to not(selected(.,'none') and count-selected(.)>1)
The text was updated successfully, but these errors were encountered:
I'm writing my first form in medic/cht-core#6727 and think it'd be helpful to new app builders if we documented some top used tricks when building an xlsx
brain dump:
select_one
ormulti_select
field is filled out a specific way: setrelevent
toselected(${attend_clinic}, 'yes')
relevent
tonot(selected(${attend_clinic}, 'yes'))
>
to be in past):constraint
todecimal-date-time(.) >= floor(decimal-date-time(today()))
type/name/appearance
entry of:db:person/ _id/db-object
type/name
entry of:hidden/date_of_birth
type/name/calculation
ofcalculate/patient_age_in_years/floor( difference-in-months( ${date_of_birth}, today() ) div 12 )
type/name/calculation
ofcalculate/patient_age_in_months/difference-in-months( ${date_of_birth}, today() )
type/name/calculation
ofcalculate/patient_age_in_days/floor(decimal-date-time(today()) - decimal-date-time(${date_of_birth}) )
appearance
tofield-list
window.debugFormModel()
. also see forum posth1 yellow center
today()
(or from a user input date with${input}
):format-date-time(date-time(floor(decimal-date-time(today())) + 1), "%Y-%m-%d")
date
input to be within next 7 days, setconstraint
todecimal-date-time(.) >= floor(decimal-date-time(today())) and decimal-date-time(.) <= floor(decimal-date-time(today() + 7))
window.debugFormModel();
selected()
logic as well as<
operatorsselect_multiple
) with a "none of the above" option that doesn't allow them to select any other options. Setconstraint
tonot(selected(.,'none') and count-selected(.)>1)
The text was updated successfully, but these errors were encountered: