using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HNWD.Pregrant.Model;
using HNWD.Pregrant.Common;
using System.Text;
using HNWD.Pregrant.DataAccess;
using HNWD.Pregrant.WebService;
namespace HNWD.Pregrant.WebService.WDHS_I
{
///
/// 房间数据
///
public partial class callingMainNurse_room : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
string DeviceID = this.GetValueByKey("deviceId");
if (string.IsNullOrEmpty(DeviceID))
{
this.ResponseDefaultError();
return;
}
if (!this.InitializeDataAccess())
{
this.ResponseDefaultError(PromptingMessage.Error_Data_Initialized);
return;
}
if (this.wd_PartInfoDataAccess.ext.messageDataList.Count < 0)
{
this.ResponseDefaultError(PromptingMessage.Error_PartInfo);
return;
}
List list_deviceInfo = wd_DeviceInfoDataAccess.ext.messageDataList.FindAll(f => f.DEVICE_TYPE == "3").OrderBy(f => f.DEVICE_ROOM_NUM).ToList();
if(list_deviceInfo == null)
{
this.ResponseDefaultError(PromptingMessage.Error_DeviceInfo);
return;
}
//若当前门口机的主机ID是入参时,或 托管主机ID
wardInformationExt wardInformationext = new wardInformationExt();
foreach (WD_DeviceInfo wd in list_deviceInfo)
{
//if (wd.DEVICE_SIP_HOSTING_ID == DeviceID || wd.DEVICE_SIP_HOSTING_ID.Contains("#" + DeviceID))
//{
wardInformation wdinformation = new wardInformation();
wdinformation.roomNumID = wd.ID;
wdinformation.roomNum = wd.DEVICE_ROOM_NUM;
wdinformation.bedNum = wd.DEVICE_BED_NUM;
wdinformation.bedName = wd.DEVICE_NAME;
wdinformation.SipID = wd.DEVICE_SIP_ID;
wdinformation.roomByname = wd.DEVICE_NAME;
//if (wd.DEVICE_SIP_HOSTING_ID == DeviceID)
//{
// wdinformation.trusteeshipState = "0";
//}
//else
//{
wdinformation.trusteeshipState = "1";
//}
//===================================================找到对应门口机下属的分机
List list_bedInfo = wd_DeviceInfoDataAccess.ext.messageDataList.FindAll(f=>f.DEVICE_ROOM_ID == wd.ID);
foreach(WD_DeviceInfo wd_beddevice in list_bedInfo)
{
//if(wd_beddevice.DEVICE_SIP_HOSTING_ID.Contains(DeviceID) || wd_beddevice.DEVICE_SIP_HOSTING_ID.Contains("#" + DeviceID))
//{
bedInfo bedinfo = new bedInfo();
bedinfo.bedID = wd_beddevice.ID;
bedinfo.bedNum = wd_beddevice.DEVICE_BED_NUM;
bedinfo.bedName = wd_beddevice.DEVICE_BED_NAME;
bedinfo.SipID = wd_beddevice.DEVICE_SIP_ID;
bedinfo.roomNumID = wd.ID;
bedinfo.roomByname = wd_beddevice.DEVICE_BED_NAME;
WD_PatientInfo wd_PatientInfo = wd_PatientInfoDataAccess.ext.messageDataList.Find(f=>f.ID == wd_beddevice.DEVICE_HUMAN_ID);
if (wd_PatientInfo == null)
{
bedinfo.PatientID = "0";
bedinfo.patientName = "0";
bedinfo.PatientAge = "0";
bedinfo.patientGender = "0";
bedinfo.admissionTime = "0";
bedinfo.attendingDoctor = "0";
bedinfo.nurseInCharge = "0";
bedinfo.Condition = "0";
bedinfo.gradeLevel = "0";
bedinfo.DosageLevel = "0";
bedinfo.InsulateLevel = "0";
bedinfo.AllerayLevel = "0";
}
else
{
bedinfo.PatientID = wd_PatientInfo.PATIENT_ID;
bedinfo.patientName = wd_PatientInfo.PATIENT_NAME;
bedinfo.PatientAge = wd_PatientInfo.PATIENT_AGE + wd_PatientInfo.PATIENT_AGE_UNIT;
bedinfo.patientGender = wd_PatientInfo.PATIENT_SEX;
bedinfo.admissionTime = wd_PatientInfo.PATIENT_INDATE;
bedinfo.babyName = wd_PatientInfo.PATIENT_BABYNAME;
bedinfo.babySex = wd_PatientInfo.PATIENT_BABYSEX;
bedinfo.name = wd_PatientInfo.PATIENT_NAME;
bedinfo.avoidCertainFood = wd_PatientInfo.PATIENT_ILLNESS;
List listUrgeInfo = wd_UrgeInfoDataAccess.ext.messageDataList.FindAll(f => f.URGE_PATIENT_ID == wd_PatientInfo.ID);
if (listUrgeInfo == null || listUrgeInfo.Count == 0)
{
}
else
{
listUrgeInfo.ForEach(f => bedinfo.carefulMatter.Add(new CarefulMatter() { item = f.URGE_VALUE }));
}
bedinfo.roomByname = wd_beddevice.DEVICE_BED_NAME;
WD_StaffInfo wd_StaffDoc = wd_StaffInfoDataAccess.ext.messageDataList.Find(f => f.ID == wd_PatientInfo.PATIENT_DOCTOR_ID);
if (wd_StaffDoc == null)
{
bedinfo.attendingDoctor = "未知";
}
else
{
bedinfo.attendingDoctor = wd_StaffDoc.STAFF_NAME;
}
WD_StaffInfo wd_StaffNur = wd_StaffInfoDataAccess.ext.messageDataList.Find(f => f.ID == wd_PatientInfo.PATIENT_NURSE_ID);
if (wd_StaffNur == null)
{
bedinfo.nurseInCharge = "未知";
}
else
{
bedinfo.nurseInCharge = wd_StaffNur.STAFF_NAME;
}
bedinfo.Condition = wd_PatientInfo.PATIENT_ILLNESS;
WD_NurseCfgInfo wd_NurseCfg0 = wd_NurseCfgInfoDataAccess.ext.messageDataList.Find(f => f.ID == wd_PatientInfo.PATIENT_NURSE_LEVEL0);
if (wd_NurseCfg0 == null)
{
bedinfo.gradeLevel = "未知";
}
else
{
bedinfo.gradeLevel = wd_NurseCfg0.NURSECFG_VALUE;
bedinfo.gradeNurse = wd_NurseCfg0.NURSECFG_NAME;
}
WD_NurseCfgInfo wd_NurseCfg1 = wd_NurseCfgInfoDataAccess.ext.messageDataList.Find(f => f.ID == wd_PatientInfo.PATIENT_NURSE_LEVEL1);
if (wd_NurseCfg1 == null)
{
bedinfo.DietLevel = "未知";
}
else
{
bedinfo.DietLevel = wd_NurseCfg1.NURSECFG_NAME;
}
WD_NurseCfgInfo wd_NurseCfg2 = wd_NurseCfgInfoDataAccess.ext.messageDataList.Find(f => f.ID == wd_PatientInfo.PATIENT_NURSE_LEVEL2);
if (wd_NurseCfg2 == null)
{
bedinfo.DosageLevel = "未知";
}
else
{
bedinfo.DosageLevel = wd_NurseCfg2.NURSECFG_NAME;
}
WD_NurseCfgInfo wd_NurseCfg3 = wd_NurseCfgInfoDataAccess.ext.messageDataList.Find(f => f.ID == wd_PatientInfo.PATIENT_NURSE_LEVEL3);
if (wd_NurseCfg3 == null)
{
bedinfo.InsulateLevel = "未知";
}
else
{
bedinfo.InsulateLevel = wd_NurseCfg3.NURSECFG_NAME;
}
WD_NurseCfgInfo wd_NurseCfg4 = wd_NurseCfgInfoDataAccess.ext.messageDataList.Find(f => f.ID == wd_PatientInfo.PATIENT_NURSE_LEVEL4);
if (wd_NurseCfg4 == null)
{
bedinfo.AllerayLevel = "未知";
}
else
{
bedinfo.AllerayLevel = wd_NurseCfg4.NURSECFG_NAME;
}
}
wdinformation.sickbedInformationList.Add(bedinfo);
}
//}
wardInformationext.wardInformationList.Add(wdinformation);
//}
}
Response.Write(JsonHelper.SerializeWithSuffix(wardInformationext));
WD_SysLogInfo wd_SysLogInfo = new WD_SysLogInfo();
wd_SysLogInfo.LOG_TYPE = "3";
wd_SysLogInfo.LOG_SOURCE = "主机";
wd_SysLogInfo.LOG_CONTENT = "下载了所有门口机和分机的设备数据";
this.DataBaseLog(wd_SysLogInfo);
}
}
}