From d43a0f1175479e9d16a274c7bc72a4a41105fbb1 Mon Sep 17 00:00:00 2001
From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com>
Date: Mon, 29 Apr 2024 23:24:06 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E8=B4=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 .../RegisterCheckAsbitemAppService.cs         | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
diff --git a/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs b/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs
index 1da0148..d71d75b 100644
--- a/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs
+++ b/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs
@@ -7,6 +7,7 @@ using Shentun.Peis.DeviceTypes;
 using Shentun.Peis.Enums;
 using Shentun.Peis.ForSexs;
 using Shentun.Peis.Models;
+using Shentun.Peis.PatientRegisters;
 using Shentun.Peis.RegisterCheckCriticalValues;
 using Shentun.Peis.RegisterCheckItems;
 using Shentun.Peis.RegisterCheckPictures;
@@ -330,8 +331,79 @@ namespace Shentun.Peis.RegisterAsbitems
                    OrderBy(o => o.Id).ToList();
             return entdto;
         }
+        /// 
+        /// 
+        /// 
+        /// 
+        /// 
+        [HttpGet("api/app/registerasbitem/GetCanChargeAsbitemsByPatientRegisterId")]
+        public async Task> GetCanChargeAsbitemsByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
+        {
+            var patientReigister = await _patientRegisterRepository.GetAsync(input.PatientRegisterId);
+            var entlist = (await _registerCheckAsbitemRepository.GetQueryableAsync())
+                .Include(x => x.Asbitem)
+                .Include(x => x.Asbitem.ItemType)
+                .Include(x => x.RegisterCheck)
+              .Where(m => m.PatientRegisterId == input.PatientRegisterId && 
+                        m.IsCharge == 'Y' && m.PayTypeFlag == PayTypeFlag.PersonPay).ToList().OrderByDescending(o => o.GroupPackageId).ThenBy(o => o.Asbitem.DisplayOrder);
 
 
+            var entdto = entlist.Select(s => new RegisterCheckAsbitemOrAsbitemDto
+            {
+                Discount = s.StandardPrice == 0 ? 100 : Math.Round(Convert.ToDecimal(s.ChargePrice * 100 / s.StandardPrice), 2),
+                IsLock = s.RegisterCheck.IsLock,
+                CreationTime = s.CreationTime,
+                CreatorId = s.CreatorId,
+                Id = s.Id,
+                LastModificationTime = s.LastModificationTime,
+                LastModifierId = s.LastModifierId,
+                Amount = s.Amount,
+                AsbitemId = s.AsbitemId,
+                AsbitemName = s.Asbitem.DisplayName,
+                ChargePrice = s.ChargePrice,
+                IsBelongGroupPackage = 'N',
+                //GroupPackageId = s.GroupPackageId,
+                CheckCompleteFlag = s.RegisterCheck.CompleteFlag,
+                DeviceTypeName = s.Asbitem.DeviceTypeId != null ? _cacheService.GetDeviceTypeNameAsync(s.Asbitem.DeviceTypeId.Value).Result : "",
+                IsCharge = s.IsCharge,
+                ItemTypeName = s.Asbitem.ItemType.DisplayName,
+                LisRequestId = s.LisRequestId,
+                PatientRegisterId = s.PatientRegisterId,
+                PayTypeFlag = s.PayTypeFlag,
+                SexName = _cacheService.GetForSexNameAsync(s.Asbitem.ForSexId).Result,
+                StandardPrice = s.StandardPrice,
+                CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
+                LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
+            }).ToList();
+
+            //设置GroupPackageId
+            if (patientReigister.CustomerOrgGroupId != null && patientReigister.CustomerOrgGroupId != Guid.Empty)
+            {
+                var groupDetails = (await _customerOrgGroupDetailRepository.GetQueryableAsync()).Where(o => o.CustomerOrgGroupId == patientReigister.CustomerOrgGroupId).ToList();
+                entdto.ForEach(o =>
+                {
+                    if (groupDetails.Where(x => x.AsbitemId == o.AsbitemId).Count() > 0)
+                    {
+                        o.IsBelongGroupPackage = 'Y';
+                    }
+                });
+            }
+            else if (patientReigister.MedicalPackageId != null && patientReigister.MedicalPackageId != Guid.Empty)
+            {
+                var groupDetails = (await _medicalPackageDetailRepository.GetQueryableAsync()).Where(o => o.MedicalPackageId == patientReigister.MedicalPackageId).ToList();
+                entdto.ForEach(o =>
+                {
+                    if (groupDetails.Where(x => x.AsbitemId == o.AsbitemId).Count() > 0)
+                    {
+                        o.IsBelongGroupPackage = 'Y';
+                    }
+                });
+            }
+
+            entdto = entdto.OrderByDescending(o => o.IsBelongGroupPackage).
+                   OrderBy(o => o.Id).ToList();
+            return entdto;
+        }
 
         #region 批量操作组合项目业务,单位操作