Click here to Skip to main content
11,640,626 members (61,551 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
DROP PROCEDURE IF EXISTS hms.Select_Parameter1;
CREATE PROCEDURE hms.`Select_Parameter1`(_Branch_Id     int,
                                         _Tenant_Id     int,
                                         _disease_Id    int,_ParameterId int,_Patient_Id int)
BEGIN
      IF EXISTS
            (SELECT  b.Target_Value
               FROM patient_progress_tracking_header b
              WHERE b.DiseaseId = _disease_Id)
      THEN
         SELECT a.ParameterName,
                b.Target_Value,
                b.Measurement_Frequency,
                date_format(c.Last_Date,"%y/%d/%m") as 'Last_Date',
                c.Result,
                 date_format(c.Next_Due_Date,"%y/%d/%m") as 'Next_Due_Date',
                
                date_format(c.Current_Test_Date,"%y/%d/%m") as 'Current_Test_Date',
                c.Test_Result,
                b.ParameterId 
                
           FROM patient_progress_tracking_header b
                RIGHT JOIN Disease_parameter a
                   ON  b.DiseaseId=a.DiseaseId
                INNER JOIN patient_progress_tracking_details c
                   ON b.DiseaseId = c.DiseaseId
          WHERE     a.Branch_Id = _Branch_Id
                AND a.Tenant_Id = _Tenant_Id
                AND a.DiseaseId = _disease_Id
               AND a.Patient_Id=_Patient_Id;
      ELSE
      Insert Into patient_progress_tracking_header(Branch_Id,Tenant_Id,Patient_Id,DiseaseId)values(_Branch_Id,_Tenant_Id,_Patient_Id,_disease_Id);
      Insert Into patient_progress_tracking_details(DiseaseId,Patient_Id,Branch_Id,Tenant_Id)values(_disease_Id,_Patient_Id,_Branch_Id,_Tenant_Id);
        
         SELECT a.ParameterName,
                a.Target_Value,
                b.Measurement_Frequency,
                date_format(c.Last_Date,"%y/%d/%m") as 'Last_Date',
                c.Result,
                 date_format(c.Next_Due_Date,"%y/%d/%m") as 'Next_Due_Date',
                
                date_format(c.Current_Test_Date,"%y/%d/%m") as 'Current_Test_Date',
                c.Test_Result,
                b.ParameterId
                
           FROM patient_progress_tracking_header b
                RIGHT JOIN Disease_parameter a
                   ON  b.DiseaseId =a.DiseaseId
                INNER JOIN patient_progress_tracking_details c
                   ON b.DiseaseId = c.DiseaseId
          WHERE     a.Branch_Id = _Branch_Id
                AND a.Tenant_Id = _Tenant_Id
                AND a.DiseaseId = _disease_Id
                AND a.Patient_Id=_Patient_Id;
                
      END IF;
   END;
thsi is my procedure..
in else part first time all the parametername and targetvalue are coming from Disease_Parameter table but when all the value get inserted into othe two tables..only one parametername is getting Proper DiseasId...Other parameter gets 0 DiseasId...It should be also take same DiseaseID.
Posted 30-Dec-12 23:05pm
ujali439
Edited 30-Dec-12 23:17pm
v5

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

refer below links:
Link 1[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mika Wendelius 370
1 OriginalGriff 205
2 CPallini 125
3 Afzaal Ahmad Zeeshan 124
4 DamithSL 103
0 Mika Wendelius 370
1 OriginalGriff 205
2 CPallini 125
3 DamithSL 105
4 Afzaal Ahmad Zeeshan 70


Advertise | Privacy | Mobile
Web04 | 2.8.150731.1 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100