Click here to Skip to main content
12,625,694 members (36,244 online)
Rate this:
 
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 31-Dec-12 0:05am
ujali450
Updated 31-Dec-12 0:17am
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2016
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