123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- using System;
- using Dapper;
- using HNWD.Pregrant.Model;
- using System.Collections.Generic;
- using System.Text;
- namespace HNWD.Pregrant.DataAccess
- {
- public class WD_PatientInfoDataAccess : GenericDataAccess<WD_PatientInfo>
- {
- private WD_PatientInfo wd_DeviceInfo = null;
- public WD_PatientInfoExt ext = new WD_PatientInfoExt();
- private readonly static WD_PatientInfoDataAccess wd_PatientInfoDataAccess = new WD_PatientInfoDataAccess(null);
- private readonly static object lockobj = new object();
- public static WD_PatientInfoDataAccess GetInstance()
- {
- lock (lockobj)
- {
- return wd_PatientInfoDataAccess;
- }
- }
- private WD_PatientInfoDataAccess(WD_PatientInfo wd_PatientInfo)
- {
- this.wd_DeviceInfo = wd_PatientInfo;
- }
- private string webPath = string.Empty;
- public WD_PatientInfoDataAccess(string webPath,string r2)
- {
- this.webPath = webPath;
- }
- public List<WD_PatientInfo> Query()
- {
- string strSql = " select {0} from [WD_PatientInfo] where [ID]=" + this.wd_DeviceInfo.ID;
- ext.messageDataList = this.Query(strSql, new WD_PatientInfo());
- ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
- ext.messageDataList.ForEach(f => f.Code = this.Code);
- ext.messageDataList.ForEach(f => f.Message = this.Message);
- ext.messageDataList.ForEach(f => f.Rows = this.Rows);
- ext.bSuccess = this.bSuccess;
- ext.Code = this.Code;
- ext.Message = this.Message;
- ext.Rows = this.Rows;
- this.SetSexAndAge(ext);
- return ext.messageDataList;
- }
- public List<WD_PatientInfo> QueryAll()
- {
- string strSql = " select DATEDIFF(day,getdate(),[PATIENT_DATETIME]) DiffDays , {0} from [WD_PatientInfo] ";
- ext.messageDataList = this.Query(strSql, new WD_PatientInfo());
- ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
- ext.messageDataList.ForEach(f => f.Code = this.Code);
- ext.messageDataList.ForEach(f => f.Message = this.Message);
- ext.messageDataList.ForEach(f => f.Rows = this.Rows);
- ext.bSuccess = this.bSuccess;
- ext.Code = this.Code;
- ext.Message = this.Message;
- ext.Rows = this.Rows;
- this.SetSexAndAge(ext);
- return ext.messageDataList;
- }
- public List<WD_PatientInfo> QueryNativeAll()
- {
- string strSql = " select DATEDIFF(day,getdate(),[PATIENT_DATETIME]) DiffDays , {0} from [WD_PatientInfo] ";
- ext.messageDataList = this.Query(strSql, new WD_PatientInfo());
- ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
- ext.messageDataList.ForEach(f => f.Code = this.Code);
- ext.messageDataList.ForEach(f => f.Message = this.Message);
- ext.messageDataList.ForEach(f => f.Rows = this.Rows);
- ext.bSuccess = this.bSuccess;
- ext.Code = this.Code;
- ext.Message = this.Message;
- ext.Rows = this.Rows;
- return ext.messageDataList;
- }
- private void SetSexAndAge(WD_PatientInfoExt ex)
- {
- foreach (WD_PatientInfo wd in ex.messageDataList)
- {
- if (wd.PATIENT_SEX == "1")
- {
- wd.PATIENT_SEX = "男";
- }
- else if (wd.PATIENT_SEX == "2")
- {
- wd.PATIENT_SEX = "女";
- }
- else
- {
- wd.PATIENT_SEX = "未知";
- }
- if (wd.PATIENT_BABYSEX == "1")
- {
- wd.PATIENT_BABYSEX = "男";
- }
- else if (wd.PATIENT_BABYSEX == "2")
- {
- wd.PATIENT_BABYSEX = "女";
- }
- else
- {
- wd.PATIENT_BABYSEX = "未知";
- }
- if (wd.PATIENT_AGE_UNIT == "Y")
- {
- wd.PATIENT_AGE_UNIT = "岁";
- }
- else if (wd.PATIENT_AGE_UNIT == "M")
- {
- wd.PATIENT_AGE_UNIT = "月";
- }
- else if (wd.PATIENT_AGE_UNIT == "D")
- {
- wd.PATIENT_AGE_UNIT = "周";
- }
- else
- {
- wd.PATIENT_AGE_UNIT = "岁";
- }
- }
- }
- private WD_PatientInfoExt QueryMAXID()
- {
- string strSql = " select top 1 * from [WD_PatientInfo] order by ID desc ";
- ext.messageDataList = this.Query(strSql, new WD_PatientInfo());
- ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
- ext.messageDataList.ForEach(f => f.Code = this.Code);
- ext.messageDataList.ForEach(f => f.Message = this.Message);
- ext.messageDataList.ForEach(f => f.Rows = this.Rows);
- ext.bSuccess = this.bSuccess;
- ext.Code = this.Code;
- ext.Message = this.Message;
- ext.Rows = this.Rows;
- return ext;
- }
- public void Business(List<WD_PatientInfo> il, List<WD_PatientInfo> ul, List<WD_PatientInfo> dl)
- {
- StringBuilder sb_itemp = new StringBuilder();
- sb_itemp.Append(" INSERT INTO [WD_PatientInfo] ( ");
- sb_itemp.Append(" [PATIENT_PHOC_ID],[PATIENT_ID],[PATIENT_CARD_ID],[PATIENT_NAME],[PATIENT_NAME_PY], ");
- sb_itemp.Append(" [PATIENT_SEX],[PATIENT_AGE],[PATIENT_AGE_UNIT],[PATIENT_BIRTHDAY],[PATIENT_IDCARD], ");
- sb_itemp.Append(" [PATIENT_ADDRESS],[PATIENT_MOBLIE],[PATIENT_INDATE],[PATIENT_DOCTOR_ID],[PATIENT_NURSE_ID], ");
- sb_itemp.Append(" [PATIENT_WORKERS_ID],[PATIENT_NURSE_LEVEL0],[PATIENT_NURSE_LEVEL1],[PATIENT_NURSE_LEVEL2],[PATIENT_NURSE_LEVEL3], ");
- sb_itemp.Append(" [PATIENT_NURSE_LEVEL4],[PATIENT_INTIMES],[PATIENT_STATUS],[PATIENT_ILLNESS],[PATIENT_BABYNAME], ");
- sb_itemp.Append(" [PATIENT_BABYSEX],[PATIENT_DATETIME] ");
- sb_itemp.Append(" ) values (");
- sb_itemp.Append(" '{0}','{1}','{2}','{3}','{4}', ");
- sb_itemp.Append(" '{5}','{6}','{7}','{8}','{9}', ");
- sb_itemp.Append(" '{10}','{11}','{12}','{13}','{14}', ");
- sb_itemp.Append(" '{15}','{16}','{17}','{18}','{19}', ");
- sb_itemp.Append(" '{20}','{21}','{22}','{23}','{24}', ");
- sb_itemp.Append(" '{25}','{26}' ");
-
- StringBuilder strSql_utemp = new StringBuilder();
- strSql_utemp.Append(" Update WD_PatientInfo set ");
- strSql_utemp.Append(" PATIENT_PHOC_ID = '{0}' , PATIENT_ID = '{1}' , PATIENT_CARD_ID = '{2}' , PATIENT_NAME = '{3}' , PATIENT_NAME_PY = '{4}', ");
- strSql_utemp.Append(" PATIENT_SEX = '{5}' , PATIENT_AGE = '{6}' , PATIENT_AGE_UNIT = '{7}' , PATIENT_BIRTHDAY = '{8}' , PATIENT_IDCARD = '{9}', ");
- strSql_utemp.Append(" PATIENT_ADDRESS = '{10}' , PATIENT_MOBLIE = '{11}' , PATIENT_INDATE = '{12}' , PATIENT_DOCTOR_ID = '{13}' , PATIENT_NURSE_ID = '{14}', ");
- strSql_utemp.Append(" PATIENT_WORKERS_ID = '{15}' , PATIENT_NURSE_LEVEL0 = '{16}' , PATIENT_NURSE_LEVEL1 = '{17}' , PATIENT_NURSE_LEVEL2 = '{18}' , PATIENT_NURSE_LEVEL3 = '{19}', ");
- strSql_utemp.Append(" PATIENT_NURSE_LEVEL4 = '{20}' , PATIENT_INTIMES = '{21}' , PATIENT_STATUS = '{22}' , PATIENT_ILLNESS = '{23}' , PATIENT_BABYNAME = '{24}', ");
- strSql_utemp.Append(" PATIENT_BABYSEX = '{25}' , PATIENT_DATETIME = '{26}' ");
- strSql_utemp.Append(" where ID = '{27}' ");
- StringBuilder strSql_dtemp = new StringBuilder();
- strSql_dtemp.Append(" Update WD_PatientInfo set [PATIENT_STATUS]='3' where [ID]= '{0}' ");
- StringBuilder sb_append = new StringBuilder();
-
- StringBuilder sb_i = new StringBuilder();
- foreach (WD_PatientInfo wd in il)
- {
- sb_itemp.AppendFormat(sb_itemp.ToString(),
- wd.PATIENT_PHOC_ID,
- wd.PATIENT_ID,
- wd.PATIENT_CARD_ID,
- wd.PATIENT_NAME,
- wd.PATIENT_NAME_PY,
- wd.PATIENT_SEX,
- wd.PATIENT_AGE,
- wd.PATIENT_AGE_UNIT,
- wd.PATIENT_BIRTHDAY,
- wd.PATIENT_IDCARD,
- wd.PATIENT_ADDRESS,
- wd.PATIENT_MOBLIE,
- wd.PATIENT_INDATE,
- wd.PATIENT_DOCTOR_ID,
- wd.PATIENT_NURSE_ID,
- wd.PATIENT_WORKERS_ID,
- wd.PATIENT_NURSE_LEVEL0,
- wd.PATIENT_NURSE_LEVEL1,
- wd.PATIENT_NURSE_LEVEL2,
- wd.PATIENT_NURSE_LEVEL3,
- wd.PATIENT_NURSE_LEVEL4,
- wd.PATIENT_INTIMES,
- wd.PATIENT_STATUS,
- wd.PATIENT_ILLNESS,
- wd.PATIENT_BABYNAME,
- wd.PATIENT_BABYSEX,
- wd.PATIENT_DATETIME
- );
-
-
- WD_PatientInfoExt wd_extmax = this.QueryMAXID();
- if(wd_extmax.bSuccess && wd_extmax.Rows == 0)
- {
- wd.ID = "1";
- }
- else
- {
- wd.ID = wd_extmax.messageDataList[0].ID ;
- }
- //有问题
- clsOpenSIPSAccount clsopenSIPSAccount = new clsOpenSIPSAccount(this.webPath);
- WD_DeviceInfo wd_DeviceInfo = new WD_DeviceInfo();
- wd_DeviceInfo.DEVICE_SIP_ID = clsopenSIPSAccount.GetSipAccount("4", wd.ID);
- wd_DeviceInfo.DEVICE_SIP_PASSWORD = wd_DeviceInfo.DEVICE_SIP_ID;
- //wd_DeviceInfo.DEVICE_SIP_STATUS = "1";
- if(clsopenSIPSAccount.OpenSIPs_ConnectDefault())
- {
- if(!clsopenSIPSAccount.OpenSIPs_AccountCheck(wd_DeviceInfo.DEVICE_SIP_ID, true))
- {
- clsopenSIPSAccount.OpenSIPs_AccountAdd(wd_DeviceInfo.DEVICE_SIP_ID, wd_DeviceInfo.DEVICE_SIP_PASSWORD);
- }
- }
- clsopenSIPSAccount.OpenSIPs_Close();
-
- sb_append.AppendFormat(" update [WD_DeviceInfo] SET [DEVICE_HUMAN_TYPE]='1', ");
- sb_append.AppendFormat(" [DEVICE_HUMAN_ID]='{0}',[DEVICE_SIP_IP]='{1}',[DEVICE_SIP_ID]='{2}'," , wd.ID ,clsopenSIPSAccount.GetSIPSerIP , wd_DeviceInfo.DEVICE_SIP_ID);
- //sb_append.AppendFormat(" [DEVICE_SIP_PASSWORD]='{0}',[DEVICE_SIP_STATUS]='{1}' where [ID] = '{0}' " , wd_DeviceInfo.DEVICE_SIP_PASSWORD ,wd_DeviceInfo.DEVICE_SIP_STATUS , wd.BEDID);
- }
- StringBuilder sb_u = new StringBuilder();
- foreach (WD_PatientInfo wd in ul)
- {
- sb_u.AppendFormat(strSql_utemp.ToString(),
- wd.PATIENT_PHOC_ID,
- wd.PATIENT_ID,
- wd.PATIENT_CARD_ID,
- wd.PATIENT_NAME,
- wd.PATIENT_NAME_PY,
- wd.PATIENT_SEX,
- wd.PATIENT_AGE,
- wd.PATIENT_AGE_UNIT,
- wd.PATIENT_BIRTHDAY,
- wd.PATIENT_IDCARD,
- wd.PATIENT_ADDRESS,
- wd.PATIENT_MOBLIE,
- wd.PATIENT_INDATE,
- wd.PATIENT_DOCTOR_ID,
- wd.PATIENT_NURSE_ID,
- wd.PATIENT_WORKERS_ID,
- wd.PATIENT_NURSE_LEVEL0,
- wd.PATIENT_NURSE_LEVEL1,
- wd.PATIENT_NURSE_LEVEL2,
- wd.PATIENT_NURSE_LEVEL3,
- wd.PATIENT_NURSE_LEVEL4,
- wd.PATIENT_INTIMES,
- wd.PATIENT_STATUS,
- wd.PATIENT_ILLNESS,
- wd.PATIENT_BABYNAME,
- wd.PATIENT_BABYSEX,
- wd.PATIENT_DATETIME,
- wd.ID);
- }
- StringBuilder sb_d = new StringBuilder();
- foreach (WD_PatientInfo wd in dl)
- {
- sb_d.AppendFormat(strSql_dtemp.ToString(),
- wd.ID);
- sb_append.AppendFormat(" update [WD_DeviceInfo] SET [DEVICE_HUMAN_TYPE]='0', ");
- sb_append.AppendFormat(" [DEVICE_HUMAN_ID]='0',[DEVICE_SIP_IP]='',[DEVICE_SIP_ID]='',");
- sb_append.AppendFormat(" [DEVICE_SIP_PASSWORD]='',[DEVICE_SIP_STATUS]='2' where [ID] = '{0}' " , wd.BEDID);
-
- }
- this.Execute(sb_i.ToString(), sb_u.ToString(), sb_d.ToString(), sb_append.ToString());
- }
- }
- }
|