From 49016e3bdef5d4f620d7d46faf7abbe0fe4f6675 Mon Sep 17 00:00:00 2001 From: Diana Barsan Date: Mon, 27 Apr 2020 17:29:25 +0300 Subject: [PATCH 1/4] Adds documentation for update_patient transition. --- configuration/transitions.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/configuration/transitions.md b/configuration/transitions.md index 5cb912e6..aeed1ba4 100644 --- a/configuration/transitions.md +++ b/configuration/transitions.md @@ -42,6 +42,7 @@ The following transitions are available and executed in order. | resolve_pending | Sets the state of pending messages to sent. It is useful during builds where we don't want any outgoing messages queued for sending. | | [muting](#muting) | Implements muting/unmuting actions of people and places. Available since 3.2.x. | | [mark_for_outbound](./outbound.md) | Enables outbound pushes. Available since 3.5.x | +| [update_patient](#update_patient) | Maps patient to sender. Available since 3.9.x | ## Transition Configuration Guide @@ -427,3 +428,24 @@ Supported `events_types` are: ] } ``` + +### update_patient + +Updates a `data_record` to set its patient to its sender, the resulting doc will have `fields.patient_uuid` and `fields.patient_id` filled with the sender's information. Provides hydrated patient information to subsequent transitions. +If a doc already contains a `patient` field, does not have a sender (`from` field) or does not have a configured `form` field, it will be ignored by this transition. + +#### Configuration +Configuration is stored in the `update_patient` field of `app_settings.json`. + +| Property | Description | +|---|---| +| `forms` | An array of form codes which will trigger the transition. **Required** | + + +##### Example + +```json +"update_patient": { + "forms": ["one", "two"] +} +``` From a7fcb088dbddc30bc49c00cff0a847670aba15cb Mon Sep 17 00:00:00 2001 From: Diana Barsan Date: Tue, 28 Apr 2020 16:07:09 +0300 Subject: [PATCH 2/4] Explains who the sender is. --- configuration/transitions.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configuration/transitions.md b/configuration/transitions.md index aeed1ba4..3e8d0727 100644 --- a/configuration/transitions.md +++ b/configuration/transitions.md @@ -431,8 +431,9 @@ Supported `events_types` are: ### update_patient -Updates a `data_record` to set its patient to its sender, the resulting doc will have `fields.patient_uuid` and `fields.patient_id` filled with the sender's information. Provides hydrated patient information to subsequent transitions. -If a doc already contains a `patient` field, does not have a sender (`from` field) or does not have a configured `form` field, it will be ignored by this transition. +Updates a `data_record` to set its patient to its sender. The resulting doc will have `fields.patient_uuid` and `fields.patient_id` filled with the sender's information. Provides hydrated patient information to subsequent transitions. +The sender is considered the contact document associated with the phone number that sent the original SMS. +If a doc already contains a `patient` field, does not have a sender or does not have a configured `form` field, it will be ignored by this transition. #### Configuration Configuration is stored in the `update_patient` field of `app_settings.json`. From ef4f44252d8c43880de1cb0e35410812b2ef7fc7 Mon Sep 17 00:00:00 2001 From: Diana Barsan Date: Wed, 29 Apr 2020 12:24:52 +0300 Subject: [PATCH 3/4] Update transition name and add messages config --- configuration/transitions.md | 53 ++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/configuration/transitions.md b/configuration/transitions.md index 3e8d0727..ef62c81e 100644 --- a/configuration/transitions.md +++ b/configuration/transitions.md @@ -42,7 +42,7 @@ The following transitions are available and executed in order. | resolve_pending | Sets the state of pending messages to sent. It is useful during builds where we don't want any outgoing messages queued for sending. | | [muting](#muting) | Implements muting/unmuting actions of people and places. Available since 3.2.x. | | [mark_for_outbound](./outbound.md) | Enables outbound pushes. Available since 3.5.x | -| [update_patient](#update_patient) | Maps patient to sender. Available since 3.9.x | +| [self_report](#self_report) | Maps patient to sender. Available since 3.9.x | ## Transition Configuration Guide @@ -429,24 +429,61 @@ Supported `events_types` are: } ``` -### update_patient +### self_report Updates a `data_record` to set its patient to its sender. The resulting doc will have `fields.patient_uuid` and `fields.patient_id` filled with the sender's information. Provides hydrated patient information to subsequent transitions. -The sender is considered the contact document associated with the phone number that sent the original SMS. +The `sender` is the contact associated with the phone number that sent the original SMS. If a doc already contains a `patient` field, does not have a sender or does not have a configured `form` field, it will be ignored by this transition. #### Configuration -Configuration is stored in the `update_patient` field of `app_settings.json`. +Configuration is stored in the `self_report` field of `app_settings.json` as a list of objects connecting forms to messages. +Every object should have this structure: | Property | Description | |---|---| -| `forms` | An array of form codes which will trigger the transition. **Required** | +| `form` | Form code. **Required** | +| `messages` | List of tasks/errors that will be created, determined by `event_type`. Optional. | +Supported `events_types` are: + +| Event Type | Trigger | +|---|---| +| `report_accepted` | On successful sender updating | +| `sender_not_found` | Sender not found | ##### Example ```json -"update_patient": { - "forms": ["one", "two"] -} +"self_report": [ + { + "form": "FORM", + "messages": [ + { + "event_type": "report_accepted", + "recipient": "reporting_unit", + "translation_key": "messages.form.report_accepted" + }, + { + "event_type": "sender_not_found", + "recipient": "reporting_unit", + "translation_key": "messages.form.sender_not_found" + } + ] + }, + { + "form": "OTHER", + "messages": [ + { + "event_type": "report_accepted", + "recipient": "reporting_unit", + "translation_key": "messages.other.report_accepted" + }, + { + "event_type": "sender_not_found", + "recipient": "reporting_unit", + "translation_key": "messages.other.sender_not_found" + } + ] + } +] ``` From 60171c9f405f65c4129b01a3b691b9c9aad15239 Mon Sep 17 00:00:00 2001 From: Diana Barsan Date: Thu, 30 Apr 2020 16:00:39 +0300 Subject: [PATCH 4/4] review feedback. --- configuration/transitions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/transitions.md b/configuration/transitions.md index ef62c81e..53b01bce 100644 --- a/configuration/transitions.md +++ b/configuration/transitions.md @@ -433,7 +433,7 @@ Supported `events_types` are: Updates a `data_record` to set its patient to its sender. The resulting doc will have `fields.patient_uuid` and `fields.patient_id` filled with the sender's information. Provides hydrated patient information to subsequent transitions. The `sender` is the contact associated with the phone number that sent the original SMS. -If a doc already contains a `patient` field, does not have a sender or does not have a configured `form` field, it will be ignored by this transition. +If a doc already contains a `patient` field, does not have a sender or its `form` is not configured to be enabled for this transition, it will be ignored. #### Configuration Configuration is stored in the `self_report` field of `app_settings.json` as a list of objects connecting forms to messages.