Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Thailand Production RACD Plan Generation to OpenSRP #853

Closed
10 tasks done
samkanga opened this issue Jun 17, 2021 · 5 comments
Closed
10 tasks done

Move Thailand Production RACD Plan Generation to OpenSRP #853

samkanga opened this issue Jun 17, 2021 · 5 comments

Comments

@samkanga
Copy link

samkanga commented Jun 17, 2021

Presently, on Thailand production environment, case triggered plans (RACD) are generated from NiFi.

  • NiFi polls the MSSQL table which receives the index cases and creates a Case Detail Event for every new index case.
  • NiFi queries OpenSRP with the Case Detail Event to check if a plan has been created.
  • If no plan exists, NiFi triggers the RACD plan generation in OpenSRP
  • NiFi updates the dbo.auto_generated_plans table to confirm a POST event for plan generation has been completed.

In the recent past, there has been issues with plan generation. This was pointed to unavailability of nay of the 3 systems that are involved in RACD plan generation, that include OpenSRP and postgreSQL DB. As a mitigation, a recommendation was made to shift the plan generation from NiFi to OpenSRP to reduce the number of components involved in plan generation. This move is anticipated to reduce the incidents where RAC plan generation failed.

This work is anticipated to take about 3.5 weeks to complete. The technical scoping can be accessed here.

Tasks

QA

  1. Test that addition and retrieving of plan templates works (This step does not have to be repeated unless there are bugs related to it)
    a) POST the plan templates 1 and 2 as explained here
    b) For each of the templates retrive the by making a GET request t0 /rest/templates/{templateId}
    c) Verify that the templates are correct
  2. Test that case triggered plans are generated when a case is inserted
    a) Insert an index case into the mhealth db
    b) After 10 or so minutes check whether the plan has been created. This can be done using the web UI or a db query
    c) Verify that the plan is well formed
    d) verify that the correct template was used as documented here
    e) verify that 2 plans were created if the index case has both a p_site_id and a source_site_id. This can be checked by confirming that data inserted to mhealth DB contains p_site_id and a source_site_id.
  3. Test that tasks are generated for each of the actions listed in the plan
    a) Assign the plan to a team and OA
    b) Activate the plan
    c) Verify on the android app that tasks have been genrated for all the actions available on the plan
@Rkareko
Copy link
Contributor

Rkareko commented Nov 9, 2021

