Advertisement
Ranish666

for dhulikhel

Jul 27th, 2021
1,286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.27 KB | None | 0 0
  1. alter proc [dbo].[PaitentinfogetPaitentinfo]      
  2.  @PaitentID nvarchar(max)              
  3.  as    
  4.  begin    
  5.  select  tp.ID,tp.PatientID,ltrim(rtrim((tp.srtfname))) srtfname, ltrim(rtrim(tp.strlname)) strlname,  
  6.  tp.strGender,tp.dtmDOB,isnull(tp.CountryId,1) as CountryId,tp.State,tp.strDistrict,tp.[VDC/Municipality] as intMID,tp.strAddress,        
  7.  isnull(tp.localaddress,'') as localaddress,isnull(tp.strGuardian,'') as strGuardian,tp.strRelation,isnull(tp.intmobile,'') as Contact,isnull(tp.strEmail,'') as strEmail,  
  8.  tp.intFileNumber,isnull(tp.strPanNo,'') as strPanNo,tp.dtmEntrydate,tp.dtmUpdatedate,tp.intUserID,tp.IsActive,tp.extra1,              
  9.  tp.extra2,tp.UHID,te.ID,te.strEncounterID,te.strPatientID,te.srtDepartment,te.strCurrentLocation,te.dtmDOR,te.dtmDOA,te.dtmDOD,TE.CreditLimit,              
  10.  te.dblCashbalance,te.strpatientType,te.dblDisountPercent,te.intConsultantID,te.intBillingModeID,te.intRefer_CorporateID,te.intRefer_doctorID,isnull(tp.BloodGroup,0) as BloodGroup ,              
  11.  te.dtmFollowupdate,te.strVisitType,te.IsActive,te.strIsFollowUp,te.ConsultDate,isnull(te.Policy_Num,'') as Policy_Num,isnull(te.Claim_ID,'') as Claim_ID,te.userid  
  12.  ,mu.Municipality, dis.DistrictName, st.StateName,  
  13.  case when DATEDIFF(year, dtmDOB, getdate()) > 0 then floor(DATEDIFF(Day, dtmDOB, getdate())/365.25)                    
  14. else case when DATEDIFF(month, dtmDOB, getdate()) > 0 then DATEDIFF(month, dtmDOB, getdate())                    
  15. else DATEDIFF(day, dtmDOB, getdate()) end                    
  16. end age,                    
  17. case when DATEDIFF(year, dtmDOB, getdate()) > 0 then 'Years'                    
  18. else case when DATEDIFF(month, dtmDOB, getdate()) > 0 then 'Months'                    
  19. else 'Days' end                    
  20. end strAge  
  21.  from tblpaitentinfo tp              
  22.  inner join tblEncounter te on tp.PatientID=te.strPatientID      
  23.  inner join tblDistrict dis on dis.ID = tp.strDistrict                    
  24.  left join tblState st on st.Id = dis.State                    
  25.  inner join tblMunicipality mu on mu.mID = tp.[VDC/Municipality]                    
  26.  where tp.patientID=@paitentID order by te.ID desc    
  27.  end
  28. go
  29. Alter proc [dbo].[PrefixinsertPreFixID]      
  30. @ID int,    
  31. @fiscalyearid int,      
  32. @type nvarchar(max),      
  33. @prefix nvarchar(250),      
  34. @suffix nvarchar(250),      
  35. @startindex int,      
  36. @startdate datetime,      
  37. @enddate datetime,      
  38. @userid int,      
  39. @UpdatedIndex int      
  40. as      
  41. BEGIN      
  42.  IF @ID=0 or @ID=null      
  43.  BEGIN      
  44.  --IF NOT EXISTS(select * from tblprefixsetting where CONVERT(date, GETDATE()) between CONVERT(date, @startdate) and CONVERT(date, @enddate) and  Type=@type)      
  45.  -- BEGIN      
  46. insert into tblPrefixSetting(fiscalyearid,type,prefix,suffix,startindex,startdate,enddate,UpdatedIndex,userid,CreatedDate)      
  47. values(@fiscalyearid,@type,@prefix,@suffix,@startindex,@startdate,@enddate,@UpdatedIndex,@userid,getdate())      
  48. select 1      
  49. -- END      
  50. --ELSE      
  51. -- BEGIN      
  52. --  select 0      
  53.  -- END      
  54. END      
  55. ELSE      
  56. BEGIN      
  57. update tblPrefixSetting set fiscalyearid=@fiscalyearid,type=@type,prefix=@prefix,suffix=@suffix,startindex=@startindex,startdate=@startdate,enddate=@enddate where ID=@ID      
  58. select 1      
  59. END      
  60. END      
  61. go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement