CREATE Procedure [dbo].My_StoredProcedure
@masterlbtint
AS
declare @tbl table(
LID int,
szDescription varchar(100),
szName varchar(50)
)
insert into @tbl (LID,Descript,szName)
select LT.lid as LID, LT.Descript as Descript ,isnull(LTC.szName,'') as szName from Map_MasterLabTestsToLabTests LoinMap
inner join LaboratoryTest LT on LT.lid =LoinMap.lbtesting and LoinMap.lbtesting=(select max(lid) from LaboratoryTest where Descript=lt.Descript)
INNER JOIN TechnicaltestcatLTCM ON LT.lID = LTCM.lLabTest
INNER JOIN testcategoryLTC ON LTCM.lCategory = LTC.lID
inner join LOINCDB myDB on myDB.lid=LoinMap.imastertestlb
where LoinMap.imastertestlb=@masterlbt
select LID,Descript,szName from @tbl order by Descript
k
No comments:
Post a Comment