Esempio n. 1
0
        /// <summary>
        /// 发送配药指令
        /// </summary>
        /// <param name="id"></param>
        private void SendDispensing(int id)
        {
            Patient    patient    = MedicineLogic.QueryPatientById(id);
            Device     device     = MedicineLogic.QueryDeviceById(patient.DeviceId);
            Dispensing dispensing = MedicineLogic.QueryFirstDispensingByPatientId(id);

            if (dispensing == null || dispensing.Id <= 0)
            {
                return;
            }
            byte[] zero     = { 0x00 };
            byte[] deviceNo = device.DeviceNo <= 255 ? zero.Concat(Common.IntToHexByte(device.DeviceNo)).ToArray() : Common.IntToHexByte(device.DeviceNo);
            byte[] funcNo   = { 0x02 };
            byte[] data     = { };
            byte[] open     = { 0x31 };
            byte[] close    = { 0x30 };
            byte[] byteflg  = dispensing.Id > 255 ? Common.IntToHexByte(dispensing.Id) : zero.Concat(Common.IntToHexByte(dispensing.Id)).ToArray();
            data = Enum.GetValues(typeof(TakeTime)).Cast <object>().Aggregate(data, (current, i) => current.Concat((Convert.ToInt32(dispensing.TakeTime) & i.GetHashCode()) != 0 ? open : close).ToArray());
            data = deviceNo.Concat(funcNo).Concat(data).Concat(byteflg).ToArray();
            AutoSendData(device.DeviceIP, data, byteflg);
        }
Esempio n. 2
0
        /// <summary>
        /// 单元格点击事件,查询病人信息并显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvPatient_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex <= -1 || e.RowIndex <= -1)
            {
                return;
            }
            int     id      = Convert.ToInt32(dgvPatient.Rows[e.RowIndex].Cells[0].Value);
            Patient patient = MedicineLogic.QueryPatientById(id);
            Device  device  = MedicineLogic.QueryDeviceById(id);

            labId.Text      = id.ToString();
            labName.Text    = patient.Name;
            labSex.Text     = patient.Sex.ToString();
            labAge.Text     = patient.Age.ToString();
            labHeight.Text  = patient.Height.ToString("0.##");
            labWeight.Text  = patient.Weight.ToString("0.##");
            labIllness.Text = patient.Illness;
            labWardNo.Text  = patient.WardNo;
            labBedNo.Text   = patient.BedNo;

            labDeviceNo.Text = device.DeviceNo.ToString();

            txtMorningHour.Text   = patient.MorningHour == -1 ? string.Empty : patient.MorningHour.ToString();
            txtMorningMinute.Text = patient.MorningMinute == -1 ? string.Empty : patient.MorningMinute.ToString();
            txtNoonHour.Text      = patient.NoonHour == -1 ? string.Empty : patient.NoonHour.ToString();
            txtnoonMinute.Text    = patient.NoonMinute == -1 ? string.Empty : patient.NoonMinute.ToString();
            txtEveningHour.Text   = patient.EveningHour == -1 ? string.Empty : patient.EveningHour.ToString();
            txtEveningMinute.Text = patient.EveningMinute == -1 ? string.Empty : patient.EveningMinute.ToString();
            txtAddHour.Text       = patient.AdditionalHour == -1 ? string.Empty : patient.AdditionalHour.ToString();
            txtAddMinute.Text     = patient.AdditionalMinute == -1 ? string.Empty : patient.AdditionalMinute.ToString();

            picMorningStatus.Image = GetLight(patient.MorningStatus);
            picNoonStatus.Image    = GetLight(patient.NoonStatus);
            picEveningStatus.Image = GetLight(patient.EveningStatus);
            picAddStatus.Image     = GetLight(patient.AdditionalStatus);

            ShowDispensing(id);
        }
Esempio n. 3
0
        /// <summary>
        /// 发送服药时间
        /// </summary>
        /// <param name="info">服药时间信息</param>
        private void SendTakeTime(TakeTimeInfo info)
        {
            Device device = MedicineLogic.QueryDeviceById(info.Id);

            byte[] zero          = { 0x00 };
            byte[] nodata        = { 0xff };
            byte[] deviceNo      = device.DeviceNo <= 255 ? zero.Concat(Common.IntToHexByte(device.DeviceNo)).ToArray() : Common.IntToHexByte(device.DeviceNo);
            byte[] funcNo        = { 0x05 };
            byte[] morningHour   = info.MorningHour == -1 ? nodata : Common.IntToHexByte(info.MorningHour);
            byte[] morningMinute = info.MorningMinute == -1 ? nodata : Common.IntToHexByte(info.MorningMinute);

            byte[] noonHour   = info.NoonHour == -1 ? nodata : Common.IntToHexByte(info.NoonHour);
            byte[] noonMinute = info.NoonMinute == -1 ? nodata : Common.IntToHexByte(info.NoonMinute);

            byte[] eveningHour   = info.EveningHour == -1 ? nodata : Common.IntToHexByte(info.EveningHour);
            byte[] eveningMinute = info.EveningMinute == -1 ? nodata : Common.IntToHexByte(info.EveningMinute);

            byte[] addHour   = info.AdditionalHour == -1 ? nodata : Common.IntToHexByte(info.AdditionalHour);
            byte[] addMinute = info.AdditionalMinute == -1 ? nodata : Common.IntToHexByte(info.AdditionalMinute);

            byte[] byteflg = Common.BuildFlg();

            byte[] data =
                deviceNo.Concat(funcNo)
                .Concat(morningHour)
                .Concat(morningMinute)
                .Concat(noonHour)
                .Concat(noonMinute)
                .Concat(eveningHour)
                .Concat(eveningMinute)
                .Concat(addHour)
                .Concat(addMinute)
                .Concat(byteflg)
                .ToArray();
            AutoSendData(device.DeviceIP, data, byteflg);
        }