Skip to content

Instantly share code, notes, and snippets.

@zindel
Last active February 2, 2016 09:55
Show Gist options
  • Save zindel/804c2e253f6edeaae284 to your computer and use it in GitHub Desktop.
Save zindel/804c2e253f6edeaae284 to your computer and use it in GitHub Desktop.
paths:
/with-for-demo:
action:
title: with()/for() demo
type: wizard
path:
- pick-case-type:
- make-individual:
# - replace: ../../pick-individual/view-individual
#- pick-individual:
# - view-individual:
actions:
pick-case-type:
type: pick
entity: case_type
make-individual:
type: make
entity: individual
input:
- case_type: case_type
value:
case_type: $case_type
fields:
- sex
- value_key: identity
label: Identity
type: fieldset
fields:
- value_key: surname
label: Surname
- value_key: givenname
label: Given Name
- value_key: case_x_individual
label: Cases (add several)
type: list
fields:
- value_key: code
type: string
label: Case
- value_key: case_role
type: entity
data:
entity: case_role
title: title
mask: case_type=$case_type
query: |
/do(
$_individual := insert(individual := {sex := $sex}),
$_identity := with($identity, insert(
identity := {
individual := $_individual,
surname := $surname,
givenname := $givenname
}
)),
for($case := $case_x_individual, with($case, do(
$_case := merge(case := {code := $code, case_type := $case_type}),
$_case_x_individual := merge(case_x_individual := {
case := $_case,
individual := $_individual,
case_role := $case_role
})
))),
{id := $_individual}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment