StableVersion4.3/HL_FristAidPlatform_Apoplexy/Page/UserControl_IntracranialAne...

252 lines
10 KiB
C#
Raw Normal View History

2024-03-11 09:47:34 +08:00
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.Drawing;
using System.IO;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Apoplexy
{
public partial class UserControl_IntracranialAneurysm : UserControl
{
public string guid;
public string fileAddress;
public byte[] patientSignature;
public byte[] doctorSignature;
public string name;
public string gender;
public int age;
public string number;
public string patientGuid;
public string diagnose;
public string imageFile;
public T_Service_InformedConsentDTO dto;
public UserControl_IntracranialAneurysm(string _patientGuid, string _name, string _gender, int _age, string _number, string _diagnose,string _fileAddress)
{
InitializeComponent();
patientGuid = _patientGuid;
name = _name;
gender = _gender;
age = _age;
number = _number;
diagnose = _diagnose;
fileAddress = _fileAddress;
}
private void UserControl_CraniotomyInformedConsent_Load(object sender, EventArgs e)
{
lbl_name.Text = name;
if (gender == "0")
lbl_gender.Text = "未知";
if (gender == "1")
lbl_gender.Text = "男";
if (gender == "2")
lbl_gender.Text = "女";
lbl_age.Text = age.ToString();
lbl_number.Text = number;
labelControl12.Text = diagnose;
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, 6));
if (dto != null)
{
fileAddress = dto.FileAddress;
time_PatientSigningTime.TimeValue = dto.PatientSignatureTime;
//text_PatientPhone.Text = dto.PatientPhone;
text_Relationship.Text = dto.Relationship;
time_DoctorSignatureTime.TimeValue = dto.DoctorSignatureTime;
time_PatientSigningTime.TimeValue = dto.PatientSignatureTime;
//comboBox_Agree.Text = dto.Agree;
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;
}
}
}
}
public void SaveInformedConsent(int type)
{
dto = new T_Service_InformedConsentDTO();
List<T_Service_InformedConsentDTO> list = new List<T_Service_InformedConsentDTO>();
dto.FileAddress = fileAddress;
dto.DoctorSignature = doctorSignature;
dto.PatientSignature = patientSignature;
dto.PatientGuid = patientGuid;
if (!string.IsNullOrEmpty(time_PatientSigningTime.TimeValue))
{
dto.PatientSignatureTime = time_PatientSigningTime.TimeValue != null ? Convert.ToDateTime(time_PatientSigningTime.TimeValue).ToString("yyyy-MM-dd HH:mm") : "";
}
if (!string.IsNullOrEmpty(time_DoctorSignatureTime.TimeValue))
{
dto.DoctorSignatureTime = time_DoctorSignatureTime.TimeValue != null ? Convert.ToDateTime(time_DoctorSignatureTime.TimeValue).ToString("yyyy-MM-dd HH:mm") : "";
}
dto.Relationship = text_Relationship.Text;
if (!string.IsNullOrEmpty(imageFile))
{
dto.InformedConsentImg = Convert.FromBase64String(imageFile);
lbl_imageMessage.Visible = false;
hyperlinklbl_Image.Visible = true;
}
//dto.Agree = comboBox_Agree.Text;
dto.Flag = 6;
//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 void PrintIntracranialAneurysm()
{
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;
coronary.Diagnosis = diagnose;
Print.PrintInformedConsent(coronary, dto.Flag);
}
public class ModelTools
{
/// <summary>
/// 模型赋值
/// </summary>
/// <param name="target">目标</param>
/// <param name="source">数据源</param>
public static void CopyModel<T, M>(T target, M source)
{
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));
}
}
}
}
private void simpleButton1_Click_1(object sender, EventArgs e)
{
#region
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Image Files(*.JPG;*.PNG;*.JPEG;;*.BMP)|*.JPG;*.PNG;;*.BMP;*.JPEG";
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
int Config109 = PublicClass.ToInt32(PublicClassForDataBase.Config109, 5);
string FileName = openFileDialog.FileName;
if (PublicClass.GetFileSize(FileName) <= Config109)
{
FileInfo file = new FileInfo(FileName);
Bitmap bitmap = new Bitmap(FileName);
imageFile = file.Extension;
if (imageFile.ToLower() == ".png")
{
imageFile = PublicClass.Png2String(bitmap);
}
else
{
imageFile = PublicClass.Jpeg2String(bitmap);
}
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "上传知情同意书:\r\n" + ex);
}
}
#endregion
}
private void hyperlinklbl_Image_Click_1(object sender, EventArgs e)
{
byte[] image = Convert.FromBase64String(imageFile);
HL_FristAidPlatform_MultiSystemPublic.Form_ImageShow frm = new HL_FristAidPlatform_MultiSystemPublic.Form_ImageShow(image);
frm.ShowDialog();
}
}
}