Browse Source

单位

bjmzak
wxd 1 year ago
parent
commit
afe13a3547
  1. 40
      src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgTreeChildDto.cs
  2. 2
      src/Shentun.Peis.Application.Contracts/PatientRegisters/UpdatePatientRegisterAuditorDoctorDto.cs
  3. 50
      src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs
  4. 43
      src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs
  5. 8
      src/Shentun.Peis.Application/PeisReports/PeisReportAppService.cs
  6. 32
      src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
  7. 7
      src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrg.cs
  8. 53
      src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs
  9. 14969
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240605134759_init20240605002.Designer.cs
  10. 26
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240605134759_init20240605002.cs
  11. 5
      src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

40
src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgTreeChildDto.cs

@ -0,0 +1,40 @@
using Shentun.Peis.OrganizationUnits;
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.CustomerOrgs
{
public class CustomerOrgTreeChildDto
{
//组织Id
public Guid Id { get; set; }
//组织名称
public string DisplayName { get; set; }
//父节点Id
public Guid? ParentId { get; set; }
/// <summary>
/// 用来做递归的 新用法
/// </summary>
public string Code { get; set; }
/// <summary>
/// 短名称
/// </summary>
public string ShortName { get; set; }
/// <summary>
/// 单位编码
/// </summary>
public string CustomerOrgCode { get; set; }
/// <summary>
/// 拼音简码
/// </summary>
public string SimpleCode { get; set; }
public int DisplayOrder { get; set; }
public List<CustomerOrgTreeChildDto> TreeChildren { get; set; }
}
}

2
src/Shentun.Peis.Application.Contracts/PatientRegisters/UpdatePatientRegisterAuditorDoctorDto.cs

@ -14,7 +14,7 @@ namespace Shentun.Peis.PatientRegisters
/// <summary>
/// 审核医生(不传默认为当前用户)
/// </summary>
public string? AuditDoctor { get; set; }
public string? AuditDoctorId { get; set; }
/// <summary>
/// 审核日期(格式:2023-07-18) 空值跟null取当前日期
/// </summary>

50
src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs

@ -278,27 +278,56 @@ namespace Shentun.Peis.CustomerOrgs
/// <param name="Filter">名字搜索,支持模糊查找</param>
/// <returns></returns>
[HttpGet("api/app/customerorg/getbycodeall")]
public async Task<List<TreeChildViewDto>> GetByCodeAllAsync(string Filter, int IsHidePerson = 0)
public async Task<List<CustomerOrgTreeChildDto>> GetByCodeAllAsync(string Filter, int IsHidePerson = 0)
{
var dataList = await Repository.GetListAsync();
List<CustomerOrgTreeChildDto> result = new List<CustomerOrgTreeChildDto>();
var customerOrgPerson = await Repository.FirstOrDefaultAsync(f => f.Id == GuidFlag.PersonCustomerOrgId);
var dataList = (await Repository.GetQueryableAsync());
if (!string.IsNullOrEmpty(Filter))
dataList = dataList.Where(m => m.DisplayName.Contains(Filter) || m.ShortName.Contains(Filter)).ToList();
dataList = dataList.Where(m => m.DisplayName.Contains(Filter) || m.ShortName.Contains(Filter));
if (IsHidePerson == 1)
{
dataList = dataList.Where(m => m.Id != GuidFlag.PersonCustomerOrgId).ToList();
dataList = dataList.Where(m => m.Id != GuidFlag.PersonCustomerOrgId);
}
else
{
if (customerOrgPerson != null)
{
result.Add(new CustomerOrgTreeChildDto
{
Code = customerOrgPerson.PathCode,
CustomerOrgCode = customerOrgPerson.CustomerOrgCode,
DisplayName = customerOrgPerson.DisplayName,
DisplayOrder = customerOrgPerson.DisplayOrder,
Id = customerOrgPerson.Id,
ParentId = customerOrgPerson.ParentId,
ShortName = customerOrgPerson.ShortName,
SimpleCode = customerOrgPerson.SimpleCode,
TreeChildren = null
});
}
}
var items = from p in dataList.OrderBy(o => o.DisplayOrder)
select new TreeChildViewDto()
var items = from p in dataList.Where(m => m.Id != GuidFlag.PersonCustomerOrgId).OrderByDescending(o => o.DisplayOrder)
select new CustomerOrgTreeChildDto()
{
Id = p.Id,
ParentId = p.ParentId,
Code = p.PathCode,
DisplayName = p.DisplayName,
SimpleCode = p.SimpleCode,
ShortName = p.ShortName
ShortName = p.ShortName,
CustomerOrgCode = p.CustomerOrgCode
};
return GetTree(items.ToList(), 0, "");
var customerOrgTreeChildList = GetTree(items.ToList(), 0, "");
result.AddRange(customerOrgTreeChildList);
return result;
}
/// <summary>
@ -308,12 +337,12 @@ namespace Shentun.Peis.CustomerOrgs
/// <param name="deep"></param>
/// <param name="prefix"></param>
/// <returns></returns>
private List<TreeChildViewDto> GetTree(List<TreeChildViewDto> items, int deep, string prefix)
private List<CustomerOrgTreeChildDto> GetTree(List<CustomerOrgTreeChildDto> items, int deep, string prefix)
{
return (from p in items
where p.Code.StartsWith(prefix) && p.Code.Count(a => a == '.') == deep
let subs = GetTree(items, deep + 1, p.Code)
select new TreeChildViewDto()
select new CustomerOrgTreeChildDto()
{
Id = p.Id,
ParentId = p.ParentId,
@ -321,6 +350,7 @@ namespace Shentun.Peis.CustomerOrgs
DisplayName = p.DisplayName,
SimpleCode = p.SimpleCode,
ShortName = p.ShortName,
CustomerOrgCode = p.CustomerOrgCode,
TreeChildren = subs.ToList()
}
).ToList();

43
src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs

@ -3114,24 +3114,24 @@ namespace Shentun.Peis.DataMigrations
foreach (var item in TempDate)
{
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
{
{
#region 修复建议头ID
var sumDiagnosisList = await _sumDiagnosisRepository.GetListAsync(m => m.PatientRegisterId == item.Id);
foreach (var sumDiagnosis in sumDiagnosisList)
{
var isSumSuggestionHeaderId = await _sumSuggestionHeaderRepository.CountAsync(c => c.Id == sumDiagnosis.SumSuggestionHeaderId);
if (isSumSuggestionHeaderId == 0)
foreach (var sumDiagnosis in sumDiagnosisList)
{
var sumSuggestionContentEnt = await _sumSuggestionContentRepository.FirstOrDefaultAsync(m => m.Id == sumDiagnosis.SumSuggestionHeaderId);
if (sumSuggestionContentEnt != null)
var isSumSuggestionHeaderId = await _sumSuggestionHeaderRepository.CountAsync(c => c.Id == sumDiagnosis.SumSuggestionHeaderId);
if (isSumSuggestionHeaderId == 0)
{
sumDiagnosis.SumSuggestionHeaderId = sumSuggestionContentEnt.SumSuggestionHeaderId;
var sumSuggestionContentEnt = await _sumSuggestionContentRepository.FirstOrDefaultAsync(m => m.Id == sumDiagnosis.SumSuggestionHeaderId);
if (sumSuggestionContentEnt != null)
{
sumDiagnosis.SumSuggestionHeaderId = sumSuggestionContentEnt.SumSuggestionHeaderId;
}
}
}
}
await _sumDiagnosisRepository.UpdateManyAsync(sumDiagnosisList);
await _sumDiagnosisRepository.UpdateManyAsync(sumDiagnosisList);
#endregion
@ -5241,6 +5241,29 @@ namespace Shentun.Peis.DataMigrations
return "";
}
/// <summary>
/// 同步单位编号
/// </summary>
/// <returns></returns>
public async Task UpdateCustomerOrgData()
{
var customerOrgs = await _customerOrgRepository.GetListAsync();
foreach (var item in customerOrgs)
{
var oldKeyEnt = await _fieldComparisonRepository.FirstOrDefaultAsync(m => m.TableName == "customer_org" && m.NewKeyValue == item.Id.ToString());
if (oldKeyEnt != null)
{
item.CustomerOrgCode = oldKeyEnt.OldKeyValue;
}
else
{
item.CustomerOrgCode = "";
}
await _customerOrgRepository.UpdateAsync(item);
}
}
}

8
src/Shentun.Peis.Application/PeisReports/PeisReportAppService.cs

@ -243,10 +243,10 @@ namespace Shentun.Peis.PeisReports
{
sumquery = sumquery.Where(m => m.a.CompleteFlag == input.CompleteFlag);
}
else
{
sumquery = sumquery.Where(m => m.a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration);
}
//else
//{
// sumquery = sumquery.Where(m => m.a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration);
//}
if (input.IsAudit != null)
{

32
src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs

@ -168,6 +168,12 @@ namespace Shentun.Peis.TransToWebPeis
[HttpPost("api/app/TransToWebPeis/UploadPeisReport")]
public async Task UploadPeisReportAsync(UploadPeisReportIuputDto input)
{
var isPatientRegister = await _patientRegisterRepository.FirstOrDefaultAsync(f => f.Id == input.PatientRegisterId);
if (isPatientRegister == null)
throw new UserFriendlyException("人员不存在");
if (isPatientRegister.CompleteFlag != PatientRegisterCompleteFlag.SumCheck)
throw new UserFriendlyException("人员未总检,无法上传");
//同步数据
await TransPatientRegisterByPatientRegisterIdAsync(new PatientRegisterIdInputDto { PatientRegisterId = input.PatientRegisterId });
//上传报告
@ -693,13 +699,13 @@ namespace Shentun.Peis.TransToWebPeis
{
foreach (var customerOrgGroup in customerOrgGroups)
{
await WebDb.Ado.ExecuteCommandAsync("INSERT INTO public.customer_org_group(customer_org_group_id, display_name, price, for_sex_id, marital_status_id, age_lower_limit, age_upper_limit," +
await WebDb.Ado.ExecuteCommandAsync("INSERT INTO public.customer_org_group(customer_org_group_id, customer_org_group_name, price, for_sex_id, marital_status_id, age_lower_limit, age_upper_limit," +
"job_post, job_title, remark, display_order, customer_org_register_id, concurrency_stamp, creation_time, creator_id,last_modification_time, last_modifier_id) " +
"VALUES (@customer_org_group_id,@display_name,@price,@for_sex_id,@marital_status_id,@age_lower_limit,@age_upper_limit," +
"VALUES (@customer_org_group_id,@customer_org_group_name,@price,@for_sex_id,@marital_status_id,@age_lower_limit,@age_upper_limit," +
"@job_post,@job_title,@remark,@display_order,@customer_org_register_id,@concurrency_stamp,@creation_time,@creator_id,@last_modification_time,@last_modifier_id);",
new List<SugarParameter>() {
new SugarParameter("customer_org_group_id",customerOrgGroup.Id),
new SugarParameter("display_name",customerOrgGroup.DisplayName),
new SugarParameter("customer_org_group_name",customerOrgGroup.DisplayName),
new SugarParameter("price",customerOrgGroup.Price),
new SugarParameter("for_sex_id",customerOrgGroup.ForSexId),
new SugarParameter("marital_status_id",customerOrgGroup.MaritalStatusId),
@ -779,8 +785,8 @@ namespace Shentun.Peis.TransToWebPeis
.Where(m => m.Id == PatientRegisterId).FirstOrDefault();
if (patientRegisterEnt != null)
{
if (patientRegisterEnt.CompleteFlag != PatientRegisterCompleteFlag.SumCheck)
throw new UserFriendlyException("人员未总检,不能同步");
//if (patientRegisterEnt.CompleteFlag != PatientRegisterCompleteFlag.SumCheck)
// throw new UserFriendlyException("人员未总检,不能同步");
@ -834,11 +840,11 @@ namespace Shentun.Peis.TransToWebPeis
await WebDb.Ado.ExecuteCommandAsync("INSERT INTO public.patient_register(patient_register_id, patient_register_no, patient_id, medical_times, customer_org_id, customer_org_group_id, medical_package_id," +
"patient_name,sex_id, birth_date, age, job_card_no, medical_card_no, marital_status_id, medical_type_id, personnel_type_id, job_post, job_title, photo," +
" sex_hormone_term_id, interpose_measure, medical_conclusion_id, complete_flag, is_medical_start, medical_start_date, summary_date, is_audit, audit_date, is_vip, third_info,remark,medical_center_id," +
"customer_org_register_id, concurrency_stamp, creation_time, creator_id, last_modification_time, last_modifier_id, audit_doctor_id,summary_doctor_id, his_patient_id,third_register_id,appoint_patient_register_id) VALUES " +
"customer_org_register_id, concurrency_stamp, creation_time, creator_id, last_modification_time, last_modifier_id, audit_doctor_id,summary_doctor_id, his_patient_id,third_register_id) VALUES " +
"(@patient_register_id,@patient_register_no,@patient_id,@medical_times,@customer_org_id,@customer_org_group_id::uuid,@medical_package_id::uuid," +
"@patient_name,@sex_id,CAST(@birth_date as timestamp),@age,@job_card_no,@medical_card_no,@marital_status_id,@medical_type_id::uuid,@personnel_type_id::uuid,@job_post,@job_title,@photo," +
"@sex_hormone_term_id::uuid,@interpose_measure,@medical_conclusion_id::uuid,@complete_flag,@is_medical_start,@medical_start_date,CAST(@summary_date as timestamp),@is_audit,CAST(@audit_date as timestamp),@is_vip,@third_info,@remark,@medical_center_id," +
"@customer_org_register_id,@concurrency_stamp,@creation_time,@creator_id,@last_modification_time,@last_modifier_id,@audit_doctor_id::uuid,@summary_doctor_id::uuid,@his_patient_id,@third_register_id,@appoint_patient_register_id);",
"@customer_org_register_id,@concurrency_stamp,@creation_time,@creator_id,@last_modification_time,@last_modifier_id,@audit_doctor_id::uuid,@summary_doctor_id::uuid,@his_patient_id,@third_register_id);",
new List<SugarParameter>() {
new SugarParameter("patient_register_id",patientRegisterEnt.Id),
new SugarParameter("patient_register_no",patientRegisterEnt.PatientRegisterNo),
@ -882,8 +888,7 @@ namespace Shentun.Peis.TransToWebPeis
new SugarParameter("audit_doctor_id",patientRegisterEnt.AuditDoctorId),
new SugarParameter("summary_doctor_id",patientRegisterEnt.SummaryDoctorId),
new SugarParameter("his_patient_id",patientRegisterEnt.HisPatientId),
new SugarParameter("third_register_id",third_register_id),
new SugarParameter("appoint_patient_register_id",patientRegisterEnt.AppointPatientRegisterId)
new SugarParameter("third_register_id",third_register_id)
});
#endregion
@ -904,10 +909,10 @@ namespace Shentun.Peis.TransToWebPeis
#region register_check
await WebDb.Ado.ExecuteCommandAsync("INSERT INTO public.register_check(register_check_id, patient_register_id, check_request_no, third_info, complete_flag, critical_value, critical_value_flag, critical_value_process_content," +
"critical_value_process_flag, critical_value_process_doctor, critical_value_process_date, critical_value_create_date, check_doctor_id, check_date, is_audit," +
" auditor_user_id, audit_time, concurrency_stamp, creation_time, creator_id, last_modification_time, last_modifier_id, exec_organization_unit_id,is_sign_in,sign_in_person,sign_in_time) VALUES " +
" auditor_user_id, audit_time, concurrency_stamp, creation_time, creator_id, last_modification_time, last_modifier_id, exec_organization_unit_id) VALUES " +
"(@register_check_id,@patient_register_id,@check_request_no,@third_info,@complete_flag,@critical_value,@critical_value_flag,@critical_value_process_content," +
"@critical_value_process_flag,@critical_value_process_doctor,CAST(@critical_value_process_date as timestamp),CAST(@critical_value_create_date as timestamp),@check_doctor_id,CAST(@check_date as timestamp),@is_audit," +
"@auditor_user_id::uuid,CAST(@audit_time as timestamp),@concurrency_stamp,@creation_time,@creator_id,@last_modification_time,@last_modifier_id,@exec_organization_unit_id::uuid,@is_sign_in,@sign_in_person,@sign_in_time);",
"@auditor_user_id::uuid,CAST(@audit_time as timestamp),@concurrency_stamp,@creation_time,@creator_id,@last_modification_time,@last_modifier_id,@exec_organization_unit_id::uuid);",
new List<SugarParameter>() {
new SugarParameter("register_check_id",registerCheckWithDetail.Id),
new SugarParameter("patient_register_id",registerCheckWithDetail.PatientRegisterId),
@ -931,10 +936,7 @@ namespace Shentun.Peis.TransToWebPeis
new SugarParameter("creator_id",registerCheckWithDetail.CreatorId),
new SugarParameter("last_modification_time",registerCheckWithDetail.LastModificationTime),
new SugarParameter("last_modifier_id",registerCheckWithDetail.LastModifierId),
new SugarParameter("exec_organization_unit_id",registerCheckWithDetail.ExecOrganizationUnitId),
new SugarParameter("is_sign_in",registerCheckWithDetail.IsSignIn),
new SugarParameter("sign_in_person",registerCheckWithDetail.SignInPerson),
new SugarParameter("sign_in_time",registerCheckWithDetail.SignInTime)
new SugarParameter("exec_organization_unit_id",registerCheckWithDetail.ExecOrganizationUnitId)
});
#endregion

7
src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrg.cs

@ -157,6 +157,13 @@ namespace Shentun.Peis.Models
public string SalesPersonPhone { get; set; }
/// <summary>
/// 单位编码 兼容老系统
/// </summary>
[Column("customer_org_code")]
[StringLength(50)]
public string CustomerOrgCode { get; set; }
//[Column("creator_id")]
//public Guid CreatorId { get; set; }
//[Column("creation_time", TypeName = "timestamp without time zone")]

53
src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs

@ -72,7 +72,7 @@ namespace Shentun.Peis.CustomerOrgs
CustomerOrg entity
)
{
if(entity.OrgTypeId == Guid.Empty)
if (entity.OrgTypeId == Guid.Empty)
{
entity.OrgTypeId = (await _customerOrgTypeRepository.GetListAsync()).FirstOrDefault().Id;
}
@ -206,7 +206,56 @@ namespace Shentun.Peis.CustomerOrgs
/// <returns></returns>
public async Task UpdateManySortAsync(Guid id, int SortType)
{
await EntityHelper.UpdateManySortAsync(_repository, id, SortType);
var entity = await _repository.GetAsync(id);
List<CustomerOrg> UptList = new List<CustomerOrg>();
if (SortType == 1)
{
UptList = (await _repository.GetListAsync(o => o.ParentId == entity.ParentId && o.DisplayOrder > entity.DisplayOrder)).OrderBy(o => o.DisplayOrder).ToList();
if (UptList.Count > 0)
{
int indexnum = entity.DisplayOrder; //原有值
entity.DisplayOrder = UptList[UptList.Count - 1].DisplayOrder; //修改当前排序值为最大
//置顶操作,往上一行开始,逐渐替换
foreach (var item in UptList)
{
int dqnum = item.DisplayOrder;
item.DisplayOrder = indexnum;
indexnum = dqnum;
}
}
}
else
{
UptList = (await _repository.GetListAsync(o => o.ParentId == entity.ParentId && o.DisplayOrder < entity.DisplayOrder)).OrderByDescending(o => o.DisplayOrder).ToList(); ;
if (UptList.Count > 0)
{
int indexnum = entity.DisplayOrder; //原有值
entity.DisplayOrder = UptList[UptList.Count - 1].DisplayOrder; //修改当前排序值为最小
//置底操作,往下一行开始,逐渐替换
foreach (var item in UptList)
{
int dqnum = item.DisplayOrder;
item.DisplayOrder = indexnum;
indexnum = dqnum;
}
}
}
UptList.Add(entity);
await _repository.UpdateManyAsync(UptList);
}

14969
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240605134759_init20240605002.Designer.cs
File diff suppressed because it is too large
View File

26
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240605134759_init20240605002.cs

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class init20240605002 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "customer_org_code",
table: "customer_org",
type: "character varying(50)",
maxLength: 50,
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "customer_org_code",
table: "customer_org");
}
}
}

5
src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

@ -2628,6 +2628,11 @@ namespace Shentun.Peis.Migrations
.HasColumnType("uuid")
.HasColumnName("creator_id");
b.Property<string>("CustomerOrgCode")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("customer_org_code");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(50)

Loading…
Cancel
Save