198 lines
6.2 KiB
C#
198 lines
6.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using EAS.Services;
|
|
using SOH.Entities;
|
|
using SOH.Data;
|
|
namespace SOH.BLL
|
|
{
|
|
[ServiceObject("科室维护模块")]
|
|
[ServiceBind(typeof(It_ks))]
|
|
public class t_ksBll : It_ks
|
|
{
|
|
/// <summary>
|
|
/// 获取所有科室
|
|
/// </summary>
|
|
/// <param name="lx" >类型 -1代表所有类型</param>
|
|
/// <returns></returns>
|
|
|
|
public List<Entities.keshi> GetAllks(string ksmc, int lx,int fddm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
// if (ksmc == "" && lx == -1)
|
|
// {
|
|
// return db.keshis.ToList();
|
|
// }
|
|
// else return db.keshis.Where(t => t.ksmc.Contains(ksmc) && t.lx == lx).ToList();
|
|
var ks = db.keshis.Where(t=>t.zhuxiao==0);
|
|
//if(if (ksmc == "" && lx == -1))
|
|
if (!string.IsNullOrEmpty(ksmc))
|
|
{
|
|
ks= ks.Where(t => t.ksmc.Contains(ksmc));
|
|
}
|
|
if (lx != -1)
|
|
{
|
|
ks= ks.Where(t => t.lx == lx);
|
|
}
|
|
if (fddm != 0)
|
|
{
|
|
ks= ks.Where(t => t.fddm == fddm);
|
|
}
|
|
return ks.ToList();
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据科室助记符和所在分店获取科室信息
|
|
/// </summary>
|
|
/// <param name="zjm"></param>
|
|
/// <param name="fddm"></param>
|
|
/// <returns></returns>
|
|
public List<Entities.keshi> GetKsByZJM(string zjm, int fddm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data=db.keshis.Where(t => t.fddm == fddm);
|
|
if(!string.IsNullOrEmpty(zjm))
|
|
{
|
|
zjm = zjm.ToUpper(); //助记符大写
|
|
data = data.Where(t => t.kszjm.Contains(zjm)||t.ksmc.Contains(zjm));
|
|
}
|
|
if (data.Any())
|
|
{
|
|
return data.ToList() ;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Data.OperationResult Update(keshi ks)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
try
|
|
{
|
|
ks.upflag = "1";
|
|
ks.zoom = "0.00";
|
|
db.keshis.OrmAccessor.Update(ks);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
or.State = 0;
|
|
or.Message = ex.Message;
|
|
}
|
|
}
|
|
|
|
or.State = 1;
|
|
or.Message = "修改成功";
|
|
or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(ks);
|
|
return or;
|
|
//throw new NotImplementedException();
|
|
}
|
|
|
|
public Data.OperationResult Insert(keshi ks)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
ks.zoom = "0.00";
|
|
ks.upflag = "1";
|
|
db.keshis.OrmAccessor.Insert(ks);
|
|
}
|
|
OperationResult or = new OperationResult();
|
|
or.State = 1;
|
|
or.Message = "添加成功";
|
|
or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(ks);
|
|
return or;
|
|
|
|
}
|
|
|
|
|
|
public keshi Model(keshi id)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.keshis.OrmAccessor.Read(id);
|
|
}
|
|
|
|
//throw new NotImplementedException();
|
|
}
|
|
|
|
public String getHuaYanKeshi(string czy)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var list = db.t_kss.Where(t => t.lx == 1 && t.zhuxiao==0).Join(db.t_czylrqxs, t => t.ksbm, p => p.ksbm, (t, p) => new
|
|
{
|
|
ksbm = t.ksbm,
|
|
ksmc = t.ksmc,
|
|
czy = p.czy,
|
|
zdjg = t.kszdjg
|
|
}).Where(t=>t.czy == czy);
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(list);
|
|
}
|
|
}
|
|
|
|
public String getHuaYanKeshiWaiSong(string czy)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var list = db.t_kss.Where(t => t.bgbt == "化验室" && t.zhuxiao == 0).Join(db.t_czylrqxs, t => t.ksbm, p => p.ksbm, (t, p) => new
|
|
{
|
|
ksbm = t.ksbm,
|
|
ksmc = t.ksmc,
|
|
czy = p.czy,
|
|
zdjg = t.kszdjg
|
|
}).Where(t => t.czy == czy);
|
|
|
|
var list2 = list.Join(db.t_zhxms, t => t.ksbm, p => p.ksbm, (t, p) => new {
|
|
ksbm = t.ksbm,
|
|
ksmc = t.ksmc,
|
|
czy = t.czy,
|
|
zdjg = t.zdjg,
|
|
zhuxiao=p.zhuxiao,
|
|
wsbj=p.wsbj
|
|
}).Where(t => t.zhuxiao=="0" && t.wsbj==1).GroupBy(t => new { t.ksbm, t.ksmc, t.czy, t.zdjg, t.zhuxiao, t.wsbj }).Select(
|
|
t=>new {ksbm=t.Key.ksbm,ksmc=t.Key.ksmc,cczy=t.Key.czy,zdjg=t.Key.zdjg,zhuxiao=t.Key.zhuxiao,wsbj=t.Key.wsbj });
|
|
|
|
//var list3 = list2.GroupBy(t => new { t.ksbm, t.ksmc, t.czy, t.zdjg, t.zhuxiao, t.wsbj }).ToList();
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(list2);
|
|
}
|
|
}
|
|
|
|
public List<keshi> getccks()
|
|
{
|
|
//throw new NotImplementedException();
|
|
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.keshis.Where(t => t.ccks == 1).ToList();
|
|
}
|
|
}
|
|
|
|
public List<FamiliarDiagnose> GetFLD()
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = db.FamiliarDiagnoses; ;
|
|
if (data.Any())
|
|
{
|
|
List<FamiliarDiagnose> fld = data.ToList();
|
|
return fld;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|