@ -13,6 +13,7 @@ package com.ynxbd.common.dao.lis;
import com.ynxbd.common.bean.lis.* ;
import com.ynxbd.common.config.db.LisDB ;
import org.apache.commons.lang3.ObjectUtils ;
import java.util.ArrayList ;
import java.util.List ;
@ -22,59 +23,59 @@ public class XBDLisDao {
public List < XBDLisReport > getReport ( String treatId , String patientType ) {
String condition = "0" . equals ( patientType ) ? "in" : "not in" ;
String sql = "SELECT DISTINCT" +
" ID," +
" r.SampleName AS ReportName," +
" r.ReportClass AS ReportType," +
" ReqDeptName," +
" ReqDoctorName as ReqDoctName," +
" xc.ReqItemName," +
" CONVERT(varchar,CONVERT(datetime,ReqDate),20) as ReqDate," +
" Reporter," +
" CONVERT(varchar,CONVERT(datetime,ReportDate),20) as ReportDate," +
" CONVERT(varchar,CONVERT(datetime,p.TestDate),23) as TestDate," +
" p.SampleCode," +
" SpecimenName," +
" PatientID AS TreatId," +
" PatientName," +
" CASE Sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex," +
" CONVERT(VARCHAR(10), Age) + AgeClass AS Age," +
" PatientClass As PatientType," +
" BedNo" +
" FROM" +
" dbo.Rpt_Patient p (NOLOCK)" +
" LEFT JOIN ( SELECT" +
" STUFF(( SELECT" +
" ',' + ReqItemName" +
" FROM" +
" Rpt_CheckCost (NOLOCK)" +
" WHERE" +
" SampleCode = c.SampleCode AND TestDate = c.TestDate" +
" FOR" +
" XML PATH('') ), 1, 1, '') AS ReqItemName," +
" c.ReqItemCode," +
" SampleCode," +
" TestDate" +
" FROM" +
" Rpt_CheckCost c (NOLOCK)" +
" GROUP BY" +
" c.SampleCode," +
" c.TestDate," +
" c.ReqItemCode ) xc ON p.SampleCode = xc.SampleCode AND p.TestDate = xc.TestDate"
+
" LEFT JOIN dbo.Dict_Report r (NOLOCK) ON SUBSTRING(p.SampleCode, 1, 2) = r.SampleCode"
+
" LEFT JOIN dbo.Dict_PatientClass pc (NOLOCK) ON p.PatientClassCode = pc.PatientClassCode"
+
" WHERE" +
" ISNULL(Checker, '') <> '' AND p.PatientClassCode " + condition
+ " (SELECT PatientClassCode FROM dbo.Dict_PatientClass WHERE (PatientClassName = '住院' OR PatientClassName = '住院急诊')) AND PatientID = ?"
+
" ORDER BY" +
" ReportDate" ;
" ID," +
" r.SampleName AS ReportName," +
" r.ReportClass AS ReportType," +
" ReqDeptName," +
" ReqDoctorName as ReqDoctName," +
" xc.ReqItemName," +
" CONVERT(varchar,CONVERT(datetime,ReqDate),20) as ReqDate," +
" Reporter," +
" CONVERT(varchar,CONVERT(datetime,ReportDate),20) as ReportDate," +
" CONVERT(varchar,CONVERT(datetime,p.TestDate),23) as TestDate," +
" p.SampleCode," +
" SpecimenName," +
" PatientID AS TreatId," +
" PatientName," +
" CASE Sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex," +
" CONVERT(VARCHAR(10), Age) + AgeClass AS Age," +
" PatientClass As PatientType," +
" BedNo" +
" FROM" +
" dbo.Rpt_Patient p (NOLOCK)" +
" LEFT JOIN ( SELECT" +
" STUFF(( SELECT" +
" ',' + ReqItemName" +
" FROM" +
" Rpt_CheckCost (NOLOCK)" +
" WHERE" +
" SampleCode = c.SampleCode AND TestDate = c.TestDate" +
" FOR" +
" XML PATH('') ), 1, 1, '') AS ReqItemName," +
" c.ReqItemCode," +
" SampleCode," +
" TestDate" +
" FROM" +
" Rpt_CheckCost c (NOLOCK)" +
" GROUP BY" +
" c.SampleCode," +
" c.TestDate," +
" c.ReqItemCode ) xc ON p.SampleCode = xc.SampleCode AND p.TestDate = xc.TestDate"
+
" LEFT JOIN dbo.Dict_Report r (NOLOCK) ON SUBSTRING(p.SampleCode, 1, 2) = r.SampleCode"
+
" LEFT JOIN dbo.Dict_PatientClass pc (NOLOCK) ON p.PatientClassCode = pc.PatientClassCode"
+
" WHERE" +
" ISNULL(Checker, '') <> '' AND p.PatientClassCode " + condition
+ " (SELECT PatientClassCode FROM dbo.Dict_PatientClass WHERE (PatientClassName = '住院' OR PatientClassName = '住院急诊')) AND PatientID = ?"
+
" ORDER BY" +
" ReportDate" ;
return LisDB . select ( sql , XBDLisReport . class , ps - > {
ps . setString ( 1 , treatId ) ;
@ -83,23 +84,23 @@ public class XBDLisDao {
public List < XBDLisResult > getResult ( String testDate , String sampleCode ) {
String sql = "SELECT" +
" a.rptItemCode as reportItemCode," +
" b.rptItemName as reportItemName," +
" a.resultStr as result," +
" a.unit," +
" a.range," +
" CASE a.UnusualFlag WHEN ' ' THEN '' ELSE a.UnusualFlag END AS UnusualFlag,"
+
" a.insCode," +
" b.seq" +
" FROM" +
" dbo.Rpt_CheckResult a" +
" LEFT JOIN dbo.Dict_ReportToItem b ON a.RptItemCode = b.RptItemCode" +
" WHERE" +
" a.TestDate = ? AND a.SampleCode = ? AND b.SampleCode = SUBSTRING(a.SampleCode, 1, 2)"
+
" ORDER BY" +
" b.Seq" ;
" a.rptItemCode as reportItemCode," +
" b.rptItemName as reportItemName," +
" a.resultStr as result," +
" a.unit," +
" a.range," +
" CASE a.UnusualFlag WHEN ' ' THEN '' ELSE a.UnusualFlag END AS UnusualFlag,"
+
" a.insCode," +
" b.seq" +
" FROM" +
" dbo.Rpt_CheckResult a" +
" LEFT JOIN dbo.Dict_ReportToItem b ON a.RptItemCode = b.RptItemCode" +
" WHERE" +
" a.TestDate = ? AND a.SampleCode = ? AND b.SampleCode = SUBSTRING(a.SampleCode, 1, 2)"
+
" ORDER BY" +
" b.Seq" ;
return LisDB . select ( sql , XBDLisResult . class , ps - > {
ps . setString ( 1 , testDate ) ;
ps . setString ( 2 , sampleCode ) ;
@ -117,15 +118,15 @@ public class XBDLisDao {
public List < XBDLisBactResult > getBactResult ( String testDate , String sampleCode ) {
List < XBDLisBactResult > bactResults = new ArrayList < > ( ) ;
String sql = "SELECT" +
" isnull(b.BactName,'') as BactName," +
" isnull(a.Result,'') as Result," +
" isnull(a.InsCode,'') as InsCode," +
" a.Seq" +
" FROM" +
" dbo.Rpt_BactResult (NOLOCK) a" +
" Right JOIN dbo.Dict_Bacteria (NOLOCK) b ON a.BactCode = b.BactCode" +
" WHERE" +
" a.TestDate = ? AND a.SampleCode = ?" ;
" isnull(b.BactName,'') as BactName," +
" isnull(a.Result,'') as Result," +
" isnull(a.InsCode,'') as InsCode," +
" a.Seq" +
" FROM" +
" dbo.Rpt_BactResult (NOLOCK) a" +
" Right JOIN dbo.Dict_Bacteria (NOLOCK) b ON a.BactCode = b.BactCode" +
" WHERE" +
" a.TestDate = ? AND a.SampleCode = ?" ;
bactResults = LisDB . select ( sql , XBDLisBactResult . class , ps - > {
ps . setString ( 1 , testDate ) ;
ps . setString ( 2 , sampleCode ) ;
@ -142,17 +143,17 @@ public class XBDLisDao {
private List < XBDLisAntbResult > getAntbResult ( String testDate , String sampleCode , int seq ) {
String sql = "SELECT" +
" isnull(a.AntbCode,'') as AntbCode," +
" isnull(b.AntbName,'') as AntbName," +
" isnull(a.Result,'') as Result," +
" isnull(a.Mic,'') as Mic," +
" isnull(a.InsCode,'') as InsCode," +
" a.Seq" +
" FROM" +
" dbo.Rpt_AntbResult (NOLOCK) a" +
" LEFT JOIN dbo.Dict_Antibiotic (NOLOCK) b ON a.AntbCode = b.AntbCode" +
" WHERE" +
" a.TestDate = ? AND a.SampleCode = ? AND a.seq = ?" ;
" isnull(a.AntbCode,'') as AntbCode," +
" isnull(b.AntbName,'') as AntbName," +
" isnull(a.Result,'') as Result," +
" isnull(a.Mic,'') as Mic," +
" isnull(a.InsCode,'') as InsCode," +
" a.Seq" +
" FROM" +
" dbo.Rpt_AntbResult (NOLOCK) a" +
" LEFT JOIN dbo.Dict_Antibiotic (NOLOCK) b ON a.AntbCode = b.AntbCode" +
" WHERE" +
" a.TestDate = ? AND a.SampleCode = ? AND a.seq = ?" ;
return LisDB . select ( sql , XBDLisAntbResult . class , ps - > {
ps . setString ( 1 , testDate ) ;
ps . setString ( 2 , sampleCode ) ;
@ -173,66 +174,66 @@ public class XBDLisDao {
public List < XBDLisReport > getReport4KH ( String treatId , String patientType ) {
String condition = patientType . equals ( "0" ) ? "in" : "not in" ;
String sql = "SELECT" +
" ID" +
" ,r.report_name AS ReportName" +
" ,CASE r.REPORT_TYPE WHEN 1 THEN '细菌报告单' ELSE '基本报告单' END AS ReportType"
+
" ,Require_BM AS ReqDeptName" +
" ,Require_Doctor AS ReqDoctName" +
" ,xc.ReqItemName" +
" ,CONVERT(varchar,CONVERT(datetime,Require_Date),20) as ReqDate"
+
" ,u.Name AS Reporter" +
" ,CONVERT(varchar,CONVERT(DATETIME, Date_Report),20) as ReportDate"
+
" ,CONVERT(varchar,CONVERT(datetime,p.Date_Test),23) as TestDate"
+
" ,p.YBH AS SampleCode" +
" ,k.Kind_Name AS SpecimenName" +
" ,Patient_Code AS TreatId" +
" ,p.Name AS PatientName" +
" ,CASE Sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex" +
" ,Age" +
" ,age_flag AS Age" +
" ,Patient_kind_name As PatientType," +
" Bed_no AS BedNo" +
" FROM" +
" dbo.UT_Check_Patient p (NOLOCK)" +
" LEFT JOIN ( SELECT" +
" STUFF(( SELECT" +
" ',' + Item_name" +
" FROM" +
" dbo.UT_CHECK_COST (NOLOCK)" +
" WHERE" +
" YBH = c.YBH AND Date_test = c.Date_test" +
" FOR" +
" XML PATH('') ), 1, 1, '') AS ReqItemName," +
" c.YBH," +
" c.Date_test" +
" FROM" +
" dbo.UT_CHECK_COST c (NOLOCK)" +
" GROUP BY" +
" c.YBH," +
" c.Date_test) xc ON p.YBH = xc.YBH AND p.Date_test = xc.Date_test" +
" LEFT JOIN UT_DICT_Report r (NOLOCK) ON SUBSTRING(p.YBH, 1, 2) = r.code"
+
" LEFT JOIN UT_DICT_Patient_kind pc (NOLOCK) ON p.Patient_Kind = pc.Patient_kind_code"
+
" LEFT JOIN UT_Check_Module_Kind k(nolock) on p.Kind = k.kind_code"
+
" LEFT JOIN dbo.UT_DICT_User u (nolock) on p.Reporter = u.User_ID"
+
" WHERE" +
" Flag_Send =5 AND p.Patient_Kind " + condition
+ " (SELECT Patient_kind_code FROM UT_DICT_Patient_kind WHERE (Patient_kind_name = '住院' OR Patient_kind_name = '住院急诊')) "
+
" AND Patient_Code = ?" +
" ORDER BY" +
" ReportDate" ;
" ID" +
" ,r.report_name AS ReportName" +
" ,CASE r.REPORT_TYPE WHEN 1 THEN '细菌报告单' ELSE '基本报告单' END AS ReportType"
+
" ,Require_BM AS ReqDeptName" +
" ,Require_Doctor AS ReqDoctName" +
" ,xc.ReqItemName" +
" ,CONVERT(varchar,CONVERT(datetime,Require_Date),20) as ReqDate"
+
" ,u.Name AS Reporter" +
" ,CONVERT(varchar,CONVERT(DATETIME, Date_Report),20) as ReportDate"
+
" ,CONVERT(varchar,CONVERT(datetime,p.Date_Test),23) as TestDate"
+
" ,p.YBH AS SampleCode" +
" ,k.Kind_Name AS SpecimenName" +
" ,Patient_Code AS TreatId" +
" ,p.Name AS PatientName" +
" ,CASE Sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex" +
" ,Age" +
" ,age_flag AS Age" +
" ,Patient_kind_name As PatientType," +
" Bed_no AS BedNo" +
" FROM" +
" dbo.UT_Check_Patient p (NOLOCK)" +
" LEFT JOIN ( SELECT" +
" STUFF(( SELECT" +
" ',' + Item_name" +
" FROM" +
" dbo.UT_CHECK_COST (NOLOCK)" +
" WHERE" +
" YBH = c.YBH AND Date_test = c.Date_test" +
" FOR" +
" XML PATH('') ), 1, 1, '') AS ReqItemName," +
" c.YBH," +
" c.Date_test" +
" FROM" +
" dbo.UT_CHECK_COST c (NOLOCK)" +
" GROUP BY" +
" c.YBH," +
" c.Date_test) xc ON p.YBH = xc.YBH AND p.Date_test = xc.Date_test" +
" LEFT JOIN UT_DICT_Report r (NOLOCK) ON SUBSTRING(p.YBH, 1, 2) = r.code"
+
" LEFT JOIN UT_DICT_Patient_kind pc (NOLOCK) ON p.Patient_Kind = pc.Patient_kind_code"
+
" LEFT JOIN UT_Check_Module_Kind k(nolock) on p.Kind = k.kind_code"
+
" LEFT JOIN dbo.UT_DICT_User u (nolock) on p.Reporter = u.User_ID"
+
" WHERE" +
" Flag_Send =5 AND p.Patient_Kind " + condition
+ " (SELECT Patient_kind_code FROM UT_DICT_Patient_kind WHERE (Patient_kind_name = '住院' OR Patient_kind_name = '住院急诊')) "
+
" AND Patient_Code = ?" +
" ORDER BY" +
" ReportDate" ;
return LisDB . select ( sql , XBDLisReport . class , ps - > {
ps . setString ( 1 , treatId ) ;
} ) ;
@ -241,85 +242,85 @@ public class XBDLisDao {
public List < XBDLisReport > getReport4KH_Hhzfy ( String treatId , String patientType ) {
String condition = patientType . equals ( "0" ) ? "in" : "not in" ;
String condition2 =
patientType . equals ( "0" ) ? String . format ( " AND Patient_Code = '%s'" , treatId )
: String . format ( " AND Bed_No = '%s'" , treatId ) ;
patientType . equals ( "0" ) ? String . format ( " AND Patient_Code = '%s'" , treatId )
: String . format ( " AND Bed_No = '%s'" , treatId ) ;
System . out . println ( "conditon2:" + condition2 ) ;
String sql = "SELECT" +
" ID" +
" ,r.report_name AS ReportName" +
" ,CASE r.REPORT_TYPE WHEN 1 THEN '细菌报告单' ELSE '基本报告单' END AS ReportType"
+
" ,Require_BM AS ReqDeptName" +
" ,Require_Doctor AS ReqDoctName" +
" ,xc.ReqItemName" +
" ,CONVERT(varchar,CONVERT(datetime,Require_Date),20) as ReqDate"
+
" ,u.Name AS Reporter" +
" ,CONVERT(varchar,CONVERT(DATETIME, Date_Report),20) as ReportDate"
+
" ,CONVERT(varchar,CONVERT(datetime,p.Date_Test),23) as TestDate"
+
" ,p.YBH AS SampleCode" +
" ,k.Kind_Name AS SpecimenName" +
" ,Patient_Code AS TreatId" +
" ,p.Name AS PatientName" +
" ,CASE Sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex" +
" ,Age" +
" ,age_flag AS Age" +
" ,Patient_kind_name As PatientType," +
" Bed_no AS BedNo" +
" FROM" +
" dbo.UT_Check_Patient p (NOLOCK)" +
" LEFT JOIN ( SELECT" +
" STUFF(( SELECT" +
" ',' + Item_name" +
" FROM" +
" dbo.UT_CHECK_COST (NOLOCK)" +
" WHERE" +
" YBH = c.YBH AND Date_test = c.Date_test" +
" FOR" +
" XML PATH('') ), 1, 1, '') AS ReqItemName," +
" c.YBH," +
" c.Date_test" +
" FROM" +
" dbo.UT_CHECK_COST c (NOLOCK)" +
" GROUP BY" +
" c.YBH," +
" c.Date_test) xc ON p.YBH = xc.YBH AND p.Date_test = xc.Date_test" +
" LEFT JOIN UT_DICT_Report r (NOLOCK) ON SUBSTRING(p.YBH, 1, 2) = r.code"
+
" LEFT JOIN UT_DICT_Patient_kind pc (NOLOCK) ON p.Patient_Kind = pc.Patient_kind_code"
+
" LEFT JOIN UT_Check_Module_Kind k(nolock) on p.Kind = k.kind_code"
+
" LEFT JOIN dbo.UT_DICT_User u (nolock) on p.Reporter = u.User_ID"
+
" WHERE" +
" Flag_Send =5 AND p.Patient_Kind " + condition
+ " (SELECT Patient_kind_code FROM UT_DICT_Patient_kind WHERE (Patient_kind_name = '住院' OR Patient_kind_name = '住院急诊')) "
+ condition2 +
" ORDER BY" +
" ReportDate" ;
" ID" +
" ,r.report_name AS ReportName" +
" ,CASE r.REPORT_TYPE WHEN 1 THEN '细菌报告单' ELSE '基本报告单' END AS ReportType"
+
" ,Require_BM AS ReqDeptName" +
" ,Require_Doctor AS ReqDoctName" +
" ,xc.ReqItemName" +
" ,CONVERT(varchar,CONVERT(datetime,Require_Date),20) as ReqDate"
+
" ,u.Name AS Reporter" +
" ,CONVERT(varchar,CONVERT(DATETIME, Date_Report),20) as ReportDate"
+
" ,CONVERT(varchar,CONVERT(datetime,p.Date_Test),23) as TestDate"
+
" ,p.YBH AS SampleCode" +
" ,k.Kind_Name AS SpecimenName" +
" ,Patient_Code AS TreatId" +
" ,p.Name AS PatientName" +
" ,CASE Sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex" +
" ,Age" +
" ,age_flag AS Age" +
" ,Patient_kind_name As PatientType," +
" Bed_no AS BedNo" +
" FROM" +
" dbo.UT_Check_Patient p (NOLOCK)" +
" LEFT JOIN ( SELECT" +
" STUFF(( SELECT" +
" ',' + Item_name" +
" FROM" +
" dbo.UT_CHECK_COST (NOLOCK)" +
" WHERE" +
" YBH = c.YBH AND Date_test = c.Date_test" +
" FOR" +
" XML PATH('') ), 1, 1, '') AS ReqItemName," +
" c.YBH," +
" c.Date_test" +
" FROM" +
" dbo.UT_CHECK_COST c (NOLOCK)" +
" GROUP BY" +
" c.YBH," +
" c.Date_test) xc ON p.YBH = xc.YBH AND p.Date_test = xc.Date_test" +
" LEFT JOIN UT_DICT_Report r (NOLOCK) ON SUBSTRING(p.YBH, 1, 2) = r.code"
+
" LEFT JOIN UT_DICT_Patient_kind pc (NOLOCK) ON p.Patient_Kind = pc.Patient_kind_code"
+
" LEFT JOIN UT_Check_Module_Kind k(nolock) on p.Kind = k.kind_code"
+
" LEFT JOIN dbo.UT_DICT_User u (nolock) on p.Reporter = u.User_ID"
+
" WHERE" +
" Flag_Send =5 AND p.Patient_Kind " + condition
+ " (SELECT Patient_kind_code FROM UT_DICT_Patient_kind WHERE (Patient_kind_name = '住院' OR Patient_kind_name = '住院急诊')) "
+ condition2 +
" ORDER BY" +
" ReportDate" ;
return LisDB . select ( sql , XBDLisReport . class ) ;
}
public List < XBDLisResult > getResult4KH ( String testDate , String sampleCode ) {
String sql = "SELECT a.Item_Code AS reportItemCode" +
" ,b.Item_Name AS reportItemName" +
" ,a.Test_Value2 AS result" +
" ,a.Text_Danwei AS unit" +
" ,a.Text_range AS range" +
" ,ISNULL(a.Text_Note, '') AS unusualFlag" +
" ,a.Flag_YQ AS insCode" +
" ,a.Out_Order AS seq" +
" FROM UT_Check_Result a LEFT JOIN" +
" UT_DICT_Items b ON a.Item_Code = b.Item_Code" +
" WHERE a.Test_Date = ? AND a.YBH = ?" +
" ORDER BY a.Out_Order" ;
" ,b.Item_Name AS reportItemName" +
" ,a.Test_Value2 AS result" +
" ,a.Text_Danwei AS unit" +
" ,a.Text_range AS range" +
" ,ISNULL(a.Text_Note, '') AS unusualFlag" +
" ,a.Flag_YQ AS insCode" +
" ,a.Out_Order AS seq" +
" FROM UT_Check_Result a LEFT JOIN" +
" UT_DICT_Items b ON a.Item_Code = b.Item_Code" +
" WHERE a.Test_Date = ? AND a.YBH = ?" +
" ORDER BY a.Out_Order" ;
return LisDB . select ( sql , XBDLisResult . class , ps - > {
ps . setString ( 1 , testDate ) ;
ps . setString ( 2 , sampleCode ) ;
@ -337,12 +338,12 @@ public class XBDLisDao {
public List < XBDLisBactResult > getBactResult4KH ( String testDate , String sampleCode ) {
List < XBDLisBactResult > bactResults = new ArrayList < > ( ) ;
String sql = "SELECT" +
" ISNULL(Bacteria_name, '') AS BactName" +
",ISNULL(Test_Value, '') AS Result" +
",ISNULL(Flag_YQ, '') AS InsCode" +
",Bacteria_serial AS Seq" +
" FROM ut_check_bacteria (NOLOCK)" +
" WHERE test_date = ? AND ybh = ?" ;
" ISNULL(Bacteria_name, '') AS BactName" +
",ISNULL(Test_Value, '') AS Result" +
",ISNULL(Flag_YQ, '') AS InsCode" +
",Bacteria_serial AS Seq" +
" FROM ut_check_bacteria (NOLOCK)" +
" WHERE test_date = ? AND ybh = ?" ;
bactResults = LisDB . select ( sql , XBDLisBactResult . class , ps - > {
ps . setString ( 1 , testDate ) ;
ps . setString ( 2 , sampleCode ) ;
@ -350,7 +351,7 @@ public class XBDLisDao {
for ( XBDLisBactResult item : bactResults ) {
List < XBDLisAntbResult > antbResults = getAntbResult4KH ( testDate , sampleCode ,
item . getSeq ( ) ) ;
item . getSeq ( ) ) ;
item . setAntbResults ( antbResults ) ;
List < XBDLisComment > comments = getComment4KH ( testDate , sampleCode , item . getSeq ( ) ) ;
item . setComments ( comments ) ;
@ -361,18 +362,18 @@ public class XBDLisDao {
private List < XBDLisAntbResult > getAntbResult4KH ( String testDate , String sampleCode , int seq ) {
String sql = "SELECT" +
" isnull(a.Antibiotic_code,'') as AntbCode" +
" ,isnull(b.Antibiotic_name,'') as AntbName" +
" ,isnull(a.Test_value,'') as Result" +
" ,isnull(a.Mic,'') as Mic" +
" ,'' as InsCode" +
" ,a.Bacteria_serial AS Seq" +
" FROM " +
" ut_check_antibiotic a (NOLOCK)" +
" LEFT JOIN ut_dict_antibiotic b (NOLOCK) ON a.Antibiotic_code = b.Antibiotic_code"
+
" WHERE" +
" a.test_date = ? AND a.ybh = ? AND a.Bacteria_serial = ?" ;
" isnull(a.Antibiotic_code,'') as AntbCode" +
" ,isnull(b.Antibiotic_name,'') as AntbName" +
" ,isnull(a.Test_value,'') as Result" +
" ,isnull(a.Mic,'') as Mic" +
" ,'' as InsCode" +
" ,a.Bacteria_serial AS Seq" +
" FROM " +
" ut_check_antibiotic a (NOLOCK)" +
" LEFT JOIN ut_dict_antibiotic b (NOLOCK) ON a.Antibiotic_code = b.Antibiotic_code"
+
" WHERE" +
" a.test_date = ? AND a.ybh = ? AND a.Bacteria_serial = ?" ;
return LisDB . select ( sql , XBDLisAntbResult . class , ps - > {
ps . setString ( 1 , testDate ) ;
ps . setString ( 2 , sampleCode ) ;
@ -422,39 +423,50 @@ public class XBDLisDao {
} ) ;
}
// 瑞美
public List < XBDLisReport > getReport4RM ( String treatId ) {
// 瑞美 patientType:0:住院 1:门诊
public List < XBDLisReport > getReport4RM ( String treatId , String patientType ) {
String reportPatTypeCode = "('1','2','3')" ;
if ( ObjectUtils . isEmpty ( patientType ) | | "0" . equals ( patientType ) ) { // 住院
reportPatTypeCode = "('3')" ;
} else if ( "1" . equals ( patientType ) ) { // 门诊
reportPatTypeCode = "('1','2')" ;
} else if ( "4" . equals ( patientType ) ) { // 体检
reportPatTypeCode = "('4')" ;
}
String sql = "SELECT" +
" a.reportid AS ID" +
" ,RTRIM(b.rptunitname) AS ReportName" +
" ,CASE e.resultclass WHEN '细菌' THEN '细菌报告单' ELSE '基本报告单' END AS ReportType" +
" ,isnull(c.deptname,'') AS ReqDeptName" +
" ,isnull(d.doctorname,'') AS ReqDoctName" +
" ,isnull(a.req_reason,'') AS ReqItemName" +
" ,isnull(a.req_dt,'') AS ReqDate" +
" ,isnull(a.report_username,'') AS Reporter" +
" ,isnull(a.report_dt,'') AS ReportDate" +
" ,CONVERT(VARCHAR, CONVERT(DATETIME, a.sampledate), 23) AS TestDate" +
" ,isnull(a.sampleno,'') AS SampleCode" +
" ,isnull(a.specimen_name,'') AS SpecimenName" +
" ,a.pat_no AS TreatId" +
" ,isnull(a.pat_name,'') AS PatientName" +
" ,CASE a.pat_sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex" +
" ,isnull(a.pat_agestr,'') AS Age" +
" ,isnull(a.pat_typecode,'') AS PatientType" +
" ,isnull(a.req_bedno,'') AS BedNo" +
" FROM " +
" lab_report a left JOIN" +
" lab_reportunit b ON a.rptunitid = b.rptunitid left JOIN" +
" dc_dept c ON a.req_deptno = c.deptno left JOIN" +
" dc_doctor d ON a.req_docno = d.doctorno left JOIN" +
" lab_reportunit e ON a.rptunitid = e.rptunitid" +
" WHERE " +
" a.rechk_dt is not null AND a.rechk_user IS NOT NULL AND a.pat_no = ?" ;
" a.reportid AS ID" +
" ,RTRIM(b.rptunitname) AS ReportName" +
" ,CASE e.resultclass WHEN '细菌' THEN '细菌报告单' ELSE '基本报告单' END AS ReportType" +
" ,isnull(c.deptname,'') AS ReqDeptName" +
" ,isnull(d.doctorname,'') AS ReqDoctName" +
" ,isnull(a.req_reason,'') AS ReqItemName" +
" ,isnull(a.req_dt,'') AS ReqDate" +
" ,isnull(a.report_username,'') AS Reporter" +
" ,isnull(a.report_dt,'') AS ReportDate" +
" ,CONVERT(VARCHAR, CONVERT(DATETIME, a.sampledate), 23) AS TestDate" +
" ,isnull(a.sampleno,'') AS SampleCode" +
" ,isnull(a.specimen_name,'') AS SpecimenName" +
" ,a.pat_no AS TreatId" +
" ,isnull(a.pat_name,'') AS PatientName" +
" ,CASE a.pat_sex" +
" WHEN 1 THEN '男'" +
" WHEN 2 THEN '女'" +
" ELSE ''" +
" END AS Sex" +
" ,isnull(a.pat_agestr,'') AS Age" +
" ,isnull(a.pat_typecode,'') AS PatientType" +
" ,isnull(a.req_bedno,'') AS BedNo" +
" FROM " +
" lab_report a left JOIN" +
" lab_reportunit b ON a.rptunitid = b.rptunitid left JOIN" +
" dc_dept c ON a.req_deptno = c.deptno left JOIN" +
" dc_doctor d ON a.req_docno = d.doctorno left JOIN" +
" lab_reportunit e ON a.rptunitid = e.rptunitid" +
" WHERE " +
" a.rechk_dt is not null AND a.rechk_user IS NOT NULL AND pat_typecode IN " + reportPatTypeCode + " AND a.pat_no = ?" ;
// pat_typeCode[1、2门诊;3住院;4:体检]
return LisDB . select ( sql , XBDLisReport . class , ps - > {
ps . setString ( 1 , treatId ) ;
} ) ;
@ -490,7 +502,7 @@ public class XBDLisDao {
" dc_dept c ON a.req_deptno = c.deptno left JOIN" +
" dc_doctor d ON a.req_docno = d.doctorno left JOIN" +
" lab_rptunit e ON a.rptunitid = e.rptunitid left join" +
" secsysuser f on a.report_user = f.userno " +
" secsysuser f on a.report_user = f.userno " +
" WHERE " +
" a.rechk_dt is not null AND a.rechk_user IS NOT NULL AND a.pat_no = ?" ;
return LisDB . select ( sql , XBDLisReport . class , ps - > {
@ -500,30 +512,30 @@ public class XBDLisDao {
public List < XBDLisResult > getResult4RM ( int reportId ) {
String sql = "SELECT" +
" a.rpt_itemcode AS ReportItemCode" +
" ,c.rpt_itemname AS ReportItemName" +
" ,a.result_str AS Result" +
" ,a.result_unit AS Unit" +
" ,a.result_ref AS Range" +
" ,CAST(CASE RTRIM(CASE WHEN a.result_flag IS NULL AND RTRIM(a.result_str) = '阴性' THEN 'N' WHEN a.result_flag IS NULL AND RTRIM(a.result_str) = '未检出' THEN 'M' ELSE a.result_flag END) "
+
" WHEN 'H' THEN '↑'" +
" WHEN 'L' THEN '↓'" +
" WHEN 'P' THEN '阳性'" +
" WHEN 'Q' THEN '弱阳性'" +
" WHEN 'N' THEN '阴性'" +
" WHEN 'M' THEN ''" +
" ELSE RTRIM(a.result_flag) END AS VARCHAR) AS UnusualFlag --异常标志 H偏高、L偏低、P阳性、Q弱阳性、N阴性、E错误、M正常\n"
+
" ,'' AS InsCode" +
" ,b.Seq" +
" FROM " +
" dbo.lab_result a LEFT JOIN" +
" lab_rptunit_item b ON a.rptunitid = b.rptunitid AND a.rpt_itemid = b.rpt_itemid LEFT JOIN"
+
" dbo.lab_rptitem c ON a.rpt_itemid = c.rpt_itemid" +
" WHERE " +
" reportid = ? ORDER BY b.seq" ;
" a.rpt_itemcode AS ReportItemCode" +
" ,c.rpt_itemname AS ReportItemName" +
" ,a.result_str AS Result" +
" ,a.result_unit AS Unit" +
" ,a.result_ref AS Range" +
" ,CAST(CASE RTRIM(CASE WHEN a.result_flag IS NULL AND RTRIM(a.result_str) = '阴性' THEN 'N' WHEN a.result_flag IS NULL AND RTRIM(a.result_str) = '未检出' THEN 'M' ELSE a.result_flag END) "
+
" WHEN 'H' THEN '↑'" +
" WHEN 'L' THEN '↓'" +
" WHEN 'P' THEN '阳性'" +
" WHEN 'Q' THEN '弱阳性'" +
" WHEN 'N' THEN '阴性'" +
" WHEN 'M' THEN ''" +
" ELSE RTRIM(a.result_flag) END AS VARCHAR) AS UnusualFlag --异常标志 H偏高、L偏低、P阳性、Q弱阳性、N阴性、E错误、M正常\n"
+
" ,'' AS InsCode" +
" ,b.Seq" +
" FROM " +
" dbo.lab_result a LEFT JOIN" +
" lab_rptunit_item b ON a.rptunitid = b.rptunitid AND a.rpt_itemid = b.rpt_itemid LEFT JOIN"
+
" dbo.lab_rptitem c ON a.rpt_itemid = c.rpt_itemid" +
" WHERE " +
" reportid = ? and isnull(b.unprintflag, 0) <> '1' and (result_num IS NOT NULL OR ISNULL(result_unit,'') <> '' OR ISNULL(result_ref,'') <> '' OR ISNULL(result6,'') = '') ORDER BY b.seq" ;
return LisDB . select ( sql , XBDLisResult . class , ps - > {
ps . setInt ( 1 , reportId ) ;
} ) ;
@ -577,19 +589,19 @@ public class XBDLisDao {
public List < XBDLisBactResult > getBactResult4RM ( int reportId ) {
List < XBDLisBactResult > bactResults = new ArrayList < > ( ) ;
String sql = "SELECT" +
" a.resultid" +
" ,a.rpt_itemcode AS ReportItemCode" +
" ,c.rpt_itemname AS BactName" +
" ,a.result_str AS Result" +
" ,'' AS InsCode" +
" ,b.Seq" +
" FROM " +
" dbo.lab_result a LEFT JOIN" +
" lab_rptunit_item b ON a.rptunitid = b.rptunitid AND a.rpt_itemid = b.rpt_itemid LEFT JOIN\n"
+
" dbo.lab_rptitem c ON a.rpt_itemid = c.rpt_itemid" +
" WHERE" +
" reportid = ? ORDER BY b.seq" ;
" a.resultid" +
" ,a.rpt_itemcode AS ReportItemCode" +
" ,c.rpt_itemname AS BactName" +
" ,a.result_str AS Result" +
" ,'' AS InsCode" +
" ,b.Seq" +
" FROM " +
" dbo.lab_result a LEFT JOIN" +
" lab_rptunit_item b ON a.rptunitid = b.rptunitid AND a.rpt_itemid = b.rpt_itemid LEFT JOIN\n"
+
" dbo.lab_rptitem c ON a.rpt_itemid = c.rpt_itemid" +
" WHERE" +
" reportid = ? ORDER BY b.seq" ;
bactResults = LisDB . select ( sql , XBDLisBactResult . class , ps - > {
ps . setInt ( 1 , reportId ) ;
} ) ;
@ -610,17 +622,17 @@ public class XBDLisDao {
private List < XBDLisAntbResult > getAntbResult4RM ( int resultId ) {
String sql = "SELECT" +
" a.medcode AS AntbCode" +
" ,b.medname AS AntbName" +
" ,a.medresult AS Result" +
" ,a.mic AS Mic" +
" , '' AS InsCode" +
" , '' AS Seq" +
" FROM " +
" lab_resultmed a LEFT JOIN" +
" lab_med b ON a.medcode = b.medcode" +
" WHERE " +
" resultid = ?" ;
" a.medcode AS AntbCode" +
" ,b.medname AS AntbName" +
" ,a.medresult AS Result" +
" ,a.mic AS Mic" +
" , '' AS InsCode" +
" , '' AS Seq" +
" FROM " +
" lab_resultmed a LEFT JOIN" +
" lab_med b ON a.medcode = b.medcode" +
" WHERE " +
" resultid = ?" ;
return LisDB . select ( sql , XBDLisAntbResult . class , ps - > {
ps . setInt ( 1 , resultId ) ;
} ) ;