update :accept_for_doctor do
argument :code, :string, allow_nil?: false
validate attribute_equals(:role, :doctor)
validate attribute_equals(:code, arg(:code))
validate attributes_absent(:member_id)
# this is not so important
change relation(:accepted_doctor, %{user_id: actor(:id), entity_id: attr(:entity_id)},
on_lookup: :relate,
on_no_match: :error,
on_match: :error,
on_missing: :ignore
)
# this should create a member, if it does not exist, or error out
# `relation` function just does manage_relationship with the values provided
change relation(:member, %{user_id: actor(:id), role: :doctor},
use_identities: [:user_id, :entity_id],
on_lookup: :relate,
on_no_match: :create,
on_match: :error
)
end
update :accept_for_doctor do
argument :code, :string, allow_nil?: false
validate attribute_equals(:role, :doctor)
validate attribute_equals(:code, arg(:code))
validate attributes_absent(:member_id)
# this is not so important
change relation(:accepted_doctor, %{user_id: actor(:id), entity_id: attr(:entity_id)},
on_lookup: :relate,
on_no_match: :error,
on_match: :error,
on_missing: :ignore
)
# this should create a member, if it does not exist, or error out
# `relation` function just does manage_relationship with the values provided
change relation(:member, %{user_id: actor(:id), role: :doctor},
use_identities: [:user_id, :entity_id],
on_lookup: :relate,
on_no_match: :create,
on_match: :error
)
end