Template 1

  {
    "identifier": "${planIdentifier}",
    "version": "1",
    "name": "${focus_status}-${focus_name}-${patient_name}_${patient_surname}-${currentDate}-${flag}",
    "title": "${focus_status} - ${focus_name} - ${patient_name} ${patient_surname} - ${currentDate} - ${flag}",
    "status": "draft",
    "date": "${currentDate}",
    "effectivePeriod": {
      "start": "${currentDate}",
      "end": "${endDate}"
    },
    "useContext": [
      {
        "code": "interventionType",
        "valueCodableConcept": "Dynamic-FI"
      },
      {
        "code": "fiStatus",
        "valueCodableConcept": "${focus_status}"
      },
      {
        "code": "fiReason",
        "valueCodableConcept": "Case Triggered"
      },
      {
        "code": "opensrpEventId",
        "valueCodableConcept": "${opensrpCaseClassificationEventId}"
      },
      {
        "code": "caseNum",
        "valueCodableConcept": "${case_number}"
      },
      {
        "code": "taskGenerationStatus",
        "valueCodableConcept": "internal"
      }
    ],
    "jurisdiction": [
      {
        "code": "${focus_id}"
      }
    ],
    "serverVersion": 0,
    "goal": [
          {
        "id": "Case_Confirmation",
        "description": "ยืนยันบ้านผู้ป่วย",
        "priority": "medium-priority",
        "target": [
          {
            "measure": "จำนวนผู้ป่วยที่ได้รับการยืนยัน",
            "detail": {
              "detailQuantity": {
                "value": 1,
                "comparator": ">=",
                "unit": "case(s)"
              }
            },
            "due": "${endDate}"
          }
        ]
      },
        {
            "id": "RACD_register_families",
            "description": "ลงทะเบียนครัวเรือนและสมาชิกในครัวเรือน (100%) ภายในพื้นที่ปฏิบัติงาน",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "ร้อยละของบ้าน สิ่งปลูกสร้างที่ได้ลงทะเบียนข้อมูลครัวเรือน",
                "detail": {
                  "detailQuantity": {
                    "value": 100.0,
                    "comparator": ">=",
                    "unit": "%"
                  }
                },
                "due": "${endDate}"
              }
            ]
        },
        {
            "id": "RACD_Blood_Screening",
            "description": "เจาะเลือดรอบบ้านผู้ป่วยในรัศมี 1 กิโลเมตร (100%)",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "จำนวนผู้ที่ได้รับการเจาะโลหิต",
                "detail": {
                  "detailQuantity": {
                    "value": 50.0,
                    "comparator": ">=",
                    "unit": "คน"
                  }
                },
                "due": "${endDate}"
              }
            ]
        },
        {
            "id": "BCC_Focus",
            "description": "ให้สุขศึกษาในพื้นที่ปฏิบัติงานอย่างน้อย 1 ครั้ง",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "จำนวนกิจกรรมการให้สุขศึกษา",
                "detail": {
                  "detailQuantity": {
                    "value": 1.0,
                    "comparator": ">=",
                    "unit": "แห่ง"
                  }
                },
                "due": "${endDate}"
              }
            ]
        },
        {
            "id": "RACD_bednet_distribution",
            "description": "แจกมุ้งทุกหลังคาเรือนในพื้นที่ปฏิบัติงาน (100%)",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "จำนวนบ้าน/สิ่งปลูกสร้างที่ได้รับมุ้ง",
                "detail": {
                  "detailQuantity": {
                    "value": 90.0,
                    "comparator": ">=",
                    "unit": "%"
                  }
                },
                "due": "${endDate}"
              }
            ]
        },
        {
            "id": "Larval_Dipping",
            "description": "ดำเนินกิจกรรมจับลูกน้ำอย่างน้อย 3 แห่งในพื้นที่ปฏิบัติงาน",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "จำนวนกิจกรรมการตักลูกน้ำ",
                "detail": {
                  "detailQuantity": {
                    "value": 3.0,
                    "comparator": ">=",
                    "unit": "แห่ง"
                  }
                },
                "due": "${endDate}"
              }
            ]
        },
        {
            "id": "Mosquito_Collection",
            "description": "กิจกรรมจับยุงกำหนดไว้อย่างน้อย 3 แห่ง",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "จำนวนกิจกรรมการจับยุง",
                "detail": {
                  "detailQuantity": {
                    "value": 3.0,
                    "comparator": ">=",
                    "unit": "แห่ง"
                  }
                },
                "due": "${endDate}"
              }
            ]
        }
    ],
    "action": [
          {
        "identifier": "662d4bff-43cc-4f50-af1e-3bc86f8af253",
        "prefix": 1,
        "title": "การยืนยันบ้านผู้ป่วย",
        "description": "ยืนยันบ้านผู้ป่วย",
        "code": "Case Confirmation",
        "timingPeriod": {
          "start": "2021-09-13",
          "end": "2021-09-23"
        },
        "reason": "Investigation",
        "goalId": "Case_Confirmation",
        "subjectCodableConcept": {
          "text": "Jurisdiction"
        },
      "trigger": [
          {
              "type": "named-event",
              "name": "plan-activation"
          }
      ],
      "condition": [
          {
              "kind": "applicability",
              "expression": {
                  "description": "Event is case details event",
                  "expression": "questionnaire = 'Case_Details'"
              }
          }
      ],
      "definitionUri": "case_confirmation.json",
      "type": "create"
      },
        {
            "identifier": "${registerFamilyActionId}",
            "prefix": 2,
            "title": "ลงทะเบียนครัวเรือน",
            "description": "ลงทะเบียนครัวเรือนและสมาชิกในครัวเรือน (100%) ภายในพื้นที่ปฏิบัติงาน",
            "code": "RACD Register Family",
            "timingPeriod": {
              "start": "${currentDate}",
              "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "RACD_register_families",
            "subjectCodableConcept": {
              "text": "Location"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                },
                {
                    "type": "named-event",
                    "name": "event-submission",
                    "expression": {
                        "description": "Trigger when a Register_Structure event is submitted",
                        "expression": "questionnaire = 'Register_Structure' or questionnaire = 'Archive_Family'"
                    }
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Structure is residential or type does not exist",
                          "expression": "$this.is(FHIR.QuestionnaireResponse) or (($this.type.where(id='locationType').exists().not() or $this.type.where(id='locationType').text = 'Residential Structure') and $this.contained.exists().not())",
                        "subjectCodableConcept": {
                            "text": "Family"
                        }
                    }
                },
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Apply to residential structures in Register_Structure questionnaires",
                        "expression": "$this.is(FHIR.Location) or (questionnaire = 'Register_Structure' and $this.item.where(linkId='structureType').answer.value ='Residential Structure')"
                    }
                }
            ],
            "definitionUri": "family_register.json",
            "type": "create"
        },
        {
            "identifier": "${bloodScreeningActionId}",
            "prefix": 3,
            "title": "กิจกรรมการเจาะโลหิต",
            "description": "เจาะเลือดรอบบ้านผู้ป่วยในรัศมี 1 กิโลเมตร (100%)",
            "code": "Blood Screening",
            "timingPeriod": {
                "start": "${currentDate}",
                "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "RACD_Blood_Screening",
            "subjectCodableConcept": {
                "text": "Person"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                },
                {
                    "type": "named-event",
                    "name": "event-submission",
                    "expression": {
                        "description": "Trigger when a Family Registration or Family Member Registration event is submitted",
                        "expression": "questionnaire = 'Family_Registration' or questionnaire = 'Family_Member_Registration'"
                    }
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Person is older than 5 years or person associated with questionnaire response if older than 5 years",
                        "expression": "($this.is(FHIR.Patient) and $this.birthDate <= today() - 5 'years') or ($this.contained.where(Patient.birthDate <= today() - 5 'years').exists())"
                    }
                }
            ],
            "definitionUri": "blood_screening.json",
            "type": "create"
        },
        {
            "identifier": "${bccActionId}",
            "prefix": 4,
            "title": "กิจกรรมการให้สุขศึกษา",
            "description": "ดำเนินกิจกรรมให้สุขศึกษา",
            "code": "BCC",
            "timingPeriod": {
                "start": "${currentDate}",
                "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "BCC_Focus",
            "subjectCodableConcept": {
                "text": "Jurisdiction"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Jurisdiction type location",
                        "expression": "Location.physicalType.coding.exists(code='jdn')"
                    }
                }
            ],
            "definitionUri": "behaviour_change_communication.json",
            "type": "create"
        },
        {
            "identifier": "${bednetDistributionActionId}",
            "prefix": 5,
            "title": "กิจกรรมสำรวจ/ชุบ/แจกมุ้ง",
            "description": "แจกมุ้งทุกหลังคาเรือนในพื้นที่ปฏิบัติงาน (100%)",
            "code": "Bednet Distribution",
            "timingPeriod": {
              "start": "${currentDate}",
              "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "RACD_bednet_distribution",
            "subjectCodableConcept": {
              "text": "Location"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                },
                {
                    "type": "named-event",
                    "name": "event-submission",
                    "expression": {
                        "description": "Trigger when a Family Registration event is submitted",
                        "expression": "questionnaire = 'Family_Registration'"
                    }
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Structure is residential or type does not exist",
                        "expression": "$this.is(FHIR.QuestionnaireResponse) or (($this.type.where(id='locationType').exists().not() or $this.type.where(id='locationType').text = 'Residential Structure') and $this.contained.exists())",
                        "subjectCodableConcept": {
                            "text": "Family"
                        }
                    }
                }
            ],
            "definitionUri": "bednet_distribution.json",
            "type": "create"
        },
        {
            "identifier": "${larvalDippingActionId}",
            "prefix": 6,
            "title": "กิจกรรมการตักลูกน้ำ",
            "description": "ดำเนินกิจกรรมจับลูกน้ำอย่างน้อย 3 แห่งในพื้นที่ปฏิบัติงาน",
            "code": "Larval Dipping",
            "timingPeriod": {
                "start": "${currentDate}",
                "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "Larval_Dipping",
            "subjectCodableConcept": {
                "text": "Location"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                },
                {
                    "type": "named-event",
                    "name": "event-submission",
                    "expression": {
                        "description": "Trigger when a Register_Structure event is submitted",
                        "expression": "questionnaire = 'Register_Structure'"
                    }
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Structure is a larval breeding site",
                        "expression": "$this.is(FHIR.QuestionnaireResponse) or $this.type.where(id='locationType').text = 'Larval Breeding Site'"
                    }
                },
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Apply to larval breeding sites in Register_Structure questionnaires",
                        "expression": "$this.is(FHIR.Location) or (questionnaire = 'Register_Structure' and $this.item.where(linkId='structureType').answer.value ='Larval Breeding Site')"
                    }
                }
            ],
            "definitionUri": "larval_dipping_form.json",
            "type": "create"
        },
        {
            "identifier": "${mosquitoCollectionActionId}",
            "prefix": 7,
            "title": "กิจกรรมการจับยุง",
            "description": "กิจกรรมจับยุงกำหนดไว้อย่างน้อย 3 แห่ง",
            "code": "Mosquito Collection",
            "timingPeriod": {
                "start": "${currentDate}",
                "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "Mosquito_Collection",
            "subjectCodableConcept": {
                "text": "Location"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                },
                {
                    "type": "named-event",
                    "name": "event-submission",
                    "expression": {
                        "description": "Trigger when a Register_Structure event is submitted",
                        "expression": "questionnaire = 'Register_Structure'"
                    }
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Structure is a mosquito collection point",
                        "expression": "$this.is(FHIR.QuestionnaireResponse) or $this.type.where(id='locationType').text = 'Mosquito Collection Point'"
                    }
                },
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Apply to mosquito collection point in Register_Structure questionnaires",
                        "expression": "$this.is(FHIR.Location) or (questionnaire = 'Register_Structure' and $this.item.where(linkId='structureType').answer.value ='Mosquito Collection Point')"
                    }
                }
            ],
            "definitionUri": "mosquito_collection_form.json",
            "type": "create"
        }
    ]
  }

@Rkareko
Copy link
Contributor

Rkareko commented Nov 9, 2021

Template 2

  {
    "identifier": "${planIdentifier}",
    "version": "1",
    "name": "${focus_status}-${focus_name}-${patient_name}_${patient_surname}-${currentDate}-${flag}",
    "title": "${focus_status} - ${focus_name} - ${patient_name} ${patient_surname} - ${currentDate} - ${flag}",
    "status": "draft",
    "date": "${currentDate}",
    "effectivePeriod": {
      "start": "${currentDate}",
      "end": "${endDate}"
    },
    "useContext": [
      {
        "code": "interventionType",
        "valueCodableConcept": "Dynamic-FI"
      },
      {
        "code": "fiStatus",
        "valueCodableConcept": "${focus_status}"
      },
      {
        "code": "fiReason",
        "valueCodableConcept": "Case Triggered"
      },
      {
        "code": "opensrpEventId",
        "valueCodableConcept": "${opensrpCaseClassificationEventId}"
      },
      {
        "code": "caseNum",
        "valueCodableConcept": "${case_number}"
      },
      {
        "code": "taskGenerationStatus",
        "valueCodableConcept": "internal"
      }
    ],
    "jurisdiction": [
      {
        "code": "${focus_id}"
      }
    ],
    "serverVersion": 0,
    "goal": [
          {
        "id": "Case_Confirmation",
        "description": "ยืนยันบ้านผู้ป่วย",
        "priority": "medium-priority",
        "target": [
          {
            "measure": "จำนวนผู้ป่วยที่ได้รับการยืนยัน",
            "detail": {
              "detailQuantity": {
                "value": 1,
                "comparator": "&gt;=",
                "unit": "case(s)"
              }
            },
            "due": "${endDate}"
          }
        ]
      },
        {
            "id": "RACD_register_families",
            "description": "ลงทะเบียนครัวเรือนและสมาชิกในครัวเรือน (100%) ภายในพื้นที่ปฏิบัติงาน",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "ร้อยละของบ้าน สิ่งปลูกสร้างที่ได้ลงทะเบียนข้อมูลครัวเรือน",
                "detail": {
                  "detailQuantity": {
                    "value": 100.0,
                    "comparator": ">=",
                    "unit": "%"
                  }
                },
                "due": "${endDate}"
              }
            ]
        },
        {
            "id": "RACD_Blood_Screening",
            "description": "เจาะเลือดรอบบ้านผู้ป่วยในรัศมี 1 กิโลเมตร (100%)",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "จำนวนผู้ที่ได้รับการเจาะโลหิต",
                "detail": {
                  "detailQuantity": {
                    "value": 50.0,
                    "comparator": ">=",
                    "unit": "คน"
                  }
                },
                "due": "${endDate}"
              }
            ]
        },
        {
            "id": "BCC_Focus",
            "description": "ให้สุขศึกษาในพื้นที่ปฏิบัติงานอย่างน้อย 1 ครั้ง",
            "priority": "medium-priority",
            "target": [
              {
                "measure": "จำนวนกิจกรรมการให้สุขศึกษา",
                "detail": {
                  "detailQuantity": {
                    "value": 1.0,
                    "comparator": ">=",
                    "unit": "แห่ง"
                  }
                },
                "due": "${endDate}"
              }
            ]
        }
    ],
    "action": [
          {
        "identifier": "662d4bff-43cc-4f50-af1e-3bc86f8af253",
        "prefix": 1,
        "title": "การยืนยันบ้านผู้ป่วย",
        "description": "ยืนยันบ้านผู้ป่วย",
        "code": "Case Confirmation",
        "timingPeriod": {
          "start": "2021-09-13",
          "end": "2021-09-23"
        },
        "reason": "Investigation",
        "goalId": "Case_Confirmation",
        "subjectCodableConcept": {
          "text": "Jurisdiction"
        },
      "trigger": [
          {
              "type": "named-event",
              "name": "plan-activation"
          }
      ],
      "condition": [
          {
              "kind": "applicability",
              "expression": {
                  "description": "Event is case details event",
                  "expression": "questionnaire = 'Case_Details'"
              }
          }
      ],
      "definitionUri": "case_confirmation.json",
      "type": "create"
      },
        {
            "identifier": "${registerFamilyActionId}",
            "prefix": 2,
            "title": "ลงทะเบียนครัวเรือน",
            "description": "ลงทะเบียนครัวเรือนและสมาชิกในครัวเรือน (100%) ภายในพื้นที่ปฏิบัติงาน",
            "code": "RACD Register Family",
            "timingPeriod": {
              "start": "${currentDate}",
              "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "RACD_register_families",
            "subjectCodableConcept": {
              "text": "Location"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                },
                {
                    "type": "named-event",
                    "name": "event-submission",
                    "expression": {
                        "description": "Trigger when a Register_Structure event is submitted",
                        "expression": "questionnaire = 'Register_Structure' or questionnaire = 'Archive_Family'"
                    }
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Structure is residential or type does not exist",
                          "expression": "$this.is(FHIR.QuestionnaireResponse) or (($this.type.where(id='locationType').exists().not() or $this.type.where(id='locationType').text = 'Residential Structure') and $this.contained.exists().not())",
                        "subjectCodableConcept": {
                            "text": "Family"
                        }
                    }
                },
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Apply to residential structures in Register_Structure questionnaires",
                        "expression": "$this.is(FHIR.Location) or (questionnaire = 'Register_Structure' and $this.item.where(linkId='structureType').answer.value ='Residential Structure')"
                    }
                }
            ],
            "definitionUri": "family_register.json",
            "type": "create"
        },
        {
            "identifier": "${bloodScreeningActionId}",
            "prefix": 3,
            "title": "กิจกรรมการเจาะโลหิต",
            "description": "เจาะเลือดรอบบ้านผู้ป่วยในรัศมี 1 กิโลเมตร (100%)",
            "code": "Blood Screening",
            "timingPeriod": {
                "start": "${currentDate}",
                "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "RACD_Blood_Screening",
            "subjectCodableConcept": {
                "text": "Person"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                },
                {
                    "type": "named-event",
                    "name": "event-submission",
                    "expression": {
                        "description": "Trigger when a Family Registration or Family Member Registration event is submitted",
                        "expression": "questionnaire = 'Family_Registration' or questionnaire = 'Family_Member_Registration'"
                    }
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Person is older than 5 years or person associated with questionnaire response if older than 5 years",
                        "expression": "($this.is(FHIR.Patient) and $this.birthDate <= today() - 5 'years') or ($this.contained.where(Patient.birthDate <= today() - 5 'years').exists())"
                    }
                }
            ],
            "definitionUri": "blood_screening.json",
            "type": "create"
        },
        {
            "identifier": "${bccActionId}",
            "prefix": 4,
            "title": "กิจกรรมการให้สุขศึกษา",
            "description": "ดำเนินกิจกรรมให้สุขศึกษา",
            "code": "BCC",
            "timingPeriod": {
                "start": "${currentDate}",
                "end": "${endDate}"
            },
            "reason": "Investigation",
            "goalId": "BCC_Focus",
            "subjectCodableConcept": {
                "text": "Jurisdiction"
            },
            "trigger": [
                {
                    "type": "named-event",
                    "name": "plan-activation"
                }
            ],
            "condition": [
                {
                    "kind": "applicability",
                    "expression": {
                        "description": "Jurisdiction type location",
                        "expression": "Location.physicalType.coding.exists(code='jdn')"
                    }
                }
            ],
            "definitionUri": "behaviour_change_communication.json",
            "type": "create"
        }
    ]
  }

@Rkareko
Copy link
Contributor

Rkareko commented Nov 9, 2021

How to post a plan template

Make a POST request to /rest/templates

The request body should contain the following

{
"templateId": 1,
"template": {{template_body}},
"version": 0,
"type": "plan"
}

The template id refers the template version used. The examples given above are 1 and 2 . The type is plan for both templates

template_body

The template field contains the actual plan template. For simplicity and ease in viewing the template we use the pre-request-scripts functionlaity in postman to store the plan template in a template_body variable that is reference above.

var body = 
// template goes here
;

pm.environment.set('template_body', JSON.stringify(body));

pre_request_script

@madrinekariuki
Copy link

@Rkareko cc @samkanga

Tested adding a plan template and this was tested on the Thai - preview and template 1 above.
Noted that when you try to retrieve the same template via GET to this endpoint https://reveal-th-preview.smartregister.org/opensrp/rest/templates/1
The template is incomplete and missing some parts.

see below template retrieved compared to the one posted here

Retrieved template:

{ "templateId": 1, "template": { "identifier": "${planIdentifier}", "version": "1", "name": "${focus_status}-${focus_name}-${patient_name}_${patient_surname}-${currentDate}-${flag}", "title": "${focus_status} - ${focus_name} - ${patient_name} ${patient_surname} - ${currentDate} - ${flag}", "status": "draft", "date": "${currentDate}", "effectivePeriod": { "start": "${currentDate}", "end": "${endDate}" }, "useContext": [ { "code": "interventionType", "valueCodableConcept": "Dynamic-FI" }, { "code": "fiStatus", "valueCodableConcept": "${focus_status}" }, { "code": "fiReason", "valueCodableConcept": "Case Triggered" }, { "code": "opensrpEventId", "valueCodableConcept": "${opensrpCaseClassificationEventId}" }, { "code": "caseNum", "valueCodableConcept": "${case_number}" }, { "code": "taskGenerationStatus", "valueCodableConcept": "internal" } ], "jurisdiction": [ { "code": "${focus_id}" } ], "serverVersion": 0, "experimental": false }, "version": 0

@madrinekariuki
Copy link

madrinekariuki commented Nov 11, 2021

Template 1 and template 2 can be successfully added and retrieved. This has been tested by Posting the two templates and then doing a get request and comparing the response payload with that of the initial post.

However there has been an issue noted on task generation where RabbitMQ was missing on thai preview.This has since been installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants