using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using CYQ.Data.Table; using CYQ.Data; using Dapper; using dccdc.Models; namespace dccdc.DAL { public class examination_processDal { /// /// 通过条码,类型获取采集信息状态 /// /// /// /// public Models.ExaminationProcessModel getMode(string num, string lx) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { return conn.Query("select * from examination_process where physical_num=@num and group_name=@lx", new { num = num, lx = lx }).FirstOrDefault(); } } public bool Add(ExaminationProcessModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { string sql = @"INSERT INTO [dbo].[examination_process] ([person_id] ,[exam_group_maintain_id] ,[group_name] ,[is_entry] ,[entry_date] ,[is_review] ,[review_date] ,[is_complete] ,[complete_date] ,[collect_doctor] ,[commit_doctor] ,[review_need] ,[physical_num] ,[is_treatment] ,[treatment_date] ,[treatment_person]) VALUES (@person_id ,@exam_group_maintain_id ,@group_name ,@is_entry ,@entry_date ,@is_review ,@review_date ,@is_complete ,@complete_date ,@collect_doctor ,@commit_doctor ,@review_need ,@physical_num ,@is_treatment ,@treatment_date ,@treatment_person)"; return (conn.Execute(sql, model) != 0 ? true : false); } } /// /// 更新采集信息状态 /// /// public bool updateCollection(ExaminationProcessModel proModel) { //throw new NotImplementedException(); //过程表 相应采集分组的完成状态为“已完成” string sql = @"update examination_process set [is_complete] = @is_complete ,[complete_date] =@complete_date ,[collect_doctor] = @collect_doctor where id=@id "; using (IDbConnection conn = CommHelper.GetSqlConnection()) { int c = conn.Execute(sql, proModel); int c1 = 0; //若未采集更新采集状态为“已采集”,若“已采集”更新状态为'已录入检查结果' sql = "select is_complete from examination_process where person_id=" + proModel.person_id + " group by is_complete"; List epList = conn.Query(sql).ToList(); if (epList.Count == 1 && epList[0].is_complete == "已完成") { sql = "update professionalExam_register set procedure_status='已录入检查结果' " + " where (procedure_status!='已打印健康证' and procedure_status!='主检医生已审核') and id=" + proModel.person_id; c1 = conn.Execute(sql); } else { sql = "update professionalExam_register set procedure_status ='已采集' where physical_num = @num"; c1 = conn.Execute(sql, new { num = proModel.physical_num }); } //更新抽血状态:是否抽血(是、否) sql = "update professionalExam_register set haemospasia='是',check_date='" + DateTime.Now.ToString("yyyy-MM-dd") + "',blood_num=null where physical_num=@num"; int c2 = conn.Execute(sql, new { num = proModel.physical_num }); if (c > 0 && c1 > 0 && c2 > 0) { return true; } else { return false; } } } public bool updateWz(ExaminationProcessModel proModel) { //throw new NotImplementedException(); string sql = @"update examination_process set [is_complete] = @is_complete ,[is_entry] =@is_entry ,[entry_date] =@entry_date ,[complete_date] =@complete_date ,[commit_doctor] = @commit_doctor where id=@id "; using (IDbConnection conn = CommHelper.GetSqlConnection()) { int c2 = conn.Execute(sql, proModel); sql = "select is_complete from examination_process where person_id=" + proModel.person_id + " group by is_complete"; List epList = conn.Query(sql).ToList(); if (epList.Count == 1 && epList[0].is_complete == "已完成") { sql = "update professionalExam_register set procedure_status='已录入检查结果' where (procedure_status!='已打印健康证' and procedure_status!='主检医生已审核') and id=" + proModel.person_id; conn.Execute(sql); } if (c2 > 0) { return true; } else { return false; } } } /// /// 获取日期的采集状态 /// /// 类型(采血) /// 日期 /// public Models.DTO.CJDT getCaiJiZhuanTai(string lx, string date,int jgid) { using (var conn = CommHelper.GetSqlConnection()) { string sql = "select count(1) from professionalExam_register where register_date=@data"; if (jgid != 49) sql += " and jgid=" + jgid; Models.DTO.CJDT cjdt = new Models.DTO.CJDT(); cjdt.drdj = conn.ExecuteScalar(sql, new { data = date }); sql = @"select COUNT(1) from professionalExam_register a join examination_process b on a.physical_num=b.physical_num where b.group_name = @lx and a.register_date=@data"; if (jgid != 49) sql += " and jgid=" + jgid; cjdt.xyrs = conn.ExecuteScalar(sql, new { data = date ,lx=lx}); sql = @"select COUNT(1) from professionalExam_register a join examination_process b on a.physical_num=b.physical_num where b.group_name = @lx and a.register_date=@data and b.is_complete='已完成'"; if (jgid != 49) sql += " and jgid=" + jgid; cjdt.wcrs = conn.ExecuteScalar(sql, new { data = date, lx = lx }); return cjdt; } } public List getList(ExaminationProcessModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { String str = "select * from examination_process examinatio0_ where (examinatio0_.collect_doctor is null) and examinatio0_.person_id = @person_id"; List list = conn.Query(str,model).ToList(); return list; } } public List getWzList(ExaminationProcessModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { String str = "select * from examination_process where person_id = @person_id and group_name = @group_name"; List list = conn.Query(str, model).ToList(); return list; } } /// /// 根据physical_num获取体检小组检查进度 /// /// /// public List getProcessList(string physical_num) { string sql = "select * from examination_process where 1=1"; if (!string.IsNullOrEmpty(physical_num)) { sql += " and physical_num = @physical_num "; } using (IDbConnection conn = CommHelper.GetSqlConnection()) { return conn.Query(sql, new { physical_num = physical_num }).ToList(); } } public MDataTable GetPersonList_NoCompleteByGroupID(string groupid, string page = "1", string limit = "30") { string sql = $@" select p.group_name,r.physical_num,r.person_name,r.register_date,r.util_name from examination_process p left join professionalExam_register r on r.physical_num = p.physical_num where p.is_complete is null and p.exam_group_maintain_id = {groupid} "; string sqlWhere = " order by util_name,physical_num "; MAction ma = new MAction(sql); return ma.Select(int.Parse(page), int.Parse(limit), sqlWhere); } } }