You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1597 lines
71 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using Castle.Core.Logging;
  2. using Microsoft.AspNetCore.Authorization;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.Extensions.Logging;
  6. using Shentun.Peis.CommonCharTypes;
  7. using Shentun.Peis.CustomerOrgRegisters;
  8. using Shentun.Peis.CustomerOrgs;
  9. using Shentun.Peis.Enums;
  10. using Shentun.Peis.Models;
  11. using Shentun.Peis.Patients;
  12. using Shentun.Peis.RegisterAsbitems;
  13. using Shentun.Peis.RegisterChecks;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Diagnostics;
  17. using System.Linq;
  18. using System.Security;
  19. using System.Threading.Tasks;
  20. using TencentCloud.Cwp.V20180228.Models;
  21. using TencentCloud.Mps.V20190612.Models;
  22. using TencentCloud.Npp.V20190823.Models;
  23. using Volo.Abp;
  24. using Volo.Abp.Application.Dtos;
  25. using Volo.Abp.Application.Services;
  26. using Volo.Abp.Domain.Repositories;
  27. using Volo.Abp.Identity;
  28. using Volo.Abp.ObjectMapping;
  29. namespace Shentun.Peis.PatientRegisters
  30. {
  31. /// <summary>
  32. /// 人员体检登记
  33. /// </summary>
  34. [ApiExplorerSettings(GroupName = "Work")]
  35. //[Authorize]
  36. public class PatientRegisterAppService : CrudAppService<
  37. PatientRegister, //The Book entity
  38. PatientRegisterDto, //Used to show books
  39. Guid, //Primary key of the book entity
  40. PagedAndSortedResultRequestDto, //Used for paging/sorting
  41. CreatePatientRegisterDto,
  42. UpdatePatientRegisterDto>
  43. {
  44. private readonly IRepository<PatientRegister, Guid> _repository;
  45. private readonly IRepository<Patient, Guid> _patientrepository;
  46. private readonly IRepository<IdentityUser, Guid> _userRepository;
  47. private readonly IRepository<Sex> _sexRepository;
  48. private readonly IRepository<BirthPlace, Guid> _birthPlaceRepository;
  49. private readonly IRepository<MaritalStatus> _maritalStatusRepository;
  50. private readonly IRepository<Nation> _nationRepository;
  51. private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository;
  52. private readonly IRepository<CustomerOrgGroupDetail> _customerOrgGroupDetailRepository;
  53. private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
  54. private readonly IRepository<PersonnelType, Guid> _personnelTypeRepository;
  55. private readonly IRepository<MedicalType, Guid> _medicalTypeRepository;
  56. private readonly IRepository<SexHormoneTerm, Guid> _sexHormoneTermRepository;
  57. private readonly IRepository<PayMode> _payModeRepository;
  58. private readonly IRepository<RegisterAsbitem, Guid> _registerAsbitemRepository;
  59. private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
  60. private readonly IRepository<RegisterCheckItem> _registerCheckItemRepository;
  61. private readonly IRepository<Item, Guid> _itemRepository;
  62. private readonly IPatientRegisterChargeRepository _patientRegisterChargeRepository;
  63. private readonly ILogger<PatientRegisterAppService> _logger;
  64. private readonly CustomerOrgManager _customerOrgManager;
  65. private readonly CustomerOrgRegisterManager _customerOrgRegisterManager;
  66. private readonly PatientManager _patientManager;
  67. private readonly PatientRegisterManager _patientRegisterManager;
  68. private readonly RegisterAsbitemManager _registerAsbitemManager;
  69. //private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
  70. //private readonly IRepository<PrimarykeyBuilder> _primarykeyBuilderRepository;
  71. //private readonly IRepository<SysParmValue> _sysParmValueRepository;
  72. private readonly PatientRegisterManager _manager;
  73. public PatientRegisterAppService(
  74. IRepository<PatientRegister, Guid> repository,
  75. IRepository<Patient, Guid> patientrepository,
  76. IRepository<IdentityUser, Guid> userRepository,
  77. IRepository<Sex> sexRepository,
  78. IRepository<BirthPlace, Guid> birthPlaceRepository,
  79. IRepository<MaritalStatus> maritalStatusRepository,
  80. IRepository<Nation> nationRepository,
  81. IRepository<CustomerOrgGroup, Guid> customerOrgGroupRepository,
  82. IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository,
  83. IRepository<CustomerOrg, Guid> customerOrgRepository,
  84. IRepository<PersonnelType, Guid> personnelTypeRepository,
  85. IRepository<MedicalType, Guid> medicalTypeRepository,
  86. IRepository<SexHormoneTerm, Guid> sexHormoneTermRepository,
  87. IRepository<PayMode> payModeRepository,
  88. IRepository<RegisterAsbitem, Guid> registerAsbitemRepository,
  89. IRepository<RegisterCheck, Guid> registerCheckRepository,
  90. IRepository<RegisterCheckItem> registerCheckItemRepository,
  91. IRepository<Item, Guid> itemRepository,
  92. //IRepository<SysParmValue> sysParmValueRepository,
  93. //IRepository<CustomerOrg, Guid> customerOrgRepository,
  94. //IRepository<PrimarykeyBuilder> primarykeyBuilderRepository,
  95. IPatientRegisterChargeRepository patientRegisterChargeRepository,
  96. ILogger<PatientRegisterAppService> logger,
  97. CustomerOrgManager customerOrgManager,
  98. CustomerOrgRegisterManager customerOrgRegisterManager,
  99. PatientManager patientManager,
  100. PatientRegisterManager patientRegisterManager,
  101. RegisterAsbitemManager registerAsbitemManager,
  102. PatientRegisterManager manager)
  103. : base(repository)
  104. {
  105. this._repository = repository;
  106. this._patientrepository = patientrepository;
  107. this._userRepository = userRepository;
  108. this._sexRepository = sexRepository;
  109. this._birthPlaceRepository = birthPlaceRepository;
  110. this._maritalStatusRepository = maritalStatusRepository;
  111. this._nationRepository = nationRepository;
  112. this._customerOrgGroupRepository = customerOrgGroupRepository;
  113. this._customerOrgGroupDetailRepository = customerOrgGroupDetailRepository;
  114. this._customerOrgRepository = customerOrgRepository;
  115. this._personnelTypeRepository = personnelTypeRepository;
  116. this._medicalTypeRepository = medicalTypeRepository;
  117. this._sexHormoneTermRepository = sexHormoneTermRepository;
  118. this._payModeRepository = payModeRepository;
  119. this._registerAsbitemRepository = registerAsbitemRepository;
  120. this._registerCheckRepository = registerCheckRepository;
  121. this._registerCheckItemRepository = registerCheckItemRepository;
  122. this._itemRepository = itemRepository;
  123. this._patientRegisterChargeRepository = patientRegisterChargeRepository;
  124. this._logger = logger;
  125. this._customerOrgManager = customerOrgManager;
  126. this._customerOrgRegisterManager = customerOrgRegisterManager;
  127. this._patientManager = patientManager;
  128. this._patientRegisterManager = patientRegisterManager;
  129. this._registerAsbitemManager = registerAsbitemManager;
  130. //this._customerOrgRepository = customerOrgRepository;
  131. //this._primarykeyBuilderRepository = primarykeyBuilderRepository;
  132. //this._sysParmValueRepository = sysParmValueRepository;
  133. _manager = manager;
  134. }
  135. /// <summary>
  136. /// 获取通过主键
  137. /// </summary>
  138. /// <param name="id"></param>
  139. /// <returns></returns>
  140. public override async Task<PatientRegisterDto> GetAsync(Guid id)
  141. {
  142. return await base.GetAsync(id);
  143. }
  144. /// <summary>
  145. /// 编辑反写接口,包含档案表跟登记表的信息
  146. /// </summary>
  147. /// <param name="PatientRegisterId">登记表ID</param>
  148. /// <returns></returns>
  149. public async Task<PatientRegisterOrNoDto> GetInfoOrPatientAsync(Guid PatientRegisterId)
  150. {
  151. var ent = (await _repository.GetDbSetAsync()).Include(x => x.Patient).Where(m => m.Id == PatientRegisterId).FirstOrDefault();
  152. var entdto = new PatientRegisterOrNoDto();
  153. if (ent != null)
  154. {
  155. var userList = await _userRepository.GetListAsync();
  156. entdto = new PatientRegisterOrNoDto
  157. {
  158. Age = ent.Age,
  159. AuditDate = ent.AuditDate.ToString(),
  160. Id = ent.Id,
  161. AuditDoctor = ent.AuditDoctor,
  162. BirthDate = ent.BirthDate.ToString(),
  163. CompleteFlag = ent.CompleteFlag,
  164. CreationTime = ent.CreationTime,
  165. CreatorId = ent.CreatorId,
  166. CustomerOrgGroupId = ent.CustomerOrgGroupId,
  167. CustomerOrgId = ent.CustomerOrgId,
  168. CustomerOrgRegisterId = ent.CustomerOrgRegisterId,
  169. GuidePrintTimes = ent.GuidePrintTimes,
  170. InterposeMeasure = ent.InterposeMeasure,
  171. IsAudit = ent.IsAudit,
  172. IsLock = ent.IsLock,
  173. IsMedicalStart = ent.IsMedicalStart,
  174. IsNameHide = ent.IsNameHide,
  175. IsPhoneFollow = ent.IsPhoneFollow,
  176. IsRecoverGuide = ent.IsRecoverGuide,
  177. IsUpload = ent.IsUpload,
  178. IsVip = ent.IsVip,
  179. JobCardNo = ent.JobCardNo,
  180. JobPost = ent.JobPost,
  181. JobTitle = ent.JobTitle,
  182. LastModificationTime = ent.LastModificationTime,
  183. LastModifierId = ent.LastModifierId,
  184. MaritalStatusId = ent.MaritalStatusId,
  185. MedicalCardNo = ent.MedicalCardNo,
  186. MedicalConclusionId = ent.MedicalConclusionId,
  187. MedicalPackageId = ent.MedicalPackageId,
  188. MedicalStartDate = ent.MedicalStartDate.ToString(),
  189. MedicalTimes = ent.MedicalTimes,
  190. MedicalTypeId = ent.MedicalTypeId,
  191. OrganizationUnitId = ent.OrganizationUnitId,
  192. PatientId = ent.PatientId,
  193. PatientName = ent.PatientName,
  194. PatientRegisterNo = ent.PatientRegisterNo,
  195. PersonnelTypeId = ent.PersonnelTypeId,
  196. Photo = ent.Photo,
  197. Remark = ent.Remark,
  198. ReportPrintTimes = ent.ReportPrintTimes,
  199. Salesman = ent.Salesman,
  200. SexHormoneTermId = ent.SexHormoneTermId,
  201. SexId = ent.SexId,
  202. SummaryDate = ent.SummaryDate.ToString(),
  203. SummaryDoctor = ent.SummaryDoctor,
  204. ThirdInfo = ent.ThirdInfo,
  205. CreatorName = EntityHelper.GetUserNameNoSql(userList, ent.CreatorId),
  206. LastModifierName = EntityHelper.GetUserNameNoSql(userList, ent.LastModifierId),
  207. Address = ent.Patient.Address, //档案表信息
  208. BirthPlaceId = ent.Patient.BirthPlaceId,
  209. DisplayName = ent.Patient.DisplayName,
  210. Email = ent.Patient.Email,
  211. IdNo = ent.Patient.IdNo,
  212. MobileTelephone = ent.Patient.MobileTelephone,
  213. NationId = ent.Patient.NationId,
  214. PatientNo = ent.Patient.PatientNo,
  215. PatientPassword = ent.Patient.PatientPassword,
  216. PostalCode = ent.Patient.PostalCode,
  217. Telephone = ent.Patient.Telephone,
  218. CustomerOrgName = "",
  219. CustomerOrgParentName = ""
  220. };
  221. }
  222. return entdto;
  223. }
  224. /// <summary>
  225. /// 获取列表 人员体检
  226. /// </summary>
  227. /// <param name="input"></param>
  228. /// <returns></returns>
  229. [RemoteService(false)]
  230. public override async Task<PagedResultDto<PatientRegisterDto>> GetListAsync(PagedAndSortedResultRequestDto input)
  231. {
  232. return await base.GetListAsync(input);
  233. }
  234. /// <summary>
  235. /// 获取档案登记列表 带联合搜索条件
  236. /// </summary>
  237. /// <param name="input"></param>
  238. /// <returns></returns>
  239. [HttpPost("api/app/patientregister/getlistinfilter")]
  240. public async Task<PagedResultDto<PatientRegisterOrNoDto>> GetListInFilterAsync(GetListInSearchDto input)
  241. {
  242. var userList = await _userRepository.GetListAsync();
  243. var customerOrgList = await _customerOrgRepository.GetListAsync();
  244. //Stopwatch stopwatch = Stopwatch.StartNew();
  245. //stopwatch.Start();
  246. #region MyRegion
  247. var entlist = (await _repository.GetDbSetAsync()).Include(x => x.Patient).AsQueryable();
  248. if (!string.IsNullOrEmpty(input.PatientNo))
  249. entlist = entlist.Where(m => m.Patient.PatientNo == input.PatientNo);
  250. if (!string.IsNullOrEmpty(input.IdNo))
  251. entlist = entlist.Where(m => m.Patient.IdNo == input.IdNo);
  252. if (!string.IsNullOrEmpty(input.PatientName))
  253. entlist = entlist.Where(m => !string.IsNullOrEmpty(m.PatientName) && m.PatientName.Contains(input.PatientName));
  254. if (!string.IsNullOrEmpty(input.PatientRegisterNo))
  255. entlist = entlist.Where(m => m.PatientRegisterNo == input.PatientRegisterNo);
  256. if (input.SexId != null)
  257. if (input.SexId.ToString() != ForSexFlag.All)
  258. entlist = entlist.Where(m => m.SexId == input.SexId);
  259. if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate))
  260. entlist = entlist.Where(m => m.CreationTime >= Convert.ToDateTime(input.StartDate) &&
  261. m.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1));
  262. if (input.CompleteFlag != null)
  263. entlist = entlist.Where(m => m.CompleteFlag == input.CompleteFlag);
  264. if (input.CustomerOrgId != null && input.CustomerOrgId != Guid.Empty)
  265. {
  266. var CustomerOrgIds = await _customerOrgManager.GetCustomerOrgChildrenId(input.CustomerOrgId.Value);
  267. entlist = entlist.Where(m => CustomerOrgIds.Contains(m.CustomerOrgId));
  268. }
  269. #endregion
  270. int totalCount = entlist.Count();
  271. entlist = entlist.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount);
  272. var entdto = entlist.Select(s => new PatientRegisterOrNoDto
  273. {
  274. CreationTime = s.CreationTime,
  275. CreatorId = s.CreatorId,
  276. Id = s.Id,
  277. LastModificationTime = s.LastModificationTime,
  278. LastModifierId = s.LastModifierId,
  279. ThirdInfo = s.ThirdInfo,
  280. SummaryDoctor = s.SummaryDoctor,
  281. SummaryDate = s.SummaryDate.ToString(),
  282. SexId = s.SexId,
  283. Age = s.Age,
  284. AuditDate = s.AuditDate.ToString(),
  285. AuditDoctor = s.AuditDoctor,
  286. BirthDate = s.BirthDate.ToString(),
  287. CompleteFlag = s.CompleteFlag,
  288. CustomerOrgGroupId = s.CustomerOrgGroupId,
  289. CustomerOrgId = s.CustomerOrgId,
  290. CustomerOrgRegisterId = s.CustomerOrgRegisterId,
  291. GuidePrintTimes = s.GuidePrintTimes,
  292. InterposeMeasure = s.InterposeMeasure,
  293. IsAudit = s.IsAudit,
  294. IsLock = s.IsLock,
  295. IsMedicalStart = s.IsMedicalStart,
  296. IsNameHide = s.IsNameHide,
  297. IsPhoneFollow = s.IsPhoneFollow,
  298. IsRecoverGuide = s.IsRecoverGuide,
  299. IsUpload = s.IsUpload,
  300. IsVip = s.IsVip,
  301. JobCardNo = s.JobCardNo,
  302. JobPost = s.JobPost,
  303. JobTitle = s.JobTitle,
  304. MaritalStatusId = s.MaritalStatusId,
  305. MedicalCardNo = s.MedicalCardNo,
  306. MedicalConclusionId = s.MedicalConclusionId,
  307. MedicalPackageId = s.MedicalPackageId,
  308. MedicalStartDate = s.MedicalStartDate.ToString(),
  309. MedicalTimes = s.MedicalTimes,
  310. MedicalTypeId = s.MedicalTypeId,
  311. OrganizationUnitId = s.OrganizationUnitId,
  312. PatientId = s.PatientId,
  313. PatientName = s.PatientName,
  314. PatientRegisterNo = s.PatientRegisterNo,
  315. PersonnelTypeId = s.PersonnelTypeId,
  316. Photo = s.Photo,
  317. Remark = s.Remark,
  318. ReportPrintTimes = s.ReportPrintTimes,
  319. Salesman = s.Salesman,
  320. SexHormoneTermId = s.SexHormoneTermId,
  321. CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId),
  322. LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId),
  323. Address = s.Patient.Address, //档案表信息
  324. BirthPlaceId = s.Patient.BirthPlaceId,
  325. DisplayName = s.Patient.DisplayName,
  326. Email = s.Patient.Email,
  327. IdNo = s.Patient.IdNo,
  328. MobileTelephone = s.Patient.MobileTelephone,
  329. NationId = s.Patient.NationId,
  330. PatientNo = s.Patient.PatientNo,
  331. PatientPassword = s.Patient.PatientPassword,
  332. PostalCode = s.Patient.PostalCode,
  333. Telephone = s.Patient.Telephone,
  334. CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList, s.CustomerOrgId),
  335. CustomerOrgParentId = EntityHelper.GetParentNoSql(customerOrgList, s.CustomerOrgId),
  336. CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, s.CustomerOrgId)
  337. }).ToList();
  338. return new PagedResultDto<PatientRegisterOrNoDto>(totalCount, entdto);
  339. //return entdto;
  340. //stopwatch.Stop();
  341. //var s2 = stopwatch.ElapsedMilliseconds;
  342. //return entdto.Take(100).ToList();
  343. }
  344. /// <summary>
  345. /// 获取档案登记信息 根据档案号或者条码号(档案号条件返回最新的一条)
  346. /// </summary>
  347. /// <param name="input"></param>
  348. /// <returns></returns>
  349. public async Task<PatientRegisterOrNoDto> GetPatientRegisterOrPatientAsync(GetPatientRegisterOrPatientDto input)
  350. {
  351. var entdto = new PatientRegisterOrNoDto();
  352. #region MyRegion
  353. var entlist = (await _repository.GetDbSetAsync()).Include(x => x.Patient).ToList();
  354. if (input.SType == 1)
  355. entlist = entlist.Where(m => m.PatientRegisterNo == input.PatientRegisterNo).ToList();
  356. else
  357. entlist = entlist.Where(m => m.Patient.PatientNo == input.PatientNo).OrderByDescending(o => o.MedicalTimes).ToList();
  358. var ent = entlist.FirstOrDefault();
  359. #endregion
  360. if (ent != null)
  361. {
  362. var userList = await _userRepository.GetListAsync();
  363. var customerOrgList = await _customerOrgRepository.GetListAsync();
  364. entdto = new PatientRegisterOrNoDto
  365. {
  366. CreationTime = ent.CreationTime,
  367. CreatorId = ent.CreatorId,
  368. Id = ent.Id,
  369. LastModificationTime = ent.LastModificationTime,
  370. LastModifierId = ent.LastModifierId,
  371. ThirdInfo = ent.ThirdInfo,
  372. SummaryDoctor = ent.SummaryDoctor,
  373. SummaryDate = ent.SummaryDate.ToString(),
  374. SexId = ent.SexId,
  375. Age = ent.Age,
  376. AuditDate = ent.AuditDate.ToString(),
  377. AuditDoctor = ent.AuditDoctor,
  378. BirthDate = ent.BirthDate.ToString(),
  379. CompleteFlag = ent.CompleteFlag,
  380. CustomerOrgGroupId = ent.CustomerOrgGroupId,
  381. CustomerOrgId = ent.CustomerOrgId,
  382. CustomerOrgRegisterId = ent.CustomerOrgRegisterId,
  383. GuidePrintTimes = ent.GuidePrintTimes,
  384. InterposeMeasure = ent.InterposeMeasure,
  385. IsAudit = ent.IsAudit,
  386. IsLock = ent.IsLock,
  387. IsMedicalStart = ent.IsMedicalStart,
  388. IsNameHide = ent.IsNameHide,
  389. IsPhoneFollow = ent.IsPhoneFollow,
  390. IsRecoverGuide = ent.IsRecoverGuide,
  391. IsUpload = ent.IsUpload,
  392. IsVip = ent.IsVip,
  393. JobCardNo = ent.JobCardNo,
  394. JobPost = ent.JobPost,
  395. JobTitle = ent.JobTitle,
  396. MaritalStatusId = ent.MaritalStatusId,
  397. MedicalCardNo = ent.MedicalCardNo,
  398. MedicalConclusionId = ent.MedicalConclusionId,
  399. MedicalPackageId = ent.MedicalPackageId,
  400. MedicalStartDate = ent.MedicalStartDate.ToString(),
  401. MedicalTimes = ent.MedicalTimes,
  402. MedicalTypeId = ent.MedicalTypeId,
  403. OrganizationUnitId = ent.OrganizationUnitId,
  404. PatientId = ent.PatientId,
  405. PatientName = ent.PatientName,
  406. PatientRegisterNo = ent.PatientRegisterNo,
  407. PersonnelTypeId = ent.PersonnelTypeId,
  408. Photo = ent.Photo,
  409. Remark = ent.Remark,
  410. ReportPrintTimes = ent.ReportPrintTimes,
  411. Salesman = ent.Salesman,
  412. SexHormoneTermId = ent.SexHormoneTermId,
  413. CreatorName = EntityHelper.GetUserNameNoSql(userList, ent.CreatorId),
  414. LastModifierName = EntityHelper.GetUserNameNoSql(userList, ent.LastModifierId),
  415. Address = ent.Patient.Address, //档案表信息
  416. BirthPlaceId = ent.Patient.BirthPlaceId,
  417. DisplayName = ent.Patient.DisplayName,
  418. Email = ent.Patient.Email,
  419. IdNo = ent.Patient.IdNo,
  420. MobileTelephone = ent.Patient.MobileTelephone,
  421. NationId = ent.Patient.NationId,
  422. PatientNo = ent.Patient.PatientNo,
  423. PatientPassword = ent.Patient.PatientPassword,
  424. PostalCode = ent.Patient.PostalCode,
  425. Telephone = ent.Patient.Telephone,
  426. CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList, ent.CustomerOrgId),
  427. CustomerOrgParentId = EntityHelper.GetParentNoSql(customerOrgList, ent.CustomerOrgId),
  428. CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, ent.CustomerOrgId)
  429. };
  430. }
  431. else
  432. {
  433. entdto = null;
  434. }
  435. return entdto;
  436. }
  437. ///// <summary>
  438. ///// 创建 登记档案 弃用
  439. ///// </summary>
  440. ///// <param name="input"></param>
  441. ///// <returns></returns>
  442. //[RemoteService(false)]
  443. //public override async Task<PatientRegisterDto> CreateAsync(CreatePatientRegisterDto input)
  444. //{
  445. // var createEntity = ObjectMapper.Map<CreatePatientRegisterDto, PatientRegister>(input);
  446. // var createPatientEntity = ObjectMapper.Map<CreatePatientRegisterDto, Patient>(input);
  447. // var entity = await _manager.CreateAsync(createEntity, createPatientEntity);
  448. // var dto = ObjectMapper.Map<PatientRegister, PatientRegisterDto>(entity);
  449. // return dto;
  450. //}
  451. /// <summary>
  452. /// 创建 登记档案 用这个 返回信息包含了档案跟登记信息
  453. /// </summary>
  454. /// <param name="input"></param>
  455. /// <returns></returns>
  456. [HttpPost("api/patientregister/createreturninfo")]
  457. public async Task<PatientRegisterOrNoDto> CreateReturnInfoAsync(CreatePatientRegisterDto input)
  458. {
  459. PatientRegisterOrNoDto msg = new PatientRegisterOrNoDto();
  460. var createEntity = ObjectMapper.Map<CreatePatientRegisterDto, PatientRegister>(input);
  461. var createPatientEntity = ObjectMapper.Map<CreatePatientRegisterDto, Patient>(input);
  462. var entity = await _manager.CreateAsync(createEntity, createPatientEntity, input.IsMaxMedicalTimes);
  463. if (entity != null)
  464. {
  465. msg = await GetPatientRegisterOrNo(entity.Id);
  466. }
  467. return msg;
  468. }
  469. /// <summary>
  470. /// 更新
  471. /// </summary>
  472. /// <param name="PatientRegisterId">登记表ID</param>
  473. /// <param name="input">更新参数(包含档案跟登记)</param>
  474. /// <returns></returns>
  475. [HttpPost("api/patientregister/updatepatientregister")]
  476. public async Task<PatientRegisterDto> UpdatePatientRegisterAsync(Guid PatientRegisterId, UpdatePatientRegisterDto input)
  477. {
  478. var patientRegisterEnt = await Repository.GetAsync(PatientRegisterId);
  479. var patientEnt = await _patientrepository.GetAsync(input.PatientId);
  480. var patientRegisterSourceEntity = ObjectMapper.Map<UpdatePatientRegisterDto, PatientRegister>(input);
  481. var patientSourceEntity = ObjectMapper.Map<UpdatePatientRegisterDto, Patient>(input);
  482. _patientManager.UpdateAsync(patientSourceEntity, patientEnt);
  483. _manager.UpdateAsync(patientRegisterSourceEntity, patientRegisterEnt);
  484. await _patientrepository.UpdateAsync(patientEnt);
  485. patientRegisterEnt = await Repository.UpdateAsync(patientRegisterEnt);
  486. return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(patientRegisterEnt);
  487. }
  488. /// <summary>
  489. /// 修改人员照片
  490. /// </summary>
  491. /// <param name="input"></param>
  492. /// <returns></returns>
  493. [HttpPost]
  494. public async Task<PatientRegisterDto> UpdatePhotoAsync(UpdatePhotoDto input)
  495. {
  496. var ent = await _repository.GetAsync(input.PatientRegisterId);
  497. if (ent != null)
  498. {
  499. ent.Photo = input.Photo;
  500. var newent = await _repository.UpdateAsync(ent);
  501. return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newent);
  502. }
  503. else
  504. {
  505. return new PatientRegisterDto();
  506. }
  507. }
  508. ///// <summary>
  509. ///// 修改人员照片 二进制
  510. ///// </summary>
  511. ///// <param name="input"></param>
  512. ///// <returns></returns>
  513. //[HttpPost]
  514. //public async Task<PatientRegisterDto> UpdatePhoto2Async(UpdatePhoto2Dto input)
  515. //{
  516. // var ent = await _repository.GetAsync(input.PatientRegisterId);
  517. // if (ent != null)
  518. // {
  519. // ent.Photo = input.Photo;
  520. // var newent = await _repository.UpdateAsync(ent);
  521. // return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newent);
  522. // }
  523. // else
  524. // {
  525. // return new PatientRegisterDto();
  526. // }
  527. //}
  528. //
  529. /// <summary>
  530. /// 上传图片 手动拼接"http://81.70.217.145/"
  531. /// </summary>
  532. /// <returns></returns>
  533. public string UpLoadImg(UpdatePhotoDto input)
  534. {
  535. //_logger.LogInformation(input.Photo);
  536. string imgurl = "UpLoad/" + input.PatientRegisterId;
  537. var isupload = ImageHelper.Base64StrToImage(input.Photo, imgurl);
  538. if (!string.IsNullOrEmpty(isupload))
  539. return isupload;
  540. else
  541. return "";
  542. }
  543. /// <summary>
  544. /// 删除
  545. /// </summary>
  546. /// <param name="id"></param>
  547. /// <returns></returns>
  548. public override async Task DeleteAsync(Guid id)
  549. {
  550. await _manager.CheckAndDeleteAsync(id);
  551. }
  552. /// <summary>
  553. /// 批量删除
  554. /// </summary>
  555. /// <param name="input"></param>
  556. /// <returns></returns>
  557. [HttpPost]
  558. public async Task DeleteManyAsync(DeletePatientRegisterManyDto input)
  559. {
  560. if (input.PatientRegisterIds.Count > 0)
  561. {
  562. var entlist = await _repository.GetListAsync(m => input.PatientRegisterIds.Contains(m.Id));
  563. if (entlist.Count > 0)
  564. {
  565. foreach (var ent in entlist)
  566. {
  567. await _manager.CheckAndDeleteAsync(ent.Id);
  568. }
  569. }
  570. }
  571. else
  572. {
  573. throw new UserFriendlyException($"无可删除数据");
  574. }
  575. }
  576. /// <summary>
  577. /// 人员签到 批量
  578. /// </summary>
  579. /// <param name="PatientRegisterIds">登记表ID集合</param>
  580. /// <returns></returns>
  581. [HttpPost("api/app/patientregister/updatesigninmany")]
  582. public async Task<List<PatientRegisterDto>> UpdateSignInManyAsync(List<Guid> PatientRegisterIds)
  583. {
  584. List<PatientRegisterDto> msg = new List<PatientRegisterDto>();
  585. if (!PatientRegisterIds.Any())
  586. throw new UserFriendlyException($"请求参数有误");
  587. foreach (var PatientRegisterId in PatientRegisterIds)
  588. {
  589. var entity = await Repository.FindAsync(f => f.Id == PatientRegisterId && f.IsMedicalStart != 'Y');
  590. if (entity != null)
  591. {
  592. entity.IsMedicalStart = 'Y';
  593. entity.MedicalStartDate = DateOnly.FromDateTime(DateTime.Now);
  594. var newentity = await Repository.UpdateAsync(entity);
  595. msg.Add(ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newentity));
  596. }
  597. }
  598. return msg;
  599. }
  600. /// <summary>
  601. /// 批量回收表格,暂时不加是否签到跟是否做完体检的判断
  602. /// </summary>
  603. /// <param name="PatientRegisterIds"></param>
  604. /// <returns></returns>
  605. [HttpPost("api/app/patientregister/updaterecoverguidemany")]
  606. public async Task<List<PatientRegisterDto>> UpdateRecoverGuideManyAsync(List<Guid> PatientRegisterIds)
  607. {
  608. List<PatientRegisterDto> msg = new List<PatientRegisterDto>();
  609. if (!PatientRegisterIds.Any())
  610. throw new UserFriendlyException($"请求参数有误");
  611. foreach (var PatientRegisterId in PatientRegisterIds)
  612. {
  613. var newentity = await _manager.UpdateRecoverGuideAsync(PatientRegisterId);
  614. msg.Add(ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newentity));
  615. }
  616. return msg;
  617. }
  618. ///// <summary>
  619. ///// 人员签到
  620. ///// </summary>
  621. ///// <param name="PatientRegisterId">登记表ID</param>
  622. ///// <returns></returns>
  623. //public async Task<PatientRegisterDto> UpdateSignIn(Guid PatientRegisterId)
  624. //{
  625. // var entity = await Repository.GetAsync(PatientRegisterId);
  626. // if (entity == null)
  627. // {
  628. // throw new UserFriendlyException($"最后一次体检还未结束,不能新开,请结束最后一次体检");
  629. // }
  630. // else
  631. // {
  632. // entity.IsMedicalStart = 'N';
  633. // entity.MedicalStartDate = DateOnly.FromDateTime(DateTime.Now);
  634. // var newentity = await Repository.UpdateAsync(entity);
  635. // return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newentity);
  636. // }
  637. //}
  638. ///// <summary>
  639. ///// 回收表格,暂时不加是否签到跟是否做完体检的判断
  640. ///// </summary>
  641. ///// <param name="PatientRegisterId"></param>
  642. ///// <returns></returns>
  643. //public async Task<PatientRegisterDto> UpdateRecoverGuideAsync(Guid PatientRegisterId)
  644. //{
  645. // var entity = await _manager.UpdateRecoverGuideAsync(PatientRegisterId);
  646. // return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(entity);
  647. //}
  648. /// <summary>
  649. /// 修改人员锁定状态
  650. /// </summary>
  651. /// <param name="PatientRegisterId">人员登记ID</param>
  652. /// <param name="IsLock">是否锁住(Y N)</param>
  653. /// <returns></returns>
  654. public async Task<PatientRegisterDto> UpdatePatientRegisterIsLockAsync(Guid PatientRegisterId, char IsLock)
  655. {
  656. PatientRegisterDto msg = new PatientRegisterDto();
  657. var ent = await _repository.GetAsync(PatientRegisterId);
  658. if (ent != null)
  659. {
  660. ent.IsLock = IsLock;
  661. var newent = await _repository.UpdateAsync(ent);
  662. msg = ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newent);
  663. }
  664. return msg;
  665. }
  666. /// <summary>
  667. /// 更改总检审核医生信息(保存时,医生跟日期不传时取默认登录的用户跟当前时间;取消时,如果不传就不更新医生跟日期,只更新状态)
  668. /// </summary>
  669. /// <param name="input"></param>
  670. /// <returns></returns>
  671. [HttpPost("api/app/patientregister/updatepatientregisterauditordoctor")]
  672. public async Task<PatientRegisterDto> UpdatePatientRegisterAuditorDoctorAsync(UpdatePatientRegisterAuditorDoctorDto input)
  673. {
  674. if (input == null || input.PatientRegisterId == Guid.Empty)
  675. {
  676. throw new UserFriendlyException("请求参数有误");
  677. }
  678. var entity = await _repository.GetAsync(input.PatientRegisterId);
  679. var entitydto = ObjectMapper.Map<UpdatePatientRegisterAuditorDoctorDto, PatientRegister>(input);
  680. var newentity = await _manager.UpdatePatientRegisterAuditorDoctorAsync(entitydto, entity);
  681. return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newentity);
  682. }
  683. /// <summary>
  684. /// 更改总检检查医生信息(保存时,医生跟日期不传时取默认登录的用户跟当前时间;取消时,如果不传就不更新医生跟日期,只更新状态)
  685. /// </summary>
  686. /// <param name="input"></param>
  687. /// <returns></returns>
  688. [HttpPost("api/app/patientregister/updatepatientregistersummarydoctor")]
  689. public async Task<PatientRegisterDto> UpdatePatientRegisterSummaryDoctorAsync(UpdatePatientRegisterSummaryDoctorDto input)
  690. {
  691. if (input == null || input.PatientRegisterId == Guid.Empty)
  692. {
  693. throw new UserFriendlyException("请求参数有误");
  694. }
  695. var entity = await _repository.GetAsync(input.PatientRegisterId);
  696. var entitydto = ObjectMapper.Map<UpdatePatientRegisterSummaryDoctorDto, PatientRegister>(input);
  697. var newentity = await _manager.UpdatePatientRegisterSummaryDoctorAsync(entitydto, entity);
  698. return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newentity);
  699. }
  700. /// <summary>
  701. /// 批量修改指引单打印次数 原有基础上加1
  702. /// </summary>
  703. /// <param name="Ids"></param>
  704. /// <returns></returns>
  705. [HttpPost("api/app/patientregister/updatepatientregisterguideprinttimesmany")]
  706. public async Task UpdatePatientRegisterGuidePrintTimesManyAsync(List<Guid> Ids)
  707. {
  708. var entlist = await _repository.GetListAsync(m => Ids.Contains(m.Id));
  709. entlist.ForEach(f => f.GuidePrintTimes = (f.GuidePrintTimes == null ? (short?)1 : (short?)(f.GuidePrintTimes + 1)));
  710. }
  711. /// <summary>
  712. /// 批量修改体检报告打印次数 原有基础上加1
  713. /// </summary>
  714. /// <param name="Ids"></param>
  715. /// <returns></returns>
  716. [HttpPost("api/app/patientregister/updatepatientregisterreportprinttimesmany")]
  717. public async Task UpdatePatientRegisterReportPrintTimesManyAsync(List<Guid> Ids)
  718. {
  719. var entlist = await _repository.GetListAsync(m => Ids.Contains(m.Id));
  720. entlist.ForEach(f => f.ReportPrintTimes = (f.ReportPrintTimes == null ? (short?)1 : (short?)(f.ReportPrintTimes + 1)));
  721. }
  722. /// <summary>
  723. /// 导入体检名单操作
  724. /// </summary>
  725. /// <param name="input"></param>
  726. /// <returns></returns>
  727. [HttpPost("api/app/patientregister/createpatientregisterexcel")]
  728. public async Task<ResultDto> CreatePatientRegisterExcelAsync(CreatePatientRegisterExcelDto input)
  729. {
  730. ResultDto msg;
  731. if (input != null)
  732. {
  733. //自动创建部门
  734. #region 转换性别、出生地、婚姻状况、民族数据、单位分组、人员类别、体检类别、性激素期限
  735. //转换性别ID
  736. char? SexId = null;
  737. if (!DateHelper.IsNullOrEmpty(input.SexName))
  738. {
  739. var SexEnt = await _sexRepository.FindAsync(m => m.DisplayName == input.SexName);
  740. if (SexEnt != null)
  741. {
  742. SexId = SexEnt.Id;
  743. }
  744. else
  745. {
  746. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "性别不存在" };
  747. }
  748. }
  749. //出生地
  750. Guid? BirthPlaceId = null;
  751. if (!DateHelper.IsNullOrEmpty(input.BirthPlaceName))
  752. {
  753. var BirthPlaceEnt = await _birthPlaceRepository.FindAsync(m => m.DisplayName == input.BirthPlaceName);
  754. if (BirthPlaceEnt != null)
  755. {
  756. BirthPlaceId = BirthPlaceEnt.Id;
  757. }
  758. else
  759. {
  760. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "出生地不存在" };
  761. }
  762. }
  763. //婚姻状况
  764. char? MaritalStatusId = null;
  765. if (!DateHelper.IsNullOrEmpty(input.MaritalStatusName))
  766. {
  767. var MaritalStatusEnt = await _maritalStatusRepository.FindAsync(m => m.DisplayName == input.MaritalStatusName);
  768. if (MaritalStatusEnt != null)
  769. {
  770. MaritalStatusId = MaritalStatusEnt.Id;
  771. }
  772. else
  773. {
  774. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "婚姻状况不存在" };
  775. }
  776. }
  777. //民族
  778. string? NationId = null;
  779. if (!DateHelper.IsNullOrEmpty(input.NationName))
  780. {
  781. var NationEnt = await _nationRepository.FindAsync(m => m.DisplayName == input.NationName);
  782. if (NationEnt != null)
  783. {
  784. NationId = NationEnt.NationId;
  785. }
  786. else
  787. {
  788. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "民族不存在" };
  789. }
  790. }
  791. //单位分组
  792. Guid? CustomerOrgGroupId = null;
  793. if (!DateHelper.IsNullOrEmpty(input.CustomerOrgGroupName))
  794. {
  795. var CustomerOrgGroupEnt = await _customerOrgGroupRepository.FindAsync(m => m.DisplayName == input.CustomerOrgGroupName);
  796. if (CustomerOrgGroupEnt != null)
  797. {
  798. CustomerOrgGroupId = CustomerOrgGroupEnt.Id;
  799. }
  800. else
  801. {
  802. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "单位分组不存在" };
  803. }
  804. }
  805. //体检类别
  806. Guid? MedicalTypeId = null;
  807. if (!DateHelper.IsNullOrEmpty(input.MedicalTypeName))
  808. {
  809. var MedicalTypeEnt = await _medicalTypeRepository.FindAsync(m => m.DisplayName == input.MedicalTypeName);
  810. if (MedicalTypeEnt != null)
  811. {
  812. MedicalTypeId = MedicalTypeEnt.Id;
  813. }
  814. else
  815. {
  816. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "体检类别不存在" };
  817. }
  818. }
  819. //人员类别
  820. Guid? PersonnelTypeId = null;
  821. if (!DateHelper.IsNullOrEmpty(input.PersonnelTypeName))
  822. {
  823. var PersonnelTypeEnt = await _personnelTypeRepository.FindAsync(m => m.DisplayName == input.PersonnelTypeName);
  824. if (PersonnelTypeEnt != null)
  825. {
  826. PersonnelTypeId = PersonnelTypeEnt.Id;
  827. }
  828. else
  829. {
  830. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "人员类别不存在" };
  831. }
  832. }
  833. //性激素期限
  834. Guid? SexHormoneTermId = null;
  835. if (!DateHelper.IsNullOrEmpty(input.SexHormoneTermName))
  836. {
  837. var SexHormoneTermEnt = await _sexHormoneTermRepository.FindAsync(m => m.DisplayName == input.SexHormoneTermName);
  838. if (SexHormoneTermEnt != null)
  839. {
  840. SexHormoneTermId = SexHormoneTermEnt.Id;
  841. }
  842. else
  843. {
  844. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "性激素期限不存在" };
  845. }
  846. }
  847. //支付方式
  848. string? PayModeId = null;
  849. if (!DateHelper.IsNullOrEmpty(input.PayTypeFlag))
  850. {
  851. var PayModeEnt = await _payModeRepository.FindAsync(m => m.DisplayName == input.PayTypeFlag);
  852. if (PayModeEnt != null)
  853. {
  854. PayModeId = PayModeEnt.Id;
  855. }
  856. else
  857. {
  858. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "支付方式不存在" };
  859. }
  860. }
  861. #endregion
  862. Guid PatientId = Guid.Empty;
  863. #region 判断重名逻辑 先不判断 直接生成新的
  864. #endregion
  865. #region 生成档案信息
  866. var createPatientEntity = new Patient
  867. {
  868. Address = input.Address,
  869. BirthDate = PageHelper.ConvertDate(input.BirthDate),
  870. Telephone = input.Telephone,
  871. SexId = SexId,
  872. BirthPlaceId = BirthPlaceId,
  873. DisplayName = input.PatientName,
  874. IdNo = input.IdNo,
  875. Email = input.Email,
  876. MaritalStatusId = MaritalStatusId,
  877. MobileTelephone = input.MobileTelephone,
  878. NationId = NationId,
  879. // PatientNo = input.PatientNo,
  880. PatientPassword = "",
  881. PostalCode = input.PostalCode
  882. };
  883. if (input.IsAutoCreatePatientNo == 'Y')
  884. {
  885. //根据工卡号生成档案号
  886. if (DateHelper.IsNullOrEmpty(input.JobCardNo))
  887. {
  888. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "工卡号不能为空" };
  889. }
  890. else
  891. {
  892. if (input.JobCardNo.Trim().Length >= input.CardStartNum + input.CardLength)
  893. {
  894. string PatientNo = input.JobCardNo.Trim().Substring(input.CardStartNum, input.CardLength); //截取工卡号做档案号
  895. createPatientEntity.PatientNo = PatientNo;
  896. var PatientEnt_New = await _patientrepository.InsertAsync(createPatientEntity, true);
  897. if (PatientEnt_New != null)
  898. PatientId = PatientEnt_New.Id;
  899. }
  900. else
  901. {
  902. return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "工卡号长度不够" };
  903. }
  904. }
  905. }
  906. else
  907. {
  908. var PatientEnt_New = await _patientManager.CreateAsync(input.OrganizationUnitId.Value, createPatientEntity);
  909. if (PatientEnt_New != null)
  910. PatientId = PatientEnt_New.Id;
  911. }
  912. #endregion
  913. #region 部门判断 需要生成的进行生成,更新单位ID
  914. //_customerOrgRepository
  915. if (!DateHelper.IsNullOrEmpty(input.DepartmentName))
  916. {
  917. var departmentent = await _customerOrgRepository.FindAsync(m => m.ParentId == input.CustomerOrgId && m.DisplayName == input.DepartmentName); //当前单位下一级
  918. if (departmentent != null)
  919. {
  920. input.CustomerOrgId = departmentent.Id; //找到部门,单位ID为下级的部门ID
  921. }
  922. else
  923. {
  924. if (input.IsAutoCreateDepartment == 'Y')
  925. {
  926. var parentCustomerOrgEnt = await _customerOrgRepository.FindAsync(m => m.Id == input.CustomerOrgId); //当前单位下一级
  927. if (parentCustomerOrgEnt != null)
  928. {
  929. var customerOrg_Insert = new CustomerOrg
  930. {
  931. Accounts = parentCustomerOrgEnt.Accounts,
  932. Address = parentCustomerOrgEnt.Address,
  933. Bank = parentCustomerOrgEnt.Bank,
  934. DisplayName = input.DepartmentName,
  935. Fax = parentCustomerOrgEnt.Fax,
  936. InvoiceName = parentCustomerOrgEnt.InvoiceName,
  937. IsActive = parentCustomerOrgEnt.IsActive,
  938. IsLock = parentCustomerOrgEnt.IsLock,
  939. OrganizationUnitId = parentCustomerOrgEnt.OrganizationUnitId,
  940. //DisplayOrder = parentCustomerOrgEnt.DisplayOrder,
  941. OrgTypeId = parentCustomerOrgEnt.OrgTypeId,
  942. ParentId = parentCustomerOrgEnt.ParentId,
  943. // PathCode = parentCustomerOrgEnt.PathCode,
  944. PostalCode = parentCustomerOrgEnt.PostalCode,
  945. Remark = parentCustomerOrgEnt.Remark,
  946. ShortName = parentCustomerOrgEnt.ShortName,
  947. // SimpleCode = parentCustomerOrgEnt.SimpleCode,
  948. Telephone = parentCustomerOrgEnt.Telephone
  949. };
  950. var DepartmentEnt = await _customerOrgManager.CreateAsync(customerOrg_Insert);
  951. var DepartmentReturn = await _customerOrgRepository.InsertAsync(DepartmentEnt, true);
  952. if (DepartmentReturn != null)
  953. {
  954. input.CustomerOrgId = DepartmentReturn.Id; //单位ID转为 生成的部门ID
  955. }
  956. }
  957. }
  958. }
  959. }
  960. #endregion
  961. #region 获取单位体检次数 根据单位ID 转换为一级单位ID
  962. Guid CustomerOrgParentId = EntityHelper.GetParentNoSql(await _customerOrgRepository.GetListAsync(), input.CustomerOrgId); //一级单位ID
  963. Guid CustomerOrgRegisterId = Guid.Empty; //最新单位次数ID
  964. if (CustomerOrgParentId != Guid.Empty)
  965. {
  966. var customerOrgRegisterEnt = await _customerOrgRegisterManager.GetMaxAsync(CustomerOrgParentId);
  967. if (customerOrgRegisterEnt != null)
  968. CustomerOrgRegisterId = customerOrgRegisterEnt.Id;
  969. }
  970. #endregion
  971. var createPatientRegisterEntity = new PatientRegister
  972. {
  973. Age = input.Age,
  974. AuditDate = PageHelper.ConvertDate(input.AuditDate),
  975. AuditDoctor = input.AuditDoctor,
  976. BirthDate = PageHelper.ConvertDate(input.BirthDate),
  977. CompleteFlag = input.CompleteFlag,
  978. CustomerOrgGroupId = CustomerOrgGroupId,
  979. CustomerOrgId = input.CustomerOrgId,
  980. CustomerOrgRegisterId = CustomerOrgRegisterId,
  981. GuidePrintTimes = input.GuidePrintTimes,
  982. InterposeMeasure = input.InterposeMeasure,
  983. IsAudit = input.IsAudit,
  984. IsLock = input.IsLock,
  985. IsMedicalStart = input.IsMedicalStart,
  986. IsNameHide = input.IsNameHide,
  987. IsPhoneFollow = input.IsPhoneFollow,
  988. IsRecoverGuide = input.IsRecoverGuide,
  989. IsUpload = input.IsUpload,
  990. IsVip = input.IsVip,
  991. JobCardNo = input.JobCardNo,
  992. JobPost = input.JobPost,
  993. JobTitle = input.JobTitle,
  994. MaritalStatusId = MaritalStatusId,
  995. MedicalCardNo = input.MedicalCardNo,
  996. MedicalConclusionId = input.MedicalConclusionId,
  997. MedicalPackageId = null,
  998. MedicalStartDate = PageHelper.ConvertDate(input.MedicalStartDate),
  999. MedicalTimes = 1,
  1000. MedicalTypeId = MedicalTypeId,
  1001. OrganizationUnitId = input.OrganizationUnitId,
  1002. PatientId = PatientId,
  1003. PatientName = input.PatientName,
  1004. PatientRegisterNo = await _patientRegisterManager.CreatePatientRegisterNo(input.OrganizationUnitId.Value),
  1005. PersonnelTypeId = PersonnelTypeId,
  1006. Photo = input.Photo,
  1007. Remark = input.Remark,
  1008. ReportPrintTimes = input.ReportPrintTimes,
  1009. Salesman = input.Salesman,
  1010. SexHormoneTermId = SexHormoneTermId,
  1011. SexId = SexId,
  1012. SummaryDate = PageHelper.ConvertDate(input.SummaryDate),
  1013. SummaryDoctor = input.SummaryDoctor,
  1014. ThirdInfo = input.ThirdInfo
  1015. };
  1016. var patientRegisterEntity_New = await _repository.InsertAsync(createPatientRegisterEntity, true);
  1017. if (patientRegisterEntity_New != null)
  1018. {
  1019. #region 导入registerasbitem相关数据
  1020. //生成registerasbitem数据 根据登记Id和单位分组Id
  1021. var customerOrgGroupDetailList = (await _customerOrgGroupDetailRepository.GetDbSetAsync()).Include(x => x.Asbitem)
  1022. .Where(m => m.CustomerOrgGroupId == CustomerOrgGroupId)
  1023. .Select(s => new RegisterAsbitem
  1024. {
  1025. Amount = 1,
  1026. AsbitemId = s.AsbitemId,
  1027. ChargePrice = s.Price,
  1028. GroupPackageId = CustomerOrgGroupId,
  1029. IsCharge = 'N',
  1030. PatientRegisterId = patientRegisterEntity_New.Id,
  1031. PayTypeFlag = PayModeId,
  1032. StandardPrice = s.Asbitem.Price
  1033. }).ToList();
  1034. foreach (var item in customerOrgGroupDetailList)
  1035. {
  1036. await _registerAsbitemManager.CreateAsync(input.OrganizationUnitId.Value, item, true);
  1037. }
  1038. #endregion
  1039. msg = new ResultDto { code = 1, msg = "[数据:" + input.PatientName + "]=>" + "导入成功" };
  1040. }
  1041. else
  1042. {
  1043. msg = new ResultDto { code = 1, msg = "[数据:" + input.PatientName + "]=>" + "导入失败" };
  1044. }
  1045. }
  1046. else
  1047. {
  1048. msg = new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "请求参数有误" };
  1049. }
  1050. return msg;
  1051. }
  1052. #region 调整分组
  1053. /// <summary>
  1054. /// 调整体检人员分组
  1055. /// </summary>
  1056. /// <returns></returns>
  1057. [HttpPost("api/app/patientregister/updatepatientregistercustomerorggroup")]
  1058. public async Task UpdatePatientRegisterCustomerOrgGroupAsync(UpdatePatientRegisterCustomerOrgGroupDto input)
  1059. {
  1060. //当前人员信息
  1061. var patientRegisterEnt = (await _repository.GetDbSetAsync())
  1062. .Include(x => x.RegisterAsbitems)
  1063. .ThenInclude(x => x.RegisterCheck)
  1064. .Where(m => m.Id == input.PatientRegisterId).FirstOrDefault();
  1065. if (patientRegisterEnt != null)
  1066. {
  1067. if (patientRegisterEnt.CustomerOrgId == null || patientRegisterEnt.CustomerOrgId == Guid.Empty)
  1068. {
  1069. throw new UserFriendlyException("个人体检不支持调整");
  1070. }
  1071. if (patientRegisterEnt.CompleteFlag == '3')
  1072. {
  1073. throw new UserFriendlyException("当前体检人员已完成总检");
  1074. }
  1075. if (patientRegisterEnt.CustomerOrgGroupId == input.CustomerOrgGroupId)
  1076. {
  1077. throw new UserFriendlyException("当前体检人员已在此分组");
  1078. }
  1079. //原有分组下的组合项目
  1080. //var oldGroupAsbitemList = await _customerOrgGroupDetailRepository.GetListAsync(m => m.CustomerOrgGroupId == patientRegisterEnt.CustomerOrgGroupId);
  1081. var oldGroupAsbitemList = (await _customerOrgGroupDetailRepository.GetDbSetAsync())
  1082. .Include(x => x.Asbitem)
  1083. .Where(m => m.CustomerOrgGroupId == patientRegisterEnt.CustomerOrgGroupId).ToList();
  1084. //需要调整的分组包含的组合项目
  1085. //var newGroupAsbitemList = await _customerOrgGroupDetailRepository.GetListAsync(m => m.CustomerOrgGroupId == input.CustomerOrgGroupId);
  1086. var newGroupAsbitemList = (await _customerOrgGroupDetailRepository.GetDbSetAsync())
  1087. .Include(x => x.Asbitem)
  1088. .Where(m => m.CustomerOrgGroupId == input.CustomerOrgGroupId).ToList();
  1089. var registerAsbitem = patientRegisterEnt.RegisterAsbitems; //当前登记的组合项目
  1090. if (registerAsbitem.Any())
  1091. {
  1092. //删除操作
  1093. List<RegisterAsbitem> ReserveList = new List<RegisterAsbitem>(); //保留项目
  1094. List<RegisterAsbitem> DeleteList = new List<RegisterAsbitem>(); //删除项目
  1095. foreach (var item in registerAsbitem)
  1096. {
  1097. //判断是否为已收费、已检、弃检
  1098. if (item.IsCharge == 'Y' || item.RegisterCheck.CompleteFlag != '0')
  1099. {
  1100. //保留
  1101. ReserveList.Add(item);
  1102. }
  1103. else
  1104. {
  1105. if (input.IsReserveAddAsbitem == 'Y')
  1106. {
  1107. //保留额外项目
  1108. if (oldGroupAsbitemList.Where(m => m.AsbitemId == item.AsbitemId).Count() == 0)
  1109. {
  1110. //额外项目
  1111. ReserveList.Add(item);
  1112. }
  1113. else
  1114. {
  1115. DeleteList.Add(item);
  1116. }
  1117. }
  1118. else
  1119. {
  1120. DeleteList.Add(item);
  1121. }
  1122. }
  1123. }
  1124. await _registerAsbitemRepository.DeleteManyAsync(DeleteList);
  1125. //遍历查询保留的项目是否存在新分组,如果存在,修改新分组的ID,然后list里面剔除项目
  1126. ReserveList.ForEach(reserveitem =>
  1127. {
  1128. var IsnewGroupAsbitem = newGroupAsbitemList.Find(m => m.AsbitemId == reserveitem.AsbitemId); //项目是否存在新分组内
  1129. if (IsnewGroupAsbitem != null)
  1130. {
  1131. //新分组内有需要保留的项目
  1132. reserveitem.GroupPackageId = input.CustomerOrgGroupId; //修改之前项目的分组ID
  1133. //从list里面删除新分组包含的组合项目
  1134. newGroupAsbitemList.Remove(IsnewGroupAsbitem);
  1135. }
  1136. else
  1137. {
  1138. reserveitem.GroupPackageId = null; //不包含,修改为null
  1139. }
  1140. });
  1141. await _registerAsbitemRepository.UpdateManyAsync(ReserveList); //修改保留项目的分组
  1142. }
  1143. if (newGroupAsbitemList.Any())
  1144. {
  1145. //需要处理的新分组下的数据 重复的已剔除
  1146. var newRegisterAsbitemList = newGroupAsbitemList.Select(s => new RegisterAsbitem
  1147. {
  1148. Amount = 1,
  1149. AsbitemId = s.AsbitemId,
  1150. ChargePrice = s.Price,
  1151. GroupPackageId = input.CustomerOrgGroupId,
  1152. IsCharge = 'N',
  1153. PatientRegisterId = input.PatientRegisterId,
  1154. PayTypeFlag = input.PayTypeFlag,
  1155. StandardPrice = s.Asbitem.Price
  1156. }).ToList();
  1157. foreach (var item in newRegisterAsbitemList)
  1158. {
  1159. await _registerAsbitemManager.CreateAsync(patientRegisterEnt.OrganizationUnitId.Value, item, true);
  1160. }
  1161. }
  1162. patientRegisterEnt.CustomerOrgGroupId = input.CustomerOrgGroupId;
  1163. await _repository.UpdateAsync(patientRegisterEnt);
  1164. }
  1165. else
  1166. {
  1167. throw new UserFriendlyException("人员不存在");
  1168. }
  1169. }
  1170. #endregion
  1171. #region 登记完返回的数据
  1172. private async Task<PatientRegisterOrNoDto> GetPatientRegisterOrNo(Guid PatientRegisterId)
  1173. {
  1174. // var entold = await _repository.GetAsync(PatientRegisterId);
  1175. var ent = (await _repository.GetDbSetAsync()).Include(x => x.Patient).Where(m => m.Id == PatientRegisterId).FirstOrDefault();
  1176. // var entold = await _repository.FindAsync(m=>m.Id== PatientRegisterId);
  1177. var entdto = new PatientRegisterOrNoDto();
  1178. if (ent != null)
  1179. {
  1180. var userList = await _userRepository.GetListAsync();
  1181. entdto = new PatientRegisterOrNoDto
  1182. {
  1183. Age = ent.Age,
  1184. AuditDate = ent.AuditDate.ToString(),
  1185. Id = ent.Id,
  1186. AuditDoctor = ent.AuditDoctor,
  1187. BirthDate = ent.BirthDate.ToString(),
  1188. CompleteFlag = ent.CompleteFlag,
  1189. CreationTime = ent.CreationTime,
  1190. CreatorId = ent.CreatorId,
  1191. CustomerOrgGroupId = ent.CustomerOrgGroupId,
  1192. CustomerOrgId = ent.CustomerOrgId,
  1193. CustomerOrgRegisterId = ent.CustomerOrgRegisterId,
  1194. GuidePrintTimes = ent.GuidePrintTimes,
  1195. InterposeMeasure = ent.InterposeMeasure,
  1196. IsAudit = ent.IsAudit,
  1197. IsLock = ent.IsLock,
  1198. IsMedicalStart = ent.IsMedicalStart,
  1199. IsNameHide = ent.IsNameHide,
  1200. IsPhoneFollow = ent.IsPhoneFollow,
  1201. IsRecoverGuide = ent.IsRecoverGuide,
  1202. IsUpload = ent.IsUpload,
  1203. IsVip = ent.IsVip,
  1204. JobCardNo = ent.JobCardNo,
  1205. JobPost = ent.JobPost,
  1206. JobTitle = ent.JobTitle,
  1207. LastModificationTime = ent.LastModificationTime,
  1208. LastModifierId = ent.LastModifierId,
  1209. MaritalStatusId = ent.MaritalStatusId,
  1210. MedicalCardNo = ent.MedicalCardNo,
  1211. MedicalConclusionId = ent.MedicalConclusionId,
  1212. MedicalPackageId = ent.MedicalPackageId,
  1213. MedicalStartDate = ent.MedicalStartDate.ToString(),
  1214. MedicalTimes = ent.MedicalTimes,
  1215. MedicalTypeId = ent.MedicalTypeId,
  1216. OrganizationUnitId = ent.OrganizationUnitId,
  1217. PatientId = ent.PatientId,
  1218. PatientName = ent.PatientName,
  1219. PatientRegisterNo = ent.PatientRegisterNo,
  1220. PersonnelTypeId = ent.PersonnelTypeId,
  1221. Photo = ent.Photo,
  1222. Remark = ent.Remark,
  1223. ReportPrintTimes = ent.ReportPrintTimes,
  1224. Salesman = ent.Salesman,
  1225. SexHormoneTermId = ent.SexHormoneTermId,
  1226. SexId = ent.SexId,
  1227. SummaryDate = ent.SummaryDate.ToString(),
  1228. SummaryDoctor = ent.SummaryDoctor,
  1229. ThirdInfo = ent.ThirdInfo,
  1230. CreatorName = EntityHelper.GetUserNameNoSql(userList, ent.CreatorId),
  1231. LastModifierName = EntityHelper.GetUserNameNoSql(userList, ent.LastModifierId),
  1232. Address = ent.Patient.Address, //档案表信息
  1233. BirthPlaceId = ent.Patient.BirthPlaceId,
  1234. DisplayName = ent.Patient.DisplayName,
  1235. Email = ent.Patient.Email,
  1236. IdNo = ent.Patient.IdNo,
  1237. MobileTelephone = ent.Patient.MobileTelephone,
  1238. NationId = ent.Patient.NationId,
  1239. PatientNo = ent.Patient.PatientNo,
  1240. PatientPassword = ent.Patient.PatientPassword,
  1241. PostalCode = ent.Patient.PostalCode,
  1242. Telephone = ent.Patient.Telephone,
  1243. CustomerOrgName = "",
  1244. CustomerOrgParentName = ""
  1245. };
  1246. }
  1247. return entdto;
  1248. }
  1249. #endregion
  1250. #region 收费、退费、未收费
  1251. /// <summary>
  1252. /// 收费
  1253. /// </summary>
  1254. /// <param name="input"></param>
  1255. /// <returns></returns>
  1256. [HttpPost("api/app/patientregister/getpatientregisterchargelist")]
  1257. public async Task<PagedResultDto<GetPatientRegisterChargeListDto>> GetPatientRegisterChargeListAsync(PatientRegisterChargeRequestDto input)
  1258. {
  1259. PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto
  1260. {
  1261. EndDate = input.EndDate,
  1262. InvoiceNo = input.InvoiceNo,
  1263. PatientName = input.PatientName,
  1264. PatientNo = input.PatientNo,
  1265. PatientRegisterNo = input.PatientRegisterNo,
  1266. StartDate = input.StartDate
  1267. };
  1268. var patientRegisterChargeList = await _patientRegisterChargeRepository.GetPatientRegisterChargeListAsync(patientRegisterChargeEfCoreDto);
  1269. int totalCount = patientRegisterChargeList.Count;
  1270. patientRegisterChargeList = patientRegisterChargeList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
  1271. return new PagedResultDto<GetPatientRegisterChargeListDto>(totalCount, patientRegisterChargeList);
  1272. }
  1273. /// <summary>
  1274. /// 未收费
  1275. /// </summary>
  1276. /// <param name="input"></param>
  1277. /// <returns></returns>
  1278. [HttpPost("api/app/patientregister/getpatientregisternotchargedlist")]
  1279. public async Task<PagedResultDto<GetPatientRegisterNotChargedListDto>> GetPatientRegisterNotChargedListAsync(PatientRegisterChargeRequestDto input)
  1280. {
  1281. PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto
  1282. {
  1283. EndDate = input.EndDate,
  1284. InvoiceNo = input.InvoiceNo,
  1285. PatientName = input.PatientName,
  1286. PatientNo = input.PatientNo,
  1287. PatientRegisterNo = input.PatientRegisterNo,
  1288. StartDate = input.StartDate
  1289. };
  1290. var patientRegisterNotChargedList = await _patientRegisterChargeRepository.GetPatientRegisterNotChargedListAsync(patientRegisterChargeEfCoreDto);
  1291. int totalCount = patientRegisterNotChargedList.Count;
  1292. patientRegisterNotChargedList = patientRegisterNotChargedList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
  1293. return new PagedResultDto<GetPatientRegisterNotChargedListDto>(totalCount, patientRegisterNotChargedList);
  1294. }
  1295. /// <summary>
  1296. /// 退费
  1297. /// </summary>
  1298. /// <param name="input"></param>
  1299. /// <returns></returns>
  1300. [HttpPost("api/app/patientregister/getpatientregisterchargebacklist")]
  1301. public async Task<PagedResultDto<GetPatientRegisterChargeBackListDto>> GetPatientRegisterChargeBackListAsync(PatientRegisterChargeRequestDto input)
  1302. {
  1303. PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto
  1304. {
  1305. EndDate = input.EndDate,
  1306. InvoiceNo = input.InvoiceNo,
  1307. PatientName = input.PatientName,
  1308. PatientNo = input.PatientNo,
  1309. PatientRegisterNo = input.PatientRegisterNo,
  1310. StartDate = input.StartDate
  1311. };
  1312. var patientRegisterChargeBackList = await _patientRegisterChargeRepository.GetPatientRegisterChargeBackListAsync(patientRegisterChargeEfCoreDto);
  1313. int totalCount = patientRegisterChargeBackList.Count;
  1314. patientRegisterChargeBackList = patientRegisterChargeBackList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
  1315. return new PagedResultDto<GetPatientRegisterChargeBackListDto>(totalCount, patientRegisterChargeBackList);
  1316. }
  1317. #endregion
  1318. #region 查询体检人员项目情况
  1319. /// <summary>
  1320. /// 查询体检人员的项目状况
  1321. /// </summary>
  1322. /// <returns></returns>
  1323. [HttpGet("api/app/patientregister/getpatientregisteritemstatus")]
  1324. public async Task<GetPatientRegisterItemStatusDto> GetPatientRegisterItemStatusAsync(Guid PatientRegisterId)
  1325. {
  1326. //未检组合项目
  1327. var UnCheckedAsbitem = (await _registerAsbitemRepository.GetDbSetAsync())
  1328. .Include(x => x.Asbitem)
  1329. .Include(x => x.RegisterCheck)
  1330. .Where(m => m.PatientRegisterId == PatientRegisterId && m.RegisterCheck.CompleteFlag == '0').OrderBy(o => o.Asbitem.DisplayOrder).Select(s => s.Asbitem.DisplayName).ToList();
  1331. //弃检检组合项目
  1332. var GiveUpAsbitem = (await _registerAsbitemRepository.GetDbSetAsync())
  1333. .Include(x => x.Asbitem)
  1334. .Include(x => x.RegisterCheck)
  1335. .Where(m => m.PatientRegisterId == PatientRegisterId && m.RegisterCheck.CompleteFlag == '2').OrderBy(o => o.Asbitem.DisplayOrder).Select(s => s.Asbitem.DisplayName).ToList();
  1336. //组合项目已检,项目无明细的项目
  1337. var registerAsbItemQueryable = await _registerAsbitemRepository.GetQueryableAsync();
  1338. var registerCheckQueryable = await _registerCheckRepository.GetQueryableAsync();
  1339. var registerCheckItemQueryable = await _registerCheckItemRepository.GetQueryableAsync();
  1340. var itemQueryable = await _itemRepository.GetQueryableAsync();
  1341. var CheckedNullValueItem = (from a in registerCheckItemQueryable
  1342. join b in registerCheckQueryable on a.RegisterCheckId equals b.Id
  1343. join c in registerAsbItemQueryable on b.Id equals c.RegisterCheckId
  1344. join d in itemQueryable on a.ItemId equals d.Id into dd
  1345. from ad in dd.DefaultIfEmpty()
  1346. where (c.PatientRegisterId == PatientRegisterId && string.IsNullOrEmpty(a.Result) && b.CompleteFlag == '1')
  1347. orderby ad.DisplayOrder ascending
  1348. select new { ItemName = ad.DisplayName }).Select(s => s.ItemName).ToList();
  1349. //组合项目已检,项目弃检
  1350. var CheckedGiveUpItem = (from a in registerCheckItemQueryable
  1351. join b in registerCheckQueryable on a.RegisterCheckId equals b.Id
  1352. join c in registerAsbItemQueryable on b.Id equals c.RegisterCheckId
  1353. join d in itemQueryable on a.ItemId equals d.Id into dd
  1354. from ad in dd.DefaultIfEmpty()
  1355. where (c.PatientRegisterId == PatientRegisterId && b.CompleteFlag == '1' && !string.IsNullOrEmpty(a.Result) && a.Result.Contains("放弃检查"))
  1356. orderby ad.DisplayOrder ascending
  1357. select new { ItemName = ad.DisplayName }).Select(s => s.ItemName).ToList();
  1358. var entdto = new GetPatientRegisterItemStatusDto
  1359. {
  1360. GiveUpAsbitem = GiveUpAsbitem,
  1361. CheckedGiveUpItem = CheckedGiveUpItem,
  1362. CheckedNullValueItem = CheckedNullValueItem,
  1363. UnCheckedAsbitem = UnCheckedAsbitem
  1364. };
  1365. return entdto;
  1366. }
  1367. #endregion
  1368. }
  1369. }