diff --git a/PEIS/Entity/ExamCareerHisInq.cs b/PEIS/Entity/ExamCareerHisInq.cs index f7a2197..a480b0a 100644 --- a/PEIS/Entity/ExamCareerHisInq.cs +++ b/PEIS/Entity/ExamCareerHisInq.cs @@ -151,4 +151,33 @@ namespace PEIS.Entity public int DispOrder { get; set; } } + + public class ECInqReportModele : ExamCareerHisInq + { + public bool SmokeState_1 { get; set; } = false; + public bool SmokeState_2 { get; set; } = false; + public bool SmokeState_3 { get; set; } = false; + public bool DrinkState_1 { get; set; } = false; + public bool DrinkState_2 { get; set; } = false; + public bool DrinkState_3 { get; set; } = false; + } + public class SymptomReportModele + { + /// + /// 症状名称 + /// + public string SMName0 { get; set; } + /// + /// 症状值 + /// + public string SMValue0 { get; set; } + /// + /// 症状名称 + /// + public string SMName1 { get; set; } + /// + /// 症状值 + /// + public string SMValue1 { get; set; } + } } diff --git a/PEIS/Model/Exam/CareerHisInqModel.cs b/PEIS/Model/Exam/CareerHisInqModel.cs index d4c1339..8279199 100644 --- a/PEIS/Model/Exam/CareerHisInqModel.cs +++ b/PEIS/Model/Exam/CareerHisInqModel.cs @@ -22,7 +22,7 @@ namespace PEIS.Model.Exam public List GetEmploymentHises(Int64 eID) { var list = DAOHelp.GetDataBySQL($@"Select * From Exam_EmploymentHis a WHERE a.PID = {eID}"); - return list; + return list==null?new List():list; } public List GetBaseSymptom() { @@ -32,7 +32,7 @@ namespace PEIS.Model.Exam public List GetCareerHisInqSymptom(Int64 eID) { var list = DAOHelp.GetDataBySQL($@"Select * From Exam_CareerHisInqSymptom a where a.PID={eID} ORDER BY a.DispOrder "); - return list; + return list==null?new List(): list; } public bool DelByPID(Int64 eID) { diff --git a/PEIS/PEIS.csproj b/PEIS/PEIS.csproj index 4d0ef66..8ab1858 100644 --- a/PEIS/PEIS.csproj +++ b/PEIS/PEIS.csproj @@ -747,6 +747,7 @@ Settings.settings True + Always diff --git a/PEIS/ReportFiles/CAPReport.frx b/PEIS/ReportFiles/CAPReport.frx new file mode 100644 index 0000000..d328f2e --- /dev/null +++ b/PEIS/ReportFiles/CAPReport.frx @@ -0,0 +1,627 @@ + + + using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Windows.Forms; +using System.Drawing; +using System.Drawing.Imaging; +using System.Data; +using System.IO; +using FastReport; +using FastReport.Data; +using FastReport.Dialog; +using FastReport.Barcode; +using FastReport.Table; +using FastReport.Utils; + +namespace FastReport +{ + public class ReportScript + { + String _pDeptName = "科室"; + string picpathbase = System.Windows.Forms.Application.StartupPath + "\\ReportFiles\\"; + private void Logo_BeforePrint(object sender, EventArgs e) + { + Logo.ImageLocation = picpathbase + "Logo.jpg"; + } + private void Picture7_BeforePrint(object sender, EventArgs e) + { + Logo.ImageLocation = picpathbase + "Exam_Signature.png"; + } + + private void General_AfterData(object sender, EventArgs e) + { + DataSourceBase rowData = Report.GetDataSource("G"); + Text95.Text = rowData["Summary"].ToString(); + Text97.Text = rowData["Checker"].ToString(); + Text99.Text = rowData["CheckTime"].ToString(); + } + + private void FeeItems_AfterData(object sender, EventArgs e) + { + DataSourceBase rowData = Report.GetDataSource("F"); + Object rowValue = rowData.CurrentRow; + Text132.Text = rowData["IsDeptGiveUp"].ToString() == "1" ? "是" : ""; + Text134.Text = rowData["GiveUpTime"] == null ? "" : "是"; + } + + private void Picture3_BeforePrint(object sender, EventArgs e) + { + //Picture3.Image = Base64ToImage((string)Report.GetParameterValue("Avatar")); + Picture6.Image = Base64ToImage((string)Report.GetParameterValue("Avatar")); + } + + private void Cell171_AfterData(object sender, EventArgs e) + { + if(Cell171.Text.Contains("↑")) + { + Cell167.FillColor = Color.LightCoral; + Cell168.FillColor = Color.LightCoral; + Cell169.FillColor = Color.LightCoral; + Cell170.FillColor = Color.LightCoral; + Cell171.FillColor = Color.LightCoral; + }else if (Cell171.Text.Contains("↓")) + { + Cell167.FillColor = Color.LightCyan; + Cell168.FillColor = Color.LightCyan; + Cell169.FillColor = Color.LightCyan; + Cell170.FillColor = Color.LightCyan; + Cell171.FillColor = Color.LightCyan; + }else + { + Cell167.FillColor = Color.White; + Cell168.FillColor = Color.White; + Cell169.FillColor = Color.White; + Cell170.FillColor = Color.White; + Cell171.FillColor = Color.White; + } + } + + private void Picture4_BeforePrint(object sender, EventArgs e) + { + DataSourceBase rowData = Report.GetDataSource("P"); + + Object rowValue = rowData.CurrentRow; + var Picture = rowValue.GetType().GetProperty("PImage").GetValue(rowValue, null); + + if(rowData["PImage"] != null){ + Picture4.Image = Image.FromStream(new MemoryStream((Byte[])Picture)); + Picture4.Visible = true; + }else{ + Picture4.Image = null; + Picture4.Visible = false; + } + } + + private void Page6_StartPage(object sender, EventArgs e) + { + DataSourceBase rowData = Report.GetDataSource("I"); + Object rowValue = rowData.CurrentRow; + if(rowValue == null) + { + Page6.Visible = false; + return; + } + } + + private void Picture5_BeforePrint(object sender, EventArgs e) + { + DataSourceBase rowData = Report.GetDataSource("I"); + Object rowValue = rowData.CurrentRow; + if(rowValue == null) + { + Page6.Visible = false; + return; + } + + var Picture = rowValue.GetType().GetProperty("ReportImage").GetValue(rowValue, null); + if(rowData["ReportImage"] != null){ + Picture5.Image = Image.FromStream(new MemoryStream((Byte[])Picture)); + Picture5.Visible = true; + }else{ + Picture5.Image = null; + Picture5.Visible = false; + } + } + + public Image Base64ToImage(string base64Str) + { + if(base64Str == null || base64Str == "") + { + return null; + } + + byte[] imageBytes = Convert.FromBase64String(base64Str); + using (MemoryStream ms = new MemoryStream(imageBytes)) + { + Image image = Image.FromStream(ms); + using (MemoryStream stream = new MemoryStream()) + { + image.Save(stream, ImageFormat.Png); + return image; + } + + } + } + + + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PEIS/ReportFiles/Exam_Signature.png b/PEIS/ReportFiles/Exam_Signature.png new file mode 100644 index 0000000..5d85717 Binary files /dev/null and b/PEIS/ReportFiles/Exam_Signature.png differ diff --git a/PEIS/Utils/ReportHelper.cs b/PEIS/Utils/ReportHelper.cs index 970ccb4..5dd4e9f 100644 --- a/PEIS/Utils/ReportHelper.cs +++ b/PEIS/Utils/ReportHelper.cs @@ -28,6 +28,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using FastReport.Export.Pdf; +using PEIS.Model.Exam; namespace PEIS.Utils { @@ -141,6 +142,8 @@ namespace PEIS.Utils return EasyReport(patient, eid, filePath); case "Health.frx": return EasyReport(patient, eid, filePath); + case "CAPReport.frx": + return CAPReport(patient, eid, filePath); default: return General(patient, eid, filePath); } @@ -231,15 +234,14 @@ namespace PEIS.Utils return null; } } - /// - /// 一般体检 + /// 职业病体检 /// /// /// /// /// - private static FastReport.Report General(EnrollmentPatient patient, Int64 eid, string filePath) + private static FastReport.Report CAPReport(EnrollmentPatient patient, Int64 eid, string filePath) { var rpt = new FastReport.Report(); //实例化一个Report报表 @@ -251,6 +253,10 @@ namespace PEIS.Utils var lstPacs = new ReportModel().GetPacsResult(eid); var lstPacsPhotos = new ReportModel().GetPacsPhoto(eid); + var lstSymptom = new CareerHisInqModel().GetCareerHisInqSymptom(10154); + var examCareerHisInq = new CareerHisInqModel().GetExamCareerHisInqByEid(10008); + var examEmploymentHis = new CareerHisInqModel().GetEmploymentHises(10028); + // 登记信息 rpt.SetParameterValue("PatientName", patient.Name); rpt.SetParameterValue("CardNo", patient.CardNo); @@ -271,7 +277,14 @@ namespace PEIS.Utils rpt.SetParameterValue("HospitalName", Global._hospital.Name); rpt.SetParameterValue("DeptName", patient.DeptName); - if(string.IsNullOrEmpty(patient.Photo)) + + rpt.SetParameterValue("EnrollmentType", "岗中"); + rpt.SetParameterValue("IDCard", patient.CardNo); + rpt.SetParameterValue("HospitalAddress", "无"); + rpt.SetParameterValue("HospitalCertificate", "无"); + rpt.SetParameterValue("HospitalTel", Global._hospital.Tel); + + if (string.IsNullOrEmpty(patient.Photo)) { rpt.SetParameterValue("Avatar", patient.Photo); } @@ -289,7 +302,96 @@ namespace PEIS.Utils } } - + List testList = new List() + { + //new { PatientName="张三1",Sex="男",IDCard="530128199403243610",MaritalStatus="已婚",HDTAge="10年",HDAge="5年",HDStr="高温、高压"}, + }; + foreach (var item in examEmploymentHis) + { + testList.Add(new + { + PatientName = patient.Name, + Sex = patient.Sex == "1" ? "男" : patient.Sex == "2" ? "女" : "", + IDCard = patient.CardNo, + MaritalStatus = patient.Marriage, + HDTAge = "", + HDAge = "", + HDStr = item.HarmfulFactors + }); + } + + List symptoms = new List(); + for (int i = 0; i < lstSymptom.Count; i = i + 2) + { + SymptomReportModele sm = new SymptomReportModele(); + sm.SMName0 = $"{lstSymptom[i].DispOrder}、{lstSymptom[i].SMName}"; + sm.SMValue0 = lstSymptom[i].SMValue; + if ((i + 1) < lstSymptom.Count) + { + sm.SMName1 = $"{lstSymptom[i + 1].DispOrder}、{lstSymptom[i + 1].SMName}"; + sm.SMValue1 = lstSymptom[i + 1].SMValue; + } + symptoms.Add(sm); + } + + var careerHisInq = new List(); + ECInqReportModele eCInqReport = new ECInqReportModele(); + if (examCareerHisInq != null) + { + eCInqReport.PastHistory = string.IsNullOrEmpty(examCareerHisInq.PastHistory) ? "/" : examCareerHisInq.PastHistory; + eCInqReport.Menarche = string.IsNullOrEmpty(examCareerHisInq.Menarche) ? "/" : examCareerHisInq.Menarche; + eCInqReport.MenarchePeriod = string.IsNullOrEmpty(examCareerHisInq.MenarchePeriod) ? "/" : examCareerHisInq.MenarchePeriod; + eCInqReport.MenarcheCycle = string.IsNullOrEmpty(examCareerHisInq.MenarcheCycle) ? "/" : examCareerHisInq.MenarcheCycle; + eCInqReport.LastMenstrualPod = string.IsNullOrEmpty(examCareerHisInq.LastMenstrualPod) ? "/" : examCareerHisInq.LastMenstrualPod; + eCInqReport.ExistingChildren = string.IsNullOrEmpty(examCareerHisInq.ExistingChildren) ? "/" : examCareerHisInq.ExistingChildren; + eCInqReport.Abortion = string.IsNullOrEmpty(examCareerHisInq.Abortion) ? "/" : examCareerHisInq.Abortion; + eCInqReport.PrematureDelivery = string.IsNullOrEmpty(examCareerHisInq.PrematureDelivery) ? "/" : examCareerHisInq.PrematureDelivery; + eCInqReport.Stillbirth = string.IsNullOrEmpty(examCareerHisInq.Stillbirth) ? "/" : examCareerHisInq.Stillbirth; + eCInqReport.AbnormalFetus = string.IsNullOrEmpty(examCareerHisInq.AbnormalFetus) ? "/" : examCareerHisInq.AbnormalFetus; + if (examCareerHisInq.SmokeState == 1) eCInqReport.SmokeState_1 = true; + if (examCareerHisInq.SmokeState == 2) eCInqReport.SmokeState_2 = true; + if (examCareerHisInq.SmokeState == 3) eCInqReport.SmokeState_3 = true; + eCInqReport.SmokeQuantity = string.IsNullOrEmpty(examCareerHisInq.SmokeQuantity) ? "/" : examCareerHisInq.SmokeQuantity; + eCInqReport.SmokeYears = string.IsNullOrEmpty(examCareerHisInq.SmokeQuantity) ? "/" : examCareerHisInq.SmokeYears; + eCInqReport.SmokeMonths = string.IsNullOrEmpty(examCareerHisInq.SmokeMonths) ? "/" : examCareerHisInq.SmokeMonths; + if (examCareerHisInq.DrinkState == 1) eCInqReport.DrinkState_1 = true; + if (examCareerHisInq.DrinkState == 2) eCInqReport.DrinkState_2 = true; + if (examCareerHisInq.DrinkState == 3) eCInqReport.DrinkState_3 = true; + eCInqReport.DrinkQuantity = string.IsNullOrEmpty(examCareerHisInq.DrinkQuantity) ? "/" : examCareerHisInq.DrinkQuantity; + eCInqReport.DrinkYears = string.IsNullOrEmpty(examCareerHisInq.DrinkYears) ? "/" : examCareerHisInq.DrinkYears; + eCInqReport.SleepCondition = string.IsNullOrEmpty(examCareerHisInq.SleepCondition) ? "/" : examCareerHisInq.SleepCondition; + eCInqReport.Other = string.IsNullOrEmpty(examCareerHisInq.Other) ? "/" : examCareerHisInq.Other; + } + else + { + eCInqReport.PastHistory = "/"; + eCInqReport.Menarche = "/"; + eCInqReport.MenarchePeriod = "/"; + eCInqReport.MenarcheCycle = "/"; + eCInqReport.LastMenstrualPod = "/"; + eCInqReport.ExistingChildren = "/"; + eCInqReport.Abortion = "/"; + eCInqReport.PrematureDelivery = "/"; + eCInqReport.Stillbirth = "/"; + eCInqReport.AbnormalFetus = "/"; + if (examCareerHisInq.SmokeState == 1) eCInqReport.SmokeState_1 = true; + if (examCareerHisInq.SmokeState == 2) eCInqReport.SmokeState_2 = true; + if (examCareerHisInq.SmokeState == 3) eCInqReport.SmokeState_3 = true; + eCInqReport.SmokeQuantity = "/"; + eCInqReport.SmokeYears = "/"; + eCInqReport.SmokeMonths = "/"; + if (examCareerHisInq.DrinkState == 1) eCInqReport.DrinkState_1 = true; + if (examCareerHisInq.DrinkState == 2) eCInqReport.DrinkState_2 = true; + if (examCareerHisInq.DrinkState == 3) eCInqReport.DrinkState_3 = true; + eCInqReport.DrinkQuantity = "/"; + eCInqReport.DrinkYears = "/"; + eCInqReport.SleepCondition = "/"; + eCInqReport.Other = "/"; + } + + + careerHisInq.Add(eCInqReport); + // 收费列表 SetDataSource(ref rpt, lstEFeeItems, "F", "FeeItems"); @@ -303,7 +405,86 @@ namespace PEIS.Utils SetDataSource(ref rpt, lstLis, "L", "LIS"); // PacsImage SetDataSource(ref rpt, lstPacsPhotos, "I", "PACSImage"); + // 职业史 + SetDataSource(ref rpt, testList, "CAH", "CAItems"); + //问诊 + SetDataSource(ref rpt, careerHisInq, "CAC", "CareerHisInq"); + //症状 + SetDataSource(ref rpt, symptoms, "CAS", "Symptoms"); + + + + rpt.Prepare(); //准备 + return rpt; + } + /// + /// 一般体检 + /// + /// + /// + /// + /// + private static FastReport.Report General(EnrollmentPatient patient, Int64 eid, string filePath) + { + var rpt = new FastReport.Report(); //实例化一个Report报表 + + rpt.Load(filePath); + var lstEFeeItems = new ReportModel().GetEFeeItem(eid); + var lstConclusions = new ReportModel().GetExamConclusions(eid); + var lstGeneral = new ReportModel().GetGeneralResult(eid); + var lstLis = new ReportModel().GetLisResult(eid); + var lstPacs = new ReportModel().GetPacsResult(eid); + var lstPacsPhotos = new ReportModel().GetPacsPhoto(eid); + // 登记信息 + rpt.SetParameterValue("PatientName", patient.Name); + rpt.SetParameterValue("CardNo", patient.CardNo); + rpt.SetParameterValue("Nation", patient.Nation); + rpt.SetParameterValue("Age", patient.Age + patient.AgeClass); + rpt.SetParameterValue("Sex", patient.Sex == "1" ? "男" : patient.Sex == "2" ? "女" : ""); + rpt.SetParameterValue("ExamID", patient.ID.ToString()); + rpt.SetParameterValue("ExamDate", patient.SignTime?.ToShortDateString()); + rpt.SetParameterValue("Marriage", patient.Marriage); + rpt.SetParameterValue("TeamName", patient.OrgName); + rpt.SetParameterValue("GroupName", patient.GroupName); + rpt.SetParameterValue("Company", patient.Company); + rpt.SetParameterValue("ExamType", patient.Type); + rpt.SetParameterValue("Address", patient.Address1); + rpt.SetParameterValue("Tel", patient.Tel1); + rpt.SetParameterValue("FinishPerson", patient.Finisher); + rpt.SetParameterValue("FinishDate", patient.FinishTime?.ToShortDateString()); + rpt.SetParameterValue("HospitalName", Global._hospital.Name); + rpt.SetParameterValue("DeptName", patient.DeptName); + + if (string.IsNullOrEmpty(patient.Photo)) + { + rpt.SetParameterValue("Avatar", patient.Photo); + } + else + { + byte[] imageBytes = Convert.FromBase64String(patient.Photo); + using (MemoryStream ms = new MemoryStream(imageBytes)) + { + Image image = Image.FromStream(ms); + using (MemoryStream stream = new MemoryStream()) + { + image.Save(stream, ImageFormat.Png); + rpt.SetParameterValue("Avatar", Convert.ToBase64String(stream.ToArray())); + } + } + } + // 收费列表 + SetDataSource(ref rpt, lstEFeeItems, "F", "FeeItems"); + // 总结结论词 + SetDataSource(ref rpt, lstConclusions, "C", "Conclusion"); + //一般检查 + SetDataSource(ref rpt, lstGeneral, "G", "General"); + //PACS + SetDataSource(ref rpt, lstPacs, "P", "PACS"); + //LIS + SetDataSource(ref rpt, lstLis, "L", "LIS"); + // PacsImage + SetDataSource(ref rpt, lstPacsPhotos, "I", "PACSImage"); rpt.Prepare(); //准备 return rpt; }