268 lines
10 KiB
C#
268 lines
10 KiB
C#
using DevExpress.XtraEditors;
|
|
using HL_FristAidPlatform_DTO;
|
|
using HL_FristAidPlatform_Public;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace HL_FristAidPlatform_ChestPain
|
|
{
|
|
public partial class UserControl_Thrombolysis : UserControl
|
|
{
|
|
public string guid;
|
|
public string fileAddress;
|
|
public byte[] patientSignature;
|
|
public byte[] doctorSignature;
|
|
public T_Service_InformedConsentDTO dto;
|
|
|
|
public string name;
|
|
public string gender;
|
|
public string age;
|
|
public string number;
|
|
public string patientGuid;
|
|
public UserControl_Thrombolysis(string _patientGuid, string _name, string _gender, string _age, string _number)
|
|
{
|
|
InitializeComponent();
|
|
patientGuid = _patientGuid;
|
|
name = _name;
|
|
gender = _gender;
|
|
age = _age;
|
|
number = _number;
|
|
}
|
|
|
|
private void UserControl_CoronaryArtery_Load(object sender, EventArgs e)
|
|
{
|
|
lbl_name.Text = name;
|
|
lbl_gender.Text = gender;
|
|
lbl_age.Text = age;
|
|
lbl_number.Text = number;
|
|
GetnformedConsentByPatientGuid();
|
|
}
|
|
|
|
public void GetnformedConsentByPatientGuid()
|
|
{
|
|
T_Service_InformedConsentDTO dto = DBHelpClass.GetDateModel<T_Service_InformedConsentDTO>(string.Format("api/service/T_Service_InformedConsent/GetnformedConsentByPatientGuid?patientGuid={0}&flag={1}", patientGuid, 5));
|
|
if (dto != null)
|
|
{
|
|
fileAddress = dto.FileAddress;
|
|
time_PatientSigningTime.TimeValue = dto.PatientSignatureTime;
|
|
time_StartTime.TimeValue = dto.StartTime;
|
|
text_PatientPhone.Text = dto.PatientPhone;
|
|
text_Relationship.Text = dto.Relationship;
|
|
time_DoctorSignatureTime.TimeValue = dto.DoctorSignatureTime;
|
|
time_PatientSigningTime.TimeValue = dto.PatientSignatureTime;
|
|
time_StartTime.TimeValue = dto.StartTime;
|
|
if (dto.PatientSignature != null)
|
|
{
|
|
string ReferringDoctorSignature = Convert.ToBase64String(dto.PatientSignature);
|
|
if (!string.IsNullOrEmpty(ReferringDoctorSignature))
|
|
{
|
|
MemoryStream ms = new MemoryStream(Convert.FromBase64String(ReferringDoctorSignature));
|
|
Image img = Image.FromStream(ms);
|
|
pic_PatientSignature.Image = img;
|
|
}
|
|
}
|
|
if (dto.DoctorSignature != null)
|
|
{
|
|
string signature = Convert.ToBase64String(dto.DoctorSignature);
|
|
if (!string.IsNullOrEmpty(signature))
|
|
{
|
|
MemoryStream ms = new MemoryStream(Convert.FromBase64String(signature));
|
|
Image img = Image.FromStream(ms);
|
|
pic_DoctorSignature.Image = img;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void pictureBox2_Click(object sender, EventArgs e)
|
|
{
|
|
SaveInformedConsent(1);
|
|
if (dto != null)
|
|
{
|
|
CoronaryArteryDTO coronary = new CoronaryArteryDTO();
|
|
ModelTools.CopyModel(coronary, dto);
|
|
coronary.Name = lbl_name.Text;
|
|
coronary.Age = lbl_age.Text;
|
|
coronary.Gender = lbl_gender.Text;
|
|
coronary.Number = lbl_number.Text;
|
|
coronary.HospitalName = Information.Hospital.Name;
|
|
Print.PrintInformedConsent(coronary, dto.Flag);
|
|
}
|
|
}
|
|
|
|
public void SaveInformedConsent(int type)
|
|
{
|
|
if (string.IsNullOrEmpty(time_StartTime.TimeValue.ToString()))
|
|
{
|
|
XtraMessageBox.Show("知情同意开始时间不能为空");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(time_DoctorSignatureTime.TimeValue.ToString()))
|
|
{
|
|
XtraMessageBox.Show("医生签字时间不能为空");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(time_PatientSigningTime.TimeValue.ToString()))
|
|
{
|
|
XtraMessageBox.Show("患者/受托人签名时间不能为空");
|
|
return;
|
|
}
|
|
dto = new T_Service_InformedConsentDTO();
|
|
List<T_Service_InformedConsentDTO> list = new List<T_Service_InformedConsentDTO>();
|
|
dto.PatientGuid = patientGuid;
|
|
dto.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
|
|
dto.FileAddress = fileAddress;
|
|
dto.Flag = 5;
|
|
dto.DoctorSignature = doctorSignature;
|
|
dto.PatientSignature = patientSignature;
|
|
dto.GUID = guid;
|
|
if (!string.IsNullOrEmpty(time_PatientSigningTime.TimeValue))
|
|
dto.PatientSignatureTime = Convert.ToDateTime(time_PatientSigningTime.TimeValue).ToString("yyyy-MM-dd HH:mm");
|
|
if (!string.IsNullOrEmpty(time_StartTime.TimeValue))
|
|
dto.StartTime = Convert.ToDateTime(time_StartTime.TimeValue).ToString("yyyy-MM-dd HH:mm");
|
|
if (!string.IsNullOrEmpty(time_DoctorSignatureTime.TimeValue))
|
|
dto.DoctorSignatureTime = Convert.ToDateTime(time_DoctorSignatureTime.TimeValue).ToString("yyyy-MM-dd HH:mm");
|
|
dto.Relationship = text_Relationship.Text;
|
|
dto.PatientPhone = text_PatientPhone.Text;
|
|
list.Add(dto);
|
|
string Url = "api/service/T_Service_InformedConsent/SaveInformedConsent";
|
|
//初始化两个工厂
|
|
ClientFactory<T_Service_InformedConsentDTO> httpClient = new HttpClientFactory<T_Service_InformedConsentDTO>();
|
|
Client<T_Service_InformedConsentDTO> client = httpClient.VisitFactory();
|
|
//访问
|
|
ListEntity<T_Service_InformedConsentDTO> t = client.Post(Url, list);
|
|
if (t.Success)
|
|
{
|
|
if (type == 0)
|
|
{
|
|
if (!string.IsNullOrEmpty(t.DataString))
|
|
{
|
|
if (t.DataString.Contains("Success"))
|
|
{
|
|
JObject jo = (JObject)JsonConvert.DeserializeObject(t.DataString);
|
|
string msg = jo["Msg"].ToString();
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
XtraMessageBox.Show(msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string msg1 = t.DataString.Replace("/", "").Replace(@"\", "").Replace("\"", "");
|
|
XtraMessageBox.Show(msg1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("保存失败");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(t.DataString))
|
|
{
|
|
if (t.DataString.Contains("Success"))
|
|
{
|
|
}
|
|
else
|
|
{
|
|
string msg1 = t.DataString.Replace("/", "").Replace(@"\", "").Replace("\"", "");
|
|
XtraMessageBox.Show(msg1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("保存失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ModelTools
|
|
{
|
|
/// <summary>
|
|
/// 模型赋值
|
|
/// </summary>
|
|
/// <param name="target">目标</param>
|
|
/// <param name="source">数据源</param>
|
|
public static void CopyModel<T, M>(T target, M source)
|
|
{
|
|
if (target != null && source != null)
|
|
{
|
|
Type targetType = target.GetType();
|
|
Type sourceType = source.GetType();
|
|
foreach (var mi in sourceType.GetProperties())
|
|
{
|
|
var des = targetType.GetProperty(mi.Name);
|
|
if (des != null)
|
|
{
|
|
des.SetValue(target, mi.GetValue(source));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
public void PrintInformedConsent()
|
|
{
|
|
SaveInformedConsent(1);
|
|
if (dto != null)
|
|
{
|
|
CoronaryArteryDTO coronary = new CoronaryArteryDTO();
|
|
ModelTools.CopyModel(coronary, dto);
|
|
coronary.Name = lbl_name.Text;
|
|
coronary.Age = lbl_age.Text;
|
|
coronary.Gender = lbl_gender.Text;
|
|
coronary.Number = lbl_number.Text;
|
|
coronary.HospitalName = Information.Hospital.Name;
|
|
Print.PrintInformedConsent(coronary, dto.Flag);
|
|
}
|
|
}
|
|
|
|
private void pictureBox4_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(fileAddress))
|
|
{
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) //windows环境下打开文件
|
|
{
|
|
Process.Start(new ProcessStartInfo("cmd", $"/c start { fileAddress}") { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden });
|
|
}
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) //Linux环境下打开文件
|
|
{
|
|
Process.Start("xdg-open", fileAddress);
|
|
}
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) //Mac环境下打开文件
|
|
{
|
|
Process.Start("open", fileAddress);
|
|
}
|
|
}
|
|
else {
|
|
XtraMessageBox.Show("未上传录音文件");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
}
|
|
}
|