228 lines
6.4 KiB
C#
228 lines
6.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using dccdc.Models;
|
|
using Dapper;
|
|
|
|
namespace dccdc.DAL
|
|
{
|
|
public class DoctorInquiryDal
|
|
{
|
|
public List<DoctorInquiryModel> GetAllList(string id, string stauts)
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string param = "";
|
|
if (id != "")
|
|
{
|
|
param = " and id =@id";
|
|
}
|
|
if (stauts != "")
|
|
{
|
|
param += " and status=@stauts";
|
|
}
|
|
return conn.Query<DoctorInquiryModel>("select * from doctor_inquiry where 1=1" + param, new { @id = id, @stauts = stauts }).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public int getCount(string key)
|
|
{
|
|
string sql = "select count(1) from dbo.doctor_inquiry where 1=1";
|
|
if (!string.IsNullOrEmpty(key))
|
|
{
|
|
sql += " and physical_num like @physical_num";
|
|
}
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.ExecuteScalar<int>(sql, new { physical_num = "%" + key + "%" });
|
|
}
|
|
}
|
|
|
|
public List<DoctorInquiryModel> getList(int page, int pagesize, string key)
|
|
{
|
|
//throw new NotImplementedException();
|
|
string sql = "select *,row_number() over(order by id) as rownum from doctor_inquiry where 1=1";
|
|
if (!string.IsNullOrEmpty(key))
|
|
{
|
|
sql += " and physical_num like @physical_num";
|
|
}
|
|
sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<Models.DoctorInquiryModel>(sql, new { physical_num = "%" + key + "%" }).ToList();
|
|
}
|
|
}
|
|
|
|
public object saveExam(String key,string pNum, String type,ERPUser user)
|
|
{
|
|
DoctorInquiryDal did = new DoctorInquiryDal();
|
|
DoctorInquiryModel dim = did.getList(1, 1, pNum).FirstOrDefault();
|
|
dim.status = "是";
|
|
did.save(dim,user);
|
|
var dal = new examination_processDal();
|
|
ExaminationProcessModel model = new ExaminationProcessModel();
|
|
model.person_id = Int32.Parse(key);
|
|
model.group_name = "问诊";
|
|
model = dal.getWzList(model).FirstOrDefault();
|
|
if (type == "save")
|
|
{
|
|
model.is_entry = "已录";
|
|
model.entry_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
}else if (type == "complete")
|
|
{
|
|
model.is_complete = "已完成";
|
|
model.complete_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
model.commit_doctor = user.TrueName;
|
|
}
|
|
|
|
if(dal.updateWz(model))
|
|
{
|
|
|
|
return new { State = 1, Message = "保存成功!" };
|
|
}
|
|
else
|
|
{
|
|
return new { State = 0, Message = "操作失败,请联系管理员!" };
|
|
}
|
|
}
|
|
|
|
public object save(DoctorInquiryModel cpm, ERPUser user)
|
|
{
|
|
cpm.inquiry_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
string sql = "";
|
|
if (cpm.id == 0)
|
|
{
|
|
sql = @"INSERT INTO [dbo].[doctor_inquiry]
|
|
(
|
|
[physical_num],
|
|
[identity_num],
|
|
[name],
|
|
[status],
|
|
[family_history],
|
|
[discript],
|
|
[symptom],
|
|
[inquiry_date],
|
|
[personal],
|
|
[smoke_status],
|
|
[smoke_per_day],
|
|
[smoke_years],
|
|
[drink_status],
|
|
[drink_per_day],
|
|
[drink_years],
|
|
[menarche_age],
|
|
[menarche_time],
|
|
[menarche_per_week],
|
|
[menarche_stop_age],
|
|
[is_menarche],
|
|
[children],
|
|
[abortion_times],
|
|
[abortion_early_times],
|
|
[abortion_death_times],
|
|
[abortion_except_times],
|
|
[speedOrSlow_history_name],
|
|
[speedOrSlow_history_date],
|
|
[speedOrSlow_history_util],
|
|
[speedOrSlow_isOK],
|
|
[inquiry],
|
|
[ce_shi],
|
|
[marry_history]
|
|
)
|
|
VALUES
|
|
(
|
|
@physical_num,
|
|
@identity_num,
|
|
@name,
|
|
@status,
|
|
@family_history,
|
|
@discript,
|
|
@symptom,
|
|
@inquiry_date,
|
|
@personal,
|
|
@smoke_status,
|
|
@smoke_per_day,
|
|
@smoke_years,
|
|
@drink_status,
|
|
@drink_per_day,
|
|
@drink_years,
|
|
@menarche_age,
|
|
@menarche_time,
|
|
@menarche_per_week,
|
|
@menarche_stop_age,
|
|
@is_menarche,
|
|
@children,
|
|
@abortion_times,
|
|
@abortion_early_times,
|
|
@abortion_death_times,
|
|
@abortion_except_times,
|
|
@speedOrSlow_history_name,
|
|
@speedOrSlow_history_date,
|
|
@speedOrSlow_history_util,
|
|
@speedOrSlow_isOK,
|
|
@inquiry,
|
|
@ce_shi,
|
|
@marry_history
|
|
)
|
|
";
|
|
}
|
|
else
|
|
{
|
|
sql = @"UPDATE [dbo].[doctor_inquiry]
|
|
SET [physical_num]=@physical_num,
|
|
[family_history]=@family_history,
|
|
[discript]=@discript,
|
|
[status]=@status,
|
|
[symptom]=@symptom,
|
|
[inquiry_date]=@inquiry_date,
|
|
[personal]=@personal,
|
|
[smoke_status]=@smoke_status,
|
|
[smoke_per_day]=@smoke_per_day,
|
|
[smoke_years]=@smoke_years,
|
|
[drink_status]=@drink_status,
|
|
[drink_per_day]=@drink_per_day,
|
|
[drink_years]=@drink_years,
|
|
[menarche_age]=@menarche_age,
|
|
[menarche_time]=@menarche_time,
|
|
[menarche_per_week]=@menarche_per_week,
|
|
[menarche_stop_age]=@menarche_stop_age,
|
|
[is_menarche]=@is_menarche,
|
|
[children]=@children,
|
|
[abortion_times]=@abortion_times,
|
|
[abortion_early_times]=@abortion_early_times,
|
|
[abortion_death_times]=@abortion_death_times,
|
|
[abortion_except_times]=@abortion_except_times,
|
|
[speedOrSlow_history_name]=@speedOrSlow_history_name,
|
|
[speedOrSlow_history_date]=@speedOrSlow_history_date,
|
|
[speedOrSlow_history_util]=@speedOrSlow_history_util,
|
|
[speedOrSlow_isOK]=@speedOrSlow_isOK,
|
|
[inquiry]=@inquiry,
|
|
[ce_shi]=@ce_shi,
|
|
[marry_history]=@marry_history
|
|
WHERE id=@id";
|
|
}
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int c = conn.Execute(sql, cpm);
|
|
if (c > 0)
|
|
{
|
|
return new { State = 1, Message = "保存成功!" };
|
|
}
|
|
else
|
|
{
|
|
return new { State = 0, Message = "操作失败,请联系管理员!" };
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new { State = 0, Message = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|