Skip to content

Instantly share code, notes, and snippets.

@zindel
Created August 28, 2015 12:33
Show Gist options
  • Save zindel/e4c43f4fe36fafd01eac to your computer and use it in GitHub Desktop.
Save zindel/e4c43f4fe36fafd01eac to your computer and use it in GitHub Desktop.
/wizard/todo:
widget: !<Wizard>
initial_context:
individual: A00F5818
states:
todo:
not-skipped-not-complete:
title: Not Skipped
expression: status!='skipped'&status!='complete'
measure:
title: Measure Todo
expression: requirement.asset_type='measure'|measure_todo_fulfillment
sample:
title: Sample Todo
expression: requirement.asset_type='sample'|sample_todo_fulfillment
communication:
title: Communication Todo
expression: requirement.asset_type='communication'|communication_todo_fulfillment
consent:
title: Consent Todo
expression: requirement.asset_type='consent'|consent_todo_fulfillment
other:
title: Other Todo
expression: requirement.asset_type='consent'
awaiting-measure:
title: Measure Todo
expression: (requirement.asset_type='measure'|measure_todo_fulfillment)&status!='skipped'&status!='complete'
awaiting-sample:
title: Sample Todo
expression: (requirement.asset_type='sample'|sample_todo_fulfillment)&status!='skipped'&status!='complete'
awaiting-communication:
title: Communication Todo
expression: (requirement.asset_type='communication'|communication_todo_fulfillment)&status!='skipped'&status!='complete'
awaiting-consent:
title: Consent Todo
expression: (requirement.asset_type='consent'|consent_todo_fulfillment)&status!='skipped'&status!='complete'
awaiting-other:
title: Other Todo
expression: requirement.asset_type='other'&status!='skipped'&status!='complete'
path:
- pick-todo:
- view-todo:
- proceed-measure-todo:
- proceed-sample-todo:
- view-sample:
- edit-sample:
- pick-tube:
- view-tube:
- edit-tube:
- use-sample:
- pick-tube-usage:
- view-used-tube:
- add-tube:
- pick-used-tube:
- view-used-tube:
- proceed-communication-todo:
- proceed-consent-todo:
- proceed-other-todo:
- skip-todo:
- adhoc-measure-todo:
- adhoc-consent-todo:
- adhoc-sample-todo:
actions:
pick-todo:
type: pick
entity: todo
title: Pick Todo
input:
- individual: individual
mask: individual=$individual
columns:
- value_key: study_title
type: calculation
expression: study.title
label: Study
- value_key: time_period_title
type: calculation
expression: time_period.title
label: Visit Name
- value_key: expected_completion_date
label: Expected Completion
- value_key: title
label: Title
- value_key: status
label: Status
view-todo:
type: view
entity: todo
title: Details
skip-todo:
type: skip-todo
title: Skip Todo
submit_to: !slot
name: submit_to
default: /htsql/skip_todo.htsql
todo_details: !slot
name: todo_details
default: /data/individual/todo_details
entity: todo[not-skipped-not-complete]
proceed-measure-todo:
type: proceed-measure-todo
entity: todo[awaiting-measure]
title: Fulfill Data Entry Todo
data_entry_link: !slot
name: data_entry_link
default: rex.study.data_entry_admin:/data-entry
reconciliation_link: !slot
name: reconciliation_link
default: rex.study.data_reconciliation_admin:/reconcile
acquire_channel: !slot
name: acquire_channel
default: /data/acquire_channel
measure_candidates: !slot
name: measure_candidates
default: /data/individual/todo_measure_candidates
measure_types: !slot
name: measure_types
default: /data/individual/todo_measure_types
measure_fulfillment: !slot
name: measure_fulfillment
default: /data/individual/todo_measure_fulfillment
todo_details: !slot
name: todo_details
default: /data/individual/todo_details
use_query: !slot
name: use_query
default: /htsql/use_existing_measure.htsql
create_query: !slot
name: use_query
default: /htsql/create_new_measure.htsql
clone_query: !slot
name: clone_query
default: /htsql/clone_existing_measure.htsql
proceed-consent-todo:
type: proceed-consent-todo
entity: todo[awaiting-consent]
title: Fulfill Consent Todo
consent_types: !slot
name: consent_types
default: /data/individual/todo_consent_types
create_query: !slot
name: use_query
default: /htsql/create_new_consent.htsql
todo_details: !slot
name: todo_details
default: /data/individual/todo_details
individual_data_spec: !slot
name: individual_data_spec
default: /data/individual/autocomplete
consent_save: !slot
name: consent_save
default: /data/consent/save
storage_link: !slot
name: storage_link
default: rex.file:/
download_link: !slot
name: download_link
default: /data/consent/scan
proceed-sample-todo:
type: proceed-sample-todo
entity: todo[awaiting-sample]
title: Fulfill Sample Todo
sample_types: !slot
name: sample_types
default: /data/individual/todo_sample_types
create_query: !slot
name: use_query
default: /htsql/create_new_sample.htsql
todo_details: !slot
name: todo_details
default: /data/individual/todo_details
view_fields: !slot
name: form_fields
default:
- value_key: sample_type
label: Sample Type
- value_key: individual
label: Individual
- value_key: code
label: Code
- value_key: code_text
label: Code Text
- value_key: date_collected
label: Date Collected
- value_key: collected_by
label: Collected By
- value_key: derived_from
label: Derived From
sample_details: !slot
name: sample_details
default: /data/individual/sample_details
proceed-communication-todo:
type: edit
entity: todo[awaiting-communication]
title: Fulfill Communication Todo
proceed-other-todo:
type: edit
entity: todo[awaiting-other]
title: Fulfill Other Todo
#########################################
## Adhoc actions of TodoWizard:
#########################################
adhoc-measure-todo:
type: make
title: Add Measure Adhoc ToDo
icon: plus
entity: todo
width: 700
submit_button: Submit
value:
individual: $individual
num_required_entries: '2'
acquire_channel: entry
fields:
- value_key: study
label: Study
required: true
- value_key: measure_type
label: Measure Type
type: entity
required: true
data:
entity: measure_type
title: title
- value_key: expected_completion_date
label: Expected Completion Date
type: date
- value_key: appointment_start
label: Add Appointment Date
type: datetime
- value_key: appointment_type
label: Appointment Type
type: entity
data:
entity: appointment_type
title: title
- value_key: acquire_channel
label: Acquire Channel
type: entity
required: true
data:
entity: acquire_channel
title: title
- value_key: num_required_entries
pattern: '^\d+$'
label: Number of required entries
required: true
query:
/do(
$_time_period := top(time_period.filter(study=$study&code='anytime')).id(),
$_revision := max(
measure_type_revision.filter(
measure_type = $measure_type
& !is_null(json)
& exists(measure_type_revision_channel.acquire_channel = 'entry')
).revision
),
$_title := measure_type[$measure_type].title,
$_measure := insert( measure :=
{
measure_type_revision := [[$measure_type].$_revision],
individual := [$individual],
study := [$study],
data_entry_status := 'in-process'
}
),
$_appointment_type := if(is_null($appointment_type), 'home', $appointment_type),
$_appointment := if (
!is_null($appointment_start) &
!exists(appointment?individual=$individual
&appointment_type=$_appointment_type
&start=$appointment_start&(status='scheduled'|status='rescheduled')),
insert( appointment :=
{
individual := [$individual],
appointment_type := $_appointment_type,
start := $appointment_start,
duration := '1',
staff := [$USER],
requestor := [$USER],
acceptance_status_by_staff := 'requested',
status := 'scheduled'
}),
top(appointment?individual=$individual
&appointment_type=$_appointment_type
&start=$appointment_start).id()
),
$_todo := insert( todo :=
{
individual := [$individual],
study := [$study],
expected_completion_date := $expected_completion_date,
status := 'not-started',
title := $_title,
appointment := $_appointment,
time_period := $_time_period
}
),
$_measure_todo_fulfillment := insert( measure_todo_fulfillment :=
{
todo := $_todo,
measure := $_measure,
num_required_entries := $num_required_entries,
acquire_channel := [$acquire_channel]
}
)
)
adhoc-consent-todo:
type: make
title: Add Consent Adhoc ToDo
icon: plus
width: 700
entity: todo
submit_button: Submit
value:
individual: $individual
fields:
- value_key: study
label: Study
required: true
- type: entity
label: Consent Type
value_key: consent_type
required: true
data:
entity: consent_type
title: title
- value_key: expected_completion_date
label: Expected Completion Date
type: date
- value_key: appointment_start
label: Appointment Date
type: datetime
- value_key: appointment_type
label: Appointment Type
type: entity
data:
entity: appointment_type
title: title
query:
/do(
$_time_period := top(time_period.filter(study=$study&code='anytime')).id(),
$_title := consent_type[$consent_type].title,
$_consent := insert( consent :=
{
individual := [$individual],
consent_type := [$consent_type]
}
),
$_appointment_type := if(is_null($appointment_type), 'home', $appointment_type),
$_appointment := if (
!is_null($appointment_start) &
!exists(appointment?individual=$individual
&appointment_type=$_appointment_type
&(status='scheduled'|status='rescheduled')
&start=$appointment_start),
insert( appointment :=
{
individual := [$individual],
appointment_type := $_appointment_type,
start := $appointment_start,
duration := '1',
staff := [$USER],
requestor := [$USER],
acceptance_status_by_staff := 'requested',
status := 'scheduled'
}),
top(appointment?individual=$individual
&appointment_type=$_appointment_type
&start=$appointment_start).id()
),
$_todo := insert( todo :=
{
individual := [$individual],
study := [$study],
expected_completion_date := $expected_completion_date,
status := 'not-started',
title := $_title,
appointment := $_appointment,
time_period := $_time_period
}
),
$_consent_todo_fulfillment := insert( consent_todo_fulfillment :=
{
todo := $_todo,
consent := $_consent
}
)
)
adhoc-sample-todo:
type: make
title: Add Sample Adhoc ToDo
icon: plus
width: 700
entity: todo
submit_button: Submit
value:
individual: $individual
fields:
- value_key: study
label: Study
required: true
- type: entity
label: Sample Type
value_key: sample_type
required: true
data:
entity: sample_type
title: title
- value_key: expected_completion_date
label: Expected Completion Date
type: date
- value_key: appointment_start
label: Appointment Date
type: datetime
- value_key: appointment_type
label: Appointment Type
type: entity
data:
entity: appointment_type
title: title
query:
/do(
$_time_period := top(time_period.filter(study=$study&code='anytime')).id(),
$_title := sample_type[$sample_type].title,
$_sample := insert( sample :=
{
individual := [$individual],
sample_type := [$sample_type]
}
),
$_appointment_type := if(is_null($appointment_type), 'home', $appointment_type),
$_appointment := if (
!is_null($appointment_start) &
!exists(appointment?individual=$individual
&appointment_type=$_appointment_type
&(status='scheduled'|status='rescheduled')
&start=$appointment_start),
insert( appointment :=
{
individual := [$individual],
appointment_type := $_appointment_type,
start := $appointment_start,
duration := '1',
staff := [$USER],
requestor := [$USER],
acceptance_status_by_staff := 'requested',
status := 'scheduled'
}),
top(appointment?individual=$individual
&appointment_type=$_appointment_type
&start=$appointment_start).id()
),
$_todo := insert( todo :=
{
individual := [$individual],
study := [$study],
expected_completion_date := $expected_completion_date,
status := 'not-started',
title := $_title,
appointment := $_appointment,
time_period := $_time_period
}
),
$_sample_todo_fulfillment := insert( sample_todo_fulfillment :=
{
todo := $_todo,
sample := $_sample
}
)
)
#########################################
## Sample actions of TodoWizard:
#########################################
edit-tube:
type: edit
entity: tube
width: 500
submit_button: Submit
input:
- tube: tube
fields:
- value_key: volume_amount
label: Volume Amount
required: true
type: number
- value_key: volume_unit
label: Volume Unit
required: true
- value_key: concentration_amount
label: Concentration Amount
required: true
type: number
- value_key: concentration_unit
label: Concentration Unit
required: true
- value_key: location_memo
label: Location Memo
type: note
view-sample:
title: View
type: view
width: 500
entity: sample
input:
- sample: sample
fields:
- value_key: code_text
label: Sample Code
- value_key: sample_type
label: Sample Type
type: calculation
expression: sample_type.title
- value_key: derived_from
label: Derived From
type: calculation
expression: (derived_from.sample_type.title + ' - '+ derived_from.code_text)
- value_key: remaining_volume_ml
type: calculation
label: Remaining Volume
expression: if(exists(tube), str(sum(tube.volume_amount * switch(tube.volume_unit,
null(), 1,
'ml', 1,
'ul', 0.001)) -
sum(tube.tube_usage.used_volume_amount * switch(tube.tube_usage.used_volume_unit,
null(), 1,
'ml', 1,
'ul', 0.001))) + ' (ml)', '')
pick-tube:
type: pick
title: Sample Tubes
entity: tube
width: 700
input:
- sample: sample
mask: sample=$sample
fields:
- value_key: code
label: Code
width: 100
- value_key: volume_amount
width: 100
label: Volume
- value_key: volume_unit
width: 100
label: Unit
- value_key: concentration_amount
label: Concentration
- value_key: concentration_unit
label: Unit
- value_key: remaining_volume_ml
type: calculation
label: Remaining Vol.
expression: |
switch(volume_unit,
null(), volume_amount - sum(
if(tube_usage.used_volume_unit = 'ul',
tube_usage.used_volume_amount*0.001,
tube_usage.used_volume_amount)),
'ml', volume_amount - sum(
if(tube_usage.used_volume_unit = 'ul',
tube_usage.used_volume_amount*0.001,
tube_usage.used_volume_amount)),
'ul', volume_amount - sum(
if(tube_usage.used_volume_unit = 'ml'|is_null(tube_usage.used_volume_unit),
tube_usage.used_volume_amount*1000,
tube_usage.used_volume_amount)))
view-tube:
title: View Tube
type: view
width: 500
entity: tube
input:
- tube: tube
fields:
- value_key: sample
label: Sample
- value_key: code
label: Tube Code
- value_key: volume_amount
label: Volume
- value_key: volume_unit
label: Unit
- value_key: concentration_amount
label: Concentration
- value_key: concentration_unit
label: Unit
- value_key: remaining_volume_ml
type: calculation
label: Remaining Volume
expression: |
str(switch(volume_unit,
null(), volume_amount - sum(
if(tube_usage.used_volume_unit = 'ul',
tube_usage.used_volume_amount*0.001,
tube_usage.used_volume_amount)),
'ml', volume_amount - sum(
if(tube_usage.used_volume_unit = 'ul',
tube_usage.used_volume_amount*0.001,
tube_usage.used_volume_amount)),
'ul', volume_amount - sum(
if(tube_usage.used_volume_unit = 'ml'|is_null(tube_usage.used_volume_unit),
tube_usage.used_volume_amount*1000,
tube_usage.used_volume_amount)))) + ' (' + str(volume_unit) + ')'
- value_key: location_memo
label: Location
use-sample:
type: make
title: Use Sample
entity: tube_usage
width: 500
submit_button: Submit
value:
tube: $tube
fields:
- value_key: tube
label: Tube
read_only: true
type: entity
data:
entity: tube
title: |
(code + ' (' + str(switch(volume_unit,
null(), volume_amount - sum(
if(tube_usage.used_volume_unit = 'ul',
tube_usage.used_volume_amount*0.001,
tube_usage.used_volume_amount)),
'ml', volume_amount - sum(
if(tube_usage.used_volume_unit = 'ul',
tube_usage.used_volume_amount*0.001,
tube_usage.used_volume_amount)),
'ul', volume_amount - sum(
if(tube_usage.used_volume_unit = 'ml'|is_null(tube_usage.used_volume_unit),
tube_usage.used_volume_amount*1000,
tube_usage.used_volume_amount)))) + ' ' + str(volume_unit) + ' remaining)')
- value_key: used_volume_amount
label: Volume Used
required: true
- value_key: used_volume_unit
label: Volume Unit
required: true
- value_key: user
label: Requested By
type: entity
data:
entity: user
title: remote_user
required: true
- value_key: date_requested
label: Requested On
- value_key: note
label: Usage Note
type: note
edit-sample:
title: Edit Sample
type: edit
entity: sample
width: 500
submit_button: Complete
input:
- sample: sample
fields:
- value_key: code_text
label: Code
required: true
- value_key: sample_type
label: Type
required: true
- value_key: derived_from
label: Derived From
type: entity
data:
entity: sample
title: (sample_type.title + ' - '+ code_text)
add-tube:
type: make
title: Add Tube
entity: tube
width: 600
value:
sample: $sample
input:
- sample: sample
fields:
- value_key: volume_amount
label: Volume Amount
required: true
- value_key: volume_unit
label: Volume Unit
required: true
- value_key: concentration_amount
label: Concentration Amount
required: true
- value_key: concentration_unit
label: Concentration Unit
required: true
- value_key: location_memo
label: Location Memo
type: note
pick-used-tube:
type: pick
title: Tubes Usage
entity: tube_usage
input:
- sample: sample
mask: tube.sample=$sample
fields:
- value_key: code
label: Tube
- value_key: used_volume_amount
label: Used Vol. Amount
- value_key: used_volume_unit
label: Used Vol. Unit
- value_key: date_requested
label: Requested On
view-used-tube:
type: view
title: View
entity: tube_usage
input:
- tube_usage: tube_usage
fields:
- value_key: sample
label: Sample
type: calculation
expression: tube.sample.id()
- value_key: code
label: Tube
- value_key: user
label: Requested By
- value_key: used_volume_amount
label: Used Volume Amount
- value_key: used_volume_unit
label: Used Volume Unit
- value_key: date_requested
label: Requested On
- value_key: note
label: Usage Note
pick-tube-usage:
type: pick
title: Tube Usage
entity: tube_usage
input:
- tube: tube
mask: tube=$tube
fields:
- value_key: code
label: Tube
- value_key: used_volume_amount
label: Used Vol. Amount
- value_key: used_volume_unit
label: Used Vol. Unit
- value_key: date_requested
label: Requested On
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment