parent
25b3d88dc8
commit
583f1abc8b
12 changed files with 446 additions and 18 deletions
@ -0,0 +1,92 @@ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Data; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using PEIS.Utils; |
||||
|
||||
namespace PEIS.Model |
||||
{ |
||||
/// <summary> |
||||
/// 专病信息查询(HIS数据库视图 v_flup_zbxx) |
||||
/// </summary> |
||||
public class ZbxxInfo |
||||
{ |
||||
public long PatientID { get; set; } |
||||
public string PatientName { get; set; } |
||||
public string ChronicName { get; set; } |
||||
public string PersonID { get; set; } |
||||
|
||||
/// <summary> |
||||
/// 根据身份证号查询专病信息(直接用DataTable读取,避免DAO泛型映射问题) |
||||
/// </summary> |
||||
/// <param name="cardNo">身份证号</param> |
||||
/// <returns>专病信息列表</returns> |
||||
public static List<ZbxxInfo> GetByCardNo(string cardNo) |
||||
{ |
||||
var list = new List<ZbxxInfo>(); |
||||
if (string.IsNullOrEmpty(cardNo)) return list; |
||||
|
||||
try |
||||
{ |
||||
var sql = string.Format( |
||||
"SELECT PatientID, PatientName, ChronicName, PersonID FROM [his].[hisdata].[dbo].[v_flup_zbxx] WHERE PersonID = '{0}' AND ChronicType <> '已作废' ", |
||||
cardNo.Replace("'", "''")); |
||||
|
||||
DataTable dt = DAOHelp.GetDataBySQL(sql); |
||||
if (dt == null || dt.Rows.Count == 0) return list; |
||||
|
||||
foreach (DataRow row in dt.Rows) |
||||
{ |
||||
var item = new ZbxxInfo(); |
||||
if (dt.Columns.Contains("PatientID") && row["PatientID"] != DBNull.Value) |
||||
item.PatientID = Convert.ToInt64(row["PatientID"]); |
||||
if (dt.Columns.Contains("PatientName") && row["PatientName"] != DBNull.Value) |
||||
item.PatientName = Convert.ToString(row["PatientName"]); |
||||
if (dt.Columns.Contains("ChronicName") && row["ChronicName"] != DBNull.Value) |
||||
item.ChronicName = Convert.ToString(row["ChronicName"]); |
||||
if (dt.Columns.Contains("PersonID") && row["PersonID"] != DBNull.Value) |
||||
item.PersonID = Convert.ToString(row["PersonID"]); |
||||
list.Add(item); |
||||
} |
||||
} |
||||
catch { } |
||||
|
||||
return list; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// 根据身份证号获取专病信息摘要(病名顿号连接) |
||||
/// </summary> |
||||
/// <param name="cardNo">身份证号</param> |
||||
/// <returns>专病信息对象,含PatientID和病名文本;无数据返回null</returns> |
||||
public static ZbxxInfo GetSummaryByCardNo(string cardNo) |
||||
{ |
||||
try |
||||
{ |
||||
var list = GetByCardNo(cardNo); |
||||
if (list == null || list.Count == 0) return null; |
||||
|
||||
var chronicNames = list |
||||
.Where(x => !string.IsNullOrEmpty(x.ChronicName)) |
||||
.Select(x => x.ChronicName) |
||||
.Distinct() |
||||
.ToList(); |
||||
|
||||
if (chronicNames.Count == 0) return null; |
||||
|
||||
return new ZbxxInfo |
||||
{ |
||||
PatientID = list.First().PatientID, |
||||
PatientName = list.First().PatientName, |
||||
PersonID = list.First().PersonID, |
||||
ChronicName = string.Join("、", chronicNames) |
||||
}; |
||||
} |
||||
catch |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue