Browse Source

职业病

bjmzak
wxd 2 years ago
parent
commit
8e3f676445
  1. 2
      src/Shentun.Peis.Application.Contracts/OccupationalDiseases/OccupationalDiseaseWithDetailByPatientRegisterIdDto.cs
  2. 44
      src/Shentun.Peis.Application.Contracts/OccupationalDiseases/OccupationalDiseaseWithDetailInputDto.cs
  3. 13
      src/Shentun.Peis.Application.Contracts/OccupationalDiseases/PatientOccupationalDiseaseDto.cs
  4. 33
      src/Shentun.Peis.Application.Contracts/OccupationalDiseases/PatientPastMedicalHistoryDto.cs
  5. 24
      src/Shentun.Peis.Application.Contracts/OccupationalDiseases/PatientPoisonDto.cs
  6. 63
      src/Shentun.Peis.Application/OccupationalDiseases/OccupationalDiseaseAppService.cs
  7. 10
      src/Shentun.Peis.Domain/OccupationalContraindicationss/OccupationalContraindicationsManager.cs
  8. 42
      src/Shentun.Peis.Domain/PatientOccupationalDiseases/PatientOccupationalDisease.cs
  9. 14
      src/Shentun.Peis.Domain/PatientOccupationalDiseases/PatientOccupationalDiseaseManager.cs
  10. 68
      src/Shentun.Peis.Domain/PatientPastMedicalHistorys/PatientPastMedicalHistory.cs
  11. 34
      src/Shentun.Peis.Domain/PatientPoisons/PatientPoison.cs
  12. 5
      src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs
  13. 12
      src/Shentun.Peis.Domain/SuspectedOccupationalDiseases/SuspectedOccupationalDiseaseManager.cs
  14. 41
      src/Shentun.Peis.EntityFrameworkCore/DbMapping/PatientPastMedicalHistorys/PatientPastMedicalHistoryDbMapping.cs
  15. 5
      src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs
  16. 14910
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523092658_init20240523002.Designer.cs
  17. 105
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523092658_init20240523002.cs
  18. 14915
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523094105_init20240523003.Designer.cs
  19. 26
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523094105_init20240523003.cs
  20. 114
      src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

2
src/Shentun.Peis.Application.Contracts/OccupationalDiseases/OccupationalDiseaseWithDetailByPatientRegisterIdDto.cs

@ -12,6 +12,8 @@ namespace Shentun.Peis.OccupationalDiseases
public List<PatientOccupationalMedicalHistoryDto> PatientOccupationalMedicalHistoryDtos { get; set; }
public List<PatientPastMedicalHistoryDto> PatientPastMedicalHistoryDtos { get; set; }
public List<PatientSymptomDto> PatientSymptomDtos { get; set; }
public List<PatientOccupationalHistoryDto> PatientOccupationalHistoryDtos { get; set; }

44
src/Shentun.Peis.Application.Contracts/OccupationalDiseases/OccupationalDiseaseWithDetailInputDto.cs

@ -27,6 +27,11 @@ namespace Shentun.Peis.OccupationalDiseases
public List<PatientPoisonInputDto> PatientPoisons { get; set; }
/// <summary>
/// 既往病史
/// </summary>
public List<PatientPastMedicalHistoryInputDto> PatientPastMedicalHistorys { get; set; }
/// <summary>
/// 职业病史
/// </summary>
@ -69,9 +74,15 @@ namespace Shentun.Peis.OccupationalDiseases
public string PoisonWorkTime { get; set; }
/// <summary>
/// 既往病史
/// 接害因素
/// </summary>
public string PreviousHistory { get; set; }
public string RiskFactors { get; set; }
/// <summary>
/// 家族遗传病史
/// </summary>
public string FamilyGeneticHistory { get; set; }
/// <summary>
/// 病名
@ -284,6 +295,35 @@ namespace Shentun.Peis.OccupationalDiseases
public string? TreatmentMethods { get; set; }
}
public class PatientPastMedicalHistoryInputDto
{
/// <summary>
/// 病名
/// </summary>
public string? OccupationalDisease { get; set; }
/// <summary>
/// 诊断日期
/// </summary>
public string? DiagnosisDate { get; set; }
/// <summary>
/// 诊断单位
/// </summary>
public string? DiagnosisHospital { get; set; }
/// <summary>
/// 是否恢复
/// </summary>
public char? IsRecovery { get; set; }
/// <summary>
/// 治疗方式
/// </summary>
public string? TreatmentMethods { get; set; }
}
public class PatientSymptomInputDto
{

13
src/Shentun.Peis.Application.Contracts/OccupationalDiseases/PatientOccupationalDiseaseDto.cs

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Shentun.Peis.OccupationalDiseases
@ -29,10 +31,15 @@ namespace Shentun.Peis.OccupationalDiseases
public string PoisonWorkTime { get; set; }
/// <summary>
/// 既往病史
/// 接害因素
/// </summary>
public string PreviousHistory { get; set; }
public string RiskFactors { get; set; }
/// <summary>
/// 家族遗传病史
/// </summary>
public string FamilyGeneticHistory { get; set; }
/// <summary>

33
src/Shentun.Peis.Application.Contracts/OccupationalDiseases/PatientPastMedicalHistoryDto.cs

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.OccupationalDiseases
{
public class PatientPastMedicalHistoryDto : AuditedEntityDtoName
{
/// <summary>
/// 病名
/// </summary>
public string? OccupationalDisease { get; set; }
/// <summary>
/// 诊断日期
/// </summary>
public DateTime? DiagnosisDate { get; set; }
/// <summary>
/// 诊断单位
/// </summary>
public string? DiagnosisHospital { get; set; }
/// <summary>
/// 是否恢复
/// </summary>
public char? IsRecovery { get; set; }
/// <summary>
/// 治疗方式
/// </summary>
public string? TreatmentMethods { get; set; }
}
}

24
src/Shentun.Peis.Application.Contracts/OccupationalDiseases/PatientPoisonDto.cs

@ -14,19 +14,19 @@ namespace Shentun.Peis.OccupationalDiseases
/// </summary>
public Guid? OccupationalAbnormalId { get; set; }
/// <summary>
/// 职业禁忌症ID
/// </summary>
public Guid? OccupationalContraindicationsId { get; set; }
///// <summary>
///// 职业禁忌症ID
///// </summary>
//public Guid? OccupationalContraindicationsId { get; set; }
/// <summary>
/// 疑似职业病ID
/// </summary>
public Guid? SuspectedOccupationalDiseaseId { get; set; }
///// <summary>
///// 疑似职业病ID
///// </summary>
//public Guid? SuspectedOccupationalDiseaseId { get; set; }
/// <summary>
/// 其他疾病
/// </summary>
public string OtherDiseases { get; set; }
///// <summary>
///// 其他疾病
///// </summary>
//public string OtherDiseases { get; set; }
}
}

63
src/Shentun.Peis.Application/OccupationalDiseases/OccupationalDiseaseAppService.cs

@ -32,6 +32,7 @@ namespace Shentun.Peis.OccupationalDiseases
private readonly IRepository<PatientPoison> _patientPoisonRepository;
private readonly IRepository<PatientSymptom> _patientSymptomRepository;
private readonly IRepository<PatientOccupationalMedicalHistory, Guid> _patientOccupationalMedicalHistoryRepository;
private readonly IRepository<PatientPastMedicalHistory, Guid> _patientPastMedicalHistoryRepository;
private readonly PatientOccupationalDiseaseManager _patientOccupationalDiseaseManager;
private readonly CacheService _cacheService;
@ -72,7 +73,8 @@ namespace Shentun.Peis.OccupationalDiseases
IRepository<ResultStatus> resultStatusRepository,
IRepository<RegisterCheckSummary, Guid> registerCheckSummaryRepository,
IRepository<Asbitem, Guid> asbitemRepository,
IRepository<PatientOccupationalMedicalHistory, Guid> patientOccupationalMedicalHistoryRepository)
IRepository<PatientOccupationalMedicalHistory, Guid> patientOccupationalMedicalHistoryRepository,
IRepository<PatientPastMedicalHistory, Guid> patientPastMedicalHistoryRepository)
{
_patientOccupationalDiseaseRepository = patientOccupationalDiseaseRepository;
_patientOccupationalHistoryRepository = patientOccupationalHistoryRepository;
@ -92,6 +94,7 @@ namespace Shentun.Peis.OccupationalDiseases
_registerCheckSummaryRepository = registerCheckSummaryRepository;
_asbitemRepository = asbitemRepository;
_patientOccupationalMedicalHistoryRepository = patientOccupationalMedicalHistoryRepository;
_patientPastMedicalHistoryRepository = patientPastMedicalHistoryRepository;
}
/// <summary>
@ -141,7 +144,8 @@ namespace Shentun.Peis.OccupationalDiseases
patientPoisonList.Add(new PatientPoison
{
PatientRegisterId = input.PatientRegisterId,
PoisonId = item.PoisonId
PoisonId = item.PoisonId,
OccupationalAbnormalId = item.OccupationalAbnormalId
});
}
@ -190,6 +194,27 @@ namespace Shentun.Peis.OccupationalDiseases
#endregion
#region 既往病史
var patientPastMedicalHistorysInput = ObjectMapper.Map<List<PatientPastMedicalHistoryInputDto>, List<PatientPastMedicalHistory>>(input.PatientPastMedicalHistorys);
await _patientPastMedicalHistoryRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId);
List<PatientPastMedicalHistory> PatientPastMedicalHistoryList = new List<PatientPastMedicalHistory>();
foreach (var item in patientPastMedicalHistorysInput)
{
PatientPastMedicalHistoryList.Add(new PatientPastMedicalHistory
{
PatientRegisterId = input.PatientRegisterId,
DiagnosisDate = item.DiagnosisDate,
DiagnosisHospital = item.DiagnosisHospital,
IsRecovery = item.IsRecovery,
OccupationalDisease = item.OccupationalDisease,
TreatmentMethods = item.TreatmentMethods
});
}
await _patientPastMedicalHistoryRepository.InsertManyAsync(PatientPastMedicalHistoryList, true);
#endregion
#region 职业史
@ -273,7 +298,8 @@ namespace Shentun.Peis.OccupationalDiseases
Other = patientOccupationalDiseaseEnt.Other,
PoisonWorkTime = patientOccupationalDiseaseEnt.PoisonWorkTime,
PrematureBirthTimes = patientOccupationalDiseaseEnt.PrematureBirthTimes,
PreviousHistory = patientOccupationalDiseaseEnt.PreviousHistory,
FamilyGeneticHistory = patientOccupationalDiseaseEnt.FamilyGeneticHistory,
RiskFactors = patientOccupationalDiseaseEnt.RiskFactors,
SmokeFlag = patientOccupationalDiseaseEnt.SmokeFlag,
SmokeNum = patientOccupationalDiseaseEnt.SmokeNum,
SmokeYears = patientOccupationalDiseaseEnt.SmokeYears,
@ -294,10 +320,7 @@ namespace Shentun.Peis.OccupationalDiseases
patientPoisonDtos = patientPoisonList.Select(s => new PatientPoisonDto
{
PoisonId = s.PoisonId,
SuspectedOccupationalDiseaseId = s.SuspectedOccupationalDiseaseId,
OccupationalContraindicationsId = s.OccupationalContraindicationsId,
OccupationalAbnormalId = s.OccupationalAbnormalId,
OtherDiseases = s.OtherDiseases,
CreationTime = s.CreationTime,
CreatorId = s.CreatorId,
LastModificationTime = s.LastModificationTime,
@ -335,6 +358,31 @@ namespace Shentun.Peis.OccupationalDiseases
#endregion
#region 既往病史
List<PatientPastMedicalHistoryDto> patientPastMedicalHistoryDtos = new List<PatientPastMedicalHistoryDto>();
var patientPastMedicalHistoryList = await _patientPastMedicalHistoryRepository.GetListAsync(d => d.PatientRegisterId == input.PatientRegisterId);
patientPastMedicalHistoryDtos = patientPastMedicalHistoryList.Select(s => new PatientPastMedicalHistoryDto
{
DiagnosisDate = s.DiagnosisDate,
DiagnosisHospital = s.DiagnosisHospital,
Id = s.Id,
IsRecovery = s.IsRecovery,
OccupationalDisease = s.OccupationalDisease,
TreatmentMethods = s.TreatmentMethods,
CreationTime = s.CreationTime,
CreatorId = s.CreatorId,
LastModificationTime = s.LastModificationTime,
LastModifierId = s.LastModifierId,
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
}).ToList();
result.PatientPastMedicalHistoryDtos = patientPastMedicalHistoryDtos;
#endregion
#region 症状
var patientSymptomList = await _patientSymptomRepository.GetListAsync(m => m.PatientRegisterId == input.PatientRegisterId);
@ -608,5 +656,8 @@ namespace Shentun.Peis.OccupationalDiseases
}
}
}

10
src/Shentun.Peis.Domain/OccupationalContraindicationss/OccupationalContraindicationsManager.cs

@ -84,11 +84,11 @@ namespace Shentun.Peis.OccupationalContraindicationss
public async Task CheckAndDeleteAsync(Guid id)
{
var poisonEnt = await _patientPoisonRepository.FirstOrDefaultAsync(m => m.OccupationalContraindicationsId == id);
if (poisonEnt != null)
{
throw new UserFriendlyException($"职业禁忌症已在毒害因素中使用,不能删除");
}
//var poisonEnt = await _patientPoisonRepository.FirstOrDefaultAsync(m => m.OccupationalContraindicationsId == id);
//if (poisonEnt != null)
//{
// throw new UserFriendlyException($"职业禁忌症已在毒害因素中使用,不能删除");
//}
await _occupationalContraindicationsRepository.DeleteAsync(id);

42
src/Shentun.Peis.Domain/PatientOccupationalDiseases/PatientOccupationalDisease.cs

@ -55,36 +55,18 @@ namespace Shentun.Peis.Models
public string? PoisonWorkTime { get; set; }
/// <summary>
/// 既往病史
/// </summary>
[Column("previous_history")]
[StringLength(100)]
public string? PreviousHistory { get; set; }
///// <summary>
///// 病名
///// </summary>
//[Column("occupational_disease")]
//[StringLength(50)]
//public string? OccupationalDisease { get; set; }
///// <summary>
///// 诊断日期
///// </summary>
//[Column("diagnosis_date")]
//public DateTime? DiagnosisDate { get; set; }
///// <summary>
///// 诊断单位
///// </summary>
//[Column("diagnosis_hospital")]
//[StringLength(50)]
//public string? DiagnosisHospital { get; set; }
///// <summary>
///// 是否恢复
///// </summary>
//[Column("is_recovery")]
//public char? IsRecovery { get; set; }
/// 接害因素
/// </summary>
[Column("risk_factors")]
[StringLength(200)]
public string? RiskFactors { get; set; }
/// <summary>
/// 家族遗传病史
/// </summary>
[Column("family_genetic_history")]
[StringLength(200)]
public string? FamilyGeneticHistory { get; set; }
/// <summary>

14
src/Shentun.Peis.Domain/PatientOccupationalDiseases/PatientOccupationalDiseaseManager.cs

@ -30,8 +30,6 @@ namespace Shentun.Peis.PatientOccupationalDiseases
AbnormalTimes = entity.AbnormalTimes,
AbortionTimes = entity.AbortionTimes,
ChildrenNum = entity.ChildrenNum,
//DiagnosisDate = entity.DiagnosisDate,
//DiagnosisHospital = entity.DiagnosisHospital,
DrinkFlag = entity.DrinkFlag,
DrinkNum = entity.DrinkNum,
DrinkYears = entity.DrinkYears,
@ -48,13 +46,12 @@ namespace Shentun.Peis.PatientOccupationalDiseases
// HandleSuggestion = entity.HandleSuggestion,
LastMenstrualPeriodDate = entity.LastMenstrualPeriodDate,
OcCheckTypeId = entity.OcCheckTypeId,
//OccupationalDisease = entity.OccupationalDisease,
Other = entity.Other,
PoisonWorkTime = entity.PoisonWorkTime,
PrematureBirthTimes = entity.PrematureBirthTimes,
PreviousHistory = entity.PreviousHistory,
//IsRecovery = entity.IsRecovery,
SmokeFlag = entity.SmokeFlag,
FamilyGeneticHistory = entity.FamilyGeneticHistory,
RiskFactors = entity.RiskFactors,
SmokeNum = entity.SmokeNum,
SmokeYears = entity.SmokeYears,
StillbirthTimes = entity.StillbirthTimes,
@ -77,8 +74,6 @@ namespace Shentun.Peis.PatientOccupationalDiseases
targetEntity.AbnormalTimes = sourceEntity.AbnormalTimes;
targetEntity.AbortionTimes = sourceEntity.AbortionTimes;
targetEntity.ChildrenNum = sourceEntity.ChildrenNum;
//targetEntity.DiagnosisDate = sourceEntity.DiagnosisDate;
//targetEntity.DiagnosisHospital = sourceEntity.DiagnosisHospital;
targetEntity.DrinkFlag = sourceEntity.DrinkFlag;
targetEntity.DrinkNum = sourceEntity.DrinkNum;
targetEntity.DrinkYears = sourceEntity.DrinkYears;
@ -95,18 +90,17 @@ namespace Shentun.Peis.PatientOccupationalDiseases
//targetEntity.OccupationalAbnormal = sourceEntity.OccupationalAbnormal;
//targetEntity.OccupationalAbSuggestion = sourceEntity.OccupationalAbSuggestion;
//targetEntity.HandleSuggestion = sourceEntity.HandleSuggestion;
//targetEntity.OccupationalDisease = sourceEntity.OccupationalDisease;
targetEntity.Other = sourceEntity.Other;
targetEntity.PoisonWorkTime = sourceEntity.PoisonWorkTime;
targetEntity.PrematureBirthTimes = sourceEntity.PrematureBirthTimes;
targetEntity.PreviousHistory = sourceEntity.PreviousHistory;
//targetEntity.IsRecovery = sourceEntity.IsRecovery;
targetEntity.SmokeFlag = sourceEntity.SmokeFlag;
targetEntity.SmokeNum = sourceEntity.SmokeNum;
targetEntity.SmokeYears = sourceEntity.SmokeYears;
targetEntity.StillbirthTimes = sourceEntity.StillbirthTimes;
targetEntity.TotalWorkTime = sourceEntity.TotalWorkTime;
targetEntity.PatientRegisterId = sourceEntity.PatientRegisterId;
targetEntity.FamilyGeneticHistory = sourceEntity.FamilyGeneticHistory;
targetEntity.RiskFactors = sourceEntity.RiskFactors;
}
}
}

68
src/Shentun.Peis.Domain/PatientPastMedicalHistorys/PatientPastMedicalHistory.cs

@ -0,0 +1,68 @@
using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Entities;
namespace Shentun.Peis.Models
{
/// <summary>
/// 职业病-既往病史
/// </summary>
[Table("patient_past_medical_history")]
public class PatientPastMedicalHistory : AuditedEntity<Guid>, IHasConcurrencyStamp
{
[Column("patient_register_id")]
public Guid PatientRegisterId { get; set; }
/// <summary>
/// 病名
/// </summary>
[Column("occupational_disease")]
[StringLength(50)]
public string? OccupationalDisease { get; set; }
/// <summary>
/// 诊断日期
/// </summary>
[Column("diagnosis_date")]
public DateTime? DiagnosisDate { get; set; }
/// <summary>
/// 诊断单位
/// </summary>
[Column("diagnosis_hospital")]
[StringLength(50)]
public string? DiagnosisHospital { get; set; }
/// <summary>
/// 是否恢复
/// </summary>
[Column("is_recovery")]
public char? IsRecovery { get; set; }
/// <summary>
/// 治疗方式
/// </summary>
[Column("treatment_methods")]
public string? TreatmentMethods { get; set; }
[Column("concurrency_stamp")]
public string ConcurrencyStamp { get; set; }
[ForeignKey(nameof(PatientRegisterId))]
[InverseProperty("PatientPastMedicalHistorys")]
public virtual PatientRegister PatientRegister { get; set; } = null!;
}
}

34
src/Shentun.Peis.Domain/PatientPoisons/PatientPoison.cs

@ -27,23 +27,23 @@ namespace Shentun.Peis.Models
[Column("occupational_abnormal_id")]
public Guid? OccupationalAbnormalId { get; set; }
/// <summary>
/// 职业禁忌症ID
/// </summary>
[Column("occupational_contraindications_id")]
public Guid? OccupationalContraindicationsId { get; set; }
/// <summary>
/// 疑似职业病ID
/// </summary>
[Column("suspected_occupational_disease_id")]
public Guid? SuspectedOccupationalDiseaseId { get; set; }
/// <summary>
/// 其他疾病
/// </summary>
[Column("other_diseases")]
public string OtherDiseases { get; set; }
///// <summary>
///// 职业禁忌症ID
///// </summary>
//[Column("occupational_contraindications_id")]
//public Guid? OccupationalContraindicationsId { get; set; }
///// <summary>
///// 疑似职业病ID
///// </summary>
//[Column("suspected_occupational_disease_id")]
//public Guid? SuspectedOccupationalDiseaseId { get; set; }
///// <summary>
///// 其他疾病
///// </summary>
//[Column("other_diseases")]
//public string OtherDiseases { get; set; }
[Column("concurrency_stamp")]
public string ConcurrencyStamp { get; set; }

5
src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs

@ -33,6 +33,7 @@ namespace Shentun.Peis.Models
SumSuggestionHeaders = new HashSet<SumSuggestionHeader>();
SumSummaryHeaders = new HashSet<SumSummaryHeader>();
PatientOccupationalMedicalHistorys= new HashSet<PatientOccupationalMedicalHistory>();
PatientPastMedicalHistorys = new HashSet<PatientPastMedicalHistory>();
}
public PatientRegister(Guid id) : base(id)
@ -49,6 +50,7 @@ namespace Shentun.Peis.Models
SumSuggestionHeaders = new HashSet<SumSuggestionHeader>();
SumSummaryHeaders = new HashSet<SumSummaryHeader>();
PatientOccupationalMedicalHistorys = new HashSet<PatientOccupationalMedicalHistory>();
PatientPastMedicalHistorys = new HashSet<PatientPastMedicalHistory>();
}
@ -352,6 +354,9 @@ namespace Shentun.Peis.Models
[InverseProperty(nameof(PatientOccupationalMedicalHistory.PatientRegister))]
public virtual ICollection<PatientOccupationalMedicalHistory> PatientOccupationalMedicalHistorys { get; set; }
[InverseProperty(nameof(PatientPastMedicalHistory.PatientRegister))]
public virtual ICollection<PatientPastMedicalHistory> PatientPastMedicalHistorys { get; set; }
[ForeignKey(nameof(PatientId))]
[InverseProperty("PatientRegisters")]
public virtual Patient Patient { get; set; } = null!;

12
src/Shentun.Peis.Domain/SuspectedOccupationalDiseases/SuspectedOccupationalDiseaseManager.cs

@ -76,7 +76,7 @@ namespace Shentun.Peis.SuspectedOccupationalDiseases
/// <summary>
/// 验证是否有毒害因素使用
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
@ -84,11 +84,11 @@ namespace Shentun.Peis.SuspectedOccupationalDiseases
public async Task CheckAndDeleteAsync(Guid id)
{
var patientPoisonEnt = await _patientPoisonRepository.FirstOrDefaultAsync(m => m.SuspectedOccupationalDiseaseId == id);
if (patientPoisonEnt != null)
{
throw new UserFriendlyException($"疑似职业病已在毒害因素中使用,不能删除");
}
//var patientPoisonEnt = await _patientPoisonRepository.FirstOrDefaultAsync(m => m.SuspectedOccupationalDiseaseId == id);
//if (patientPoisonEnt != null)
//{
// throw new UserFriendlyException($"疑似职业病已在毒害因素中使用,不能删除");
//}
await _suspectedOccupationalDiseaseRepository.DeleteAsync(id);

41
src/Shentun.Peis.EntityFrameworkCore/DbMapping/PatientPastMedicalHistorys/PatientPastMedicalHistoryDbMapping.cs

@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shentun.Peis.EntityFrameworkCore;
namespace Shentun.Peis.DbMapping
{
internal class PatientPastMedicalHistoryDbMapping : IEntityTypeConfiguration<PatientPastMedicalHistory>
{
public void Configure(EntityTypeBuilder<PatientPastMedicalHistory> entity)
{
entity.HasComment("既往病史");
entity.Property(e => e.Id)
.IsFixedLength()
.HasComment("既往病史编号");
entity.Property(e => e.DiagnosisDate).HasComment("诊断日期");
entity.Property(e => e.DiagnosisHospital).HasComment("诊断单位");
entity.Property(e => e.IsRecovery).HasComment("是否恢复");
entity.Property(e => e.PatientRegisterId).HasComment("简码").IsFixedLength();
entity.Property(e => e.TreatmentMethods).HasComment("治疗方式");
entity.Property(e => e.OccupationalDisease).HasComment("病名");
entity.HasOne(d => d.PatientRegister)
.WithMany(p => p.PatientPastMedicalHistorys)
.HasForeignKey(d => d.PatientRegisterId)
.HasConstraintName("fk_patient_past_medical_historys_patient_register");
entity.ConfigureByConvention();
}
}
}

5
src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs

@ -352,6 +352,8 @@ public class PeisDbContext :
public DbSet<PatientOccupationalMedicalHistory> PatientOccupationalMedicalHistorys { get; set; } = null!;
public DbSet<PatientPastMedicalHistory> PatientPastMedicalHistorys { get; set; } = null!;
public PeisDbContext(DbContextOptions<PeisDbContext> options)
: base(options)
{
@ -590,7 +592,8 @@ public class PeisDbContext :
.ApplyConfiguration(new OccupationalAbnormalDbMapping())
.ApplyConfiguration(new OccupationalContraindicationsDbMapping())
.ApplyConfiguration(new SuspectedOccupationalDiseaseDbMapping())
.ApplyConfiguration(new PatientOccupationalMedicalHistoryDbMapping());
.ApplyConfiguration(new PatientOccupationalMedicalHistoryDbMapping())
.ApplyConfiguration(new PatientPastMedicalHistoryDbMapping());
#endregion

14910
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523092658_init20240523002.Designer.cs
File diff suppressed because it is too large
View File

105
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523092658_init20240523002.cs

@ -0,0 +1,105 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class init20240523002 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "occupational_contraindications_id",
table: "patient_poison");
migrationBuilder.DropColumn(
name: "other_diseases",
table: "patient_poison");
migrationBuilder.DropColumn(
name: "suspected_occupational_disease_id",
table: "patient_poison");
migrationBuilder.DropColumn(
name: "previous_history",
table: "patient_occupational_disease");
migrationBuilder.AddColumn<string>(
name: "risk_factors",
table: "patient_occupational_disease",
type: "character varying(200)",
maxLength: 200,
nullable: true);
migrationBuilder.CreateTable(
name: "patient_past_medical_history",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", fixedLength: true, nullable: false, comment: "既往病史编号"),
patient_register_id = table.Column<Guid>(type: "uuid", fixedLength: true, nullable: false, comment: "简码"),
occupational_disease = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "病名"),
diagnosis_date = table.Column<DateTime>(type: "timestamp without time zone", nullable: true, comment: "诊断日期"),
diagnosis_hospital = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, comment: "诊断单位"),
is_recovery = table.Column<char>(type: "character(1)", nullable: true, comment: "是否恢复"),
treatment_methods = table.Column<string>(type: "text", nullable: true, comment: "治疗方式"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
creation_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: false),
last_modification_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_patient_past_medical_history", x => x.id);
table.ForeignKey(
name: "fk_patient_past_medical_historys_patient_register",
column: x => x.patient_register_id,
principalTable: "patient_register",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "既往病史");
migrationBuilder.CreateIndex(
name: "IX_patient_past_medical_history_patient_register_id",
table: "patient_past_medical_history",
column: "patient_register_id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "patient_past_medical_history");
migrationBuilder.DropColumn(
name: "risk_factors",
table: "patient_occupational_disease");
migrationBuilder.AddColumn<Guid>(
name: "occupational_contraindications_id",
table: "patient_poison",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "other_diseases",
table: "patient_poison",
type: "text",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "suspected_occupational_disease_id",
table: "patient_poison",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "previous_history",
table: "patient_occupational_disease",
type: "character varying(100)",
maxLength: 100,
nullable: true);
}
}
}

14915
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523094105_init20240523003.Designer.cs
File diff suppressed because it is too large
View File

26
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240523094105_init20240523003.cs

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

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

@ -6559,6 +6559,11 @@ namespace Shentun.Peis.Migrations
.HasColumnType("integer")
.HasColumnName("drink_years");
b.Property<string>("FamilyGeneticHistory")
.HasMaxLength(200)
.HasColumnType("character varying(200)")
.HasColumnName("family_genetic_history");
b.Property<int?>("FirstMenstruation")
.HasColumnType("integer")
.HasColumnName("first_menstruation");
@ -6644,10 +6649,10 @@ namespace Shentun.Peis.Migrations
.HasColumnType("integer")
.HasColumnName("premature_birth_times");
b.Property<string>("PreviousHistory")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasColumnName("previous_history");
b.Property<string>("RiskFactors")
.HasMaxLength(200)
.HasColumnType("character varying(200)")
.HasColumnName("risk_factors");
b.Property<char?>("SmokeFlag")
.HasMaxLength(1)
@ -6829,6 +6834,81 @@ namespace Shentun.Peis.Migrations
b.HasComment("职业病史");
});
modelBuilder.Entity("Shentun.Peis.Models.PatientPastMedicalHistory", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid")
.HasColumnName("id")
.IsFixedLength()
.HasComment("既往病史编号");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("concurrency_stamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("timestamp without time zone")
.HasColumnName("creation_time");
b.Property<Guid?>("CreatorId")
.IsRequired()
.HasColumnType("uuid")
.HasColumnName("creator_id");
b.Property<DateTime?>("DiagnosisDate")
.HasColumnType("timestamp without time zone")
.HasColumnName("diagnosis_date")
.HasComment("诊断日期");
b.Property<string>("DiagnosisHospital")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("diagnosis_hospital")
.HasComment("诊断单位");
b.Property<char?>("IsRecovery")
.HasColumnType("character(1)")
.HasColumnName("is_recovery")
.HasComment("是否恢复");
b.Property<DateTime?>("LastModificationTime")
.IsRequired()
.HasColumnType("timestamp without time zone")
.HasColumnName("last_modification_time");
b.Property<Guid?>("LastModifierId")
.IsRequired()
.HasColumnType("uuid")
.HasColumnName("last_modifier_id");
b.Property<string>("OccupationalDisease")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("occupational_disease")
.HasComment("病名");
b.Property<Guid>("PatientRegisterId")
.HasColumnType("uuid")
.HasColumnName("patient_register_id")
.IsFixedLength()
.HasComment("简码");
b.Property<string>("TreatmentMethods")
.HasColumnType("text")
.HasColumnName("treatment_methods")
.HasComment("治疗方式");
b.HasKey("Id");
b.HasIndex("PatientRegisterId");
b.ToTable("patient_past_medical_history");
b.HasComment("既往病史");
});
modelBuilder.Entity("Shentun.Peis.Models.PatientPoison", b =>
{
b.Property<Guid>("PatientRegisterId")
@ -6869,18 +6949,6 @@ namespace Shentun.Peis.Migrations
.HasColumnType("uuid")
.HasColumnName("occupational_abnormal_id");
b.Property<Guid?>("OccupationalContraindicationsId")
.HasColumnType("uuid")
.HasColumnName("occupational_contraindications_id");
b.Property<string>("OtherDiseases")
.HasColumnType("text")
.HasColumnName("other_diseases");
b.Property<Guid?>("SuspectedOccupationalDiseaseId")
.HasColumnType("uuid")
.HasColumnName("suspected_occupational_disease_id");
b.HasKey("PatientRegisterId", "PoisonId")
.HasName("pk_patient_poison");
@ -13716,6 +13784,18 @@ namespace Shentun.Peis.Migrations
b.Navigation("PatientRegister");
});
modelBuilder.Entity("Shentun.Peis.Models.PatientPastMedicalHistory", b =>
{
b.HasOne("Shentun.Peis.Models.PatientRegister", "PatientRegister")
.WithMany("PatientPastMedicalHistorys")
.HasForeignKey("PatientRegisterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_patient_past_medical_historys_patient_register");
b.Navigation("PatientRegister");
});
modelBuilder.Entity("Shentun.Peis.Models.PatientPoison", b =>
{
b.HasOne("Shentun.Peis.Models.PatientRegister", "PatientRegister")
@ -14656,6 +14736,8 @@ namespace Shentun.Peis.Migrations
b.Navigation("PatientOccupationalMedicalHistorys");
b.Navigation("PatientPastMedicalHistorys");
b.Navigation("PatientPoisons");
b.Navigation("PatientSymptoms");

Loading…
Cancel
Save