继续开发医疗机构前置机
This commit is contained in:
		
							parent
							
								
									f220247b7d
								
							
						
					
					
						commit
						a52a446843
					
				@ -7,13 +7,17 @@ using CmdjyHisFront.Dal;
 | 
			
		||||
using HisInterfaceModels;
 | 
			
		||||
using CommonHelper;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using CmdjyHisFront.Dal.Tables;
 | 
			
		||||
 | 
			
		||||
namespace CmdjyHisFront.Bll
 | 
			
		||||
{
 | 
			
		||||
    public interface IPostHelper
 | 
			
		||||
    {
 | 
			
		||||
        void PostPrescription();
 | 
			
		||||
        void PostPrescriptionById(int id);
 | 
			
		||||
        void PostDrug();
 | 
			
		||||
        void PostDrugByDrugId(int id);
 | 
			
		||||
        void PostDrugByPrescriptionId(int id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class PostHelper:IPostHelper, IRegisterBaseInterface
 | 
			
		||||
@ -21,13 +25,76 @@ namespace CmdjyHisFront.Bll
 | 
			
		||||
        public Lazy<HisFrontDbContext> Db { get; set; }
 | 
			
		||||
 | 
			
		||||
        public void PostDrug() {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
            var db = this.Db.Value;
 | 
			
		||||
            var qu = db.DrugInfo.Join(db.DrugInfoLogs,a => a.Id,b => b.HisDrugInfoId,(a,b) => new { info = a,log = b,})
 | 
			
		||||
                .Where();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void PostPrescription() {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void PostPrescriptionById(int id) {
 | 
			
		||||
            var qu = this.Db.Value.PrescriptionInfo.Where(m => m.Id == id);
 | 
			
		||||
            if(!qu.Any()) {
 | 
			
		||||
                throw new Exception($"处方没有找到,编号{id}。");
 | 
			
		||||
            }
 | 
			
		||||
            var data = new HisPrescriptionInfo();
 | 
			
		||||
            data.CopyFrom(qu.First());
 | 
			
		||||
            var result = prescription(data);
 | 
			
		||||
            var model = new DjyPrescriptionInfoLog();
 | 
			
		||||
            if(int.TryParse(result.PrescriptionId,out var ipid)) {
 | 
			
		||||
                model.PrescriptionId = ipid;
 | 
			
		||||
            }
 | 
			
		||||
            model.HisPrescriptionInfoId = id;
 | 
			
		||||
            model.PostDatatime = DateTime.Now;
 | 
			
		||||
            model.ResultCode = (int)result.Code;
 | 
			
		||||
            model.ResultMsg = result.Msg;
 | 
			
		||||
            this.Db.Value.Entry(model).State = System.Data.Entity.EntityState.Added;
 | 
			
		||||
            this.Db.Value.SaveChanges();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void PostDrugByDrugId(int id) {
 | 
			
		||||
            var db = this.Db.Value;
 | 
			
		||||
            var qu = db.DrugInfo.Where(m => m.Id == id);
 | 
			
		||||
            if(!qu.Any()) {
 | 
			
		||||
                throw new Exception($"药品没有找到,编号{id}");
 | 
			
		||||
            }
 | 
			
		||||
            var data = new HisDrugInfo();
 | 
			
		||||
            data.CopyFrom(qu.First());
 | 
			
		||||
            var result = drug(data);
 | 
			
		||||
            var model = new DjyDrugInfoLog();
 | 
			
		||||
            if(int.TryParse(result.DrugId,out var idid)) {
 | 
			
		||||
                model.DrugId = idid;
 | 
			
		||||
            }
 | 
			
		||||
            model.HisDrugInfoId = id;
 | 
			
		||||
            model.PostDatatime = DateTime.Now;
 | 
			
		||||
            model.ResultCode = (int)result.Code;
 | 
			
		||||
            model.ResultMsg = result.Msg;
 | 
			
		||||
            db.Entry(model).State = System.Data.Entity.EntityState.Added;
 | 
			
		||||
            db.SaveChanges();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void PostDrugByPrescriptionId(int id) {
 | 
			
		||||
            var db = this.Db.Value;
 | 
			
		||||
            var qu = db.DrugInfo.Where(m => m.PrescriptionId == id);
 | 
			
		||||
            foreach(var item in qu) {
 | 
			
		||||
                var data = new HisDrugInfo();
 | 
			
		||||
                data.CopyFrom(item);
 | 
			
		||||
                var result = drug(data);
 | 
			
		||||
                var model = new DjyDrugInfoLog();
 | 
			
		||||
                if(int.TryParse(result.DrugId,out var idid)) {
 | 
			
		||||
                    model.DrugId = idid;
 | 
			
		||||
                }
 | 
			
		||||
                model.HisDrugInfoId = id;
 | 
			
		||||
                model.PostDatatime = DateTime.Now;
 | 
			
		||||
                model.ResultCode = (int)result.Code;
 | 
			
		||||
                model.ResultMsg = result.Msg;
 | 
			
		||||
                db.Entry(model).State = System.Data.Entity.EntityState.Added;
 | 
			
		||||
                db.SaveChanges();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private HisPrescriptionResult prescription(HisPrescriptionInfo info) {
 | 
			
		||||
            using(var server = new HisServer.HisInterfaceSoapClient()) {
 | 
			
		||||
                var msg = JsonConvert.SerializeObject(info);
 | 
			
		||||
 | 
			
		||||
@ -63,5 +63,35 @@ namespace CmdjyHisFront.Dal.Tables
 | 
			
		||||
        /// 特殊要求
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Remark { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 上传状态
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public EnumDrugPostStatus PostStatus { get; set; }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 处方信息上传状态
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Flags]
 | 
			
		||||
    public enum EnumDrugPostStatus
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 新药品,未上传
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        NewOrder = 0,
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 成功上传
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Sucess = 1,
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 上传异常
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Exception = 2,
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 取消上传
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Cancel = 4
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -167,6 +167,10 @@ namespace CmdjyHisFront.Dal.Tables
 | 
			
		||||
        /// 代煎药厂商名称
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string CompanyName { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 上传状态
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public EnumPrescriptionPostStatus PostStatus { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@ -188,4 +192,27 @@ namespace CmdjyHisFront.Dal.Tables
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        TestOrder = 4,
 | 
			
		||||
    }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 处方信息上传状态
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Flags]
 | 
			
		||||
    public enum EnumPrescriptionPostStatus
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 新处方,未上传
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        NewOrder = 0,
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 成功上传
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Sucess = 1,
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 上传异常
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Exception = 2,
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 取消上传
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Cancel = 4
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -9,7 +9,7 @@
 | 
			
		||||
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
 | 
			
		||||
  </configSections>
 | 
			
		||||
  <connectionStrings>
 | 
			
		||||
    <add name="HisFrontDbContext" connectionString="Server=FALCON-PC\SQLSERVER2008R2;Database=cmdjyHisFront;User ID=sa;Password=saabc123" providerName="System.Data.SqlClient" />
 | 
			
		||||
    <add name="HisFrontDbContext" connectionString="Server=FALCON-PC\SQLSERVER2008R2;Database=MyHis;User ID=sa;Password=saabc123" providerName="System.Data.SqlClient" />
 | 
			
		||||
  </connectionStrings>
 | 
			
		||||
  <appSettings>
 | 
			
		||||
    <add key="webpages:Version" value="3.0.0.0" />
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user