| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -17,6 +17,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public class AppointPatientRegisterManager : DomainService | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        private readonly IRepository<Person> _personRepository; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        private readonly IRepository<CustomerOrg> _customerOrgRepository; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        private readonly IRepository<CustomerOrgGroup> _customerOrgGroupRepository; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        private readonly IRepository<CustomerOrgGroupDetail> _customerOrgGroupDetailRepository; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -32,6 +33,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        private readonly IRepository<Asbitem> _asbitemRepository; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        private readonly CustomerOrgManager _customerOrgManager; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        public AppointPatientRegisterManager(IRepository<AppointPatientRegister> repository, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            IRepository<Person> personRepository, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            IRepository<IdentityUser> identityUserRepository, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            IdentityUserManager identityUserManager, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            IRepository<Nation> nationRepository, | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -48,6 +50,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            _repository = repository; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            _personRepository = personRepository; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            _identityUserRepository = identityUserRepository; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            _identityUserManager = identityUserManager; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            _nationRepository = nationRepository; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -82,7 +85,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Check.NotNull<Guid>(entity.MedicalCenterId, "体检中心"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Check.NotDefaultOrNull<Guid>(entity.CustomerOrgId, "单位"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Check.NotNull<DateTime>(entity.AppointDate, "体检日期"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if(entity.AppointDate < DateTime.Now.Date) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            var person = await _personRepository.GetAsync(o=>o.PersonId == entity.PersonId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (entity.AppointDate < DateTime.Now.Date) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("预约日期不能小于当前日期"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -94,21 +98,50 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (entity.CustomerOrgGroupId != Guid.Empty && entity.CustomerOrgGroupId != null) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if ((await _customerOrgGroupRepository.GetQueryableAsync()). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                var customerOrgGroup = (await _customerOrgGroupRepository.GetQueryableAsync()). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                     Where(o => o.CustomerOrgRegisterId == entity.CustomerOrgRegisterId && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                     o.CustomerOrgGroupId == entity.CustomerOrgGroupId).Count() == 0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                     o.CustomerOrgGroupId == entity.CustomerOrgGroupId).FirstOrDefault(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (customerOrgGroup == null) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("单位分组ID不存在"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(customerOrgGroup.ForSexId != ForSexFlag.All &&  | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    customerOrgGroup.ForSexId != person.SexId ) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("套餐的性别和人员性别不一致"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(customerOrgGroup.MaritalStatusId != MaritalStatusFlag.All &&  | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    person.MaritalStatusId == MaritalStatusFlag.UnMarried && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    customerOrgGroup.MaritalStatusId != MaritalStatusFlag.UnMarried) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("套餐的婚姻状况和人员婚姻状况不一致"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (entity.MedicalPackageId != Guid.Empty && entity.MedicalPackageId != null) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if ((await _medicalPackageRepository.GetQueryableAsync()). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                     Where(o => o.MedicalPackageId == entity.MedicalPackageId).Count() == 0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                var medicalPackage = (await _medicalPackageRepository.GetQueryableAsync()). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                     Where(o => o.MedicalPackageId == entity.MedicalPackageId).FirstOrDefault(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (medicalPackage == null) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("套餐ID不存在"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (medicalPackage.ForSexId != ForSexFlag.All && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   medicalPackage.ForSexId != person.SexId) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("套餐的性别和人员性别不一致"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (medicalPackage.MaritalStatusId != MaritalStatusFlag.All && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                  person.MaritalStatusId == MaritalStatusFlag.UnMarried && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                  medicalPackage.MaritalStatusId != MaritalStatusFlag.UnMarried) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("套餐的婚姻状况和人员婚姻状况不一致"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            var customerOrg = await _customerOrgRepository.FindAsync(o => o.CustomerOrgId == entity.CustomerOrgId); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -194,7 +227,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        var customerOrgGroup = await _customerOrgGroupRepository.GetAsync(o => o.CustomerOrgGroupId == entity.CustomerOrgGroupId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        if(addMoney > customerOrgGroup.CanAddMoney) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            throw new UserFriendlyException($"自选的单位支付金额能超过{customerOrgGroup.CanAddMoney}元"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            throw new UserFriendlyException($"自选的单位支付金额不能超过{customerOrgGroup.CanAddMoney}元"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -206,6 +239,19 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                var asbitem = asbitems.Where(o => o.AsbitemId == appointRegisterAsbitem.AsbitemId).Single(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (asbitem.ForSexId != ForSexFlag.All && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                  asbitem.ForSexId != person.SexId) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("套餐的性别和人员性别不一致"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (asbitem.MaritalStatusId != MaritalStatusFlag.All && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                 person.MaritalStatusId == MaritalStatusFlag.UnMarried && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                 asbitem.MaritalStatusId != MaritalStatusFlag.UnMarried) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    throw new UserFriendlyException("组合项目的婚姻状况和人员婚姻状况不一致"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                appointRegisterAsbitem.StandardPrice = asbitem.Price; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (appointRegisterAsbitem.ChargePrice < 0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -241,7 +287,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             o.AppointDate >= DateTime.Now.Date && o.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if(appoentPatientRegisters.Count >= 1) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("已有今天及之后的预约订单,必须先取消订单才能重新预约"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("已有今天及之后的预约订单,必须先取消订单"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |