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.
185 lines
7.9 KiB
185 lines
7.9 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Shentun.Peis.Enums;
|
|
using Shentun.Peis.Models;
|
|
using Shentun.Peis.SumSummaryContents;
|
|
using Shentun.Peis.SysParmValues;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.ObjectMapping;
|
|
|
|
namespace Shentun.Peis.SumSummaryHeaders
|
|
{
|
|
|
|
/// <summary>
|
|
/// 总检诊台小结
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class SumSummaryHeaderAppService : ApplicationService
|
|
{
|
|
|
|
private readonly IRepository<SumSummaryHeader, Guid> _sumSummaryHeaderRepository;
|
|
private readonly IRepository<SumSummaryContent, Guid> _sumSummaryContentRepository;
|
|
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
|
|
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
|
|
private readonly SysParmValueManager _sysParmValueManager;
|
|
private readonly SumSummaryHeaderManager _sumSummaryHeaderManager;
|
|
public SumSummaryHeaderAppService(
|
|
IRepository<SumSummaryHeader, Guid> sumSummaryHeaderRepository,
|
|
IRepository<SumSummaryContent, Guid> sumSummaryContentRepository,
|
|
IRepository<RegisterCheck, Guid> registerCheckRepository,
|
|
IRepository<PatientRegister, Guid> patientRegisterRepository,
|
|
SysParmValueManager sysParmValueManager,
|
|
SumSummaryHeaderManager sumSummaryHeaderManager
|
|
|
|
)
|
|
{
|
|
this._sumSummaryHeaderRepository = sumSummaryHeaderRepository;
|
|
this._sumSummaryContentRepository = sumSummaryContentRepository;
|
|
this._registerCheckRepository = registerCheckRepository;
|
|
_sysParmValueManager = sysParmValueManager;
|
|
_patientRegisterRepository = patientRegisterRepository;
|
|
_sumSummaryHeaderManager = sumSummaryHeaderManager;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取人员总检诊台小结 (如还未录入,获取医生诊台录入的小结)
|
|
/// </summary>
|
|
/// <param name="patientRegisterId">人员登记ID</param>
|
|
/// <returns></returns>
|
|
[HttpGet("api/app/sumsummaryheader/getsumsummarylist")]
|
|
public async Task<List<SumSummaryHeaderOrContentDto>> GetSumSummaryListAsync(Guid patientRegisterId)
|
|
{
|
|
|
|
List<SumSummaryHeaderOrContentDto> msg = new List<SumSummaryHeaderOrContentDto>();
|
|
var patientRegister = await _patientRegisterRepository.GetAsync(patientRegisterId);
|
|
var entlist = (await _sumSummaryHeaderRepository.GetDbSetAsync())
|
|
.Include(x => x.SumSummaryContents)
|
|
.Where(m => m.PatientRegisterId == patientRegisterId).OrderBy(o => o.DisplayOrder).ToList();
|
|
|
|
if (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.GeneralInspected)
|
|
{
|
|
//已总检取综述中的值
|
|
msg = entlist.Select(s => new SumSummaryHeaderOrContentDto
|
|
{
|
|
SummaryTitle = s.SummaryTitle,
|
|
SummaryFlag = s.SummaryFlag,
|
|
PatientRegisterId = s.PatientRegisterId,
|
|
DisplayOrder = s.DisplayOrder,
|
|
Id = s.Id,
|
|
Details = s.SumSummaryContents.OrderBy(o => o.DisplayOrder).Select(sa => new SumSummaryContentDto
|
|
{
|
|
DisplayOrder = sa.DisplayOrder,
|
|
SummaryContent = sa.SummaryContent,
|
|
SumSummaryHeaderId = sa.SumSummaryHeaderId,
|
|
}).OrderBy(o => o.DisplayOrder).ToList()
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
}
|
|
else
|
|
{
|
|
//未总检
|
|
var checklist = await _sumSummaryHeaderManager.GetSumSummarysByDoctorCheck(patientRegisterId);
|
|
|
|
if (checklist.Any() && checklist.Count(c => c.RegisterCheckSummaries.Count > 0) > 0)
|
|
{
|
|
msg = checklist.Select(s => new SumSummaryHeaderOrContentDto
|
|
{
|
|
Id = s.Id,
|
|
SummaryTitle = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.DisplayName).ToList()),
|
|
SummaryFlag = null,
|
|
PatientRegisterId = s.RegisterCheckAsbitems.FirstOrDefault().PatientRegisterId,
|
|
DisplayOrder = 0,
|
|
Details = s.RegisterCheckSummaries.OrderBy(o => o.DisplayOrder).Select(sa => new SumSummaryContentDto
|
|
{
|
|
DisplayOrder = sa.DisplayOrder,
|
|
SummaryContent = sa.Summary,
|
|
SumSummaryHeaderId = sa.RegisterCheckId
|
|
}).OrderBy(o => o.DisplayOrder).ToList()
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
}
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量插入总诊台小结
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/sumsummaryheader/createsumsummary")]
|
|
public async Task CreateSumSummaryAsync(List<CreateSumSummaryHeaderOrContentDto> input)
|
|
{
|
|
throw new UserFriendlyException("禁止使用");
|
|
if (input.Any())
|
|
{
|
|
|
|
//先删除
|
|
await _sumSummaryHeaderRepository.DeleteAsync(m => m.PatientRegisterId == input.FirstOrDefault().PatientRegisterId, true);
|
|
|
|
foreach (var item in input)
|
|
{
|
|
#region 插入SumSummaryHeader
|
|
SumSummaryHeader sumSummaryHeaderEnt = new SumSummaryHeader
|
|
{
|
|
DisplayOrder = input.IndexOf(item) + 1,
|
|
PatientRegisterId = item.PatientRegisterId,
|
|
SummaryFlag = null,
|
|
SummaryTitle = item.SummaryTitle
|
|
};
|
|
|
|
var sumSummaryHeaderEnt_New = await _sumSummaryHeaderRepository.InsertAsync(sumSummaryHeaderEnt, true);
|
|
|
|
if (sumSummaryHeaderEnt_New != null)
|
|
{
|
|
#region 插入SumSummaryContent
|
|
List<SumSummaryContent> sumSummaryContentList = new List<SumSummaryContent>();
|
|
foreach (var item2 in item.Details)
|
|
{
|
|
SumSummaryContent sumSummaryContentEnt = new SumSummaryContent
|
|
{
|
|
DisplayOrder = item.Details.IndexOf(item2) + 1,
|
|
SummaryContent = item2.SummaryContent,
|
|
SumSummaryHeaderId = sumSummaryHeaderEnt_New.Id
|
|
};
|
|
|
|
sumSummaryContentList.Add(sumSummaryContentEnt);
|
|
}
|
|
|
|
await _sumSummaryContentRepository.InsertManyAsync(sumSummaryContentList);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 清空总诊台小结内容
|
|
/// </summary>
|
|
/// <param name="PatientRegisterId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/sumsummaryheader/deletesumsummarymany")]
|
|
public async Task DeleteSumSummaryManyAsync(Guid PatientRegisterId)
|
|
{
|
|
if (PatientRegisterId != Guid.Empty)
|
|
{
|
|
await _sumSummaryHeaderRepository.DeleteAsync(d => d.PatientRegisterId == PatientRegisterId);
|
|
}
|
|
else
|
|
{
|
|
throw new UserFriendlyException("请求参数有误");
|
|
}
|
|
}
|
|
}
|
|
}
|