USE [peisdb]
GO

/****** Object:  StoredProcedure [dbo].[sp_GetLisResult]    Script Date: 06/04/2024 09:49:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

 CREATE PROCEDURE [dbo].[sp_GetLisResult] 
	@EID varchar(20) 
AS
BEGIN 
		SELECT  
		CAST(   A.req_id AS bigint) AS FID, 
		B.FeeItemName,
		A.rpt_itemname AS RptItemName,
		A.rptcode AS RptItemCode,
		A.result_str AS TextResult,
		A.result_unit AS Unit,
		CASE
			WHEN A.result_flag = 'H' THEN '↑'
			WHEN A.result_flag = 'M' THEN NULL
			WHEN A.result_flag = 'N' THEN NULL
			WHEN A.result_flag = 'L' THEN '↓'
			ELSE A.result_flag
		END AS UnusualFlag,
		A.result_ref AS RANGE,
		A.rechk_username AS Checker,
		A.rechk_dt AS CheckTime,
		ItemClass = '检验',
		A.report_username AS Reporter,
		A.report_dt AS ReportTime 
	FROM
		lis.rmcloudlis7.dbo.vw_checked_labresult A
		LEFT JOIN Enrollment_FeeItem B ON CAST(A.req_id AS varchar) = CAST(B.ID AS varchar) OR CAST(A.req_id AS varchar) = CAST(B.OldId AS varchar)
	WHERE
	 
		pat_no = @EID and pat_typecode=4 AND  B.EID= CAST( @EID AS bigint)  
END
GO


