diff --git a/DocuMed.Api/Controllers/HospitalController.cs b/DocuMed.Api/Controllers/HospitalController.cs index 3b4ac3a..7f319f1 100644 --- a/DocuMed.Api/Controllers/HospitalController.cs +++ b/DocuMed.Api/Controllers/HospitalController.cs @@ -1,4 +1,6 @@ -using DocuMed.Domain.Entities.MedicalHistory; +using DocuMed.Domain.CommandQueries.Commands; +using DocuMed.Domain.Entities.MedicalHistory; +using MediatR; namespace DocuMed.Api.Controllers; @@ -30,32 +32,32 @@ public class HospitalController : ICarterModule } // GET:Get All Entity - public virtual async Task GetAllAsync([FromQuery] int page, IMedicalHistoryRepository repository, CancellationToken cancellationToken) + private async Task GetAllAsync([FromQuery] int page, IMedicalHistoryRepository repository, CancellationToken cancellationToken) { return TypedResults.Ok(await repository.GetMedicalHistoriesAsync(page, cancellationToken)); } // GET:Get An Entity By Id - public async Task GetAsync(Guid id, IMedicalHistoryRepository repository, CancellationToken cancellationToken) + private async Task GetAsync(Guid id, IMedicalHistoryRepository repository, CancellationToken cancellationToken) { return TypedResults.Ok(await repository.GetMedicalHistoryAsync(id, cancellationToken)); } // POST:Add New Entity - public virtual async Task Post([FromBody] MedicalHistoryLDto dto, IMedicalHistoryService service, ICurrentUserService currentUserService, CancellationToken cancellationToken) + private async Task Post([FromBody] CreateHospitalCommand dto, IMediator service, ICurrentUserService currentUserService, CancellationToken cancellationToken) { - return TypedResults.Ok(await service.AddAsync(dto, cancellationToken)); + return TypedResults.Ok(await service.Send(dto,cancellationToken)); } // PUT:Update Entity - public virtual async Task Put([FromBody] MedicalHistoryLDto dto, IMedicalHistoryService service, ICurrentUserService currentUserService, CancellationToken cancellationToken) + private async Task Put([FromBody] UpdateHospitalCommand dto, IMediator service, ICurrentUserService currentUserService, CancellationToken cancellationToken) { - return TypedResults.Ok(await service.EditAsync(dto, cancellationToken)); + return TypedResults.Ok(await service.Send(dto,cancellationToken)); } // DELETE:Delete Entity - public virtual async Task Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + private async Task Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) { var ent = await repositoryWrapper.SetRepository().GetByIdAsync(cancellationToken, id); repositoryWrapper.SetRepository().Delete(ent); diff --git a/DocuMed.Api/Controllers/PatientController.cs b/DocuMed.Api/Controllers/PatientController.cs new file mode 100644 index 0000000..8f9166e --- /dev/null +++ b/DocuMed.Api/Controllers/PatientController.cs @@ -0,0 +1,21 @@ +namespace DocuMed.Api.Controllers; + +public class PatientController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Patient") + .MapGroup($"api/patient"); + + group.MapGet("", GetAllAsync) + .WithDisplayName("Get All Patient") + .HasApiVersion(1.0); + } + + private async Task GetAllAsync([FromQuery]int page , + [FromQuery]int? count , + [FromQuery]string searchName , + [FromServices]IMediator mediator, + CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetPatientsQuery(page, Count: count ?? Refers.SizeM, searchName), cancellationToken)); +} \ No newline at end of file diff --git a/DocuMed.Api/DocuMed.Api.csproj b/DocuMed.Api/DocuMed.Api.csproj index 2cbd197..0b5151c 100644 --- a/DocuMed.Api/DocuMed.Api.csproj +++ b/DocuMed.Api/DocuMed.Api.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable Linux @@ -13,42 +13,42 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + - - - - - - + + + + + + - - + + - - + + - - + + @@ -73,6 +73,7 @@ + @@ -81,6 +82,7 @@ + @@ -90,6 +92,7 @@ + diff --git a/DocuMed.Common/DocuMed.Common.csproj b/DocuMed.Common/DocuMed.Common.csproj index 348c66a..0826a13 100644 --- a/DocuMed.Common/DocuMed.Common.csproj +++ b/DocuMed.Common/DocuMed.Common.csproj @@ -1,7 +1,7 @@ - + - + + diff --git a/DocuMed.Core/CoreServices/AccountService.cs b/DocuMed.Core/CoreServices/AccountService.cs index e74767a..2bf9f94 100644 --- a/DocuMed.Core/CoreServices/AccountService.cs +++ b/DocuMed.Core/CoreServices/AccountService.cs @@ -126,7 +126,6 @@ public class AccountService( return await CompleteLogin(user, cancellationToken); } - private async Task> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken) { var token = await jwtService.Generate(user); diff --git a/DocuMed.Core/DocuMed.Core.csproj b/DocuMed.Core/DocuMed.Core.csproj index 88b8c10..f00d758 100644 --- a/DocuMed.Core/DocuMed.Core.csproj +++ b/DocuMed.Core/DocuMed.Core.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable @@ -12,7 +12,7 @@ - + diff --git a/DocuMed.Domain/CommandQueries/Commands/MedicalHistoryCommands.cs b/DocuMed.Domain/CommandQueries/Commands/MedicalHistoryCommands.cs index 44e460e..c5f2f31 100644 --- a/DocuMed.Domain/CommandQueries/Commands/MedicalHistoryCommands.cs +++ b/DocuMed.Domain/CommandQueries/Commands/MedicalHistoryCommands.cs @@ -8,6 +8,7 @@ public sealed record CreateMedicalHistoryCommand( string FatherName, string NationalId, DateTime BirthDate, + Guid PatientId, string PresentIllnessDetail, string PastDiseasesHistoryDetail, string PastSurgeryHistoryDetail, @@ -23,7 +24,6 @@ public sealed record CreateMedicalHistoryCommand( double PulseRate, double SPO2, double Temperature, - Guid ApplicationUserId, Guid MedicalHistoryTemplateId, List Answers) : IRequest; @@ -36,6 +36,7 @@ public sealed record UpdateMedicalHistoryCommand( string FatherName, string NationalId, DateTime BirthDate, + Guid PatientId, string PresentIllnessDetail, string PastDiseasesHistoryDetail, string PastSurgeryHistoryDetail, @@ -51,7 +52,6 @@ public sealed record UpdateMedicalHistoryCommand( double PulseRate, double SPO2, double Temperature, - Guid ApplicationUserId, Guid MedicalHistoryTemplateId, List Answers) : IRequest; diff --git a/DocuMed.Domain/CommandQueries/Commands/PatientCommands.cs b/DocuMed.Domain/CommandQueries/Commands/PatientCommands.cs new file mode 100644 index 0000000..cda4772 --- /dev/null +++ b/DocuMed.Domain/CommandQueries/Commands/PatientCommands.cs @@ -0,0 +1,26 @@ +namespace DocuMed.Domain.CommandQueries.Commands; + +public sealed record CreatePatientCommand( + string FirstName, + string LastName, + string UnitNumber, + string NationalId, + string Room, + string Bed, + DateTime AdmissionAt, + Guid SectionId) : IRequest; + +public sealed record UpdatePatientCommand( + Guid Id, + string FirstName, + string LastName, + string UnitNumber, + string NationalId, + string Room, + string Bed, + DateTime AdmissionAt, + Guid SectionId) : IRequest; + +public sealed record UpdatePatientSectionCommand(Guid Id, Guid SectionId) : IRequest; + +public sealed record DeletePatientCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/DocuMed.Domain/CommandQueries/Queries/PatientQueries.cs b/DocuMed.Domain/CommandQueries/Queries/PatientQueries.cs new file mode 100644 index 0000000..90ac1fa --- /dev/null +++ b/DocuMed.Domain/CommandQueries/Queries/PatientQueries.cs @@ -0,0 +1,4 @@ +namespace DocuMed.Domain.CommandQueries.Queries; + +public sealed record GetPatientQuery(Guid? Id = null , string? NationalId = null) : IRequest; +public sealed record GetPatientsQuery(int Page , int Count , string? SearchName = null , string? NationalId = null) : IRequest>; \ No newline at end of file diff --git a/DocuMed.Domain/DocuMed.Domain.csproj b/DocuMed.Domain/DocuMed.Domain.csproj index 498e132..82f2233 100644 --- a/DocuMed.Domain/DocuMed.Domain.csproj +++ b/DocuMed.Domain/DocuMed.Domain.csproj @@ -1,22 +1,22 @@  - + - + @@ -37,37 +37,37 @@ - - - + + + - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/DocuMed.Domain/Dtos/SmallDtos/PatientSDto.cs b/DocuMed.Domain/Dtos/SmallDtos/PatientSDto.cs new file mode 100644 index 0000000..9ba39ab --- /dev/null +++ b/DocuMed.Domain/Dtos/SmallDtos/PatientSDto.cs @@ -0,0 +1,19 @@ +namespace DocuMed.Domain.Dtos.SmallDtos; + +public class PatientSDto : BaseDto +{ + public string UnitNumber { get; set; } = string.Empty; + public string Room { get; set; } = string.Empty; + public string Bed { get; set; } = string.Empty; + public DateTime AdmissionAt { get; set; } + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string NationalId { get; set; } = string.Empty; + public DateTime BirthDate { get; set; } + public Gender Gender { get; set; } + public Guid HospitalId { get; set; } + public Guid SectionId { get; set; } + public string SectionName { get; set; } = string.Empty; + + public string FullName => FirstName + " " + LastName; +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.Aggregate.cs b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.Aggregate.cs index 9c62550..bacda8b 100644 --- a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.Aggregate.cs +++ b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.Aggregate.cs @@ -41,7 +41,8 @@ public partial class MedicalHistory double pulseRate, double sPO2, double temperature, - Guid applicationUserId, + Guid studentId, + Guid patientId, Guid medicalHistoryTemplateId) { var code = StringExtensions.GetIntId(6); @@ -63,7 +64,8 @@ public partial class MedicalHistory sPO2, temperature, code, - applicationUserId, + studentId, + patientId, medicalHistoryTemplateId); } diff --git a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs index 047ed3d..5218ee5 100644 --- a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs +++ b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs @@ -31,7 +31,8 @@ public partial class MedicalHistory : ApiEntity double spo2, double temperature, string code, - Guid applicationUserId, + Guid studentId, + Guid patientId, Guid medicalHistoryTemplateId) { PresentIllnessDetail = presentIllnessDetail; @@ -52,7 +53,8 @@ public partial class MedicalHistory : ApiEntity SPO2 = spo2; Temperature = temperature; Code = code; - ApplicationUserId = applicationUserId; + StudentId = studentId; + PatientId = patientId; MedicalHistoryTemplateId = medicalHistoryTemplateId; } public string ChiefComplaint { get; internal set; } = string.Empty; @@ -79,8 +81,11 @@ public partial class MedicalHistory : ApiEntity public double Temperature { get; internal set; } public Guid MedicalHistoryTemplateId { get; internal set; } - public Guid ApplicationUserId { get; internal set; } - public ApplicationUser? ApplicationUser { get; internal set; } + public Guid StudentId { get; internal set; } + public Student? Student { get; internal set; } + + public Guid PatientId { get; set; } + public Patient? Patient { get; set; } public List Answers { get; internal set; } = new(); } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs index 4529d16..48cc479 100644 --- a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs +++ b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs @@ -10,17 +10,17 @@ public partial class MedicalHistoryTemplate : ApiEntity { } - public MedicalHistoryTemplate(string chiefComplaint,Guid sectionId,Guid applicationUserId) + public MedicalHistoryTemplate(string chiefComplaint,Guid sectionId,Guid studentId) { ChiefComplaint = chiefComplaint; SectionId = sectionId; - ApplicationUserId = applicationUserId; + StudentId = studentId; } public string ChiefComplaint { get; internal set; } = string.Empty; public Guid SectionId { get; set; } public Section? Section { get; set; } - public Guid ApplicationUserId { get; internal set; } - public ApplicationUser? ApplicationUser { get; set; } + public Guid StudentId { get; internal set; } + public Student? Student { get; set; } public List Questions { get; internal set; } = new(); } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs b/DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs index ba40025..08fdb24 100644 --- a/DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs +++ b/DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs @@ -2,6 +2,6 @@ public partial class Patient { - public static Patient Create(string unitNumber, string room, string bed, DateTime admissionAt, Guid sectionId, Guid userId) - => new Patient(unitNumber, room, bed, admissionAt, sectionId, userId); -} \ No newline at end of file + public static Patient Create(string unitNumber, string room, string bed, DateTime admissionAt,Guid sectionId,Guid hospitalId, Guid userId) + => new Patient(unitNumber, room, bed, admissionAt,sectionId,hospitalId, userId); +} diff --git a/DocuMed.Domain/Entities/Patients/Patient.cs b/DocuMed.Domain/Entities/Patients/Patient.cs index c06ea6a..8b23ba7 100644 --- a/DocuMed.Domain/Entities/Patients/Patient.cs +++ b/DocuMed.Domain/Entities/Patients/Patient.cs @@ -11,13 +11,14 @@ public partial class Patient : ApiEntity } - public Patient(string unitNumber, string room, string bed, DateTime admissionAt, Guid sectionId, Guid userId) + public Patient(string unitNumber, string room, string bed, DateTime admissionAt,Guid sectionId,Guid hospitalId, Guid userId) { UnitNumber = unitNumber; Room = room; Bed = bed; AdmissionAt = admissionAt; SectionId = sectionId; + HospitalId = hospitalId; UserId = userId; } public string UnitNumber { get; internal set; } = string.Empty; @@ -28,6 +29,8 @@ public partial class Patient : ApiEntity public Guid SectionId { get; internal set; } public Section? Section { get; internal set; } + public Guid HospitalId { get; internal set; } + public Guid UserId { get; internal set; } public ApplicationUser? User { get; internal set; } } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/User/ApplicationUser.cs b/DocuMed.Domain/Entities/User/ApplicationUser.cs index dfb1346..e4b9290 100644 --- a/DocuMed.Domain/Entities/User/ApplicationUser.cs +++ b/DocuMed.Domain/Entities/User/ApplicationUser.cs @@ -1,6 +1,4 @@ -using DocuMed.Domain.Entities.Patients; - -namespace DocuMed.Domain.Entities.User; +namespace DocuMed.Domain.Entities.User; [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [GenerateMapper] @@ -13,6 +11,6 @@ public class ApplicationUser : IdentityUser public Gender Gender { get; set; } public SignUpStatus SignUpStatus { get; set; } - public Student? Student { get; set; } - public Patient? Patient { get; set; } + public List Students { get; set; } = []; + public List Patients { get; set; } = []; } diff --git a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs index 76463b8..4ed4480 100644 --- a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs +++ b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs @@ -71,60 +71,47 @@ namespace DocuMed.Domain.Mappers PhoneNumber = p5.PhoneNumber, PhoneNumberConfirmed = p5.PhoneNumberConfirmed, NationalId = p5.NationalId, - StudentId = funcMain1(p5.Student == null ? null : (Guid?)p5.Student.Id), BirthDate = p5.BirthDate, Gender = p5.Gender, SignUpStatus = p5.SignUpStatus, Id = p5.Id }; } - public static ApplicationUserSDto AdaptTo(this ApplicationUser p7, ApplicationUserSDto p8) + public static ApplicationUserSDto AdaptTo(this ApplicationUser p6, ApplicationUserSDto p7) { - if (p7 == null) + if (p6 == null) { return null; } - ApplicationUserSDto result = p8 ?? new ApplicationUserSDto(); + ApplicationUserSDto result = p7 ?? new ApplicationUserSDto(); - result.FirstName = p7.FirstName; - result.LastName = p7.LastName; - result.UserName = p7.UserName; - result.Email = p7.Email; - result.PhoneNumber = p7.PhoneNumber; - result.PhoneNumberConfirmed = p7.PhoneNumberConfirmed; - result.NationalId = p7.NationalId; - result.StudentId = funcMain2(p7.Student == null ? null : (Guid?)p7.Student.Id, result.StudentId); - result.BirthDate = p7.BirthDate; - result.Gender = p7.Gender; - result.SignUpStatus = p7.SignUpStatus; - result.Id = p7.Id; + result.FirstName = p6.FirstName; + result.LastName = p6.LastName; + result.UserName = p6.UserName; + result.Email = p6.Email; + result.PhoneNumber = p6.PhoneNumber; + result.PhoneNumberConfirmed = p6.PhoneNumberConfirmed; + result.NationalId = p6.NationalId; + result.BirthDate = p6.BirthDate; + result.Gender = p6.Gender; + result.SignUpStatus = p6.SignUpStatus; + result.Id = p6.Id; return result; } - public static Expression> ProjectToSDto => p11 => new ApplicationUserSDto() + public static Expression> ProjectToSDto => p8 => new ApplicationUserSDto() { - FirstName = p11.FirstName, - LastName = p11.LastName, - UserName = p11.UserName, - Email = p11.Email, - PhoneNumber = p11.PhoneNumber, - PhoneNumberConfirmed = p11.PhoneNumberConfirmed, - NationalId = p11.NationalId, - StudentId = p11.Student.Id.ToString(), - BirthDate = p11.BirthDate, - Gender = p11.Gender, - SignUpStatus = p11.SignUpStatus, - Id = p11.Id + FirstName = p8.FirstName, + LastName = p8.LastName, + UserName = p8.UserName, + Email = p8.Email, + PhoneNumber = p8.PhoneNumber, + PhoneNumberConfirmed = p8.PhoneNumberConfirmed, + NationalId = p8.NationalId, + BirthDate = p8.BirthDate, + Gender = p8.Gender, + SignUpStatus = p8.SignUpStatus, + Id = p8.Id }; - - private static string funcMain1(Guid? p6) - { - return p6 == null ? null : ((Guid)p6).ToString(); - } - - private static string funcMain2(Guid? p9, string p10) - { - return p9 == null ? null : ((Guid)p9).ToString(); - } } } \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs index 9f23a50..72850e9 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs @@ -6,7 +6,6 @@ using DocuMed.Domain.Dtos.LargDtos; using DocuMed.Domain.Dtos.SmallDtos; using DocuMed.Domain.Entities.Hospitals; using DocuMed.Domain.Entities.MedicalHistory; -using DocuMed.Domain.Entities.User; using Mapster.Models; namespace DocuMed.Domain.Mappers @@ -26,12 +25,6 @@ namespace DocuMed.Domain.Mappers HospitalId = p1.Section.HospitalId, Id = p1.Section.Id }, - FirstName = p1.FirstName, - LastName = p1.LastName, - FatherName = p1.FatherName, - NationalId = p1.NationalId, - Age = p1.Age, - BirthDate = p1.BirthDate, PresentIllnessDetail = p1.PresentIllnessDetail, PastDiseasesHistoryDetail = p1.PastDiseasesHistoryDetail, PastSurgeryHistoryDetail = p1.PastSurgeryHistoryDetail, @@ -49,7 +42,6 @@ namespace DocuMed.Domain.Mappers SPO2 = p1.SPO2, Temperature = p1.Temperature, MedicalHistoryTemplateId = p1.MedicalHistoryTemplateId, - ApplicationUserId = p1.ApplicationUserId, Answers = funcMain1(p1.Answers), Id = p1.Id, CreatedAt = p1.CreatedAt @@ -66,12 +58,6 @@ namespace DocuMed.Domain.Mappers result.ChiefComplaint = p3.ChiefComplaint; result.SectionId = p3.SectionId; result.Section = funcMain2(p3.Section, result.Section); - result.FirstName = p3.FirstName; - result.LastName = p3.LastName; - result.FatherName = p3.FatherName; - result.NationalId = p3.NationalId; - result.Age = p3.Age; - result.BirthDate = p3.BirthDate; result.PresentIllnessDetail = p3.PresentIllnessDetail; result.PastDiseasesHistoryDetail = p3.PastDiseasesHistoryDetail; result.PastSurgeryHistoryDetail = p3.PastSurgeryHistoryDetail; @@ -89,7 +75,6 @@ namespace DocuMed.Domain.Mappers result.SPO2 = p3.SPO2; result.Temperature = p3.Temperature; result.MedicalHistoryTemplateId = p3.MedicalHistoryTemplateId; - result.ApplicationUserId = p3.ApplicationUserId; result.Answers = funcMain3(p3.Answers, result.Answers); result.Id = p3.Id; result.CreatedAt = p3.CreatedAt; @@ -107,12 +92,6 @@ namespace DocuMed.Domain.Mappers HospitalId = p9.Section.HospitalId, Id = p9.Section.Id }, - FirstName = p9.FirstName, - LastName = p9.LastName, - FatherName = p9.FatherName, - NationalId = p9.NationalId, - Age = p9.Age, - BirthDate = p9.BirthDate, PresentIllnessDetail = p9.PresentIllnessDetail, PastDiseasesHistoryDetail = p9.PastDiseasesHistoryDetail, PastSurgeryHistoryDetail = p9.PastSurgeryHistoryDetail, @@ -130,7 +109,6 @@ namespace DocuMed.Domain.Mappers SPO2 = p9.SPO2, Temperature = p9.Temperature, MedicalHistoryTemplateId = p9.MedicalHistoryTemplateId, - ApplicationUserId = p9.ApplicationUserId, Answers = p9.Answers.Select(p10 => new MedicalHistoryAnswer() { Answer = p10.Answer, @@ -149,12 +127,6 @@ namespace DocuMed.Domain.Mappers { ChiefComplaint = p11.ChiefComplaint, SectionId = p11.SectionId, - FirstName = p11.FirstName, - LastName = p11.LastName, - FatherName = p11.FatherName, - NationalId = p11.NationalId, - Age = p11.Age, - BirthDate = p11.BirthDate, Code = p11.Code, Section = p11.Section == null ? null : new SectionSDto() { @@ -179,7 +151,6 @@ namespace DocuMed.Domain.Mappers PulseRate = p11.PulseRate, SPO2 = p11.SPO2, Temperature = p11.Temperature, - ApplicationUserId = p11.ApplicationUserId, CreatedAt = p11.CreatedAt, Answers = funcMain4(p11.Answers), Id = p11.Id @@ -195,12 +166,6 @@ namespace DocuMed.Domain.Mappers result.ChiefComplaint = p13.ChiefComplaint; result.SectionId = p13.SectionId; - result.FirstName = p13.FirstName; - result.LastName = p13.LastName; - result.FatherName = p13.FatherName; - result.NationalId = p13.NationalId; - result.Age = p13.Age; - result.BirthDate = p13.BirthDate; result.Code = p13.Code; result.Section = funcMain5(p13.Section, result.Section); result.PresentIllnessDetail = p13.PresentIllnessDetail; @@ -219,7 +184,6 @@ namespace DocuMed.Domain.Mappers result.PulseRate = p13.PulseRate; result.SPO2 = p13.SPO2; result.Temperature = p13.Temperature; - result.ApplicationUserId = p13.ApplicationUserId; result.CreatedAt = p13.CreatedAt; result.Answers = funcMain6(p13.Answers, result.Answers); result.Id = p13.Id; @@ -230,12 +194,6 @@ namespace DocuMed.Domain.Mappers { ChiefComplaint = p19.ChiefComplaint, SectionId = p19.SectionId, - FirstName = p19.FirstName, - LastName = p19.LastName, - FatherName = p19.FatherName, - NationalId = p19.NationalId, - Age = p19.Age, - BirthDate = p19.BirthDate, Code = p19.Code, Section = p19.Section == null ? null : new SectionSDto() { @@ -260,7 +218,6 @@ namespace DocuMed.Domain.Mappers PulseRate = p19.PulseRate, SPO2 = p19.SPO2, Temperature = p19.Temperature, - ApplicationUserId = p19.ApplicationUserId, CreatedAt = p19.CreatedAt, Answers = p19.Answers.Select(p20 => new MedicalHistoryAnswerSDto() { @@ -284,12 +241,6 @@ namespace DocuMed.Domain.Mappers Name = p21.SectionName, Id = p21.SectionId }, - FirstName = p21.FirstName, - LastName = p21.LastName, - FatherName = p21.FatherName, - NationalId = p21.NationalId, - Age = p21.Age, - BirthDate = p21.BirthDate, PresentIllnessDetail = p21.PresentIllnessDetail, PastDiseasesHistoryDetail = p21.PastDiseasesHistoryDetail, PastSurgeryHistoryDetail = p21.PastSurgeryHistoryDetail, @@ -307,8 +258,6 @@ namespace DocuMed.Domain.Mappers SPO2 = p21.SPO2, Temperature = p21.Temperature, MedicalHistoryTemplateId = p21.MedicalHistoryTemplateId, - ApplicationUserId = p21.ApplicationUserId, - ApplicationUser = new ApplicationUser() {Id = p21.ApplicationUserId}, Id = p21.Id, CreatedAt = p21.CreatedAt }; @@ -324,12 +273,6 @@ namespace DocuMed.Domain.Mappers result.ChiefComplaint = p22.ChiefComplaint; result.SectionId = p22.SectionId; result.Section = funcMain7(new Never(), result.Section, p22); - result.FirstName = p22.FirstName; - result.LastName = p22.LastName; - result.FatherName = p22.FatherName; - result.NationalId = p22.NationalId; - result.Age = p22.Age; - result.BirthDate = p22.BirthDate; result.PresentIllnessDetail = p22.PresentIllnessDetail; result.PastDiseasesHistoryDetail = p22.PastDiseasesHistoryDetail; result.PastSurgeryHistoryDetail = p22.PastSurgeryHistoryDetail; @@ -347,119 +290,96 @@ namespace DocuMed.Domain.Mappers result.SPO2 = p22.SPO2; result.Temperature = p22.Temperature; result.MedicalHistoryTemplateId = p22.MedicalHistoryTemplateId; - result.ApplicationUserId = p22.ApplicationUserId; - result.ApplicationUser = funcMain8(new Never(), result.ApplicationUser, p22); result.Id = p22.Id; result.CreatedAt = p22.CreatedAt; return result; } - public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p28) + public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p26) { - return p28 == null ? null : new MedicalHistorySDto() + return p26 == null ? null : new MedicalHistorySDto() { - ChiefComplaint = p28.ChiefComplaint, - SectionId = p28.SectionId, - SectionName = p28.Section != null ? p28.Section.Name : string.Empty, - FirstName = p28.FirstName, - LastName = p28.LastName, - FatherName = p28.FatherName, - NationalId = p28.NationalId, - MedicalHistoryTemplateId = p28.MedicalHistoryTemplateId, - Age = p28.Age, - BirthDate = p28.BirthDate, - Code = p28.Code, - PresentIllnessDetail = p28.PresentIllnessDetail, - PastDiseasesHistoryDetail = p28.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p28.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p28.FamilyHistoryDetail, - AllergyDetail = p28.AllergyDetail, - DrugHistoryDetail = p28.DrugHistoryDetail, - AddictionHistoryDetail = p28.AddictionHistoryDetail, - SystemReviewDetail = p28.SystemReviewDetail, - VitalSignDetail = p28.VitalSignDetail, - GeneralAppearanceDetail = p28.GeneralAppearanceDetail, - SystolicBloodPressure = p28.SystolicBloodPressure, - DiastolicBloodPressure = p28.DiastolicBloodPressure, - PulseRate = p28.PulseRate, - SPO2 = p28.SPO2, - Temperature = p28.Temperature, - ApplicationUserId = p28.ApplicationUserId, - CreatedAt = p28.CreatedAt, - Id = p28.Id + ChiefComplaint = p26.ChiefComplaint, + SectionId = p26.SectionId, + SectionName = p26.Section != null ? p26.Section.Name : string.Empty, + MedicalHistoryTemplateId = p26.MedicalHistoryTemplateId, + Code = p26.Code, + PresentIllnessDetail = p26.PresentIllnessDetail, + PastDiseasesHistoryDetail = p26.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p26.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p26.FamilyHistoryDetail, + AllergyDetail = p26.AllergyDetail, + DrugHistoryDetail = p26.DrugHistoryDetail, + AddictionHistoryDetail = p26.AddictionHistoryDetail, + SystemReviewDetail = p26.SystemReviewDetail, + VitalSignDetail = p26.VitalSignDetail, + GeneralAppearanceDetail = p26.GeneralAppearanceDetail, + SystolicBloodPressure = p26.SystolicBloodPressure, + DiastolicBloodPressure = p26.DiastolicBloodPressure, + PulseRate = p26.PulseRate, + SPO2 = p26.SPO2, + Temperature = p26.Temperature, + CreatedAt = p26.CreatedAt, + Id = p26.Id }; } - public static MedicalHistorySDto AdaptTo(this MedicalHistory p29, MedicalHistorySDto p30) + public static MedicalHistorySDto AdaptTo(this MedicalHistory p27, MedicalHistorySDto p28) { - if (p29 == null) + if (p27 == null) { return null; } - MedicalHistorySDto result = p30 ?? new MedicalHistorySDto(); + MedicalHistorySDto result = p28 ?? new MedicalHistorySDto(); - result.ChiefComplaint = p29.ChiefComplaint; - result.SectionId = p29.SectionId; - result.SectionName = p29.Section != null ? p29.Section.Name : string.Empty; - result.FirstName = p29.FirstName; - result.LastName = p29.LastName; - result.FatherName = p29.FatherName; - result.NationalId = p29.NationalId; - result.MedicalHistoryTemplateId = p29.MedicalHistoryTemplateId; - result.Age = p29.Age; - result.BirthDate = p29.BirthDate; - result.Code = p29.Code; - result.PresentIllnessDetail = p29.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p29.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p29.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p29.FamilyHistoryDetail; - result.AllergyDetail = p29.AllergyDetail; - result.DrugHistoryDetail = p29.DrugHistoryDetail; - result.AddictionHistoryDetail = p29.AddictionHistoryDetail; - result.SystemReviewDetail = p29.SystemReviewDetail; - result.VitalSignDetail = p29.VitalSignDetail; - result.GeneralAppearanceDetail = p29.GeneralAppearanceDetail; - result.SystolicBloodPressure = p29.SystolicBloodPressure; - result.DiastolicBloodPressure = p29.DiastolicBloodPressure; - result.PulseRate = p29.PulseRate; - result.SPO2 = p29.SPO2; - result.Temperature = p29.Temperature; - result.ApplicationUserId = p29.ApplicationUserId; - result.CreatedAt = p29.CreatedAt; - result.Id = p29.Id; + result.ChiefComplaint = p27.ChiefComplaint; + result.SectionId = p27.SectionId; + result.SectionName = p27.Section != null ? p27.Section.Name : string.Empty; + result.MedicalHistoryTemplateId = p27.MedicalHistoryTemplateId; + result.Code = p27.Code; + result.PresentIllnessDetail = p27.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p27.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p27.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p27.FamilyHistoryDetail; + result.AllergyDetail = p27.AllergyDetail; + result.DrugHistoryDetail = p27.DrugHistoryDetail; + result.AddictionHistoryDetail = p27.AddictionHistoryDetail; + result.SystemReviewDetail = p27.SystemReviewDetail; + result.VitalSignDetail = p27.VitalSignDetail; + result.GeneralAppearanceDetail = p27.GeneralAppearanceDetail; + result.SystolicBloodPressure = p27.SystolicBloodPressure; + result.DiastolicBloodPressure = p27.DiastolicBloodPressure; + result.PulseRate = p27.PulseRate; + result.SPO2 = p27.SPO2; + result.Temperature = p27.Temperature; + result.CreatedAt = p27.CreatedAt; + result.Id = p27.Id; return result; } - public static Expression> ProjectToSDto => p31 => new MedicalHistorySDto() + public static Expression> ProjectToSDto => p29 => new MedicalHistorySDto() { - ChiefComplaint = p31.ChiefComplaint, - SectionId = p31.SectionId, - SectionName = p31.Section != null ? p31.Section.Name : string.Empty, - FirstName = p31.FirstName, - LastName = p31.LastName, - FatherName = p31.FatherName, - NationalId = p31.NationalId, - MedicalHistoryTemplateId = p31.MedicalHistoryTemplateId, - Age = p31.Age, - BirthDate = p31.BirthDate, - Code = p31.Code, - PresentIllnessDetail = p31.PresentIllnessDetail, - PastDiseasesHistoryDetail = p31.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p31.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p31.FamilyHistoryDetail, - AllergyDetail = p31.AllergyDetail, - DrugHistoryDetail = p31.DrugHistoryDetail, - AddictionHistoryDetail = p31.AddictionHistoryDetail, - SystemReviewDetail = p31.SystemReviewDetail, - VitalSignDetail = p31.VitalSignDetail, - GeneralAppearanceDetail = p31.GeneralAppearanceDetail, - SystolicBloodPressure = p31.SystolicBloodPressure, - DiastolicBloodPressure = p31.DiastolicBloodPressure, - PulseRate = p31.PulseRate, - SPO2 = p31.SPO2, - Temperature = p31.Temperature, - ApplicationUserId = p31.ApplicationUserId, - CreatedAt = p31.CreatedAt, - Id = p31.Id + ChiefComplaint = p29.ChiefComplaint, + SectionId = p29.SectionId, + SectionName = p29.Section != null ? p29.Section.Name : string.Empty, + MedicalHistoryTemplateId = p29.MedicalHistoryTemplateId, + Code = p29.Code, + PresentIllnessDetail = p29.PresentIllnessDetail, + PastDiseasesHistoryDetail = p29.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p29.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p29.FamilyHistoryDetail, + AllergyDetail = p29.AllergyDetail, + DrugHistoryDetail = p29.DrugHistoryDetail, + AddictionHistoryDetail = p29.AddictionHistoryDetail, + SystemReviewDetail = p29.SystemReviewDetail, + VitalSignDetail = p29.VitalSignDetail, + GeneralAppearanceDetail = p29.GeneralAppearanceDetail, + SystolicBloodPressure = p29.SystolicBloodPressure, + DiastolicBloodPressure = p29.DiastolicBloodPressure, + PulseRate = p29.PulseRate, + SPO2 = p29.SPO2, + Temperature = p29.Temperature, + CreatedAt = p29.CreatedAt, + Id = p29.Id }; private static List funcMain1(List p2) @@ -619,14 +539,5 @@ namespace DocuMed.Domain.Mappers return result; } - - private static ApplicationUser funcMain8(Never p26, ApplicationUser p27, MedicalHistorySDto p22) - { - ApplicationUser result = p27 ?? new ApplicationUser(); - - result.Id = p22.ApplicationUserId; - return result; - - } } } \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs index 985a37f..fc4e08d 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs @@ -24,7 +24,6 @@ namespace DocuMed.Domain.Mappers HospitalId = p1.Section.HospitalId, Id = p1.Section.Id }, - ApplicationUserId = p1.ApplicationUserId, Questions = funcMain1(p1.Questions), Id = p1.Id, CreatedAt = p1.CreatedAt @@ -41,7 +40,6 @@ namespace DocuMed.Domain.Mappers result.ChiefComplaint = p3.ChiefComplaint; result.SectionId = p3.SectionId; result.Section = funcMain2(p3.Section, result.Section); - result.ApplicationUserId = p3.ApplicationUserId; result.Questions = funcMain3(p3.Questions, result.Questions); result.Id = p3.Id; result.CreatedAt = p3.CreatedAt; @@ -59,7 +57,6 @@ namespace DocuMed.Domain.Mappers HospitalId = p9.Section.HospitalId, Id = p9.Section.Id }, - ApplicationUserId = p9.ApplicationUserId, Questions = p9.Questions.Select(p10 => new MedicalHistoryQuestion() { Question = p10.Question, @@ -87,7 +84,6 @@ namespace DocuMed.Domain.Mappers HospitalId = p11.Section.HospitalId, Id = p11.Section.Id }, - ApplicationUserId = p11.ApplicationUserId, CreatedAt = p11.CreatedAt, Questions = funcMain4(p11.Questions), Id = p11.Id @@ -104,7 +100,6 @@ namespace DocuMed.Domain.Mappers result.ChiefComplaint = p13.ChiefComplaint; result.SectionId = p13.SectionId; result.Section = funcMain5(p13.Section, result.Section); - result.ApplicationUserId = p13.ApplicationUserId; result.CreatedAt = p13.CreatedAt; result.Questions = funcMain6(p13.Questions, result.Questions); result.Id = p13.Id; @@ -122,7 +117,6 @@ namespace DocuMed.Domain.Mappers HospitalId = p19.Section.HospitalId, Id = p19.Section.Id }, - ApplicationUserId = p19.ApplicationUserId, CreatedAt = p19.CreatedAt, Questions = p19.Questions.Select(p20 => new MedicalHistoryQuestionSDto() { @@ -143,7 +137,6 @@ namespace DocuMed.Domain.Mappers { ChiefComplaint = p21.ChiefComplaint, SectionId = p21.SectionId, - ApplicationUserId = p21.ApplicationUserId, Id = p21.Id, CreatedAt = p21.CreatedAt }; @@ -158,7 +151,6 @@ namespace DocuMed.Domain.Mappers result.ChiefComplaint = p22.ChiefComplaint; result.SectionId = p22.SectionId; - result.ApplicationUserId = p22.ApplicationUserId; result.Id = p22.Id; result.CreatedAt = p22.CreatedAt; return result; @@ -171,7 +163,6 @@ namespace DocuMed.Domain.Mappers ChiefComplaint = p24.ChiefComplaint, SectionName = p24.Section == null ? null : p24.Section.Name, SectionId = p24.SectionId, - ApplicationUserId = p24.ApplicationUserId, CreatedAt = p24.CreatedAt, Id = p24.Id }; @@ -187,7 +178,6 @@ namespace DocuMed.Domain.Mappers result.ChiefComplaint = p25.ChiefComplaint; result.SectionName = p25.Section == null ? null : p25.Section.Name; result.SectionId = p25.SectionId; - result.ApplicationUserId = p25.ApplicationUserId; result.CreatedAt = p25.CreatedAt; result.Id = p25.Id; return result; @@ -198,7 +188,6 @@ namespace DocuMed.Domain.Mappers ChiefComplaint = p27.ChiefComplaint, SectionName = p27.Section.Name, SectionId = p27.SectionId, - ApplicationUserId = p27.ApplicationUserId, CreatedAt = p27.CreatedAt, Id = p27.Id }; diff --git a/DocuMed.Domain/Mappers/PatientMapper.g.cs b/DocuMed.Domain/Mappers/PatientMapper.g.cs index c9be374..684fa78 100644 --- a/DocuMed.Domain/Mappers/PatientMapper.g.cs +++ b/DocuMed.Domain/Mappers/PatientMapper.g.cs @@ -1,6 +1,91 @@ +using System; +using System.Linq.Expressions; +using DocuMed.Domain.Dtos.SmallDtos; +using DocuMed.Domain.Entities.Patients; + namespace DocuMed.Domain.Mappers { public static partial class PatientMapper { + public static Patient AdaptToPatient(this PatientSDto p1) + { + return p1 == null ? null : new Patient() + { + UnitNumber = p1.UnitNumber, + Room = p1.Room, + Bed = p1.Bed, + AdmissionAt = p1.AdmissionAt, + SectionId = p1.SectionId, + Id = p1.Id + }; + } + public static Patient AdaptTo(this PatientSDto p2, Patient p3) + { + if (p2 == null) + { + return null; + } + Patient result = p3 ?? new Patient(); + + result.UnitNumber = p2.UnitNumber; + result.Room = p2.Room; + result.Bed = p2.Bed; + result.AdmissionAt = p2.AdmissionAt; + result.SectionId = p2.SectionId; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToPatient => p4 => new Patient() + { + UnitNumber = p4.UnitNumber, + Room = p4.Room, + Bed = p4.Bed, + AdmissionAt = p4.AdmissionAt, + SectionId = p4.SectionId, + Id = p4.Id + }; + public static PatientSDto AdaptToSDto(this Patient p5) + { + return p5 == null ? null : new PatientSDto() + { + UnitNumber = p5.UnitNumber, + Room = p5.Room, + Bed = p5.Bed, + AdmissionAt = p5.AdmissionAt, + SectionId = p5.SectionId, + SectionName = p5.Section == null ? null : p5.Section.Name, + Id = p5.Id + }; + } + public static PatientSDto AdaptTo(this Patient p6, PatientSDto p7) + { + if (p6 == null) + { + return null; + } + PatientSDto result = p7 ?? new PatientSDto(); + + result.UnitNumber = p6.UnitNumber; + result.Room = p6.Room; + result.Bed = p6.Bed; + result.AdmissionAt = p6.AdmissionAt; + result.SectionId = p6.SectionId; + result.SectionName = p6.Section == null ? null : p6.Section.Name; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new PatientSDto() + { + UnitNumber = p8.UnitNumber, + Room = p8.Room, + Bed = p8.Bed, + HospitalId = p8.HospitalId, + AdmissionAt = p8.AdmissionAt, + SectionId = p8.SectionId, + SectionName = p8.Section.Name, + Id = p8.Id + }; } } \ No newline at end of file diff --git a/DocuMed.Domain/Models/Refers.cs b/DocuMed.Domain/Models/Refers.cs index be27c3f..ba1d238 100644 --- a/DocuMed.Domain/Models/Refers.cs +++ b/DocuMed.Domain/Models/Refers.cs @@ -5,4 +5,5 @@ public static class Refers public const int SizeS = 10; public const int SizeM = 15; public const int SizeL = 20; + public const int MaxSize = 25; } \ No newline at end of file diff --git a/DocuMed.Infrastructure/DocuMed.Infrastructure.csproj b/DocuMed.Infrastructure/DocuMed.Infrastructure.csproj index 629317f..9aec464 100644 --- a/DocuMed.Infrastructure/DocuMed.Infrastructure.csproj +++ b/DocuMed.Infrastructure/DocuMed.Infrastructure.csproj @@ -1,13 +1,13 @@  - net8.0 + net9.0 enable enable - + diff --git a/DocuMed.PWA/DocuMed.PWA.csproj b/DocuMed.PWA/DocuMed.PWA.csproj index 059e5be..e16f94b 100644 --- a/DocuMed.PWA/DocuMed.PWA.csproj +++ b/DocuMed.PWA/DocuMed.PWA.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable enable service-worker-assets.js @@ -13,15 +13,15 @@ - - - + + + - - - - + + + + diff --git a/DocuMed.PWA/Models/Address.cs b/DocuMed.PWA/Models/Address.cs index 15f6f55..7f53765 100644 --- a/DocuMed.PWA/Models/Address.cs +++ b/DocuMed.PWA/Models/Address.cs @@ -15,4 +15,5 @@ public static class Address public static string UserController = $"{BaseAddress}/user"; public static string MedicalHistoryTemplateController = $"{BaseAddress}/medicalhistory/template"; public static string MedicalHistoryController = $"{BaseAddress}/medicalhistory"; + public static string PatientController = $"{BaseAddress}/patient"; } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor index 5b81dd6..0add5f8 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor @@ -5,17 +5,55 @@

شرح حال بیمار را در مراحل مختلف و اطلاعات را با دقت وارد نمایید ، در مرحله اخر میتوانید شرحال کامل را مشاهده کنید

- + - - - + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.FullName

+
+ + + + + + + + T="int" + Label="سن بیمار" + Variant="Variant.Outlined"/> @@ -28,7 +66,7 @@
- +

منتظر بمانید

@@ -40,20 +78,22 @@ - + T="string" Label="شکایت اصلی بیمار" Variant="Variant.Outlined" class="text-sm my-5"/> + + T="MedicalHistoryTemplateSDto" + Label="انتخاب از پیش نویس ها" + Variant="Variant.Outlined">
- +

منتظر بمانید

@@ -109,6 +149,10 @@ [Parameter] public MedicalHistoryTemplateSDto SelectedTemplate { get; set; } = new(); + + [Parameter] + public PatientSDto SelectedPatient { get; set; } = new(); + [Parameter] public EventCallback SelectedTemplateChanged { get; set; } @@ -123,6 +167,7 @@ public List Sections { get; private set; } = new List(); public List Templates { get; private set; } = new List(); + public List Patients { get; private set; } = new List(); public async Task> SearchTemplates(string template) @@ -149,6 +194,27 @@ } } + public async Task> SearchPatients(string name) + { + try + { + var token = await UserUtility.GetBearerTokenAsync(); + var list = await RestWrapper.PatientRestApi.GetPatientsAsync(token,0,Refers.SizeM,null,name); + Patients = list; + return Patients; + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + return Patients; + } + catch (Exception e) + { + return Patients; + } + } + + public async Task> SearchSection(string section) { try diff --git a/DocuMed.PWA/Services/RestServices/IPatientRestApi.cs b/DocuMed.PWA/Services/RestServices/IPatientRestApi.cs new file mode 100644 index 0000000..1785fbd --- /dev/null +++ b/DocuMed.PWA/Services/RestServices/IPatientRestApi.cs @@ -0,0 +1,11 @@ +namespace DocuMed.PWA.Services.RestServices; + +public interface IPatientRestApi +{ + [Get("/")] + Task> GetPatientsAsync([Header("Authorization")] string authorization, + [Query]int page , + [Query]int? count = null, + [Query]string? searchName = null, + [Query]string? nationalId = null ); +} \ No newline at end of file diff --git a/DocuMed.PWA/Services/RestServices/IRestWrapper.cs b/DocuMed.PWA/Services/RestServices/IRestWrapper.cs index e0b36c9..2d19e8e 100644 --- a/DocuMed.PWA/Services/RestServices/IRestWrapper.cs +++ b/DocuMed.PWA/Services/RestServices/IRestWrapper.cs @@ -11,4 +11,5 @@ public interface IRestWrapper public ICityRestApi CityRestApi { get; } public IUserRestApi UserRestApi { get; } public IMedicalHistoryRestApi MedicalHistoryRestApi { get; } + public IPatientRestApi PatientRestApi { get; } } \ No newline at end of file diff --git a/DocuMed.PWA/Services/RestServices/RestWrapper.cs b/DocuMed.PWA/Services/RestServices/RestWrapper.cs index 23f7237..2b0209e 100644 --- a/DocuMed.PWA/Services/RestServices/RestWrapper.cs +++ b/DocuMed.PWA/Services/RestServices/RestWrapper.cs @@ -25,4 +25,5 @@ public class RestWrapper : IRestWrapper public ICityRestApi CityRestApi => RestService.For(Address.CityController, setting); public IUserRestApi UserRestApi => RestService.For(Address.UserController, setting); public IMedicalHistoryRestApi MedicalHistoryRestApi => RestService.For(Address.MedicalHistoryController); + public IPatientRestApi PatientRestApi => RestService.For(Address.PatientController,setting); } \ No newline at end of file diff --git a/DocuMed.Repository/DocuMed.Repository.csproj b/DocuMed.Repository/DocuMed.Repository.csproj index a418364..1f5ea55 100644 --- a/DocuMed.Repository/DocuMed.Repository.csproj +++ b/DocuMed.Repository/DocuMed.Repository.csproj @@ -1,26 +1,26 @@  - net8.0 + net9.0 enable enable - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + @@ -42,10 +42,13 @@ + + + diff --git a/DocuMed.Repository/Handlers/MedicalHistories/CreateMedicalHistoryCommandHandler.cs b/DocuMed.Repository/Handlers/MedicalHistories/CreateMedicalHistoryCommandHandler.cs index ecc2eed..f01df19 100644 --- a/DocuMed.Repository/Handlers/MedicalHistories/CreateMedicalHistoryCommandHandler.cs +++ b/DocuMed.Repository/Handlers/MedicalHistories/CreateMedicalHistoryCommandHandler.cs @@ -1,18 +1,70 @@ -namespace DocuMed.Repository.Handlers.MedicalHistories; +using DocuMed.Domain.Entities.Staffs; -public class CreateMedicalHistoryCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler +namespace DocuMed.Repository.Handlers.MedicalHistories; + +public class CreateMedicalHistoryCommandHandler( + IRepositoryWrapper repositoryWrapper, + ICurrentUserService currentUserService, + IMediator mediator) : IRequestHandler { public async Task Handle(CreateMedicalHistoryCommand template, CancellationToken cancellationToken) { if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized); - var ent = MedicalHistory.Create(template.ChiefComplaint, template.SectionId, - template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail, - template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail, - template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, template.GeneralAppearanceDetail, - template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2, - template.Temperature, userId, template.MedicalHistoryTemplateId); + var student = await repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(f => f.UserId == userId, cancellationToken); + + if (student == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Student not found"); + + + Guid patientId; + if (template.PatientId != default) + { + var patient = await repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(f => f.Id == template.PatientId, cancellationToken); + if (patient == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Patient not found"); + patientId = patient.Id; + } + else + { + var patentCommand = new CreatePatientCommand(template.FirstName, + template.LastName, + string.Empty, + template.NationalId, + string.Empty, + string.Empty, + DateTime.Now, + template.SectionId + ); + + patientId = await mediator.Send(patentCommand, cancellationToken); + } + + var ent = MedicalHistory.Create(template.ChiefComplaint, + template.SectionId, + template.PresentIllnessDetail, + template.PastDiseasesHistoryDetail, + template.PastSurgeryHistoryDetail, + template.FamilyHistoryDetail, + template.AllergyDetail, + template.DrugHistoryDetail, + template.AddictionHistoryDetail, + template.SystemReviewDetail, + template.VitalSignDetail, + template.GeneralAppearanceDetail, + template.SystolicBloodPressure, + template.DiastolicBloodPressure, + template.PulseRate, + template.SPO2, + template.Temperature, + student.Id, + patientId, + template.MedicalHistoryTemplateId); foreach (var answer in template.Answers) ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType); diff --git a/DocuMed.Repository/Handlers/MedicalHistories/UpdateMedicalHistoryCommandHandler.cs b/DocuMed.Repository/Handlers/MedicalHistories/UpdateMedicalHistoryCommandHandler.cs index 88a4982..d1ee1bf 100644 --- a/DocuMed.Repository/Handlers/MedicalHistories/UpdateMedicalHistoryCommandHandler.cs +++ b/DocuMed.Repository/Handlers/MedicalHistories/UpdateMedicalHistoryCommandHandler.cs @@ -1,22 +1,75 @@ -namespace DocuMed.Repository.Handlers.MedicalHistories; +using MediatR; -public class UpdateMedicalHistoryCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler +namespace DocuMed.Repository.Handlers.MedicalHistories; + +public class UpdateMedicalHistoryCommandHandler(IRepositoryWrapper repositoryWrapper, + ICurrentUserService currentUserService, + IMediator mediator) : IRequestHandler { public async Task Handle(UpdateMedicalHistoryCommand template, CancellationToken cancellationToken) { if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized); + var student = await repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(f => f.UserId == userId, cancellationToken); + if (student == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Student not found"); var ent = await repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(m => m.Id == template.Id, cancellationToken); - if(ent==null) - throw new AppException("شرح حال پیدا نشد", ApiResultStatusCode.NotFound); - var newEnt = MedicalHistory.Create(template.ChiefComplaint, template.SectionId, - template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail, - template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail, - template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, template.GeneralAppearanceDetail, - template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2, - template.Temperature, template.ApplicationUserId, template.MedicalHistoryTemplateId); + if (ent == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "شرح حال پیدا نشد"); + + if (ent.StudentId != student.Id) + throw new BaseApiException(ApiResultStatusCode.NotFound, "شرح حال متعلق به دانشجو نیست"); + + + Guid patientId; + if (template.PatientId != default) + { + var patient = await repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(f => f.Id == template.PatientId, cancellationToken); + if (patient == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Patient not found"); + patientId = patient.Id; + } + else + { + var patentCommand = new CreatePatientCommand(template.FirstName, + template.LastName, + string.Empty, + template.NationalId, + string.Empty, + string.Empty, + DateTime.Now, + template.SectionId + ); + + patientId = await mediator.Send(patentCommand, cancellationToken); + } + + var newEnt = MedicalHistory.Create(template.ChiefComplaint, + template.SectionId, + template.PresentIllnessDetail, + template.PastDiseasesHistoryDetail, + template.PastSurgeryHistoryDetail, + template.FamilyHistoryDetail, + template.AllergyDetail, + template.DrugHistoryDetail, + template.AddictionHistoryDetail, + template.SystemReviewDetail, + template.VitalSignDetail, + template.GeneralAppearanceDetail, + template.SystolicBloodPressure, + template.DiastolicBloodPressure, + template.PulseRate, + template.SPO2, + template.Temperature, + student.Id, + patientId, + template.MedicalHistoryTemplateId); newEnt.Id = ent.Id; newEnt.CreatedAt = ent.CreatedAt; diff --git a/DocuMed.Repository/Handlers/Patients/CreatePatientCommandHandler.cs b/DocuMed.Repository/Handlers/Patients/CreatePatientCommandHandler.cs new file mode 100644 index 0000000..5c19545 --- /dev/null +++ b/DocuMed.Repository/Handlers/Patients/CreatePatientCommandHandler.cs @@ -0,0 +1,44 @@ +namespace DocuMed.Repository.Handlers.Patients; + +public class CreatePatientCommandHandler(IRepositoryWrapper repositoryWrapper , UserManager userManager) : IRequestHandler +{ + public async Task Handle(CreatePatientCommand request, CancellationToken cancellationToken) + { + var user = await userManager.Users.FirstOrDefaultAsync(u => u.NationalId == request.NationalId, + cancellationToken); + if (user == null) + { + user = new ApplicationUser + { + UserName = request.NationalId, + NationalId = request.NationalId, + FirstName = request.FirstName, + LastName = request.LastName, + SignUpStatus = SignUpStatus.StartSignUp + }; + var result = await userManager.CreateAsync(user); + if (!result.Succeeded) + throw new AppException(string.Join('|', result.Errors)); + } + var section = await repositoryWrapper.SetRepository
() + .TableNoTracking + .FirstOrDefaultAsync(f => f.Id == request.SectionId, cancellationToken); + if (section == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Section not found"); + + var patient = Patient.Create( + request.UnitNumber, + request.Room, + request.Bed, + request.AdmissionAt, + request.SectionId, + user.Id, + section.HospitalId + ); + + repositoryWrapper.SetRepository() + .Add(patient); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return patient.Id; + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Handlers/Patients/GetPatientQueryHandler.cs b/DocuMed.Repository/Handlers/Patients/GetPatientQueryHandler.cs new file mode 100644 index 0000000..0f5db85 --- /dev/null +++ b/DocuMed.Repository/Handlers/Patients/GetPatientQueryHandler.cs @@ -0,0 +1,37 @@ +namespace DocuMed.Repository.Handlers.Patients; + +public class GetPatientQueryHandler(IRepositoryWrapper repositoryWrapper,UserManager userManager) : IRequestHandler +{ + public async Task Handle(GetPatientQuery request, CancellationToken cancellationToken) + { + if (request.Id != null) + { + var ent = await repositoryWrapper.SetRepository() + .TableNoTracking + .Where(f => f.Id == request.Id) + .Select(PatientMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + if(ent == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Patient not found"); + return ent; + } + else if (request.NationalId != null) + { + var user = await userManager.Users.FirstOrDefaultAsync(f => f.NationalId == request.NationalId, + cancellationToken); + if (user == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "User with this national id not found"); + + var ent = await repositoryWrapper.SetRepository() + .TableNoTracking + .Where(f => f.UserId == user.Id) + .Select(PatientMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + if (ent == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Patient not found"); + return ent; + } + + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Request is not correct - NationalId and Id is null"); + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Handlers/Patients/GetPatientsQueryHandler.cs b/DocuMed.Repository/Handlers/Patients/GetPatientsQueryHandler.cs new file mode 100644 index 0000000..627b62c --- /dev/null +++ b/DocuMed.Repository/Handlers/Patients/GetPatientsQueryHandler.cs @@ -0,0 +1,34 @@ +namespace DocuMed.Repository.Handlers.Patients; + +public class GetPatientsQueryHandler(IRepositoryWrapper repositoryWrapper,UserManager userManager) : IRequestHandler> +{ + public async Task> Handle(GetPatientsQuery request, CancellationToken cancellationToken) + { + var count = request.Count; + if(count > Refers.MaxSize) + count = Refers.SizeM; + var query = repositoryWrapper.SetRepository() + .TableNoTracking; + + if (!string.IsNullOrEmpty(request.SearchName)) + { + + } + if(!string.IsNullOrEmpty(request.NationalId)) + { + query = from users in userManager.Users + join patients in query on users.Id equals patients.UserId + where users.NationalId == request.NationalId + select patients; + } + + var result = await query + .OrderByDescending(x => x.CreatedAt) + .Skip(request.Page * count) + .Take(count) + .Select(PatientMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + return result; + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Handlers/Patients/UpdatePatientSectionCommandHandler.cs b/DocuMed.Repository/Handlers/Patients/UpdatePatientSectionCommandHandler.cs new file mode 100644 index 0000000..b5ab2b0 --- /dev/null +++ b/DocuMed.Repository/Handlers/Patients/UpdatePatientSectionCommandHandler.cs @@ -0,0 +1,38 @@ +namespace DocuMed.Repository.Handlers.Patients; + +public class UpdatePatientSectionCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler +{ + public async Task Handle(UpdatePatientSectionCommand request, CancellationToken cancellationToken) + { + var patient = await repositoryWrapper.SetRepository() + .TableNoTracking + .Where(f => f.Id == request.Id) + .Select(PatientMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + if (patient == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Patient not found"); + + var section = await repositoryWrapper.SetRepository
() + .TableNoTracking + .FirstOrDefaultAsync(f => f.Id == request.SectionId, cancellationToken); + + if (section == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Section not found"); + + if(patient.HospitalId != section.HospitalId) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Patient and Section hospital is not same"); + + var newEnt = Patient.Create( + patient.UnitNumber, + patient.Room, + patient.Bed, + patient.AdmissionAt, + section.Id, + patient.HospitalId, + patient.Id); + repositoryWrapper.SetRepository().Update(newEnt); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return newEnt.Id; + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs b/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs index 7b4a282..9df835c 100644 --- a/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs +++ b/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs @@ -7,8 +7,15 @@ public class MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUser { if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized); + + var student = await dbContext.Set() + .AsNoTracking() + .FirstOrDefaultAsync(f => f.UserId == userId, cancellationToken); + if (student == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Student not found"); + var list = await TableNoTracking - .Where(t => t.ApplicationUserId == userId) + .Where(t => t.StudentId == student.Id) .OrderByDescending(t => t.CreatedAt) .Skip(page * 15) .Take(15) @@ -21,12 +28,20 @@ public class MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUser { if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized); + + var student = await dbContext.Set() + .AsNoTracking() + .FirstOrDefaultAsync(f => f.UserId == userId, cancellationToken); + if (student == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Student not found"); + + var list = new List(); switch (dayQuery) { case DayQueryFilter.Today: list = await TableNoTracking - .Where(t => t.ApplicationUserId == userId && t.CreatedAt.Date == DateTime.Today) + .Where(t => t.StudentId == student.Id && t.CreatedAt.Date == DateTime.Today) .OrderByDescending(t => t.CreatedAt) .Skip(page * 15) .Take(15) @@ -35,7 +50,7 @@ public class MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUser break; case DayQueryFilter.Yesterday: list = await TableNoTracking - .Where(t => t.ApplicationUserId == userId && t.CreatedAt.Date == DateTime.Today.AddDays(-1)) + .Where(t => t.StudentId == student.Id && t.CreatedAt.Date == DateTime.Today.AddDays(-1)) .OrderByDescending(t => t.CreatedAt) .Skip(page * 15) .Take(15) @@ -44,7 +59,7 @@ public class MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUser break; case DayQueryFilter.Week: list = await TableNoTracking - .Where(t => t.ApplicationUserId == userId && t.CreatedAt.Date >= DateTime.Today.AddDays(-7) ) + .Where(t => t.StudentId == student.Id && t.CreatedAt.Date >= DateTime.Today.AddDays(-7) ) .OrderByDescending(t => t.CreatedAt) .Skip(page * 15) .Take(15) diff --git a/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs b/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs index 48487bd..1523594 100644 --- a/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs +++ b/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs @@ -7,8 +7,15 @@ public class MedicalHistoryTemplateRepository(ApplicationContext dbContext, ICur { if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized); + + var student = await dbContext.Set() + .AsNoTracking() + .FirstOrDefaultAsync(f => f.UserId == userId, cancellationToken); + if (student == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Student not found"); + var list = await TableNoTracking - .Where(t => t.ApplicationUserId == userId) + .Where(t => t.StudentId == student.Id) .OrderByDescending(t => t.CreatedAt) .Skip(page * 15) .Take(15)