diff --git a/.version b/.version new file mode 100644 index 0000000..8901036 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +0.1.0.2 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e847d20 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +ENV ASPNETCORE_URLS=http://0.0.0.0:8010 +WORKDIR /app +EXPOSE 8010 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["DocuMed.Api/DocuMed.Api.csproj", "DocuMed.Api/"] +RUN dotnet restore "DocuMed.Api/DocuMed.Api.csproj" +COPY . . +WORKDIR "/src/DocuMed.Api" +RUN dotnet build "DocuMed.Api.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "DocuMed.Api.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "DocuMed.Api.dll"] \ No newline at end of file diff --git a/DocuMed.Api/AppSettings/Production/appsettings.Production.json b/DocuMed.Api/AppSettings/Production/appsettings.Production.json index d386c77..433b86c 100644 --- a/DocuMed.Api/AppSettings/Production/appsettings.Production.json +++ b/DocuMed.Api/AppSettings/Production/appsettings.Production.json @@ -1,7 +1,8 @@ { "ConnectionStrings": { "Postgres": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;", - "PostgresServer": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS" + "PostgresServer": "Host=pg-0;port=5432;Username=macsuser;Password=tDKUWlcm01iSh0O12oPqnVX1kwHQlAPks9qNC;Database=DocuMedDB", +" }, "Logging": { "LogLevel": { diff --git a/DocuMed.Api/Controllers/MedicalHistoryController.cs b/DocuMed.Api/Controllers/MedicalHistoryController.cs new file mode 100644 index 0000000..12f8c54 --- /dev/null +++ b/DocuMed.Api/Controllers/MedicalHistoryController.cs @@ -0,0 +1,63 @@ +using DocuMed.Domain.Entities.MedicalHistory; + +namespace DocuMed.Api.Controllers; +public class MedicalHistoryController : ICarterModule +{ + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("MedicalHistory").MapGroup($"api/medicalhistory") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAll") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetOne") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("", Delete) + .HasApiVersion(1.0); + } + + + // GET:Get All Entity + public virtual 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) + { + + 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) + { + return TypedResults.Ok(await service.AddAsync(dto, cancellationToken)); + } + + // PUT:Update Entity + public virtual async Task Put([FromBody] MedicalHistoryLDto dto, IMedicalHistoryService service, ICurrentUserService currentUserService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await service.EditAsync(dto, cancellationToken)); + } + + // DELETE:Delete Entity + public virtual async Task Delete(int id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().GetByIdAsync(cancellationToken, id); + repositoryWrapper.SetRepository().Delete(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } +} diff --git a/DocuMed.Api/DocuMed.Api.csproj b/DocuMed.Api/DocuMed.Api.csproj index b4994f1..0c4f407 100644 --- a/DocuMed.Api/DocuMed.Api.csproj +++ b/DocuMed.Api/DocuMed.Api.csproj @@ -6,6 +6,8 @@ enable Linux ..\docker-compose.dcproj + 0.1.0.2 + 0.1.0.2 diff --git a/DocuMed.Core/DocuMed.Core.csproj b/DocuMed.Core/DocuMed.Core.csproj index 96e5fcb..93cbef1 100644 --- a/DocuMed.Core/DocuMed.Core.csproj +++ b/DocuMed.Core/DocuMed.Core.csproj @@ -39,11 +39,13 @@ + + diff --git a/DocuMed.Core/EntityServices/Abstracts/IMedicalHistoryService.cs b/DocuMed.Core/EntityServices/Abstracts/IMedicalHistoryService.cs new file mode 100644 index 0000000..ec7f03c --- /dev/null +++ b/DocuMed.Core/EntityServices/Abstracts/IMedicalHistoryService.cs @@ -0,0 +1,8 @@ +namespace DocuMed.Core.EntityServices.Abstracts; + +public interface IMedicalHistoryService : IScopedDependency +{ + + public Task EditAsync(MedicalHistoryLDto template, CancellationToken cancellationToken); + public Task AddAsync(MedicalHistoryLDto template, CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/DocuMed.Core/EntityServices/MedicalHistoryService.cs b/DocuMed.Core/EntityServices/MedicalHistoryService.cs new file mode 100644 index 0000000..4c063fe --- /dev/null +++ b/DocuMed.Core/EntityServices/MedicalHistoryService.cs @@ -0,0 +1,54 @@ +namespace DocuMed.Core.EntityServices; + +public class MedicalHistoryService : IMedicalHistoryService +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; + private readonly IMedicalHistoryRepository _medicalHistoryRepository; + + public MedicalHistoryService(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService, IMedicalHistoryRepository medicalHistoryRepository) + { + _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; + _medicalHistoryRepository = medicalHistoryRepository; + } + + public async Task EditAsync(MedicalHistoryLDto template, CancellationToken cancellationToken) + { + if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized); + if (template.Id == Guid.Empty) + throw new AppException("شرح حال پیدا نشد", ApiResultStatusCode.NotFound); + + var ent = MedicalHistory.Create(template.ChiefComplaint, template.SectionId, template.FirstName, + template.LastName, template.FatherName, template.NationalId, template.Temperature, template.BirthDate, + template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail, + template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail, + template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, + template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2, + template.Temperature, template.ApplicationUserId); + ent.Id = template.Id; + + return true; + } + + public async Task AddAsync(MedicalHistoryLDto 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.FirstName, + template.LastName, template.FatherName, template.NationalId, template.Temperature, template.BirthDate, + template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail, + template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail, + template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, + template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2, + template.Temperature, userId); + + foreach (var answer in template.Answers) + ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType); + + _medicalHistoryRepository.Add(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs b/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs index 2a6cf6a..3bd6c09 100644 --- a/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs +++ b/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs @@ -41,7 +41,7 @@ public class MedicalHistoryTemplateService : IMedicalHistoryTemplateService } foreach (var question in template.Questions.Where(q=>q.Id==Guid.Empty)) - ent.AddQuestion(question.Question, question.Part, question.QuestionType); + ent.AddQuestion(question.Question, question.Part, question.QuestionType,question.BodySystem,question.IsSign,question.IsSymptom); _medicalHistoryTemplateRepository.Update(ent); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return true; @@ -53,7 +53,7 @@ public class MedicalHistoryTemplateService : IMedicalHistoryTemplateService throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized); var ent = MedicalHistoryTemplate.Create(template.ChiefComplaint, template.SectionId, userId); foreach (var question in template.Questions) - ent.AddQuestion(question.Question, question.Part, question.QuestionType); + ent.AddQuestion(question.Question, question.Part, question.QuestionType, question.BodySystem, question.IsSign, question.IsSymptom); _medicalHistoryTemplateRepository.Add(ent); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return true; diff --git a/DocuMed.Domain/Dtos/LargDtos/MedicalHistoryLDto.cs b/DocuMed.Domain/Dtos/LargDtos/MedicalHistoryLDto.cs index 85bd693..7a10de1 100644 --- a/DocuMed.Domain/Dtos/LargDtos/MedicalHistoryLDto.cs +++ b/DocuMed.Domain/Dtos/LargDtos/MedicalHistoryLDto.cs @@ -3,7 +3,7 @@ public class MedicalHistoryLDto : BaseDto { public string ChiefComplaint { get; set; } = string.Empty; - public string Section { get; set; } = string.Empty; + public Guid SectionId { get; set; } public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; @@ -21,6 +21,7 @@ public class MedicalHistoryLDto : BaseDto public string AddictionHistoryDetail { get; set; } = string.Empty; public string SystemReviewDetail { get; set; } = string.Empty; public string VitalSignDetail { get; set; } = string.Empty; + public string GeneralAppearanceDetail { get; set; } = string.Empty; public int SystolicBloodPressure { get; set; } diff --git a/DocuMed.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs b/DocuMed.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs index 99769f2..82b254f 100644 --- a/DocuMed.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs +++ b/DocuMed.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs @@ -15,6 +15,7 @@ public class ApplicationUserSDto : BaseDto public SignUpStatus SignUpStatus { get; set; } public Guid UniversityId { get; set; } public Guid SectionId { get; set; } + public string SectionName { get; set; } = string.Empty; public string FullName => FirstName + " " + LastName; diff --git a/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryQuestionSDto.cs b/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryQuestionSDto.cs index 8f6fe6c..bbbe058 100644 --- a/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryQuestionSDto.cs +++ b/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryQuestionSDto.cs @@ -6,4 +6,8 @@ public class MedicalHistoryQuestionSDto : BaseDto { public string ChiefComplaint { get; set; } = string.Empty; - public string Section { get; set; } = string.Empty; + public Guid SectionId { get; set; } + public string SectionName { get; set; } = string.Empty; public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; diff --git a/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryTemplateSDto.cs b/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryTemplateSDto.cs index e57ddab..15b292a 100644 --- a/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryTemplateSDto.cs +++ b/DocuMed.Domain/Dtos/SmallDtos/MedicalHistoryTemplateSDto.cs @@ -3,6 +3,7 @@ public class MedicalHistoryTemplateSDto : BaseDto { public string ChiefComplaint { get; set; } = string.Empty; + public string SectionName { get; set; } = string.Empty; public Guid SectionId { get; set; } public Guid ApplicationUserId { get; set; } } \ 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 0a233be..af3f840 100644 --- a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.Aggregate.cs +++ b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.Aggregate.cs @@ -23,7 +23,7 @@ public partial class MedicalHistory } public static MedicalHistory Create( string chiefComplaint, - string section, + Guid sectionId, string firstName, string lastName, string fatherName, @@ -55,8 +55,20 @@ public partial class MedicalHistory addictionHistoryDetail, systemReviewDetail, vitalSignDetail, - chiefComplaint, section, firstName, lastName, fatherName, nationalId, age, birthDate, systolicBloodPressure, - diastolicBloodPressure, pulseRate, sPO2, temperature, applicationUserId); + chiefComplaint, + sectionId, + firstName, + lastName, + fatherName, + nationalId, + age, + birthDate, + systolicBloodPressure, + diastolicBloodPressure, + pulseRate, + sPO2, + temperature, + applicationUserId); } } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs index 484152f..5798365 100644 --- a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs +++ b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs @@ -21,7 +21,7 @@ public partial class MedicalHistory : ApiEntity string systemReviewDetail, string vitalSignDetail, string chiefComplaint, - string section, + Guid sectionId, string firstName, string lastName, string fatherName, @@ -45,7 +45,7 @@ public partial class MedicalHistory : ApiEntity SystemReviewDetail = systemReviewDetail; VitalSignDetail = vitalSignDetail; ChiefComplaint = chiefComplaint; - Section = section; + SectionId = sectionId; FirstName = firstName; LastName = lastName; FatherName = fatherName; @@ -60,7 +60,8 @@ public partial class MedicalHistory : ApiEntity ApplicationUserId = applicationUserId; } public string ChiefComplaint { get; internal set; } = string.Empty; - public string Section { get; internal set; } = string.Empty; + public Guid SectionId { get; internal set; } + public Section? Section { get; internal set; } public string FirstName { get; internal set; } = string.Empty; public string LastName { get; internal set; } = string.Empty; diff --git a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs index e51761b..af01062 100644 --- a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs +++ b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs @@ -8,23 +8,32 @@ public partial class MedicalHistoryQuestion : ApiEntity { } - public MedicalHistoryQuestion( string question, MedicalHistoryPart part, MedicalHistoryQuestionType questionType, - Guid medicalHistoryTemplateId) + Guid medicalHistoryTemplateId, + BodySystem bodySystem, + bool isSign, + bool isSymptom) { Question = question; Part = part; QuestionType = questionType; MedicalHistoryTemplateId = medicalHistoryTemplateId; + BodySystem = bodySystem; + IsSign = isSign; + IsSymptom = isSymptom; } public string Question { get; internal set; } = string.Empty; public MedicalHistoryPart Part { get; internal set; } public MedicalHistoryQuestionType QuestionType { get; internal set; } + public BodySystem BodySystem { get; internal set; } + public bool IsSign { get; internal set; } + public bool IsSymptom { get; internal set; } + public Guid MedicalHistoryTemplateId { get; internal set; } public MedicalHistoryTemplate? MedicalHistoryTemplate { get; internal set; } } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.Aggregate.cs b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.Aggregate.cs index 5d2b41c..8b052ef 100644 --- a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.Aggregate.cs +++ b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.Aggregate.cs @@ -6,9 +6,12 @@ public partial class MedicalHistoryQuestion string question, MedicalHistoryPart part, MedicalHistoryQuestionType questionType, - Guid medicalHistoryTemplateId) + Guid medicalHistoryTemplateId, + BodySystem bodySystem, + bool isSign, + bool isSymptom) { - return new MedicalHistoryQuestion(question, part, questionType, medicalHistoryTemplateId); + return new MedicalHistoryQuestion(question, part, questionType, medicalHistoryTemplateId, bodySystem, isSign, isSymptom); } } @@ -17,14 +20,17 @@ public partial class MedicalHistoryTemplate public MedicalHistoryQuestion AddQuestion( string question, MedicalHistoryPart part, - MedicalHistoryQuestionType questionType) + MedicalHistoryQuestionType questionType, + BodySystem bodySystem, + bool isSign, + bool isSymptom) { - var mhQuestion = MedicalHistoryQuestion.Create(question, part, questionType, Id); + var mhQuestion = MedicalHistoryQuestion.Create(question, part, questionType, Id,bodySystem,isSign,isSymptom); Questions.Add(mhQuestion); return mhQuestion; } - public static MedicalHistoryTemplate Create(string chiefComplaint,Guid sectionId,Guid applicationUserId) + public static MedicalHistoryTemplate Create(string chiefComplaint, Guid sectionId, Guid applicationUserId) { return new MedicalHistoryTemplate(chiefComplaint, sectionId, applicationUserId); } diff --git a/DocuMed.Domain/Enums/BodySystem.cs b/DocuMed.Domain/Enums/BodySystem.cs new file mode 100644 index 0000000..b46f913 --- /dev/null +++ b/DocuMed.Domain/Enums/BodySystem.cs @@ -0,0 +1,47 @@ +namespace DocuMed.Domain.Enums; + +public enum BodySystem +{ + [Display(Name = "پوست")] + Skin, + [Display(Name = "جمجمه")] + Skull, + [Display(Name = "گوش")] + Ear, + [Display(Name = "چشم")] + Eyes, + [Display(Name = "بینی")] + Nose, + [Display(Name = "دهان")] + Mouth, + [Display(Name = "گلو")] + Throat, + [Display(Name = "گردن")] + Neck, + [Display(Name = "غدد لنفاوی")] + LymphaticGlands, + [Display(Name = "قفسه سینه")] + Chest, + [Display(Name = "پستان")] + Breast, + [Display(Name = "قلب")] + Heart, + [Display(Name = "ریه")] + Lung, + [Display(Name = "عروق")] + Vessels, + [Display(Name = "شکم")] + Abdomen, + [Display(Name = "اندام تناسلی مذکر")] + GenitalOrganMale, + [Display(Name = "اندام تناسلی مؤنث")] + GenitalOrganFemale, + [Display(Name = "مقعد")] + Rectum, + [Display(Name = "اعصاب")] + NervousSystem, + [Display(Name = "اندام ها(فوقانی،تحتانی)")] + Extremities, + [Display(Name = "استخوان مفاصل عضلات")] + BoneJointsMuscles +} \ No newline at end of file diff --git a/DocuMed.Domain/Enums/MedicalHistoryPart.cs b/DocuMed.Domain/Enums/MedicalHistoryPart.cs index ca38e8e..343d42c 100644 --- a/DocuMed.Domain/Enums/MedicalHistoryPart.cs +++ b/DocuMed.Domain/Enums/MedicalHistoryPart.cs @@ -17,7 +17,9 @@ public enum MedicalHistoryPart [Display(Name = "مواد مصرفی")] AddictionHistory, [Display(Name = "بررسی سیستماتیک")] - SystemReview, + ReviewOfSystem, [Display(Name = "علائم حیاتی")] VitalSign, + [Display(Name = "ظاهر کلی بیمار")] + GeneralAppearance, } \ No newline at end of file diff --git a/DocuMed.Domain/Enums/MedicalHistoryQuestionType.cs b/DocuMed.Domain/Enums/MedicalHistoryQuestionType.cs index abe61b9..672f473 100644 --- a/DocuMed.Domain/Enums/MedicalHistoryQuestionType.cs +++ b/DocuMed.Domain/Enums/MedicalHistoryQuestionType.cs @@ -9,5 +9,7 @@ public enum MedicalHistoryQuestionType [Display(Name = "بله و خیر")] YesOrNo, [Display(Name = "انتخابی")] - Selective + Selective, + [Display(Name = "انتخابی بررسی سیستم بدن")] + RosSelective } \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs index 6c9f12f..85ba834 100644 --- a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs +++ b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs @@ -1,7 +1,9 @@ using System; using System.Linq.Expressions; using DocuMed.Domain.Dtos.SmallDtos; +using DocuMed.Domain.Entities.City; using DocuMed.Domain.Entities.User; +using Mapster.Models; namespace DocuMed.Domain.Mappers { @@ -19,7 +21,13 @@ namespace DocuMed.Domain.Mappers Gender = p1.Gender, SignUpStatus = p1.SignUpStatus, UniversityId = (Guid?)p1.UniversityId, + University = new University() {Id = p1.UniversityId}, SectionId = (Guid?)p1.SectionId, + Section = new Section() + { + Name = p1.SectionName, + Id = p1.SectionId + }, Id = p1.Id, UserName = p1.UserName, Email = p1.Email, @@ -43,7 +51,9 @@ namespace DocuMed.Domain.Mappers result.Gender = p2.Gender; result.SignUpStatus = p2.SignUpStatus; result.UniversityId = (Guid?)p2.UniversityId; + result.University = funcMain1(new Never(), result.University, p2); result.SectionId = (Guid?)p2.SectionId; + result.Section = funcMain2(new Never(), result.Section, p2); result.Id = p2.Id; result.UserName = p2.UserName; result.Email = p2.Email; @@ -52,84 +62,112 @@ namespace DocuMed.Domain.Mappers return result; } - public static Expression> ProjectToApplicationUser => p4 => new ApplicationUser() - { - FirstName = p4.FirstName, - LastName = p4.LastName, - NationalId = p4.NationalId, - StudentId = p4.StudentId, - BirthDate = p4.BirthDate, - Gender = p4.Gender, - SignUpStatus = p4.SignUpStatus, - UniversityId = (Guid?)p4.UniversityId, - SectionId = (Guid?)p4.SectionId, - Id = p4.Id, - UserName = p4.UserName, - Email = p4.Email, - PhoneNumber = p4.PhoneNumber, - PhoneNumberConfirmed = p4.PhoneNumberConfirmed - }; - public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p5) - { - return p5 == null ? null : new ApplicationUserSDto() - { - FirstName = p5.FirstName, - LastName = p5.LastName, - UserName = p5.UserName, - Email = p5.Email, - PhoneNumber = p5.PhoneNumber, - PhoneNumberConfirmed = p5.PhoneNumberConfirmed, - NationalId = p5.NationalId, - StudentId = p5.StudentId, - BirthDate = p5.BirthDate, - Gender = p5.Gender, - SignUpStatus = p5.SignUpStatus, - UniversityId = p5.UniversityId == null ? default(Guid) : (Guid)p5.UniversityId, - SectionId = p5.SectionId == null ? default(Guid) : (Guid)p5.SectionId, - Id = p5.Id - }; - } - public static ApplicationUserSDto AdaptTo(this ApplicationUser p6, ApplicationUserSDto p7) - { - if (p6 == null) - { - return null; - } - ApplicationUserSDto result = p7 ?? new ApplicationUserSDto(); - - 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.StudentId = p6.StudentId; - result.BirthDate = p6.BirthDate; - result.Gender = p6.Gender; - result.SignUpStatus = p6.SignUpStatus; - result.UniversityId = p6.UniversityId == null ? default(Guid) : (Guid)p6.UniversityId; - result.SectionId = p6.SectionId == null ? default(Guid) : (Guid)p6.SectionId; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new ApplicationUserSDto() + public static Expression> ProjectToApplicationUser => p8 => new ApplicationUser() { FirstName = p8.FirstName, LastName = p8.LastName, - UserName = p8.UserName, - Email = p8.Email, - PhoneNumber = p8.PhoneNumber, - PhoneNumberConfirmed = p8.PhoneNumberConfirmed, NationalId = p8.NationalId, StudentId = p8.StudentId, BirthDate = p8.BirthDate, Gender = p8.Gender, SignUpStatus = p8.SignUpStatus, - UniversityId = p8.UniversityId == null ? default(Guid) : (Guid)p8.UniversityId, - SectionId = p8.SectionId == null ? default(Guid) : (Guid)p8.SectionId, - Id = p8.Id + UniversityId = (Guid?)p8.UniversityId, + University = new University() {Id = p8.UniversityId}, + SectionId = (Guid?)p8.SectionId, + Section = new Section() + { + Name = p8.SectionName, + Id = p8.SectionId + }, + Id = p8.Id, + UserName = p8.UserName, + Email = p8.Email, + PhoneNumber = p8.PhoneNumber, + PhoneNumberConfirmed = p8.PhoneNumberConfirmed }; + public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p9) + { + return p9 == null ? null : new ApplicationUserSDto() + { + FirstName = p9.FirstName, + LastName = p9.LastName, + UserName = p9.UserName, + Email = p9.Email, + PhoneNumber = p9.PhoneNumber, + PhoneNumberConfirmed = p9.PhoneNumberConfirmed, + NationalId = p9.NationalId, + StudentId = p9.StudentId, + BirthDate = p9.BirthDate, + Gender = p9.Gender, + SignUpStatus = p9.SignUpStatus, + UniversityId = p9.UniversityId == null ? default(Guid) : (Guid)p9.UniversityId, + SectionId = p9.SectionId == null ? default(Guid) : (Guid)p9.SectionId, + SectionName = p9.Section != null ? p9.Section.Name : string.Empty, + Id = p9.Id + }; + } + public static ApplicationUserSDto AdaptTo(this ApplicationUser p10, ApplicationUserSDto p11) + { + if (p10 == null) + { + return null; + } + ApplicationUserSDto result = p11 ?? new ApplicationUserSDto(); + + result.FirstName = p10.FirstName; + result.LastName = p10.LastName; + result.UserName = p10.UserName; + result.Email = p10.Email; + result.PhoneNumber = p10.PhoneNumber; + result.PhoneNumberConfirmed = p10.PhoneNumberConfirmed; + result.NationalId = p10.NationalId; + result.StudentId = p10.StudentId; + result.BirthDate = p10.BirthDate; + result.Gender = p10.Gender; + result.SignUpStatus = p10.SignUpStatus; + result.UniversityId = p10.UniversityId == null ? default(Guid) : (Guid)p10.UniversityId; + result.SectionId = p10.SectionId == null ? default(Guid) : (Guid)p10.SectionId; + result.SectionName = p10.Section != null ? p10.Section.Name : string.Empty; + result.Id = p10.Id; + return result; + + } + public static Expression> ProjectToSDto => p12 => new ApplicationUserSDto() + { + FirstName = p12.FirstName, + LastName = p12.LastName, + UserName = p12.UserName, + Email = p12.Email, + PhoneNumber = p12.PhoneNumber, + PhoneNumberConfirmed = p12.PhoneNumberConfirmed, + NationalId = p12.NationalId, + StudentId = p12.StudentId, + BirthDate = p12.BirthDate, + Gender = p12.Gender, + SignUpStatus = p12.SignUpStatus, + UniversityId = p12.UniversityId == null ? default(Guid) : (Guid)p12.UniversityId, + SectionId = p12.SectionId == null ? default(Guid) : (Guid)p12.SectionId, + SectionName = p12.Section != null ? p12.Section.Name : string.Empty, + Id = p12.Id + }; + + private static University funcMain1(Never p4, University p5, ApplicationUserSDto p2) + { + University result = p5 ?? new University(); + + result.Id = p2.UniversityId; + return result; + + } + + private static Section funcMain2(Never p6, Section p7, ApplicationUserSDto p2) + { + Section result = p7 ?? new Section(); + + result.Name = p2.SectionName; + result.Id = p2.SectionId; + return result; + + } } } \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs index df9f6bb..c75e6f7 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs @@ -4,7 +4,10 @@ using System.Linq; using System.Linq.Expressions; using DocuMed.Domain.Dtos.LargDtos; using DocuMed.Domain.Dtos.SmallDtos; +using DocuMed.Domain.Entities.City; using DocuMed.Domain.Entities.MedicalHistory; +using DocuMed.Domain.Entities.User; +using Mapster.Models; namespace DocuMed.Domain.Mappers { @@ -15,7 +18,12 @@ namespace DocuMed.Domain.Mappers return p1 == null ? null : new MedicalHistory() { ChiefComplaint = p1.ChiefComplaint, - Section = p1.Section, + SectionId = p1.SectionId, + Section = new Section() + { + Name = p1.SectionName, + Id = p1.SectionId + }, FirstName = p1.FirstName, LastName = p1.LastName, FatherName = p1.FatherName, @@ -37,6 +45,7 @@ namespace DocuMed.Domain.Mappers SPO2 = p1.SPO2, Temperature = p1.Temperature, ApplicationUserId = p1.ApplicationUserId, + ApplicationUser = new ApplicationUser() {Id = p1.ApplicationUserId}, Id = p1.Id }; } @@ -49,7 +58,8 @@ namespace DocuMed.Domain.Mappers MedicalHistory result = p3 ?? new MedicalHistory(); result.ChiefComplaint = p2.ChiefComplaint; - result.Section = p2.Section; + result.SectionId = p2.SectionId; + result.Section = funcMain1(new Never(), result.Section, p2); result.FirstName = p2.FirstName; result.LastName = p2.LastName; result.FatherName = p2.FatherName; @@ -71,106 +81,20 @@ namespace DocuMed.Domain.Mappers result.SPO2 = p2.SPO2; result.Temperature = p2.Temperature; result.ApplicationUserId = p2.ApplicationUserId; + result.ApplicationUser = funcMain2(new Never(), result.ApplicationUser, p2); result.Id = p2.Id; return result; } - public static Expression> ProjectToMedicalHistory => p4 => new MedicalHistory() - { - ChiefComplaint = p4.ChiefComplaint, - Section = p4.Section, - FirstName = p4.FirstName, - LastName = p4.LastName, - FatherName = p4.FatherName, - NationalId = p4.NationalId, - Age = p4.Age, - BirthDate = p4.BirthDate, - PresentIllnessDetail = p4.PresentIllnessDetail, - PastDiseasesHistoryDetail = p4.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p4.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p4.FamilyHistoryDetail, - AllergyDetail = p4.AllergyDetail, - DrugHistoryDetail = p4.DrugHistoryDetail, - AddictionHistoryDetail = p4.AddictionHistoryDetail, - SystemReviewDetail = p4.SystemReviewDetail, - VitalSignDetail = p4.VitalSignDetail, - SystolicBloodPressure = p4.SystolicBloodPressure, - DiastolicBloodPressure = p4.DiastolicBloodPressure, - PulseRate = p4.PulseRate, - SPO2 = p4.SPO2, - Temperature = p4.Temperature, - ApplicationUserId = p4.ApplicationUserId, - Id = p4.Id - }; - public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p5) - { - return p5 == null ? null : new MedicalHistorySDto() - { - ChiefComplaint = p5.ChiefComplaint, - Section = p5.Section, - FirstName = p5.FirstName, - LastName = p5.LastName, - FatherName = p5.FatherName, - NationalId = p5.NationalId, - Age = p5.Age, - BirthDate = p5.BirthDate, - PresentIllnessDetail = p5.PresentIllnessDetail, - PastDiseasesHistoryDetail = p5.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p5.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p5.FamilyHistoryDetail, - AllergyDetail = p5.AllergyDetail, - DrugHistoryDetail = p5.DrugHistoryDetail, - AddictionHistoryDetail = p5.AddictionHistoryDetail, - SystemReviewDetail = p5.SystemReviewDetail, - VitalSignDetail = p5.VitalSignDetail, - SystolicBloodPressure = p5.SystolicBloodPressure, - DiastolicBloodPressure = p5.DiastolicBloodPressure, - PulseRate = p5.PulseRate, - SPO2 = p5.SPO2, - Temperature = p5.Temperature, - ApplicationUserId = p5.ApplicationUserId, - Id = p5.Id - }; - } - public static MedicalHistorySDto AdaptTo(this MedicalHistory p6, MedicalHistorySDto p7) - { - if (p6 == null) - { - return null; - } - MedicalHistorySDto result = p7 ?? new MedicalHistorySDto(); - - result.ChiefComplaint = p6.ChiefComplaint; - result.Section = p6.Section; - result.FirstName = p6.FirstName; - result.LastName = p6.LastName; - result.FatherName = p6.FatherName; - result.NationalId = p6.NationalId; - result.Age = p6.Age; - result.BirthDate = p6.BirthDate; - result.PresentIllnessDetail = p6.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p6.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p6.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p6.FamilyHistoryDetail; - result.AllergyDetail = p6.AllergyDetail; - result.DrugHistoryDetail = p6.DrugHistoryDetail; - result.AddictionHistoryDetail = p6.AddictionHistoryDetail; - result.SystemReviewDetail = p6.SystemReviewDetail; - result.VitalSignDetail = p6.VitalSignDetail; - result.SystolicBloodPressure = p6.SystolicBloodPressure; - result.DiastolicBloodPressure = p6.DiastolicBloodPressure; - result.PulseRate = p6.PulseRate; - result.SPO2 = p6.SPO2; - result.Temperature = p6.Temperature; - result.ApplicationUserId = p6.ApplicationUserId; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new MedicalHistorySDto() + public static Expression> ProjectToMedicalHistory => p8 => new MedicalHistory() { ChiefComplaint = p8.ChiefComplaint, - Section = p8.Section, + SectionId = p8.SectionId, + Section = new Section() + { + Name = p8.SectionName, + Id = p8.SectionId + }, FirstName = p8.FirstName, LastName = p8.LastName, FatherName = p8.FatherName, @@ -192,14 +116,16 @@ namespace DocuMed.Domain.Mappers SPO2 = p8.SPO2, Temperature = p8.Temperature, ApplicationUserId = p8.ApplicationUserId, + ApplicationUser = new ApplicationUser() {Id = p8.ApplicationUserId}, Id = p8.Id }; - public static MedicalHistory AdaptToMedicalHistory(this MedicalHistoryLDto p9) + public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p9) { - return p9 == null ? null : new MedicalHistory() + return p9 == null ? null : new MedicalHistorySDto() { ChiefComplaint = p9.ChiefComplaint, - Section = p9.Section, + SectionId = p9.SectionId, + SectionName = p9.Section != null ? p9.Section.Name : string.Empty, FirstName = p9.FirstName, LastName = p9.LastName, FatherName = p9.FatherName, @@ -221,200 +147,313 @@ namespace DocuMed.Domain.Mappers SPO2 = p9.SPO2, Temperature = p9.Temperature, ApplicationUserId = p9.ApplicationUserId, - Answers = funcMain1(p9.Answers), Id = p9.Id }; } - public static MedicalHistory AdaptTo(this MedicalHistoryLDto p11, MedicalHistory p12) - { - if (p11 == null) - { - return null; - } - MedicalHistory result = p12 ?? new MedicalHistory(); - - result.ChiefComplaint = p11.ChiefComplaint; - result.Section = p11.Section; - result.FirstName = p11.FirstName; - result.LastName = p11.LastName; - result.FatherName = p11.FatherName; - result.NationalId = p11.NationalId; - result.Age = p11.Age; - result.BirthDate = p11.BirthDate; - result.PresentIllnessDetail = p11.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p11.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p11.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p11.FamilyHistoryDetail; - result.AllergyDetail = p11.AllergyDetail; - result.DrugHistoryDetail = p11.DrugHistoryDetail; - result.AddictionHistoryDetail = p11.AddictionHistoryDetail; - result.SystemReviewDetail = p11.SystemReviewDetail; - result.VitalSignDetail = p11.VitalSignDetail; - result.SystolicBloodPressure = p11.SystolicBloodPressure; - result.DiastolicBloodPressure = p11.DiastolicBloodPressure; - result.PulseRate = p11.PulseRate; - result.SPO2 = p11.SPO2; - result.Temperature = p11.Temperature; - result.ApplicationUserId = p11.ApplicationUserId; - result.Answers = funcMain2(p11.Answers, result.Answers); - result.Id = p11.Id; - return result; - - } - public static Expression> ProjectLDtoToMedicalHistory => p15 => new MedicalHistory() - { - ChiefComplaint = p15.ChiefComplaint, - Section = p15.Section, - FirstName = p15.FirstName, - LastName = p15.LastName, - FatherName = p15.FatherName, - NationalId = p15.NationalId, - Age = p15.Age, - BirthDate = p15.BirthDate, - PresentIllnessDetail = p15.PresentIllnessDetail, - PastDiseasesHistoryDetail = p15.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p15.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p15.FamilyHistoryDetail, - AllergyDetail = p15.AllergyDetail, - DrugHistoryDetail = p15.DrugHistoryDetail, - AddictionHistoryDetail = p15.AddictionHistoryDetail, - SystemReviewDetail = p15.SystemReviewDetail, - VitalSignDetail = p15.VitalSignDetail, - SystolicBloodPressure = p15.SystolicBloodPressure, - DiastolicBloodPressure = p15.DiastolicBloodPressure, - PulseRate = p15.PulseRate, - SPO2 = p15.SPO2, - Temperature = p15.Temperature, - ApplicationUserId = p15.ApplicationUserId, - Answers = p15.Answers.Select(p16 => new MedicalHistoryAnswer() - { - Answer = p16.Answer, - Question = p16.Question, - Part = p16.Part, - QuestionType = p16.QuestionType, - MedicalHistoryId = p16.MedicalHistoryId, - Id = p16.Id - }).ToList(), - Id = p15.Id - }; - public static MedicalHistoryLDto AdaptToLDto(this MedicalHistory p17) - { - return p17 == null ? null : new MedicalHistoryLDto() - { - ChiefComplaint = p17.ChiefComplaint, - Section = p17.Section, - FirstName = p17.FirstName, - LastName = p17.LastName, - FatherName = p17.FatherName, - NationalId = p17.NationalId, - Age = p17.Age, - BirthDate = p17.BirthDate, - PresentIllnessDetail = p17.PresentIllnessDetail, - PastDiseasesHistoryDetail = p17.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p17.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p17.FamilyHistoryDetail, - AllergyDetail = p17.AllergyDetail, - DrugHistoryDetail = p17.DrugHistoryDetail, - AddictionHistoryDetail = p17.AddictionHistoryDetail, - SystemReviewDetail = p17.SystemReviewDetail, - VitalSignDetail = p17.VitalSignDetail, - SystolicBloodPressure = p17.SystolicBloodPressure, - DiastolicBloodPressure = p17.DiastolicBloodPressure, - PulseRate = p17.PulseRate, - SPO2 = p17.SPO2, - Temperature = p17.Temperature, - ApplicationUserId = p17.ApplicationUserId, - Answers = funcMain3(p17.Answers), - Id = p17.Id - }; - } - public static MedicalHistoryLDto AdaptTo(this MedicalHistory p19, MedicalHistoryLDto p20) - { - if (p19 == null) - { - return null; - } - MedicalHistoryLDto result = p20 ?? new MedicalHistoryLDto(); - - result.ChiefComplaint = p19.ChiefComplaint; - result.Section = p19.Section; - result.FirstName = p19.FirstName; - result.LastName = p19.LastName; - result.FatherName = p19.FatherName; - result.NationalId = p19.NationalId; - result.Age = p19.Age; - result.BirthDate = p19.BirthDate; - result.PresentIllnessDetail = p19.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p19.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p19.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p19.FamilyHistoryDetail; - result.AllergyDetail = p19.AllergyDetail; - result.DrugHistoryDetail = p19.DrugHistoryDetail; - result.AddictionHistoryDetail = p19.AddictionHistoryDetail; - result.SystemReviewDetail = p19.SystemReviewDetail; - result.VitalSignDetail = p19.VitalSignDetail; - result.SystolicBloodPressure = p19.SystolicBloodPressure; - result.DiastolicBloodPressure = p19.DiastolicBloodPressure; - result.PulseRate = p19.PulseRate; - result.SPO2 = p19.SPO2; - result.Temperature = p19.Temperature; - result.ApplicationUserId = p19.ApplicationUserId; - result.Answers = funcMain4(p19.Answers, result.Answers); - result.Id = p19.Id; - return result; - - } - public static Expression> ProjectToLDto => p23 => new MedicalHistoryLDto() - { - ChiefComplaint = p23.ChiefComplaint, - Section = p23.Section, - FirstName = p23.FirstName, - LastName = p23.LastName, - FatherName = p23.FatherName, - NationalId = p23.NationalId, - Age = p23.Age, - BirthDate = p23.BirthDate, - PresentIllnessDetail = p23.PresentIllnessDetail, - PastDiseasesHistoryDetail = p23.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p23.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p23.FamilyHistoryDetail, - AllergyDetail = p23.AllergyDetail, - DrugHistoryDetail = p23.DrugHistoryDetail, - AddictionHistoryDetail = p23.AddictionHistoryDetail, - SystemReviewDetail = p23.SystemReviewDetail, - VitalSignDetail = p23.VitalSignDetail, - SystolicBloodPressure = p23.SystolicBloodPressure, - DiastolicBloodPressure = p23.DiastolicBloodPressure, - PulseRate = p23.PulseRate, - SPO2 = p23.SPO2, - Temperature = p23.Temperature, - ApplicationUserId = p23.ApplicationUserId, - Answers = p23.Answers.Select(p24 => new MedicalHistoryAnswerSDto() - { - Answer = p24.Answer, - Question = p24.Question, - Part = p24.Part, - QuestionType = p24.QuestionType, - MedicalHistoryId = p24.MedicalHistoryId, - Id = p24.Id - }).ToList(), - Id = p23.Id - }; - - private static List funcMain1(List p10) + public static MedicalHistorySDto AdaptTo(this MedicalHistory p10, MedicalHistorySDto p11) { if (p10 == null) { return null; } - List result = new List(p10.Count); + MedicalHistorySDto result = p11 ?? new MedicalHistorySDto(); + + result.ChiefComplaint = p10.ChiefComplaint; + result.SectionId = p10.SectionId; + result.SectionName = p10.Section != null ? p10.Section.Name : string.Empty; + result.FirstName = p10.FirstName; + result.LastName = p10.LastName; + result.FatherName = p10.FatherName; + result.NationalId = p10.NationalId; + result.Age = p10.Age; + result.BirthDate = p10.BirthDate; + result.PresentIllnessDetail = p10.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p10.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p10.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p10.FamilyHistoryDetail; + result.AllergyDetail = p10.AllergyDetail; + result.DrugHistoryDetail = p10.DrugHistoryDetail; + result.AddictionHistoryDetail = p10.AddictionHistoryDetail; + result.SystemReviewDetail = p10.SystemReviewDetail; + result.VitalSignDetail = p10.VitalSignDetail; + result.SystolicBloodPressure = p10.SystolicBloodPressure; + result.DiastolicBloodPressure = p10.DiastolicBloodPressure; + result.PulseRate = p10.PulseRate; + result.SPO2 = p10.SPO2; + result.Temperature = p10.Temperature; + result.ApplicationUserId = p10.ApplicationUserId; + result.Id = p10.Id; + return result; + + } + public static Expression> ProjectToSDto => p12 => new MedicalHistorySDto() + { + ChiefComplaint = p12.ChiefComplaint, + SectionId = p12.SectionId, + SectionName = p12.Section != null ? p12.Section.Name : string.Empty, + FirstName = p12.FirstName, + LastName = p12.LastName, + FatherName = p12.FatherName, + NationalId = p12.NationalId, + Age = p12.Age, + BirthDate = p12.BirthDate, + PresentIllnessDetail = p12.PresentIllnessDetail, + PastDiseasesHistoryDetail = p12.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p12.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p12.FamilyHistoryDetail, + AllergyDetail = p12.AllergyDetail, + DrugHistoryDetail = p12.DrugHistoryDetail, + AddictionHistoryDetail = p12.AddictionHistoryDetail, + SystemReviewDetail = p12.SystemReviewDetail, + VitalSignDetail = p12.VitalSignDetail, + SystolicBloodPressure = p12.SystolicBloodPressure, + DiastolicBloodPressure = p12.DiastolicBloodPressure, + PulseRate = p12.PulseRate, + SPO2 = p12.SPO2, + Temperature = p12.Temperature, + ApplicationUserId = p12.ApplicationUserId, + Id = p12.Id + }; + public static MedicalHistory AdaptToMedicalHistory(this MedicalHistoryLDto p13) + { + return p13 == null ? null : new MedicalHistory() + { + ChiefComplaint = p13.ChiefComplaint, + SectionId = p13.SectionId, + FirstName = p13.FirstName, + LastName = p13.LastName, + FatherName = p13.FatherName, + NationalId = p13.NationalId, + Age = p13.Age, + BirthDate = p13.BirthDate, + PresentIllnessDetail = p13.PresentIllnessDetail, + PastDiseasesHistoryDetail = p13.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p13.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p13.FamilyHistoryDetail, + AllergyDetail = p13.AllergyDetail, + DrugHistoryDetail = p13.DrugHistoryDetail, + AddictionHistoryDetail = p13.AddictionHistoryDetail, + SystemReviewDetail = p13.SystemReviewDetail, + VitalSignDetail = p13.VitalSignDetail, + SystolicBloodPressure = p13.SystolicBloodPressure, + DiastolicBloodPressure = p13.DiastolicBloodPressure, + PulseRate = p13.PulseRate, + SPO2 = p13.SPO2, + Temperature = p13.Temperature, + ApplicationUserId = p13.ApplicationUserId, + Answers = funcMain3(p13.Answers), + Id = p13.Id + }; + } + public static MedicalHistory AdaptTo(this MedicalHistoryLDto p15, MedicalHistory p16) + { + if (p15 == null) + { + return null; + } + MedicalHistory result = p16 ?? new MedicalHistory(); + + result.ChiefComplaint = p15.ChiefComplaint; + result.SectionId = p15.SectionId; + result.FirstName = p15.FirstName; + result.LastName = p15.LastName; + result.FatherName = p15.FatherName; + result.NationalId = p15.NationalId; + result.Age = p15.Age; + result.BirthDate = p15.BirthDate; + result.PresentIllnessDetail = p15.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p15.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p15.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p15.FamilyHistoryDetail; + result.AllergyDetail = p15.AllergyDetail; + result.DrugHistoryDetail = p15.DrugHistoryDetail; + result.AddictionHistoryDetail = p15.AddictionHistoryDetail; + result.SystemReviewDetail = p15.SystemReviewDetail; + result.VitalSignDetail = p15.VitalSignDetail; + result.SystolicBloodPressure = p15.SystolicBloodPressure; + result.DiastolicBloodPressure = p15.DiastolicBloodPressure; + result.PulseRate = p15.PulseRate; + result.SPO2 = p15.SPO2; + result.Temperature = p15.Temperature; + result.ApplicationUserId = p15.ApplicationUserId; + result.Answers = funcMain4(p15.Answers, result.Answers); + result.Id = p15.Id; + return result; + + } + public static Expression> ProjectLDtoToMedicalHistory => p19 => new MedicalHistory() + { + ChiefComplaint = p19.ChiefComplaint, + SectionId = p19.SectionId, + FirstName = p19.FirstName, + LastName = p19.LastName, + FatherName = p19.FatherName, + NationalId = p19.NationalId, + Age = p19.Age, + BirthDate = p19.BirthDate, + PresentIllnessDetail = p19.PresentIllnessDetail, + PastDiseasesHistoryDetail = p19.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p19.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p19.FamilyHistoryDetail, + AllergyDetail = p19.AllergyDetail, + DrugHistoryDetail = p19.DrugHistoryDetail, + AddictionHistoryDetail = p19.AddictionHistoryDetail, + SystemReviewDetail = p19.SystemReviewDetail, + VitalSignDetail = p19.VitalSignDetail, + SystolicBloodPressure = p19.SystolicBloodPressure, + DiastolicBloodPressure = p19.DiastolicBloodPressure, + PulseRate = p19.PulseRate, + SPO2 = p19.SPO2, + Temperature = p19.Temperature, + ApplicationUserId = p19.ApplicationUserId, + Answers = p19.Answers.Select(p20 => new MedicalHistoryAnswer() + { + Answer = p20.Answer, + Question = p20.Question, + Part = p20.Part, + QuestionType = p20.QuestionType, + MedicalHistoryId = p20.MedicalHistoryId, + Id = p20.Id + }).ToList(), + Id = p19.Id + }; + public static MedicalHistoryLDto AdaptToLDto(this MedicalHistory p21) + { + return p21 == null ? null : new MedicalHistoryLDto() + { + ChiefComplaint = p21.ChiefComplaint, + SectionId = 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, + FamilyHistoryDetail = p21.FamilyHistoryDetail, + AllergyDetail = p21.AllergyDetail, + DrugHistoryDetail = p21.DrugHistoryDetail, + AddictionHistoryDetail = p21.AddictionHistoryDetail, + SystemReviewDetail = p21.SystemReviewDetail, + VitalSignDetail = p21.VitalSignDetail, + SystolicBloodPressure = p21.SystolicBloodPressure, + DiastolicBloodPressure = p21.DiastolicBloodPressure, + PulseRate = p21.PulseRate, + SPO2 = p21.SPO2, + Temperature = p21.Temperature, + ApplicationUserId = p21.ApplicationUserId, + Answers = funcMain5(p21.Answers), + Id = p21.Id + }; + } + public static MedicalHistoryLDto AdaptTo(this MedicalHistory p23, MedicalHistoryLDto p24) + { + if (p23 == null) + { + return null; + } + MedicalHistoryLDto result = p24 ?? new MedicalHistoryLDto(); + + result.ChiefComplaint = p23.ChiefComplaint; + result.SectionId = p23.SectionId; + result.FirstName = p23.FirstName; + result.LastName = p23.LastName; + result.FatherName = p23.FatherName; + result.NationalId = p23.NationalId; + result.Age = p23.Age; + result.BirthDate = p23.BirthDate; + result.PresentIllnessDetail = p23.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p23.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p23.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p23.FamilyHistoryDetail; + result.AllergyDetail = p23.AllergyDetail; + result.DrugHistoryDetail = p23.DrugHistoryDetail; + result.AddictionHistoryDetail = p23.AddictionHistoryDetail; + result.SystemReviewDetail = p23.SystemReviewDetail; + result.VitalSignDetail = p23.VitalSignDetail; + result.SystolicBloodPressure = p23.SystolicBloodPressure; + result.DiastolicBloodPressure = p23.DiastolicBloodPressure; + result.PulseRate = p23.PulseRate; + result.SPO2 = p23.SPO2; + result.Temperature = p23.Temperature; + result.ApplicationUserId = p23.ApplicationUserId; + result.Answers = funcMain6(p23.Answers, result.Answers); + result.Id = p23.Id; + return result; + + } + public static Expression> ProjectToLDto => p27 => new MedicalHistoryLDto() + { + ChiefComplaint = p27.ChiefComplaint, + SectionId = p27.SectionId, + FirstName = p27.FirstName, + LastName = p27.LastName, + FatherName = p27.FatherName, + NationalId = p27.NationalId, + Age = p27.Age, + BirthDate = p27.BirthDate, + PresentIllnessDetail = p27.PresentIllnessDetail, + PastDiseasesHistoryDetail = p27.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p27.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p27.FamilyHistoryDetail, + AllergyDetail = p27.AllergyDetail, + DrugHistoryDetail = p27.DrugHistoryDetail, + AddictionHistoryDetail = p27.AddictionHistoryDetail, + SystemReviewDetail = p27.SystemReviewDetail, + VitalSignDetail = p27.VitalSignDetail, + SystolicBloodPressure = p27.SystolicBloodPressure, + DiastolicBloodPressure = p27.DiastolicBloodPressure, + PulseRate = p27.PulseRate, + SPO2 = p27.SPO2, + Temperature = p27.Temperature, + ApplicationUserId = p27.ApplicationUserId, + Answers = p27.Answers.Select(p28 => new MedicalHistoryAnswerSDto() + { + Answer = p28.Answer, + Question = p28.Question, + Part = p28.Part, + QuestionType = p28.QuestionType, + MedicalHistoryId = p28.MedicalHistoryId, + Id = p28.Id + }).ToList(), + Id = p27.Id + }; + + private static Section funcMain1(Never p4, Section p5, MedicalHistorySDto p2) + { + Section result = p5 ?? new Section(); + + result.Name = p2.SectionName; + result.Id = p2.SectionId; + return result; + + } + + private static ApplicationUser funcMain2(Never p6, ApplicationUser p7, MedicalHistorySDto p2) + { + ApplicationUser result = p7 ?? new ApplicationUser(); + + result.Id = p2.ApplicationUserId; + return result; + + } + + private static List funcMain3(List p14) + { + if (p14 == null) + { + return null; + } + List result = new List(p14.Count); int i = 0; - int len = p10.Count; + int len = p14.Count; while (i < len) { - MedicalHistoryAnswerSDto item = p10[i]; + MedicalHistoryAnswerSDto item = p14[i]; result.Add(item == null ? null : new MedicalHistoryAnswer() { Answer = item.Answer, @@ -430,20 +469,20 @@ namespace DocuMed.Domain.Mappers } - private static List funcMain2(List p13, List p14) + private static List funcMain4(List p17, List p18) { - if (p13 == null) + if (p17 == null) { return null; } - List result = new List(p13.Count); + List result = new List(p17.Count); int i = 0; - int len = p13.Count; + int len = p17.Count; while (i < len) { - MedicalHistoryAnswerSDto item = p13[i]; + MedicalHistoryAnswerSDto item = p17[i]; result.Add(item == null ? null : new MedicalHistoryAnswer() { Answer = item.Answer, @@ -459,20 +498,20 @@ namespace DocuMed.Domain.Mappers } - private static List funcMain3(List p18) + private static List funcMain5(List p22) { - if (p18 == null) + if (p22 == null) { return null; } - List result = new List(p18.Count); + List result = new List(p22.Count); int i = 0; - int len = p18.Count; + int len = p22.Count; while (i < len) { - MedicalHistoryAnswer item = p18[i]; + MedicalHistoryAnswer item = p22[i]; result.Add(item == null ? null : new MedicalHistoryAnswerSDto() { Answer = item.Answer, @@ -488,20 +527,20 @@ namespace DocuMed.Domain.Mappers } - private static List funcMain4(List p21, List p22) + private static List funcMain6(List p25, List p26) { - if (p21 == null) + if (p25 == null) { return null; } - List result = new List(p21.Count); + List result = new List(p25.Count); int i = 0; - int len = p21.Count; + int len = p25.Count; while (i < len) { - MedicalHistoryAnswer item = p21[i]; + MedicalHistoryAnswer item = p25[i]; result.Add(item == null ? null : new MedicalHistoryAnswerSDto() { Answer = item.Answer, diff --git a/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs index 635d0ad..d9fe570 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs @@ -14,6 +14,9 @@ namespace DocuMed.Domain.Mappers Question = p1.Question, Part = p1.Part, QuestionType = p1.QuestionType, + BodySystem = p1.BodySystem, + IsSign = p1.IsSign, + IsSymptom = p1.IsSymptom, MedicalHistoryTemplateId = p1.MedicalHistoryTemplateId, Id = p1.Id }; @@ -29,6 +32,9 @@ namespace DocuMed.Domain.Mappers result.Question = p2.Question; result.Part = p2.Part; result.QuestionType = p2.QuestionType; + result.BodySystem = p2.BodySystem; + result.IsSign = p2.IsSign; + result.IsSymptom = p2.IsSymptom; result.MedicalHistoryTemplateId = p2.MedicalHistoryTemplateId; result.Id = p2.Id; return result; @@ -39,6 +45,9 @@ namespace DocuMed.Domain.Mappers Question = p4.Question, Part = p4.Part, QuestionType = p4.QuestionType, + BodySystem = p4.BodySystem, + IsSign = p4.IsSign, + IsSymptom = p4.IsSymptom, MedicalHistoryTemplateId = p4.MedicalHistoryTemplateId, Id = p4.Id }; @@ -50,6 +59,9 @@ namespace DocuMed.Domain.Mappers Part = p5.Part, QuestionType = p5.QuestionType, MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId, + BodySystem = p5.BodySystem, + IsSign = p5.IsSign, + IsSymptom = p5.IsSymptom, Id = p5.Id }; } @@ -65,6 +77,9 @@ namespace DocuMed.Domain.Mappers result.Part = p6.Part; result.QuestionType = p6.QuestionType; result.MedicalHistoryTemplateId = p6.MedicalHistoryTemplateId; + result.BodySystem = p6.BodySystem; + result.IsSign = p6.IsSign; + result.IsSymptom = p6.IsSymptom; result.Id = p6.Id; return result; @@ -75,6 +90,9 @@ namespace DocuMed.Domain.Mappers Part = p8.Part, QuestionType = p8.QuestionType, MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId, + BodySystem = p8.BodySystem, + IsSign = p8.IsSign, + IsSymptom = p8.IsSymptom, Id = p8.Id }; } diff --git a/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs index 4a41cd1..cf9061c 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs @@ -48,6 +48,7 @@ namespace DocuMed.Domain.Mappers return p5 == null ? null : new MedicalHistoryTemplateSDto() { ChiefComplaint = p5.ChiefComplaint, + SectionName = p5.Section == null ? null : p5.Section.Name, SectionId = p5.SectionId, ApplicationUserId = p5.ApplicationUserId, Id = p5.Id @@ -62,6 +63,7 @@ namespace DocuMed.Domain.Mappers MedicalHistoryTemplateSDto result = p7 ?? new MedicalHistoryTemplateSDto(); result.ChiefComplaint = p6.ChiefComplaint; + result.SectionName = p6.Section == null ? null : p6.Section.Name; result.SectionId = p6.SectionId; result.ApplicationUserId = p6.ApplicationUserId; result.Id = p6.Id; @@ -71,6 +73,7 @@ namespace DocuMed.Domain.Mappers public static Expression> ProjectToSDto => p8 => new MedicalHistoryTemplateSDto() { ChiefComplaint = p8.ChiefComplaint, + SectionName = p8.Section.Name, SectionId = p8.SectionId, ApplicationUserId = p8.ApplicationUserId, Id = p8.Id @@ -127,6 +130,9 @@ namespace DocuMed.Domain.Mappers Question = p18.Question, Part = p18.Part, QuestionType = p18.QuestionType, + BodySystem = p18.BodySystem, + IsSign = p18.IsSign, + IsSymptom = p18.IsSymptom, MedicalHistoryTemplateId = p18.MedicalHistoryTemplateId, Id = p18.Id }).ToList(), @@ -185,6 +191,9 @@ namespace DocuMed.Domain.Mappers Part = p28.Part, QuestionType = p28.QuestionType, MedicalHistoryTemplateId = p28.MedicalHistoryTemplateId, + BodySystem = p28.BodySystem, + IsSign = p28.IsSign, + IsSymptom = p28.IsSymptom, Id = p28.Id }).ToList(), Id = p27.Id @@ -209,6 +218,9 @@ namespace DocuMed.Domain.Mappers Question = item.Question, Part = item.Part, QuestionType = item.QuestionType, + BodySystem = item.BodySystem, + IsSign = item.IsSign, + IsSymptom = item.IsSymptom, MedicalHistoryTemplateId = item.MedicalHistoryTemplateId, Id = item.Id }); @@ -253,6 +265,9 @@ namespace DocuMed.Domain.Mappers Question = item.Question, Part = item.Part, QuestionType = item.QuestionType, + BodySystem = item.BodySystem, + IsSign = item.IsSign, + IsSymptom = item.IsSymptom, MedicalHistoryTemplateId = item.MedicalHistoryTemplateId, Id = item.Id }); @@ -282,6 +297,9 @@ namespace DocuMed.Domain.Mappers Part = item.Part, QuestionType = item.QuestionType, MedicalHistoryTemplateId = item.MedicalHistoryTemplateId, + BodySystem = item.BodySystem, + IsSign = item.IsSign, + IsSymptom = item.IsSymptom, Id = item.Id }); i++; @@ -326,6 +344,9 @@ namespace DocuMed.Domain.Mappers Part = item.Part, QuestionType = item.QuestionType, MedicalHistoryTemplateId = item.MedicalHistoryTemplateId, + BodySystem = item.BodySystem, + IsSign = item.IsSign, + IsSymptom = item.IsSymptom, Id = item.Id }); i++; diff --git a/DocuMed.Domain/MapsterRegister.cs b/DocuMed.Domain/MapsterRegister.cs new file mode 100644 index 0000000..2e47b97 --- /dev/null +++ b/DocuMed.Domain/MapsterRegister.cs @@ -0,0 +1,16 @@ +namespace DocuMed.Domain; + +public class MapsterRegister : IRegister +{ + public void Register(TypeAdapterConfig config) + { + config.NewConfig() + .Map("SectionName", org => org.Section!=null ? org.Section.Name : string.Empty) + .TwoWays(); + + + config.NewConfig() + .Map("SectionName", org => org.Section != null ? org.Section.Name : string.Empty) + .TwoWays(); + } +} \ No newline at end of file diff --git a/DocuMed.PWA/Models/Address.cs b/DocuMed.PWA/Models/Address.cs index eb3eaae..ccdd3da 100644 --- a/DocuMed.PWA/Models/Address.cs +++ b/DocuMed.PWA/Models/Address.cs @@ -9,4 +9,5 @@ public static class Address public const string SectionController = $"{BaseAddress}/section"; public const string UserController = $"{BaseAddress}/user"; public const string MedicalHistoryTemplateController = $"{BaseAddress}/medicalhistory/template"; + public const string MedicalHistoryController = $"{BaseAddress}/medicalhistory"; } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/HomePage.razor b/DocuMed.PWA/Pages/HomePage.razor index 1d1f3ec..e7b6097 100644 --- a/DocuMed.PWA/Pages/HomePage.razor +++ b/DocuMed.PWA/Pages/HomePage.razor @@ -1,11 +1,13 @@ @page "/HomePage" @inject NavigationManager NavigationManager @inject IUserUtility UserUtility +@inject ISnackbar Snackbar +@inject IRestWrapper RestWrapper -
- +
+ @@ -16,7 +18,7 @@

@ViewModel?.User.PhoneNumber

- اطفال + @ViewModel?.User.SectionName
@@ -27,13 +29,37 @@
+ افزودن
- -
- @foreach (var item in @ViewModel.MedicalHistories) + @if (@ViewModel.IsProcessing) + { + @for (int i = 0; i < 4; i++) { - + +
+
+ + +
+ + +
+ +
+ + + +
+
} -
+ } + else + { +
+ @foreach (var item in @ViewModel.PageDto) + { + + } +
+ }
@@ -76,7 +102,7 @@ @code { - private HomePageViewModel? ViewModel { get; set; } + private HomePageViewModel ViewModel { get; set; } public void ProfileClicked() => NavigationManager.NavigateTo("ProfilePage"); @@ -88,7 +114,7 @@ protected override async Task OnInitializedAsync() { - ViewModel = new HomePageViewModel(UserUtility); + ViewModel = new HomePageViewModel(UserUtility,RestWrapper,Snackbar); await ViewModel.InitializeAsync(); await base.OnInitializedAsync(); } diff --git a/DocuMed.PWA/Pages/HomePage.razor.cs b/DocuMed.PWA/Pages/HomePage.razor.cs index c297d43..277ae40 100644 --- a/DocuMed.PWA/Pages/HomePage.razor.cs +++ b/DocuMed.PWA/Pages/HomePage.razor.cs @@ -1,60 +1,51 @@ -namespace DocuMed.PWA.Pages; +using DocuMed.Common.Models.Mapper; -public class HomePageViewModel : BaseViewModel +namespace DocuMed.PWA.Pages; + +public class HomePageViewModel : BaseViewModel> { private readonly IUserUtility _userUtility; + private readonly IRestWrapper _restWrapper; + private readonly ISnackbar _snackbar; - public HomePageViewModel(IUserUtility userUtility) + public HomePageViewModel(IUserUtility userUtility,IRestWrapper restWrapper,ISnackbar snackbar) { _userUtility = userUtility; + _restWrapper = restWrapper; + _snackbar = snackbar; } - public List MedicalHistories { get; private set; } = new List(); public ApplicationUserSDto User { get; private set; } = new ApplicationUserSDto(); public override async Task InitializeAsync() { - User = await _userUtility.GetUserAsync(); - MedicalHistories.Add(new MedicalHistorySDto + + try { - FirstName = "امیرحسین ", - LastName = "معتمدی", - Age = 35, - ChiefComplaint = "سردرد", - Section = "داخلی", - }); - MedicalHistories.Add(new MedicalHistorySDto + IsProcessing = true; + User = await _userUtility.GetUserAsync(); + await Task.Delay(500); + var token = await _userUtility.GetBearerTokenAsync(); + var list = await _restWrapper + .CrudDtoApiRest(Address.MedicalHistoryController) + .ReadAll(0, token); + PageDto = list; + + } + catch (ApiException ex) { - FirstName = "امیرحسین ", - LastName = "معتمدی", - Age = 35, - ChiefComplaint = "سردرد", - Section = "داخلی", - }); - MedicalHistories.Add(new MedicalHistorySDto + var exe = await ex.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) { - FirstName = "امیرحسین ", - LastName = "معتمدی", - Age = 35, - ChiefComplaint = "سردرد", - Section = "داخلی", - }); - MedicalHistories.Add(new MedicalHistorySDto + _snackbar.Add(e.Message, Severity.Error); + } + finally { - FirstName = "امیرحسین ", - LastName = "معتمدی", - Age = 35, - ChiefComplaint = "سردرد", - Section = "داخلی", - }); - MedicalHistories.Add(new MedicalHistorySDto - { - FirstName = "امیرحسین ", - LastName = "معتمدی", - Age = 35, - ChiefComplaint = "سردرد", - Section = "داخلی", - }); + + IsProcessing = false; + } await base.InitializeAsync(); diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor b/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor index 1ad5eb3..3516f37 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor @@ -1,86 +1,108 @@ @page "/MedicalHistoryActionPage" @inject NavigationManager NavigationManager +@inject IRestWrapper RestWrapper +@inject ISnackbar Snackbar +@inject IUserUtility UserUtility +
- +
- +
- +
- +
- +
- +
- +
- @if(!medicalHistorySubmited){ - + @if (!@ViewModel.MedicalHistorySubmitted) + { + - @if (_currentStep == 4) - { - تکمیل - } - else - { - مرحله بعد - - } + @if (@ViewModel.CurrentStep == 4) + { + تکمیل + } + else + { + + مرحله بعد + + } -

@_stepCounter

- مرحله قبل -
+

@ViewModel.StepCounter

+ مرحله قبل +
}
@code { - private MudCarousel? _carousel; - private int _currentStep = 0; - private string _stepCounter = "1 / 5"; - private bool medicalHistorySubmited = false; - private void CompleteStepClicked() + public MedicalHistoryActionPageViewModel ViewModel { get; set; } + protected override async Task OnInitializedAsync() { - _carousel?.MoveTo(++_currentStep); - _stepCounter = string.Format("{0} / 5", _currentStep + 1); - if (_currentStep == 5) - medicalHistorySubmited = true; - } - private void RollBackStepClicked() - { - _carousel?.MoveTo(--_currentStep); - _stepCounter = string.Format("{0} / 5", _currentStep + 1); + ViewModel = new MedicalHistoryActionPageViewModel(RestWrapper, NavigationManager, Snackbar, UserUtility); + await ViewModel.InitializeAsync(); + await base.OnInitializedAsync(); } - private void CompleteCreateMedicalHistory() - { - NavigationManager.NavigateTo("HomePage"); - } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor.cs b/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor.cs new file mode 100644 index 0000000..9ee0600 --- /dev/null +++ b/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor.cs @@ -0,0 +1,138 @@ +namespace DocuMed.PWA.Pages; + +public class MedicalHistoryActionPageViewModel : BaseViewModel +{ + private readonly IRestWrapper _restWrapper; + private readonly NavigationManager _navigationManager; + private readonly ISnackbar _snackbar; + private readonly IUserUtility _userUtility; + + public MedicalHistoryActionPageViewModel(IRestWrapper restWrapper, + NavigationManager navigationManager, + ISnackbar snackbar, + IUserUtility userUtility) + { + _restWrapper = restWrapper; + _navigationManager = navigationManager; + _snackbar = snackbar; + _userUtility = userUtility; + } + + public MedicalHistoryTemplateSDto SelectedTemplate { get; set; } = new(); + public MedicalHistoryTemplateLDto SelectedTemplateLDto { get; set; } = new(); + + public bool IsEditing { get; set; } = false; + + public SectionSDto? SelectedSelection { get; set; } + public List PiAnswers { get; set; } = new(); + public List PdhAnswers { get; set; } = new(); + public List PshAnswers { get; set; } = new(); + public List FhAnswers { get; set; } = new(); + public List DhAnswers { get; set; } = new(); + public List HhAnswers { get; set; } = new(); + public List GaAnswers { get; set; } = new(); + public List RosAnswers { get; set; } = new(); + + public MudCarousel? Carousel { get; set; } + public int CurrentStep { get; set; } = 0; + public string StepCounter { get; set; } = "1 / 5"; + public bool MedicalHistorySubmitted { get; set; } = false; + public async Task CompleteStepClicked() + { + CurrentStep++; + StepCounter = $"{CurrentStep + 1} / 5"; + if (CurrentStep == 1) + await CheckMedicalHistoryAsync(); + if (CurrentStep == 5) + { + //if (IsEditing) + // await EditTemplateAsync(); + //else + await SubmitMedicalHistoryAsync(); + MedicalHistorySubmitted = true; + } + Carousel?.MoveTo(CurrentStep); + } + + private async Task CheckMedicalHistoryAsync() + { + try + { + if (SelectedTemplate.Id == Guid.Empty) + return; + + IsProcessing = true; + var token = await _userUtility.GetBearerTokenAsync(); + var dto = await _restWrapper.CrudDtoApiRest(Address.MedicalHistoryTemplateController) + .ReadOne(SelectedTemplate.Id, token); + + PageDto.Id = dto.Id; + SelectedTemplateLDto = dto; + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + } + finally + { + + IsProcessing = false; + } + + } + + + public async Task SubmitMedicalHistoryAsync() + { + try + { + IsProcessing = true; + if (SelectedSelection == null) + throw new Exception("لطفا بخش مورد نظر را انتخاب نمایید"); + PageDto.SectionId = SelectedSelection.Id; + var token = await _userUtility.GetBearerTokenAsync(); + PageDto.Answers.AddRange(PiAnswers); + PageDto.Answers.AddRange(PdhAnswers); + PageDto.Answers.AddRange(PshAnswers); + PageDto.Answers.AddRange(FhAnswers); + PageDto.Answers.AddRange(DhAnswers); + PageDto.Answers.AddRange(HhAnswers); + PageDto.Answers.AddRange(GaAnswers); + PageDto.Answers.AddRange(RosAnswers); + await _restWrapper.CrudDtoApiRest(Address.MedicalHistoryController) + .Create(PageDto, token); + + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + } + finally + { + + IsProcessing = false; + } + } + + public void RollBackStepClicked() + { + Carousel?.MoveTo(--CurrentStep); + StepCounter = $"{CurrentStep + 1} / 5"; + } + + public void CompleteCreateMedicalHistory() + { + _navigationManager.NavigateTo("HomePage"); + } + +} \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor index 304efc9..e4730e3 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep1.razor @@ -1,13 +1,148 @@ +@inject IRestWrapper RestWrapper +@inject IUserUtility UserUtility

افزودن شرح حال جدید

-

لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از +

+ لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و برای شرایط فعلی تکنولوژی - مورد ده

+ مورد ده +

- - + + + + + + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.ChiefComplaint

+
+
+ + + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.Name

+
+
-@code { +@code +{ + + [Parameter] + public string PatientFirstName { get; set; } = string.Empty; + [Parameter] + public EventCallback PatientFirstNameChanged { get; set; } + + [Parameter] + public string PatientLastName { get; set; } = string.Empty; + [Parameter] + public EventCallback PatientLastNameChanged { get; set; } + + + [Parameter] + public int PatientAge { get; set; } + [Parameter] + public EventCallback PatientAgeChanged { get; set; } + + [Parameter] + public string ChiefComplaint { get; set; } = string.Empty; + [Parameter] + public EventCallback ChiefComplaintChanged { get; set; } + + [Parameter] + public SectionSDto SelectedSection { get; set; } = new(); + [Parameter] + public EventCallback SelectedSectionChanged { get; set; } + + + [Parameter] + public MedicalHistoryTemplateSDto SelectedTemplate { get; set; } = new(); + [Parameter] + public EventCallback SelectedTemplateChanged { get; set; } + + private MedicalHistoryTemplateLDto _editingTemplate = new(); + + public List Sections { get; private set; } = new List(); + + public List Templates { get; private set; } = new List(); + + + public async Task> SearchTemplates(string template) + { + try + { + var token = await UserUtility.GetBearerTokenAsync(); + var list = await RestWrapper + .CrudDtoApiRest(Address.MedicalHistoryTemplateController) + .ReadAll(0, token); + Templates = list; + if (template.IsNullOrEmpty()) + return Templates; + return Templates.Where(c => c.ChiefComplaint.Contains(template)); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + return Templates; + } + catch (Exception e) + { + return Templates; + } + } + + public async Task> SearchSection(string section) + { + try + { + var token = await UserUtility.GetBearerTokenAsync(); + var user = await UserUtility.GetUserAsync(); + Sections = await RestWrapper.SectionRestApi.GetByUniversityAsync(user.UniversityId, token); + + if (section.IsNullOrEmpty()) + return Sections; + return Sections.Where(c => c.Name.Contains(section)); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + return Sections; + } + catch (Exception e) + { + return Sections; + } + } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep2.razor b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep2.razor index 875c346..49872d4 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep2.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep2.razor @@ -2,16 +2,38 @@ - - -
+ @foreach (var question in PiQuestions) + { + + } - - +
-@code { +@code +{ + [Parameter] + public List PiAnswers { get; set; } = new(); + + [Parameter] + public List PiQuestions { get; set; } = new(); + + [Parameter] + public string PiDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback PiDetailChanged { get; set; } + + private void AnswerChanged(MedicalHistoryAnswerSDto dto) + { + var findAnswer = PiAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part); + if (findAnswer != null) + findAnswer.Answer = dto.Answer; + else + PiAnswers.Add(dto); + + } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep3.razor b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep3.razor index 8ff0264..619be21 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep3.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep3.razor @@ -2,21 +2,71 @@ - - -
- - + @foreach (var question in PdhQuestions) + { + + } - + - + + @foreach (var question in PshQuestions) + { + + } + +
-@code { +@code +{ + [Parameter] + public List PdhAnswers { get; set; } = new(); + [Parameter] + public List PdhQuestions { get; set; } = new(); + + [Parameter] + public string PdhDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback PdhDetailChanged { get; set; } + + private void PdhAnswerChanged(MedicalHistoryAnswerSDto dto) + { + var findAnswer = PdhAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part); + if (findAnswer != null) + findAnswer.Answer = dto.Answer; + else + PdhAnswers.Add(dto); + } + + [Parameter] + public List PshAnswers { get; set; } = new(); + + [Parameter] + public List PshQuestions { get; set; } = new(); + + [Parameter] + public string PshDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback PshDetailChanged { get; set; } + + private void PshAnswerChanged(MedicalHistoryAnswerSDto dto) + { + var findAnswer = PdhAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part); + if (findAnswer != null) + findAnswer.Answer = dto.Answer; + else + PdhAnswers.Add(dto); + } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep4.razor b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep4.razor index adc8526..89bde3f 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep4.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep4.razor @@ -1,36 +1,117 @@ - - + @foreach (var question in FhQuestions) + { + + } + - +
- @for (int i = 0; i < 5; i++) + @foreach (var question in DhQuestions) { - - -

ادالت کولد 500

-
-
+ }
+ +
- @for (int i = 0; i < 4; i++) + @foreach (var question in HhQuestions) { - - -

ادالت کولد 500

-
-
+ }
+ + + + + + +
@code { + + [Parameter] + public string AhDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback AhDetailChanged { get; set; } + + [Parameter] + public List FhAnswers { get; set; } = new(); + + [Parameter] + public List FhQuestions { get; set; } = new(); + + [Parameter] + public string FhDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback FhDetailChanged { get; set; } + + private void FhAnswerChanged(MedicalHistoryAnswerSDto dto) + { + var findAnswer = FhAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part); + if (findAnswer != null) + findAnswer.Answer = dto.Answer; + else + FhAnswers.Add(dto); + } + + [Parameter] + public List DhAnswers { get; set; } = new(); + + [Parameter] + public List DhQuestions { get; set; } = new(); + + [Parameter] + public string DhDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback DhDetailChanged { get; set; } + + private void DhAnswerChanged(MedicalHistoryAnswerSDto dto) + { + var findAnswer = DhAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part); + if (findAnswer != null) + findAnswer.Answer = dto.Answer; + else + DhAnswers.Add(dto); + } + + [Parameter] + public List HhAnswers { get; set; } = new(); + + [Parameter] + public List HhQuestions { get; set; } = new(); + + [Parameter] + public string HhDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback HhDetailChanged { get; set; } + + private void HhAnswerChanged(MedicalHistoryAnswerSDto dto) + { + var findAnswer = DhAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part); + if (findAnswer != null) + findAnswer.Answer = dto.Answer; + else + DhAnswers.Add(dto); + } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep5.razor b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep5.razor index 1352430..0578155 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep5.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryActionParts/MedicalHistoryActionStep5.razor @@ -1,27 +1,23 @@ - + -
- - -

بیمار هوشیار است

-
-
- - -

بیمار ILL است

-
-
+ @foreach (var question in GaQuestions) + { + + }
+ - +

فشــــار خون

- - + +
@@ -35,8 +31,82 @@ + +
+ @foreach (var question in GaQuestions) + { + + } + +
+ +
@code { + + [Parameter] + public string RosDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback RosDetailChanged { get; set; } + + [Parameter] + public List GaAnswers { get; set; } = new(); + + [Parameter] + public List GaQuestions { get; set; } = new(); + + [Parameter] + public string GaDetail { get; set; } = string.Empty; + + [Parameter] + public EventCallback GaDetailChanged { get; set; } + + private void GaAnswerChanged(MedicalHistoryAnswerSDto dto) + { + var findAnswer = GaAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part); + if (findAnswer != null) + findAnswer.Answer = dto.Answer; + else + GaAnswers.Add(dto); + } + + + [Parameter] + public int SystolicBloodPressure { get; set; } + + [Parameter] + public EventCallback SystolicBloodPressureChanged { get; set; } + + + [Parameter] + public int DiastolicBloodPressure { get; set; } + + [Parameter] + public EventCallback DiastolicBloodPressureChanged { get; set; } + + + [Parameter] + public int PulseRate { get; set; } + + [Parameter] + public EventCallback PulseRateChanged { get; set; } + + + [Parameter] + public int SPO2 { get; set; } + + [Parameter] + public EventCallback SPO2Changed { get; set; } + + + [Parameter] + public int Temperature { get; set; } + + [Parameter] + public EventCallback TemperatureChanged { get; set; } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor index 555f187..20124ff 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor @@ -35,7 +35,7 @@
- +
diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor.cs b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor.cs index 526d5f3..037b446 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor.cs +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionPage.razor.cs @@ -19,7 +19,8 @@ public class MedicalHistoryTemplateActionPageViewModel : BaseViewModel FhQuestions { get; set; } = new(); public List DhQuestions { get; set; } = new(); public List AhQuestions { get; set; } = new(); - public List VsQuestions { get; set; } = new(); + public List GaQuestions { get; set; } = new(); + public List RosQuestions { get; set; } = new(); public SectionSDto? SelectedSelection { get; set; } @@ -73,7 +74,8 @@ public class MedicalHistoryTemplateActionPageViewModel : BaseViewModel q.Part == MedicalHistoryPart.FamilyHistory)); DhQuestions.AddRange(dto.Questions.Where(q => q.Part == MedicalHistoryPart.DrugHistory)); AhQuestions.AddRange(dto.Questions.Where(q => q.Part == MedicalHistoryPart.AddictionHistory)); - VsQuestions.AddRange(dto.Questions.Where(q => q.Part == MedicalHistoryPart.VitalSign)); + GaQuestions.AddRange(dto.Questions.Where(q => q.Part == MedicalHistoryPart.GeneralAppearance)); + RosQuestions.AddRange(dto.Questions.Where(q => q.Part == MedicalHistoryPart.ReviewOfSystem)); } catch (ApiException ex) { @@ -120,12 +122,12 @@ public class MedicalHistoryTemplateActionPageViewModel : BaseViewModel(Address.MedicalHistoryTemplateController) .Create(PageDto, token); @@ -163,7 +165,8 @@ public class MedicalHistoryTemplateActionPageViewModel : BaseViewModel(Address.MedicalHistoryTemplateController) .Update(PageDto, token); diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep1.razor b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep1.razor index c2c9791..292bf4a 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep1.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep1.razor @@ -8,7 +8,8 @@ مورد ده

- +
- @foreach (var item in VitalSigns) + @foreach (var item in GeneralAppearance) { @@ -30,15 +30,15 @@

@item.Question

- معده + @item.BodySystem.ToDisplay() - @if(true) + @if(@item.IsSign) { Sign } - @if (true) + @if (@item.IsSymptom) { Symptom @@ -52,7 +52,32 @@ } - + + + + + + + + + + + + + + + + + + + + + + + + + +
VitalSigns { get; set; } = new(); + public List GeneralAppearance { get; set; } = new(); private void RemoveGeneralAppearance(MedicalHistoryQuestionSDto generalAppearance) { - VitalSigns.Remove(generalAppearance); + GeneralAppearance.Remove(generalAppearance); } private void AddGeneralAppearance() { - VitalSigns.Add(new MedicalHistoryQuestionSDto + GeneralAppearance.Add(new MedicalHistoryQuestionSDto { Question = _vitalSign, QuestionType = MedicalHistoryQuestionType.Selective, @@ -89,10 +114,13 @@ _vitalSign = string.Empty; } + private string _reviewOfSystemTitle = string.Empty; - private string _reviewOfSystemSystem = string.Empty; + private BodySystem _reviewOfSystemName; private bool _reviewOfSystemIsSign; private bool _reviewOfSystemIsSymptom; + + [Parameter] public List ReviewOfSystems { get; set; } = new(); private void RemoveReviewOfSystems(MedicalHistoryQuestionSDto review) { @@ -100,13 +128,15 @@ } private void AddReviewOfSystems() { - // ReviewOfSystems.Add(new MedicalHistorySystemReview - // { - // Title = _reviewOfSystemTitle, - // IsSign = _reviewOfSystemIsSign, - // IsSymptom = _reviewOfSystemIsSymptom, - // System = _reviewOfSystemSystem - // }); + ReviewOfSystems.Add(new MedicalHistoryQuestionSDto + { + Question = _reviewOfSystemTitle, + IsSign = _reviewOfSystemIsSign, + IsSymptom = _reviewOfSystemIsSymptom, + BodySystem = _reviewOfSystemName, + QuestionType = MedicalHistoryQuestionType.RosSelective, + Part = MedicalHistoryPart.ReviewOfSystem + }); _reviewOfSystemTitle = string.Empty; } } \ No newline at end of file diff --git a/DocuMed.PWA/Services/RestServices/ICrudApiRest.cs b/DocuMed.PWA/Services/RestServices/ICrudApiRest.cs index 3cb4dd9..866dc9f 100644 --- a/DocuMed.PWA/Services/RestServices/ICrudApiRest.cs +++ b/DocuMed.PWA/Services/RestServices/ICrudApiRest.cs @@ -3,7 +3,7 @@ public interface ICrudApiRest where T : class { [Post("")] - Task Create([Body] T payload, [Header("Authorization")] string authorization); + Task Create([Body] T payload, [Header("Authorization")] string authorization); [Get("")] Task> ReadAll([Query] int page,[Header("Authorization")] string authorization); @@ -21,9 +21,9 @@ public interface ICrudApiRest where T : class public interface ICrudDtoApiRest where T : class where TDto : class { [Post("")] - Task Create([Body] T payload, [Header("Authorization")] string authorization); + Task Create([Body] T payload, [Header("Authorization")] string authorization); [Post("")] - Task Create([Body] TDto payload, [Header("Authorization")] string authorization); + Task Create([Body] TDto payload, [Header("Authorization")] string authorization); [Get("")] Task> ReadAll([Query]int page,[Header("Authorization")] string authorization); diff --git a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor index b4f1261..4019a0b 100644 --- a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor +++ b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor @@ -5,27 +5,21 @@

@MedicalHistory.FullName

- - -

@MedicalHistory.ChiefComplaint در بخش @MedicalHistory.Section

+ + سن : @MedicalHistory.Age ساله
- - - @MedicalHistory.Age ساله + + +

شکایت اصلی : @MedicalHistory.ChiefComplaint

- + - مرد - - - - - @MedicalHistory.Section + بخش @MedicalHistory.SectionName
diff --git a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor index 6838725..43615fa 100644 --- a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor +++ b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor @@ -4,7 +4,7 @@ -

بخش @MedicalHistoryTemplate.ChiefComplaint

+

بخش @MedicalHistoryTemplate.SectionName

diff --git a/DocuMed.PWA/Shared/MedicalTemplates/BaseMedicalQuestionTemplate.razor b/DocuMed.PWA/Shared/MedicalTemplates/BaseMedicalQuestionTemplate.razor new file mode 100644 index 0000000..a18ee47 --- /dev/null +++ b/DocuMed.PWA/Shared/MedicalTemplates/BaseMedicalQuestionTemplate.razor @@ -0,0 +1,43 @@ +@switch (Question.QuestionType) +{ + case MedicalHistoryQuestionType.Selective: + + break; + case MedicalHistoryQuestionType.Hourly: + + break; + case MedicalHistoryQuestionType.Interrogatively: + + break; + case MedicalHistoryQuestionType.YesOrNo: + + break; + default: + + break; +} + +@code { + + [Parameter] + public MedicalHistoryQuestionSDto Question { get; set; } = new(); + + [Parameter] + public MedicalHistoryAnswerSDto Answer { get; set; } = new(); + + [Parameter] + public EventCallback AnswerChanged { get; set; } + + private async Task AnswerChanging(string answer) + { + Answer = new MedicalHistoryAnswerSDto + { + Question = Question.Question, + QuestionType = Question.QuestionType, + Answer = answer, + Part = Question.Part + }; + await AnswerChanged.InvokeAsync(Answer); + } + +} diff --git a/DocuMed.PWA/Shared/MedicalTemplates/HourMedicalQuestionTemplate.razor b/DocuMed.PWA/Shared/MedicalTemplates/HourMedicalQuestionTemplate.razor new file mode 100644 index 0000000..976d976 --- /dev/null +++ b/DocuMed.PWA/Shared/MedicalTemplates/HourMedicalQuestionTemplate.razor @@ -0,0 +1,40 @@ +
+

@Question

+
+ +

@Answer

+

ساعت

+ +
+
+ + +@code +{ + private int _hourCounter; + + [Parameter] + public string Answer { get; set; } = string.Empty; + + [Parameter] + public EventCallback AnswerChanged { get; set; } + + [Parameter] + public string Question { get; set; } = string.Empty; + + private async Task IncreaseHour() + { + _hourCounter++; + Answer = _hourCounter.ToString(); + await AnswerChanged.InvokeAsync(Answer); + } + + private async Task DecreaseHour() + { + _hourCounter--; + Answer = _hourCounter.ToString(); + await AnswerChanged.InvokeAsync(Answer); + } +} \ No newline at end of file diff --git a/DocuMed.PWA/Shared/MedicalTemplates/HourQuestionTemplate.razor b/DocuMed.PWA/Shared/MedicalTemplates/HourQuestionTemplate.razor deleted file mode 100644 index 4f6d752..0000000 --- a/DocuMed.PWA/Shared/MedicalTemplates/HourQuestionTemplate.razor +++ /dev/null @@ -1,18 +0,0 @@ -
-

علائم از چند ساعت پیش شروع شده است ؟

-
- -

@HourCounter

-

ساعت

- -
-
- - -@code { - public int HourCounter { get; set; } - private void IncreaseHour() => HourCounter++; - private void DecreaseHour() => HourCounter--; -} \ No newline at end of file diff --git a/DocuMed.PWA/Shared/MedicalTemplates/InterrogativelyMedicalQuestionTemplate.razor b/DocuMed.PWA/Shared/MedicalTemplates/InterrogativelyMedicalQuestionTemplate.razor new file mode 100644 index 0000000..60e5cd0 --- /dev/null +++ b/DocuMed.PWA/Shared/MedicalTemplates/InterrogativelyMedicalQuestionTemplate.razor @@ -0,0 +1,20 @@ + + + + +@code { + + [Parameter] + public string Answer { get; set; } = string.Empty; + + [Parameter] + public EventCallback AnswerChanged { get; set; } + + [Parameter] + public string Question { get; set; } = string.Empty; + +} diff --git a/DocuMed.PWA/Shared/MedicalTemplates/SelectiveMedicalQuestionTemplate.razor b/DocuMed.PWA/Shared/MedicalTemplates/SelectiveMedicalQuestionTemplate.razor new file mode 100644 index 0000000..872bbbb --- /dev/null +++ b/DocuMed.PWA/Shared/MedicalTemplates/SelectiveMedicalQuestionTemplate.razor @@ -0,0 +1,37 @@ +@if (_isSelected) +{ + + +

@Question

+
+
+} +else +{ + + +

@Question

+
+
+} + +@code +{ + [Parameter] + public string Answer { get; set; } = string.Empty; + + [Parameter] + public EventCallback AnswerChanged { get; set; } + + [Parameter] + public string Question { get; set; } = string.Empty; + + private bool _isSelected = false; + + private void SelectChanged() + { + Answer = _isSelected ? Question : string.Empty; + + _isSelected = !_isSelected; + } +} diff --git a/DocuMed.PWA/Shared/MedicalTemplates/YesOrNoMedicalQuestionTemplate.razor b/DocuMed.PWA/Shared/MedicalTemplates/YesOrNoMedicalQuestionTemplate.razor new file mode 100644 index 0000000..3643fe8 --- /dev/null +++ b/DocuMed.PWA/Shared/MedicalTemplates/YesOrNoMedicalQuestionTemplate.razor @@ -0,0 +1,73 @@ +
+

@Question

+
+ @if (_isYesSelected) + { + + + } + else + { + + + } + @if (_isNoSelected) + { + + + } + else + { + + } +
+
+ + +@code +{ + + [Parameter] + public string Answer { get; set; } = string.Empty; + + [Parameter] + public EventCallback AnswerChanged { get; set; } + + [Parameter] + public string Question { get; set; } = string.Empty; + + private bool _isYesSelected = false; + private bool _isNoSelected = false; + + private async Task Yes() + { + Answer = "بله"; + _isNoSelected = false; + _isYesSelected = true; + await AnswerChanged.InvokeAsync(Answer); + } + + private async Task No() + { + Answer = "خیر"; + _isNoSelected = true; + _isYesSelected = false; + await AnswerChanged.InvokeAsync(Answer); + } +} diff --git a/DocuMed.PWA/wwwroot/css/app.min.css b/DocuMed.PWA/wwwroot/css/app.min.css index 2b9576d..0261d0b 100644 --- a/DocuMed.PWA/wwwroot/css/app.min.css +++ b/DocuMed.PWA/wwwroot/css/app.min.css @@ -533,6 +533,10 @@ video { margin-left: 0.875rem; margin-right: 0.875rem; } +.mx-4 { + margin-left: 1rem; + margin-right: 1rem; +} .mx-5 { margin-left: 1.25rem; margin-right: 1.25rem; @@ -608,9 +612,6 @@ video { .mb-0\.5 { margin-bottom: 0.125rem; } -.mb-1 { - margin-bottom: 0.25rem; -} .mb-2 { margin-bottom: 0.5rem; } @@ -695,6 +696,9 @@ video { .h-12 { height: 3rem; } +.h-2 { + height: 0.5rem; +} .h-5 { height: 1.25rem; } @@ -771,6 +775,12 @@ video { .basis-1\/12 { flex-basis: 8.333333%; } +.basis-1\/3 { + flex-basis: 33.333333%; +} +.basis-1\/4 { + flex-basis: 25%; +} .basis-2\/4 { flex-basis: 50%; } @@ -840,6 +850,9 @@ video { border-top-left-radius: 0.75rem; border-top-right-radius: 0.75rem; } +.border-2 { + border-width: 2px; +} .border-\[--color-medicalhistory\] { border-color: var(--color-medicalhistory); } @@ -895,9 +908,6 @@ video { .bg-opacity-20 { --tw-bg-opacity: 0.2; } -.bg-opacity-70 { - --tw-bg-opacity: 0.7; -} .p-4 { padding: 1rem; } diff --git a/DocuMed.PWA/wwwroot/css/app.output.css b/DocuMed.PWA/wwwroot/css/app.output.css index b877766..23e8fac 100644 --- a/DocuMed.PWA/wwwroot/css/app.output.css +++ b/DocuMed.PWA/wwwroot/css/app.output.css @@ -594,6 +594,11 @@ video { margin-right: 0.875rem; } +.mx-4 { + margin-left: 1rem; + margin-right: 1rem; +} + .mx-5 { margin-left: 1.25rem; margin-right: 1.25rem; @@ -691,10 +696,6 @@ video { margin-bottom: 0.125rem; } -.mb-1 { - margin-bottom: 0.25rem; -} - .mb-2 { margin-bottom: 0.5rem; } @@ -807,6 +808,10 @@ video { height: 3rem; } +.h-2 { + height: 0.5rem; +} + .h-5 { height: 1.25rem; } @@ -908,6 +913,14 @@ video { flex-basis: 8.333333%; } +.basis-1\/3 { + flex-basis: 33.333333%; +} + +.basis-1\/4 { + flex-basis: 25%; +} + .basis-2\/4 { flex-basis: 50%; } @@ -999,6 +1012,10 @@ video { border-top-right-radius: 0.75rem; } +.border-2 { + border-width: 2px; +} + .border-\[--color-medicalhistory\] { border-color: var(--color-medicalhistory); } @@ -1069,10 +1086,6 @@ video { --tw-bg-opacity: 0.2; } -.bg-opacity-70 { - --tw-bg-opacity: 0.7; -} - .p-4 { padding: 1rem; } diff --git a/DocuMed.Repository/DocuMed.Repository.csproj b/DocuMed.Repository/DocuMed.Repository.csproj index a14577c..8486973 100644 --- a/DocuMed.Repository/DocuMed.Repository.csproj +++ b/DocuMed.Repository/DocuMed.Repository.csproj @@ -37,6 +37,7 @@ + diff --git a/DocuMed.Repository/Migrations/20231022193344_init.Designer.cs b/DocuMed.Repository/Migrations/20231028152226_init.Designer.cs similarity index 97% rename from DocuMed.Repository/Migrations/20231022193344_init.Designer.cs rename to DocuMed.Repository/Migrations/20231028152226_init.Designer.cs index 11de129..8cefa00 100644 --- a/DocuMed.Repository/Migrations/20231022193344_init.Designer.cs +++ b/DocuMed.Repository/Migrations/20231028152226_init.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace DocuMed.Repository.Migrations { [DbContext(typeof(ApplicationContext))] - [Migration("20231022193344_init")] + [Migration("20231028152226_init")] partial class init { /// @@ -257,9 +257,8 @@ namespace DocuMed.Repository.Migrations b.Property("SPO2") .HasColumnType("integer"); - b.Property("Section") - .IsRequired() - .HasColumnType("text"); + b.Property("SectionId") + .HasColumnType("uuid"); b.Property("SystemReviewDetail") .IsRequired() @@ -342,6 +341,9 @@ namespace DocuMed.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("BodySystem") + .HasColumnType("integer"); + b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -352,6 +354,12 @@ namespace DocuMed.Repository.Migrations b.Property("IsRemoved") .HasColumnType("boolean"); + b.Property("IsSign") + .HasColumnType("boolean"); + + b.Property("IsSymptom") + .HasColumnType("boolean"); + b.Property("MedicalHistoryTemplateId") .HasColumnType("uuid"); @@ -430,6 +438,8 @@ namespace DocuMed.Repository.Migrations b.HasIndex("ApplicationUserId"); + b.HasIndex("SectionId"); + b.ToTable("MedicalHistoryTemplates", "public"); }); @@ -738,7 +748,15 @@ namespace DocuMed.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") + .WithMany() + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.Navigation("ApplicationUser"); + + b.Navigation("Section"); }); modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => diff --git a/DocuMed.Repository/Migrations/20231022193344_init.cs b/DocuMed.Repository/Migrations/20231028152226_init.cs similarity index 96% rename from DocuMed.Repository/Migrations/20231022193344_init.cs rename to DocuMed.Repository/Migrations/20231028152226_init.cs index c01e7a1..1c0009f 100644 --- a/DocuMed.Repository/Migrations/20231022193344_init.cs +++ b/DocuMed.Repository/Migrations/20231028152226_init.cs @@ -233,7 +233,7 @@ namespace DocuMed.Repository.Migrations { Id = table.Column(type: "uuid", nullable: false), ChiefComplaint = table.Column(type: "text", nullable: false), - Section = table.Column(type: "text", nullable: false), + SectionId = table.Column(type: "uuid", nullable: false), FirstName = table.Column(type: "text", nullable: false), LastName = table.Column(type: "text", nullable: false), FatherName = table.Column(type: "text", nullable: false), @@ -295,6 +295,13 @@ namespace DocuMed.Repository.Migrations constraints: table => { table.PrimaryKey("PK_MedicalHistoryTemplates", x => x.Id); + table.ForeignKey( + name: "FK_MedicalHistoryTemplates_Sections_SectionId", + column: x => x.SectionId, + principalSchema: "public", + principalTable: "Sections", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_MedicalHistoryTemplates_Users_ApplicationUserId", column: x => x.ApplicationUserId, @@ -393,6 +400,9 @@ namespace DocuMed.Repository.Migrations Question = table.Column(type: "text", nullable: false), Part = table.Column(type: "integer", nullable: false), QuestionType = table.Column(type: "integer", nullable: false), + BodySystem = table.Column(type: "integer", nullable: false), + IsSign = table.Column(type: "boolean", nullable: false), + IsSymptom = table.Column(type: "boolean", nullable: false), MedicalHistoryTemplateId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), @@ -450,6 +460,12 @@ namespace DocuMed.Repository.Migrations table: "MedicalHistoryTemplates", column: "ApplicationUserId"); + migrationBuilder.CreateIndex( + name: "IX_MedicalHistoryTemplates_SectionId", + schema: "public", + table: "MedicalHistoryTemplates", + column: "SectionId"); + migrationBuilder.CreateIndex( name: "IX_RoleClaims_RoleId", schema: "public", diff --git a/DocuMed.Repository/Migrations/20231028181623_editMH.Designer.cs b/DocuMed.Repository/Migrations/20231028181623_editMH.Designer.cs new file mode 100644 index 0000000..f9f2e0d --- /dev/null +++ b/DocuMed.Repository/Migrations/20231028181623_editMH.Designer.cs @@ -0,0 +1,860 @@ +// +using System; +using DocuMed.Repository.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DocuMed.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20231028181623_editMH")] + partial class editMH + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("DocuMed.Domain.Entities.City.City", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Cities", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("UniversityId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UniversityId"); + + b.ToTable("Sections", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CityId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CityId"); + + b.ToTable("Universities", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddictionHistoryDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("Age") + .HasColumnType("integer"); + + b.Property("AllergyDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("ApplicationUserId") + .HasColumnType("uuid"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ChiefComplaint") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiastolicBloodPressure") + .HasColumnType("integer"); + + b.Property("DrugHistoryDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FamilyHistoryDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FatherName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PastDiseasesHistoryDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("PastSurgeryHistoryDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("PresentIllnessDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("PulseRate") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("SPO2") + .HasColumnType("integer"); + + b.Property("SectionId") + .HasColumnType("uuid"); + + b.Property("SystemReviewDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("SystolicBloodPressure") + .HasColumnType("integer"); + + b.Property("Temperature") + .HasColumnType("integer"); + + b.Property("VitalSignDetail") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("SectionId"); + + b.ToTable("MedicalHistories", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Answer") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MedicalHistoryId") + .HasColumnType("uuid"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Part") + .HasColumnType("integer"); + + b.Property("Question") + .IsRequired() + .HasColumnType("text"); + + b.Property("QuestionType") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MedicalHistoryId"); + + b.ToTable("MedicalHistoryAnswers", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BodySystem") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSign") + .HasColumnType("boolean"); + + b.Property("IsSymptom") + .HasColumnType("boolean"); + + b.Property("MedicalHistoryTemplateId") + .HasColumnType("uuid"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Part") + .HasColumnType("integer"); + + b.Property("Question") + .IsRequired() + .HasColumnType("text"); + + b.Property("QuestionType") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MedicalHistoryTemplateId"); + + b.ToTable("MedicalHistoryQuestions", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationUserId") + .HasColumnType("uuid"); + + b.Property("ChiefComplaint") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("SectionId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("SectionId"); + + b.ToTable("MedicalHistoryTemplates", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SectionId") + .HasColumnType("uuid"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("StudentId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UniversityId") + .HasColumnType("uuid"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("SectionId"); + + b.HasIndex("UniversityId"); + + b.ToTable("Users", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b => + { + b.HasOne("DocuMed.Domain.Entities.City.University", "University") + .WithMany("Sections") + .HasForeignKey("UniversityId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("University"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => + { + b.HasOne("DocuMed.Domain.Entities.City.City", "City") + .WithMany("Universities") + .HasForeignKey("CityId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("City"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => + { + b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") + .WithMany() + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => + { + b.HasOne("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", "MedicalHistory") + .WithMany("Answers") + .HasForeignKey("MedicalHistoryId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MedicalHistory"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => + { + b.HasOne("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", "MedicalHistoryTemplate") + .WithMany("Questions") + .HasForeignKey("MedicalHistoryTemplateId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MedicalHistoryTemplate"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => + { + b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") + .WithMany() + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => + { + b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") + .WithMany() + .HasForeignKey("SectionId"); + + b.HasOne("DocuMed.Domain.Entities.City.University", "University") + .WithMany() + .HasForeignKey("UniversityId"); + + b.Navigation("Section"); + + b.Navigation("University"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.City.City", b => + { + b.Navigation("Universities"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => + { + b.Navigation("Sections"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => + { + b.Navigation("Answers"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => + { + b.Navigation("Questions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DocuMed.Repository/Migrations/20231028181623_editMH.cs b/DocuMed.Repository/Migrations/20231028181623_editMH.cs new file mode 100644 index 0000000..aeada11 --- /dev/null +++ b/DocuMed.Repository/Migrations/20231028181623_editMH.cs @@ -0,0 +1,44 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DocuMed.Repository.Migrations +{ + /// + public partial class editMH : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_MedicalHistories_SectionId", + schema: "public", + table: "MedicalHistories", + column: "SectionId"); + + migrationBuilder.AddForeignKey( + name: "FK_MedicalHistories_Sections_SectionId", + schema: "public", + table: "MedicalHistories", + column: "SectionId", + principalSchema: "public", + principalTable: "Sections", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_MedicalHistories_Sections_SectionId", + schema: "public", + table: "MedicalHistories"); + + migrationBuilder.DropIndex( + name: "IX_MedicalHistories_SectionId", + schema: "public", + table: "MedicalHistories"); + } + } +} diff --git a/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs b/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs index 75715ec..44276a9 100644 --- a/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -254,9 +254,8 @@ namespace DocuMed.Repository.Migrations b.Property("SPO2") .HasColumnType("integer"); - b.Property("Section") - .IsRequired() - .HasColumnType("text"); + b.Property("SectionId") + .HasColumnType("uuid"); b.Property("SystemReviewDetail") .IsRequired() @@ -276,6 +275,8 @@ namespace DocuMed.Repository.Migrations b.HasIndex("ApplicationUserId"); + b.HasIndex("SectionId"); + b.ToTable("MedicalHistories", "public"); }); @@ -339,6 +340,9 @@ namespace DocuMed.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("BodySystem") + .HasColumnType("integer"); + b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -349,6 +353,12 @@ namespace DocuMed.Repository.Migrations b.Property("IsRemoved") .HasColumnType("boolean"); + b.Property("IsSign") + .HasColumnType("boolean"); + + b.Property("IsSymptom") + .HasColumnType("boolean"); + b.Property("MedicalHistoryTemplateId") .HasColumnType("uuid"); @@ -427,6 +437,8 @@ namespace DocuMed.Repository.Migrations b.HasIndex("ApplicationUserId"); + b.HasIndex("SectionId"); + b.ToTable("MedicalHistoryTemplates", "public"); }); @@ -702,7 +714,15 @@ namespace DocuMed.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") + .WithMany() + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.Navigation("ApplicationUser"); + + b.Navigation("Section"); }); modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => @@ -735,7 +755,15 @@ namespace DocuMed.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") + .WithMany() + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.Navigation("ApplicationUser"); + + b.Navigation("Section"); }); modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => diff --git a/DocuMed.Repository/Repositories/Entities/Abstracts/IMedicalHistoryRepository.cs b/DocuMed.Repository/Repositories/Entities/Abstracts/IMedicalHistoryRepository.cs new file mode 100644 index 0000000..7aa1d37 --- /dev/null +++ b/DocuMed.Repository/Repositories/Entities/Abstracts/IMedicalHistoryRepository.cs @@ -0,0 +1,7 @@ +namespace DocuMed.Repository.Repositories.Entities.Abstracts; + +public interface IMedicalHistoryRepository : IBaseRepository, IScopedDependency +{ + public Task> GetMedicalHistoriesAsync(int page = 0, CancellationToken cancellationToken = default); + public Task GetMedicalHistoryAsync(Guid id, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs b/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs new file mode 100644 index 0000000..e77214f --- /dev/null +++ b/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs @@ -0,0 +1,32 @@ +namespace DocuMed.Repository.Repositories.Entities; + +public class MedicalHistoryRepository : BaseRepository,IMedicalHistoryRepository +{ + public MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService) + { + } + + public async Task> GetMedicalHistoriesAsync(int page = 0, CancellationToken cancellationToken = default) + { + if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) + throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized); + var list = await TableNoTracking + .Where(t => t.ApplicationUserId == userId) + .OrderByDescending(t => t.CreatedAt) + .Skip(page * 15) + .Take(15) + .Select(MedicalHistoryMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + return list; + } + + public async Task GetMedicalHistoryAsync(Guid id, CancellationToken cancellationToken = default) + { + var dto = await TableNoTracking.Where(t => t.Id == id) + .Select(MedicalHistoryMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (dto == null) + throw new AppException("شرح حال پیدا نشد", ApiResultStatusCode.NotFound); + return dto; + } +} \ No newline at end of file diff --git a/DocuMed.sln b/DocuMed.sln index 904d329..7fc6ac0 100644 --- a/DocuMed.sln +++ b/DocuMed.sln @@ -19,6 +19,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.Infrastructure", "D EndProject Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{AE900A14-3A2E-4792-B7EF-641A1E60D345}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PublishFiles", "PublishFiles", "{29C90283-527F-431F-8AAC-001CFDDA8D8E}" + ProjectSection(SolutionItems) = preProject + .version = .version + Dockerfile = Dockerfile + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU