Skip to content

Commit 38905c8

Browse files
paras-dbavishwab1
andauthored
Optimised stored procedure Pr_GetCallHistory (#66)
* fix:changes in face embedding sql file version 2 * fix:changes sql file for migratio * fix:changes for all migrationsql * fix:new final fixes for deployement * fix:changes on 28thNov * fix:new changes 30/11/2025 * fix:new changes part-2 30/11/2025 * fix:new changes 02/12/2025 * fix:new changes part-2 02/12/2025 * fix:new changes part-3 02/12/2025 * fix: new fixes for sanofi prod 5/12/2025 * fix:t_idrdetails column modification * fix:Modify table's column and added SP * fix:change in v_23 * fix:v28 file * fix:12/12/2025 * fix:query fixed acc. to coderabbit * fix:optimised stored procedure --------- Co-authored-by: vishwab1 <vishwanath@navadhiti.com>
1 parent dd30e68 commit 38905c8

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
DROP PROCEDURE IF EXISTS Pr_GetCallHistory;
2+
3+
4+
5+
DELIMITER $$
6+
7+
CREATE DEFINER=`piramaldev`@`%` PROCEDURE `Pr_GetCallHistory`(
8+
IN v_obcallid INT
9+
)
10+
BEGIN
11+
12+
SELECT
13+
t1.callid,
14+
t2.MotherID,
15+
t3.Name,
16+
NULL AS Child_id,
17+
NULL AS child_name,
18+
t1.PhoneNo,
19+
t3.ASHA_Name,
20+
t1.ReceivedRoleName,
21+
t3.LMP_Date,
22+
NULL AS dob,
23+
t1.calltime,
24+
t2.OutboundCallType AS `ECD CallType`,
25+
t1.TypeOfComplaint,
26+
t1.complaintRemarks,
27+
t1.Remarks AS AdviceProvided
28+
FROM t_bencall t1
29+
INNER JOIN t_mctsoutboundcalls t2
30+
ON t1.obcallid = t2.obcallid
31+
INNER JOIN t_mothervalidrecord t3
32+
ON t2.MotherID = t3.MCTSID_no
33+
WHERE
34+
(v_obcallid IS NULL OR t1.obcallid = v_obcallid)
35+
36+
UNION ALL
37+
38+
SELECT
39+
t1.callid,
40+
t2.MotherID,
41+
t3.Mother_Name,
42+
t3.MCTSID_no_Child_ID AS Child_id,
43+
t3.Child_Name AS child_name,
44+
t1.PhoneNo,
45+
t3.ASHA_Name,
46+
t1.ReceivedRoleName,
47+
NULL AS LMP_Date,
48+
t3.DOB AS dob,
49+
t1.calltime,
50+
t2.OutboundCallType AS `ECD CallType`,
51+
t1.TypeOfComplaint,
52+
t1.complaintRemarks,
53+
t1.Remarks AS AdviceProvided
54+
FROM t_bencall t1
55+
INNER JOIN t_mctsoutboundcalls t2
56+
ON t1.obcallid = t2.obcallid
57+
INNER JOIN t_childvaliddata t3
58+
ON t2.childID = t3.MCTSID_no_Child_ID
59+
WHERE
60+
(v_obcallid IS NULL OR t1.obcallid = v_obcallid);
61+
62+
END$$
63+
64+
DELIMITER ;

0 commit comments

Comments
 (0)