Skip to content

Instantly share code, notes, and snippets.

@zindel
Created April 15, 2016 09:41
Show Gist options
  • Save zindel/c806b7899efce0c8abf944105c4e52cb to your computer and use it in GitHub Desktop.
Save zindel/c806b7899efce0c8abf944105c4e52cb to your computer and use it in GitHub Desktop.
edit-visit:
type: edit
entity: visit
input:
- visit
title: Edit Visit
fields:
- value_key: individual
read_only: true
- value_key: time_period
read_only: true
- value_key: study_enrollment
read_only: true
- value_key: title
- value_key: todo
label: To-Do Items
type: entity-list
data:
entity: todo
title: title
mask: |
individual=@top(visit?id()=$visit).individual
&(is_null(visit.code)|visit=$visit)
query: |
/do(
update(top(visit.filter(id()=$visit)){id(),
title := $title
}),
for($_todo_id := /todo.filter(visit.id()=$visit).id(),
update(todo[$_todo_id]{id(), visit := null()})
),
$s_e := top(visit.filter(id()=$visit)).study_enrollment,
if(!is_null(bool($todo)),
for($_todo := $todo, with($_todo,
update(top(todo.filter(id()=$id)){id(),
visit := $visit,
study_enrollment := $s_e
})
))
),
{id := $visit}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment