opensrp/opensrp-server-web

Issue on Creating 2 plans if the index case has both a p_site_id and a source_site_id

Closed this issue · 4 comments

After migration of RACD plan generation to OpenSRP, It has been noted that even if an index case contains both the p_site_id and a source_site_id only one plan is being created instead of two.

This has been tested by:

  • checking the data inserted into the mhealth DB if it contains both p_site_id and a source_site_id
  • check to confirm if on the UI we have 2 plans a site plan and a source plan

Noted:
Only one plan is created. (a site plan)

Details:

Data inserted into mhealth
INSERT INTO db_mhealth_preview.dbo.index_case (case_id,p_site_id,p_site_name,p_site_area,source_site_id,source_site_name,source_site_area,case_classification,household_id,blood_draw_date,investigtion_date,ep1_create_date,ep3_create_date,house_number,patient_name,patient_surname,patient_age,species,id) VALUES('2401224081140861235','1206030003','เมืองทอง(Site)-2','A1','1206030003','เมืองทอง(Site)-2','A2','Bz','','2021-11-11','2021-11-11','2021-11-11 00:00:00.000','2021-11-11 00:00:00.000','H321','QA','test3',69,'M',881);

plan generated:
ID 5f69e1a3-70a0-4d40-88c2-27fb40c77da1
Name: A1 - เมืองทอง(Site)-2 - QA test3 - 2021-11-15 - Site

@madrinekariuki cc @samkanga only one case details event was generated for the case number 2401224081140861235. We need @ciremusyoka to look into why this is the case. A plan is generated for each case details event that is why we have only one plan.

select json->>'_id' eventId, json->'details'->>'case_number' caseNumber from core.event where json->'details'->>'case_number' IN  ('2401224081140861235');
               eventid                |     casenumber      
--------------------------------------+---------------------
 fdf745d4-69b8-4809-971e-fa90f08aa9b0 | 2401224081140861235
(1 row)

After further investigation it was noted that the last index case was added to the same location for the Site and Source areas. They are meant to be different.
A correction was made to the INSERT statement and now inserted case triggered plans are generating 2 plan (site and a source plan).

see below screenshot
image

Issue reported again on the prod instance.
we have inserted 2 index cases 3754 & 3755 but both have only generated one plan (site plan).

8673367083424688568
8400899023317766468

Closing this ticket in favor of this one on Canopy.