diff --git a/DocuMed.Api/AppSettings/appsettings.Development.json b/DocuMed.Api/AppSettings/appsettings.Development.json index 2f58198..332518f 100644 --- a/DocuMed.Api/AppSettings/appsettings.Development.json +++ b/DocuMed.Api/AppSettings/appsettings.Development.json @@ -2,7 +2,7 @@ "ConnectionStrings": { "PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;", "PostgresCompose": "Host=postgres_image;Username=brizcouser;Password=brizco;Database=BrizCoDB;", - "Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS" + "Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=DocuMedDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS" }, "Logging": { "LogLevel": { @@ -14,7 +14,7 @@ } }, "SiteSettings": { - "BaseUrl": "http://localhost:32769", + "BaseUrl": "http://localhost:32770", "UserSetting": { "Username": "root", "Email": "info@documed.ir", diff --git a/DocuMed.Api/Controllers/CityController.cs b/DocuMed.Api/Controllers/CityController.cs new file mode 100644 index 0000000..7e3baf8 --- /dev/null +++ b/DocuMed.Api/Controllers/CityController.cs @@ -0,0 +1,65 @@ +namespace DocuMed.Api.Controllers; +public class CityController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("City").MapGroup($"api/city") + .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, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking + .Select(CityMapper.ProjectToSDto).ToListAsync(cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(int id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().GetByIdAsync(cancellationToken, id)); + + // POST:Add New Entity + public virtual async Task Post([FromBody] CitySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = City.Create(dto.Name); + repositoryWrapper.SetRepository().Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(ent); + } + + // PUT:Update Entity + public virtual async Task Put([FromBody] CitySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = City.Create(dto.Name); + ent.Id = dto.Id; + repositoryWrapper.SetRepository().Update(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } + + // 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/Controllers/UniversityController.cs b/DocuMed.Api/Controllers/UniversityController.cs new file mode 100644 index 0000000..6fca9f0 --- /dev/null +++ b/DocuMed.Api/Controllers/UniversityController.cs @@ -0,0 +1,67 @@ +namespace DocuMed.Api.Controllers; + +public class UniversityController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("University") + .MapGroup($"api/university") + .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, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking + .Select(UniversityMapper.ProjectToSDto).ToListAsync(cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(int id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().GetByIdAsync(cancellationToken, id)); + + // POST:Add New Entity + public virtual async Task Post([FromBody] UniversitySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = University.Create(dto.Name,dto.Address,dto.CityId); + repositoryWrapper.SetRepository().Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(ent); + } + + // PUT:Update Entity + public virtual async Task Put([FromBody] UniversitySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = University.Create(dto.Name,dto.Address,dto.CityId); + ent.Id = dto.Id; + repositoryWrapper.SetRepository().Update(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } + + // 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(); + } +} \ No newline at end of file diff --git a/DocuMed.Api/DocuMed.Api.csproj b/DocuMed.Api/DocuMed.Api.csproj index 30b079c..2ae1e12 100644 --- a/DocuMed.Api/DocuMed.Api.csproj +++ b/DocuMed.Api/DocuMed.Api.csproj @@ -57,6 +57,7 @@ + @@ -70,7 +71,10 @@ + + + @@ -83,6 +87,7 @@ + diff --git a/DocuMed.Api/Properties/launchSettings.json b/DocuMed.Api/Properties/launchSettings.json index be7d3b9..5acce48 100644 --- a/DocuMed.Api/Properties/launchSettings.json +++ b/DocuMed.Api/Properties/launchSettings.json @@ -25,7 +25,8 @@ "environmentVariables": { "ASPNETCORE_URLS": "http://+:80" }, - "publishAllPorts": true + "publishAllPorts": true, + "DockerfileRunArguments": " --network=mother -p 32770:80" } }, "$schema": "https://json.schemastore.org/launchsettings.json", diff --git a/DocuMed.Api/WebFramework/Bases/CrudController.cs b/DocuMed.Api/WebFramework/Bases/CrudController.cs index eee66f9..9e191bf 100644 --- a/DocuMed.Api/WebFramework/Bases/CrudController.cs +++ b/DocuMed.Api/WebFramework/Bases/CrudController.cs @@ -73,6 +73,73 @@ public class CrudEndpoint where TEntity : ApiEntity, new() +{ + private readonly string _endpointName; + + public CrudEndpoint(string endpointName) + { + _endpointName = endpointName; + } + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi(_endpointName).MapGroup($"api/{_endpointName.ToLower()}"); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAll") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithName("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, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking.ToListAsync(cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(int id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().GetByIdAsync(cancellationToken, id)); + + // POST:Add New Entity + public virtual async Task Post([FromBody] TEntity ent, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + repositoryWrapper.SetRepository().Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(ent); + } + + // PUT:Update Entity + public virtual async Task Put([FromBody] TEntity ent,IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + repositoryWrapper.SetRepository().Update(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } + + // 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(); + } +} + [ApiController] //[AllowAnonymous] [ApiResultFilter] diff --git a/DocuMed.Api/WebFramework/Configurations/ServiceExtensions.cs b/DocuMed.Api/WebFramework/Configurations/ServiceExtensions.cs index 05a51a2..cb61a40 100644 --- a/DocuMed.Api/WebFramework/Configurations/ServiceExtensions.cs +++ b/DocuMed.Api/WebFramework/Configurations/ServiceExtensions.cs @@ -65,7 +65,7 @@ public static class ServiceExtensions serviceCollection.AddDbContextFactory(options => { options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); - options.UseNpgsql(Configuration.GetConnectionString("PostgresCompose"), b => b.MigrationsAssembly("DocuMed.Repository")) + options.UseNpgsql(Configuration.GetConnectionString("Postgres"), b => b.MigrationsAssembly("DocuMed.Repository")) .UseProjectAssembly(typeof(ApplicationUser).Assembly); //options.EnableServiceProviderCaching(true); }).BuildServiceProvider(); diff --git a/DocuMed.Common/Models/Api/AccessToken.cs b/DocuMed.Common/Models/Api/AccessToken.cs index 854c03f..8a2c77e 100644 --- a/DocuMed.Common/Models/Api/AccessToken.cs +++ b/DocuMed.Common/Models/Api/AccessToken.cs @@ -46,6 +46,6 @@ namespace DocuMed.Common.Models.Api public TUser User { get; set; } public string BearerToken => $"Bearer {access_token}"; - public List Permissions { get; set; } + public List Permissions { get; set; } = new(); } } \ No newline at end of file diff --git a/DocuMed.Core/CoreServices/AccountService.cs b/DocuMed.Core/CoreServices/AccountService.cs index 724d5b9..94ab56b 100644 --- a/DocuMed.Core/CoreServices/AccountService.cs +++ b/DocuMed.Core/CoreServices/AccountService.cs @@ -69,7 +69,7 @@ public class AccountService : IAccountService user = await _userService.CreateUserAsync(phoneNumber); var token = await _userManager.GenerateTwoFactorTokenAsync(user, "Phone"); - await _smsService.SendVerifyCodeAsync(newPhoneNumber, token); + //await _smsService.SendVerifyCodeAsync(newPhoneNumber, token); return user.SignUpStatus; } diff --git a/DocuMed.Domain/Dtos/SmallDtos/MedicalHistorySDto.cs b/DocuMed.Domain/Dtos/SmallDtos/MedicalHistorySDto.cs index ea5970c..578daf1 100644 --- a/DocuMed.Domain/Dtos/SmallDtos/MedicalHistorySDto.cs +++ b/DocuMed.Domain/Dtos/SmallDtos/MedicalHistorySDto.cs @@ -28,4 +28,5 @@ public class MedicalHistorySDto : BaseDto public int PulseRate { get; set; } public int SPO2 { get; set; } public int Temperature { get; set; } + public string FullName => FirstName + " " + LastName; } \ No newline at end of file diff --git a/DocuMed.Domain/Dtos/SmallDtos/UniversitySDto.cs b/DocuMed.Domain/Dtos/SmallDtos/UniversitySDto.cs index 3ce2d32..5abda08 100644 --- a/DocuMed.Domain/Dtos/SmallDtos/UniversitySDto.cs +++ b/DocuMed.Domain/Dtos/SmallDtos/UniversitySDto.cs @@ -4,4 +4,5 @@ public class UniversitySDto : BaseDto { public string Name { get; set; } = string.Empty; public string Address { get; set; } = string.Empty; + public Guid CityId { get; set; } } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/City/City.cs b/DocuMed.Domain/Entities/City/City.cs index c7a73a8..35ab1b2 100644 --- a/DocuMed.Domain/Entities/City/City.cs +++ b/DocuMed.Domain/Entities/City/City.cs @@ -1,5 +1,8 @@ namespace DocuMed.Domain.Entities.City; +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public partial class City : ApiEntity { public City() diff --git a/DocuMed.Domain/Entities/City/University.cs b/DocuMed.Domain/Entities/City/University.cs index bf84ff2..50f7f10 100644 --- a/DocuMed.Domain/Entities/City/University.cs +++ b/DocuMed.Domain/Entities/City/University.cs @@ -1,5 +1,7 @@ namespace DocuMed.Domain.Entities.City; +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public partial class University : ApiEntity { public University() diff --git a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs index dcb0d6f..f2ff77c 100644 --- a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs +++ b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs @@ -1,9 +1,7 @@ namespace DocuMed.Domain.Entities.MedicalHistory; -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, - MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] -[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, - MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [GenerateMapper] public partial class MedicalHistory : ApiEntity diff --git a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs index bf982e7..dd583bb 100644 --- a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs +++ b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs @@ -18,7 +18,7 @@ namespace DocuMed.Domain.Mappers BirthDate = p1.BirthDate, Gender = p1.Gender, SignUpStatus = p1.SignUpStatus, - UniversityId = p1.UniversityId, + UniversityId = (Guid?)p1.UniversityId, Id = p1.Id, UserName = p1.UserName, Email = p1.Email, @@ -41,7 +41,7 @@ namespace DocuMed.Domain.Mappers result.BirthDate = p2.BirthDate; result.Gender = p2.Gender; result.SignUpStatus = p2.SignUpStatus; - result.UniversityId = p2.UniversityId; + result.UniversityId = (Guid?)p2.UniversityId; result.Id = p2.Id; result.UserName = p2.UserName; result.Email = p2.Email; @@ -59,7 +59,7 @@ namespace DocuMed.Domain.Mappers BirthDate = p4.BirthDate, Gender = p4.Gender, SignUpStatus = p4.SignUpStatus, - UniversityId = p4.UniversityId, + UniversityId = (Guid?)p4.UniversityId, Id = p4.Id, UserName = p4.UserName, Email = p4.Email, @@ -81,7 +81,7 @@ namespace DocuMed.Domain.Mappers BirthDate = p5.BirthDate, Gender = p5.Gender, SignUpStatus = p5.SignUpStatus, - UniversityId = p5.UniversityId, + UniversityId = p5.UniversityId == null ? default(Guid) : (Guid)p5.UniversityId, Id = p5.Id }; } @@ -104,7 +104,7 @@ namespace DocuMed.Domain.Mappers result.BirthDate = p6.BirthDate; result.Gender = p6.Gender; result.SignUpStatus = p6.SignUpStatus; - result.UniversityId = p6.UniversityId; + result.UniversityId = p6.UniversityId == null ? default(Guid) : (Guid)p6.UniversityId; result.Id = p6.Id; return result; @@ -122,7 +122,7 @@ namespace DocuMed.Domain.Mappers BirthDate = p8.BirthDate, Gender = p8.Gender, SignUpStatus = p8.SignUpStatus, - UniversityId = p8.UniversityId, + UniversityId = p8.UniversityId == null ? default(Guid) : (Guid)p8.UniversityId, Id = p8.Id }; } diff --git a/DocuMed.Domain/Mappers/CityMapper.g.cs b/DocuMed.Domain/Mappers/CityMapper.g.cs new file mode 100644 index 0000000..9003355 --- /dev/null +++ b/DocuMed.Domain/Mappers/CityMapper.g.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using DocuMed.Domain.Dtos.LargDtos; +using DocuMed.Domain.Dtos.SmallDtos; +using DocuMed.Domain.Entities.City; + +namespace DocuMed.Domain.Mappers +{ + public static partial class CityMapper + { + public static City AdaptToCity(this CitySDto p1) + { + return p1 == null ? null : new City() + { + Name = p1.Name, + Id = p1.Id + }; + } + public static City AdaptTo(this CitySDto p2, City p3) + { + if (p2 == null) + { + return null; + } + City result = p3 ?? new City(); + + result.Name = p2.Name; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToCity => p4 => new City() + { + Name = p4.Name, + Id = p4.Id + }; + public static CitySDto AdaptToSDto(this City p5) + { + return p5 == null ? null : new CitySDto() + { + Name = p5.Name, + Id = p5.Id + }; + } + public static CitySDto AdaptTo(this City p6, CitySDto p7) + { + if (p6 == null) + { + return null; + } + CitySDto result = p7 ?? new CitySDto(); + + result.Name = p6.Name; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new CitySDto() + { + Name = p8.Name, + Id = p8.Id + }; + public static City AdaptToCity(this CityLDto p9) + { + return p9 == null ? null : new City() + { + Name = p9.Name, + Universities = funcMain1(p9.Universities), + Id = p9.Id + }; + } + public static City AdaptTo(this CityLDto p11, City p12) + { + if (p11 == null) + { + return null; + } + City result = p12 ?? new City(); + + result.Name = p11.Name; + result.Universities = funcMain2(p11.Universities, result.Universities); + result.Id = p11.Id; + return result; + + } + public static Expression> ProjectLDtoToCity => p15 => new City() + { + Name = p15.Name, + Universities = p15.Universities.Select(p16 => new University() + { + Name = p16.Name, + Address = p16.Address, + CityId = p16.CityId, + Id = p16.Id + }).ToList(), + Id = p15.Id + }; + public static CityLDto AdaptToLDto(this City p17) + { + return p17 == null ? null : new CityLDto() + { + Name = p17.Name, + Universities = funcMain3(p17.Universities), + Id = p17.Id + }; + } + public static CityLDto AdaptTo(this City p19, CityLDto p20) + { + if (p19 == null) + { + return null; + } + CityLDto result = p20 ?? new CityLDto(); + + result.Name = p19.Name; + result.Universities = funcMain4(p19.Universities, result.Universities); + result.Id = p19.Id; + return result; + + } + public static Expression> ProjectToLDto => p23 => new CityLDto() + { + Name = p23.Name, + Universities = p23.Universities.Select(p24 => new UniversitySDto() + { + Name = p24.Name, + Address = p24.Address, + CityId = p24.CityId, + Id = p24.Id + }).ToList(), + Id = p23.Id + }; + + private static List funcMain1(List p10) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + UniversitySDto item = p10[i]; + result.Add(item == null ? null : new University() + { + Name = item.Name, + Address = item.Address, + CityId = item.CityId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p13, List p14) + { + if (p13 == null) + { + return null; + } + List result = new List(p13.Count); + + int i = 0; + int len = p13.Count; + + while (i < len) + { + UniversitySDto item = p13[i]; + result.Add(item == null ? null : new University() + { + Name = item.Name, + Address = item.Address, + CityId = item.CityId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p18) + { + if (p18 == null) + { + return null; + } + List result = new List(p18.Count); + + int i = 0; + int len = p18.Count; + + while (i < len) + { + University item = p18[i]; + result.Add(item == null ? null : new UniversitySDto() + { + Name = item.Name, + Address = item.Address, + CityId = item.CityId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p21, List p22) + { + if (p21 == null) + { + return null; + } + List result = new List(p21.Count); + + int i = 0; + int len = p21.Count; + + while (i < len) + { + University item = p21[i]; + result.Add(item == null ? null : new UniversitySDto() + { + Name = item.Name, + Address = item.Address, + CityId = item.CityId, + Id = item.Id + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/UniversityMapper.g.cs b/DocuMed.Domain/Mappers/UniversityMapper.g.cs new file mode 100644 index 0000000..14a3062 --- /dev/null +++ b/DocuMed.Domain/Mappers/UniversityMapper.g.cs @@ -0,0 +1,75 @@ +using System; +using System.Linq.Expressions; +using DocuMed.Domain.Dtos.SmallDtos; +using DocuMed.Domain.Entities.City; + +namespace DocuMed.Domain.Mappers +{ + public static partial class UniversityMapper + { + public static University AdaptToUniversity(this UniversitySDto p1) + { + return p1 == null ? null : new University() + { + Name = p1.Name, + Address = p1.Address, + CityId = p1.CityId, + Id = p1.Id + }; + } + public static University AdaptTo(this UniversitySDto p2, University p3) + { + if (p2 == null) + { + return null; + } + University result = p3 ?? new University(); + + result.Name = p2.Name; + result.Address = p2.Address; + result.CityId = p2.CityId; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToUniversity => p4 => new University() + { + Name = p4.Name, + Address = p4.Address, + CityId = p4.CityId, + Id = p4.Id + }; + public static UniversitySDto AdaptToSDto(this University p5) + { + return p5 == null ? null : new UniversitySDto() + { + Name = p5.Name, + Address = p5.Address, + CityId = p5.CityId, + Id = p5.Id + }; + } + public static UniversitySDto AdaptTo(this University p6, UniversitySDto p7) + { + if (p6 == null) + { + return null; + } + UniversitySDto result = p7 ?? new UniversitySDto(); + + result.Name = p6.Name; + result.Address = p6.Address; + result.CityId = p6.CityId; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new UniversitySDto() + { + Name = p8.Name, + Address = p8.Address, + CityId = p8.CityId, + Id = p8.Id + }; + } +} \ No newline at end of file diff --git a/DocuMed.PWA/DocuMed.PWA.csproj b/DocuMed.PWA/DocuMed.PWA.csproj index 1cbba4b..cff0112 100644 --- a/DocuMed.PWA/DocuMed.PWA.csproj +++ b/DocuMed.PWA/DocuMed.PWA.csproj @@ -12,10 +12,15 @@ + + + + + @@ -33,9 +38,28 @@ + + + + + + + + + + + - - + + + + + + + + + + diff --git a/DocuMed.PWA/Models/Address.cs b/DocuMed.PWA/Models/Address.cs new file mode 100644 index 0000000..c064e44 --- /dev/null +++ b/DocuMed.PWA/Models/Address.cs @@ -0,0 +1,9 @@ +namespace DocuMed.PWA.Models; + +public static class Address +{ + public const string BaseAddress = "http://localhost:32770/api"; + public const string AuthController = $"{BaseAddress}/auth"; + public const string CityController = $"{BaseAddress}/city"; + public const string UniversityController = $"{BaseAddress}/university"; +} \ No newline at end of file diff --git a/DocuMed.PWA/Models/Api/ApiResult.cs b/DocuMed.PWA/Models/Api/ApiResult.cs new file mode 100644 index 0000000..9ad8f81 --- /dev/null +++ b/DocuMed.PWA/Models/Api/ApiResult.cs @@ -0,0 +1,25 @@ +namespace DocuMed.PWA.Models.Api; + +public class ApiResult +{ + public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) + { + IsSuccess = isSuccess; + StatusCode = statusCode; + Message = message ?? statusCode.ToDisplay(); + } + + public bool IsSuccess { get; set; } + public ApiResultStatusCode StatusCode { get; set; } + + public string Message { get; set; } +} + +public class ApiResult : ApiResult where TData : class +{ + public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) : base(isSuccess, statusCode, message) + { + Data = data; + } + public TData Data { get; set; } +} \ No newline at end of file diff --git a/DocuMed.PWA/Models/Entities/MedicalHistory.cs b/DocuMed.PWA/Models/Entities/MedicalHistory.cs deleted file mode 100644 index 5a3ba9e..0000000 --- a/DocuMed.PWA/Models/Entities/MedicalHistory.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace DocuMed.PWA.Models.Entities; - -public class MedicalHistory -{ - public string Name { get; set; } = string.Empty; - public string Section { get; set; } = string.Empty; - public int Aag { get; set; } - public string CC { get; set; } = string.Empty; - public Gender Gender { get; set; } - -} \ No newline at end of file diff --git a/DocuMed.PWA/Models/Entities/MedicalHistoryQuestion.cs b/DocuMed.PWA/Models/Entities/MedicalHistoryQuestion.cs deleted file mode 100644 index a43227a..0000000 --- a/DocuMed.PWA/Models/Entities/MedicalHistoryQuestion.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DocuMed.PWA.Models.Entities; - -public class MedicalHistoryQuestion -{ - public string Title { get; set; } = string.Empty; - public MedicalHistoryQuestionType Type { get; set; } -} \ No newline at end of file diff --git a/DocuMed.PWA/Models/Entities/MedicalHistorySystemReview.cs b/DocuMed.PWA/Models/Entities/MedicalHistorySystemReview.cs deleted file mode 100644 index d2a9e9a..0000000 --- a/DocuMed.PWA/Models/Entities/MedicalHistorySystemReview.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DocuMed.PWA.Models.Entities -{ - public class MedicalHistorySystemReview - { - public string Title { get; set; } = string.Empty; - public string System { get; set; } = string.Empty; - public bool IsSign { get; set; } - public bool IsSymptom { get; set; } - } -} diff --git a/DocuMed.PWA/Models/Entities/MedicalHistoryTemplate.cs b/DocuMed.PWA/Models/Entities/MedicalHistoryTemplate.cs deleted file mode 100644 index 949d81c..0000000 --- a/DocuMed.PWA/Models/Entities/MedicalHistoryTemplate.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DocuMed.PWA.Models.Entities; - -public class MedicalHistoryTemplate -{ - public string CC { get; set; } = string.Empty; - public string Section { get; set; } = string.Empty; -} \ No newline at end of file diff --git a/DocuMed.PWA/Models/Enums/Gender.cs b/DocuMed.PWA/Models/Enums/Gender.cs deleted file mode 100644 index 8d15ea8..0000000 --- a/DocuMed.PWA/Models/Enums/Gender.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace DocuMed.PWA.Models.Enums; - -public enum Gender -{ - [Display(Name = "مرد")] - Male, - [Display(Name = "زن")] - Female -} \ No newline at end of file diff --git a/DocuMed.PWA/Models/Enums/MedicalHistoryQuestionType.cs b/DocuMed.PWA/Models/Enums/MedicalHistoryQuestionType.cs deleted file mode 100644 index 7c04457..0000000 --- a/DocuMed.PWA/Models/Enums/MedicalHistoryQuestionType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace DocuMed.PWA.Models.Enums; - -public enum MedicalHistoryQuestionType -{ - Hourly, - Interrogatively, - YesOrNo -} \ No newline at end of file diff --git a/DocuMed.PWA/Models/LocalStorageKeys.cs b/DocuMed.PWA/Models/LocalStorageKeys.cs new file mode 100644 index 0000000..2ac09ec --- /dev/null +++ b/DocuMed.PWA/Models/LocalStorageKeys.cs @@ -0,0 +1,6 @@ +namespace DocuMed.PWA.Models; + +public static class LocalStorageKeys +{ + public const string Token = nameof(Token); +} \ No newline at end of file diff --git a/DocuMed.PWA/Pages/HomePage.razor b/DocuMed.PWA/Pages/HomePage.razor index c0c0929..5ea3d53 100644 --- a/DocuMed.PWA/Pages/HomePage.razor +++ b/DocuMed.PWA/Pages/HomePage.razor @@ -1,4 +1,5 @@ @page "/HomePage" +@using DocuMed.Domain.Dtos.SmallDtos @inject NavigationManager NavigationManager @@ -81,56 +82,48 @@ public void MedicalHistoryTemplatesClicked() => NavigationManager.NavigateTo("MedicalHistoryTemplatesPage"); public void MedicalOrdersClicked() => NavigationManager.NavigateTo("MedicalOrdersPage"); - private List _medicalHistories = new List(); + private List _medicalHistories = new List(); protected override void OnInitialized() { - _medicalHistories.Add(new MedicalHistory + _medicalHistories.Add(new MedicalHistorySDto { - Name = "امیرحسین معتمدی", - Aag = 35, - CC = "سردرد", + FirstName = "امیرحسین ", + LastName = "معتمدی", + Age = 35, + ChiefComplaint = "سردرد", Section = "داخلی", - Gender = Gender.Male - }); - _medicalHistories.Add(new MedicalHistory - { - Name = "محمد امینی", - Aag = 40, - CC = "معده درد", - Section = "داخلی", - Gender = Gender.Male - }); - _medicalHistories.Add(new MedicalHistory - { - Name = "زیبا بروفه", - Aag = 20, - CC = "سوختگی", - Section = "سوختگی", - Gender = Gender.Female - }); - _medicalHistories.Add(new MedicalHistory - { - Name = "روشنک فدایی", - Aag = 18, - CC = "دردسینه", - Section = "داخلی", - Gender = Gender.Female - }); - _medicalHistories.Add(new MedicalHistory - { - Name = "سطلان محمدی", - Aag = 28, - CC = "روانی", - Section = "روان", - Gender = Gender.Male - }); - _medicalHistories.Add(new MedicalHistory + }); + _medicalHistories.Add(new MedicalHistorySDto { - Name = "سعید سعیدی", - Aag = 60, - CC = "بی هوشی", + FirstName = "امیرحسین ", + LastName = "معتمدی", + Age = 35, + ChiefComplaint = "سردرد", + Section = "داخلی", + }); + _medicalHistories.Add(new MedicalHistorySDto + { + FirstName = "امیرحسین ", + LastName = "معتمدی", + Age = 35, + ChiefComplaint = "سردرد", + Section = "داخلی", + }); + _medicalHistories.Add(new MedicalHistorySDto + { + FirstName = "امیرحسین ", + LastName = "معتمدی", + Age = 35, + ChiefComplaint = "سردرد", + Section = "داخلی", + }); + _medicalHistories.Add(new MedicalHistorySDto + { + FirstName = "امیرحسین ", + LastName = "معتمدی", + Age = 35, + ChiefComplaint = "سردرد", Section = "داخلی", - Gender = Gender.Male }); base.OnInitialized(); } diff --git a/DocuMed.PWA/Pages/Index.razor b/DocuMed.PWA/Pages/Index.razor index 0dccb32..3fe05cb 100644 --- a/DocuMed.PWA/Pages/Index.razor +++ b/DocuMed.PWA/Pages/Index.razor @@ -1,34 +1,42 @@ @page "/" @inject NavigationManager NavigationManager +@inject IRestWrapper RestWrapper +@inject ISnackbar Snackbar +@inject ILocalStorageService LocalStorage +@inject IUserUtility UserUtility +
+ AutoCycle="true" TData="object">
- +
-

شرح حال نویسی بیمار راحت تر +

+ شرح حال نویسی بیمار راحت تر از - همیشه

-

نرم افزار داکیومد با امکانات بسیار زیاد + همیشه +

+

+ نرم افزار داکیومد با امکانات بسیار زیاد خود - مثل شرح حال نویسی همراه و همیار همیشگی پزشکان محترم

+ مثل شرح حال نویسی همراه و همیار همیشگی پزشکان محترم +

@@ -36,15 +44,18 @@
- +
-

اوردر های شما همه در یک - اپلیکیشن

-

نرم افزار داکیومد با امکانات بسیار زیاد +

+ اوردر های شما همه در یک + اپلیکیشن +

+

+ نرم افزار داکیومد با امکانات بسیار زیاد خود - مثل شرح حال نویسی همیار همیشگی پزشکان محترم

+ مثل شرح حال نویسی همیار همیشگی پزشکان محترم +

@@ -52,15 +63,17 @@
- +
-

نرم افزار جامع داکیـــــومد +

+ نرم افزار جامع داکیـــــومد

-

نرم افزار داکیومد با امکانات بسیار زیاد +

+ نرم افزار داکیومد با امکانات بسیار زیاد خود - مثل تهیه پیشنویس شرح حال همراه همیشگی پزشکان محترم

+ مثل تهیه پیشنویس شرح حال همراه همیشگی پزشکان محترم +

@@ -68,7 +81,7 @@
+ ShowBullets="false" EnableSwipeGesture="false" AutoCycle="false" TData="object">
@@ -78,13 +91,13 @@ وارد کنید

- + + @bind-Value="@_phoneNumber" InputType="InputType.Telephone" T="string" Label="شماره تلفن همراه" + Variant="Variant.Outlined" /> - +

با تایید شماره تلفن همراه با همه شرایط @@ -105,11 +118,11 @@ وارد کنید

- + - +
@@ -118,8 +131,8 @@ ارسال مجدد پیامک + Variant="Variant.Outlined" @onclick="PhoneNumberRollBack" Color="Color.Primary" + Size="Size.Medium"> بازگشت @@ -131,19 +144,51 @@

ثبت نام

-

برای ثبت نام به اپلیکیشن داکیومد باید اطلاعات کامل خود را وارد +

+ برای ثبت نام به اپلیکیشن داکیومد باید اطلاعات کامل خود را وارد کنید

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

منتظر بمانید

+
+
+
+
+ +

@e.Name

+
+
- + + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.Name

+
+
+
+ +
@@ -154,29 +199,172 @@ @code { + private List _cities = new List(); + private List _universities = new List(); + private SignUpRequestDto _signUpRequest = new SignUpRequestDto(); private MudCarousel? _carousel; private int _currentSignOnStep = 0; - MudForm? confirmPhoneNumberForm; + private MudForm? _confirmPhoneNumberForm; + private MudForm? _confirmSignUpForm; + private CitySDto _selectedCity; + private UniversitySDto _selectedUni; + private string _phoneNumber = string.Empty; + private string _verifyCode = string.Empty; + private bool _isProcessing = false; + private SignUpStatus _signUpStatus; - private string phoneNumber = string.Empty; - private void ConfirmPhoneNumber() + private async Task ConfirmPhoneNumber() { - confirmPhoneNumberForm?.Validate(); - if (confirmPhoneNumberForm != null && confirmPhoneNumberForm.IsValid) - _carousel?.MoveTo(++_currentSignOnStep); + try + { + _confirmPhoneNumberForm?.Validate(); + if (_confirmPhoneNumberForm is {IsValid: true }) + { + _isProcessing = true; + _signUpStatus = await RestWrapper.AuthRestApi.GetVerifyCodeAsync(_phoneNumber); + _carousel?.MoveTo(++_currentSignOnStep); + } + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + if (exe != null) + Snackbar.Add(exe.Message, Severity.Error); + Snackbar.Add(ex.Content, Severity.Error); + } + catch (Exception e) + { + Snackbar.Add(e.Message, Severity.Error); + } + finally + { + _isProcessing = false; + } } - private void ConfirmVerifyCode() + private async Task ConfirmVerifyCode() { - _carousel?.MoveTo(++_currentSignOnStep); + try + { + _isProcessing = true; + var rest = await RestWrapper.AuthRestApi.LoginWithVerifyCodeAsync(new LoginRequestDto { UserName = _phoneNumber, VerifyCode = _verifyCode }); + await UserUtility.SetBearerTokenAsync(rest.BearerToken); + if (_signUpStatus == SignUpStatus.SignUpCompleted) + NavigationManager.NavigateTo("HomePage"); + else + _carousel?.MoveTo(++_currentSignOnStep); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + if (exe != null) + Snackbar.Add(exe.Message, Severity.Error); + Snackbar.Add(ex.Content, Severity.Error); + } + catch (Exception e) + { + Snackbar.Add(e.Message, Severity.Error); + } + finally + { + _isProcessing = false; + } } + private void PhoneNumberRollBack() { _carousel?.MoveTo(--_currentSignOnStep); } - private void ConfirmSignUp() + + private async Task ConfirmSignUp() { - NavigationManager.NavigateTo("HomePage"); + try + { + + _confirmSignUpForm?.Validate(); + if (_confirmSignUpForm is {IsValid:true}) + { + _isProcessing = true; + _signUpRequest.CityId = _selectedCity.Id; + _signUpRequest.UniversityId = _selectedUni.Id; + + var token = await UserUtility.GetBearerTokenAsync(); + var rest = await RestWrapper.AuthRestApi.CompleteSignUpAsync(_signUpRequest, token); + await UserUtility.SetBearerTokenAsync(rest.BearerToken); + NavigationManager.NavigateTo("HomePage"); + } + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + if (exe != null) + Snackbar.Add(exe.Message, Severity.Error); + Snackbar.Add(ex.Content, Severity.Error); + } + catch (Exception e) + { + Snackbar.Add(e.Message, Severity.Error); + } + finally + { + _isProcessing = false; + } } + private async Task> SearchCity(string city) + { + try + { + if (_cities.Count == 0) + { + var token = await UserUtility.GetBearerTokenAsync(); + _cities = await RestWrapper.CrudDtoApiRest(Address.CityController).ReadAll(0, token); + } + if (city.IsNullOrEmpty()) + return _cities; + return _cities.Where(c => c.Name.Contains(city)); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + if (exe != null) + Snackbar.Add(exe.Message, Severity.Error); + Snackbar.Add(ex.Content, Severity.Error); + return _cities; + } + catch (Exception e) + { + Snackbar.Add(e.Message, Severity.Error); + return _cities; + } + } + + + private async Task> SearchUniversity(string uni) + { + try + { + if (_universities.Count == 0) + { + var token = await UserUtility.GetBearerTokenAsync(); + _universities = await RestWrapper.CrudDtoApiRest(Address.UniversityController).ReadAll(0, token); + } + if (uni.IsNullOrEmpty()) + return _universities; + return _universities.Where(c => c.Name.Contains(uni)); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + if (exe != null) + Snackbar.Add(exe.Message, Severity.Error); + Snackbar.Add(ex.Content, Severity.Error); + return _universities; + } + catch (Exception e) + { + Snackbar.Add(e.Message, Severity.Error); + return _universities; + } + } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep2.razor b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep2.razor index 892856b..96fc91c 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep2.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep2.razor @@ -1,3 +1,4 @@ +@using DocuMed.Domain.Entities.MedicalHistoryTemplate @@ -41,10 +42,5 @@ } private void AddQuestion() { - Questions.Add(new MedicalHistoryQuestion - { - Title = _questionTitle, - Type = _questionType - }); } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep3.razor b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep3.razor index 149b223..cf83bf8 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep3.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep3.razor @@ -1,3 +1,4 @@ +@using DocuMed.Domain.Entities.MedicalHistoryTemplate @@ -66,11 +67,11 @@ } private void AddPIQuestion() { - PIQuestions.Add(new MedicalHistoryQuestion - { - Title = _piQuestionTitle, - Type = _piQuestionType - }); + // PIQuestions.Add(new MedicalHistoryQuestion + // { + // Title = _piQuestionTitle, + // Type = _piQuestionType + // }); } private void RemovePSHQuestion(MedicalHistoryQuestion question) @@ -79,11 +80,11 @@ } private void AddPSHQuestion() { - PSHQuestions.Add(new MedicalHistoryQuestion - { - Title = _pshQuestionTitle, - Type = _pshQuestionType - }); + // PSHQuestions.Add(new MedicalHistoryQuestion + // { + // Title = _pshQuestionTitle, + // Type = _pshQuestionType + // }); } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep4.razor b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep4.razor index 114b05c..e287cb6 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep4.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep4.razor @@ -1,3 +1,4 @@ +@using DocuMed.Domain.Entities.MedicalHistoryTemplate @@ -78,11 +79,11 @@ } private void AddFamilyHistory() { - FamilyHistories.Add(new MedicalHistoryQuestion - { - Title = _familyHistoryQuestionTitle, - Type = _familyHistoryQuestionType - }); + // FamilyHistories.Add(new MedicalHistoryQuestion + // { + // Title = _familyHistoryQuestionTitle, + // Type = _familyHistoryQuestionType + // }); } diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep5.razor b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep5.razor index a8a13ca..a40ce00 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep5.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplateActionParts/MedicalHistoryTemplateActionStep5.razor @@ -27,18 +27,18 @@
-

@item.Title

+

@item.Question

- @item.System + معده - @if(@item.IsSign) + @if(true) { Sign } - @if (@item.IsSymptom) + @if (true) { Symptom @@ -87,20 +87,20 @@ private string _reviewOfSystemSystem = string.Empty; private bool _reviewOfSystemIsSign; private bool _reviewOfSystemIsSymptom; - public List ReviewOfSystems { get; set; } = new(); - private void RemoveReviewOfSystems(MedicalHistorySystemReview review) + public List ReviewOfSystems { get; set; } = new(); + private void RemoveReviewOfSystems(MedicalHistoryQuestion review) { ReviewOfSystems.Remove(review); } private void AddReviewOfSystems() { - ReviewOfSystems.Add(new MedicalHistorySystemReview - { - Title = _reviewOfSystemTitle, - IsSign = _reviewOfSystemIsSign, - IsSymptom = _reviewOfSystemIsSymptom, - System = _reviewOfSystemSystem - }); + // ReviewOfSystems.Add(new MedicalHistorySystemReview + // { + // Title = _reviewOfSystemTitle, + // IsSign = _reviewOfSystemIsSign, + // IsSymptom = _reviewOfSystemIsSymptom, + // System = _reviewOfSystemSystem + // }); _reviewOfSystemTitle = string.Empty; } } \ No newline at end of file diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor b/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor index 158d855..202b987 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor @@ -10,54 +10,28 @@
+ افزودن
- +
- @foreach(var item in _medicalHistoryTemplates) - { + @foreach (var item in _medicalHistoryTemplates) + { - } + }
-@code +@code { private void CreateMedicalHistoryTemplateClicked() => NavigationManager.NavigateTo("MedicalHistoryTemplateActionPage"); private void MedicalHistoryTemplateClicked() => NavigationManager.NavigateTo("MedicalHistoryTemplateActionPage"); - private List _medicalHistoryTemplates = new(); + private List _medicalHistoryTemplates = new(); protected override void OnInitialized() { - _medicalHistoryTemplates.Add(new MedicalHistoryTemplate - { - CC = "سردرد", - Section = "داخلی" - }); - _medicalHistoryTemplates.Add(new MedicalHistoryTemplate - { - CC = "بدن درد", - Section = "فیزیو" - }); - _medicalHistoryTemplates.Add(new MedicalHistoryTemplate - { - CC = "بی خوابی", - Section = "داخلی" - }); - _medicalHistoryTemplates.Add(new MedicalHistoryTemplate + _medicalHistoryTemplates.Add(new MedicalHistoryTemplateSDto() { - CC = "دردپهلو", - Section = "داخلی" + ChiefComplaint = "سردرد", }); - _medicalHistoryTemplates.Add(new MedicalHistoryTemplate - { - CC = "سوختگی", - Section = "سوختگی" - }); - _medicalHistoryTemplates.Add(new MedicalHistoryTemplate - { - CC = "شکستگی", - Section = "فیزیو" - }); base.OnInitialized(); } } diff --git a/DocuMed.PWA/Program.cs b/DocuMed.PWA/Program.cs index a1fdd71..5deb4ab 100644 --- a/DocuMed.PWA/Program.cs +++ b/DocuMed.PWA/Program.cs @@ -1,14 +1,17 @@ -using DocuMed.PWA; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -using MudBlazor.Services; -using Toolbelt.Blazor.Extensions.DependencyInjection; - var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); -builder.Services.AddMudServices(); +builder.Services.AddMudServices(config => +{ + config.SnackbarConfiguration.VisibleStateDuration = 3500; + config.SnackbarConfiguration.HideTransitionDuration = 200; + config.SnackbarConfiguration.ShowTransitionDuration = 200; + config.SnackbarConfiguration.SnackbarVariant = Variant.Filled; + config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight; +}); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddBlazoredLocalStorage(); builder.Services.AddPWAUpdater(); await builder.Build().RunAsync(); diff --git a/DocuMed.PWA/Services/RestServices/IAuthRestApi.cs b/DocuMed.PWA/Services/RestServices/IAuthRestApi.cs new file mode 100644 index 0000000..82358f3 --- /dev/null +++ b/DocuMed.PWA/Services/RestServices/IAuthRestApi.cs @@ -0,0 +1,13 @@ +namespace DocuMed.PWA.Services.RestServices; + +public interface IAuthRestApi +{ + [Get("/verifycode")] + public Task GetVerifyCodeAsync([Query] string phoneNumber); + + [Post("/login/code")] + public Task> LoginWithVerifyCodeAsync([Body] LoginRequestDto request); + + [Post("/signup")] + public Task> CompleteSignUpAsync([Body] SignUpRequestDto request, [Header("Authorization")] string authorization); +} \ No newline at end of file diff --git a/DocuMed.PWA/Services/RestServices/ICrudApiRest.cs b/DocuMed.PWA/Services/RestServices/ICrudApiRest.cs new file mode 100644 index 0000000..3cb4dd9 --- /dev/null +++ b/DocuMed.PWA/Services/RestServices/ICrudApiRest.cs @@ -0,0 +1,42 @@ +namespace DocuMed.PWA.Services.RestServices; + +public interface ICrudApiRest where T : class +{ + [Post("")] + Task Create([Body] T payload, [Header("Authorization")] string authorization); + + [Get("")] + Task> ReadAll([Query] int page,[Header("Authorization")] string authorization); + + [Get("/{key}")] + Task ReadOne(TKey key, [Header("Authorization")] string authorization); + + [Put("")] + Task Update([Body] T payload, [Header("Authorization")] string authorization); + + [Delete("/{key}")] + Task Delete(TKey key, [Header("Authorization")] string authorization); + +} +public interface ICrudDtoApiRest where T : class where TDto : class +{ + [Post("")] + Task Create([Body] T payload, [Header("Authorization")] string authorization); + [Post("")] + Task Create([Body] TDto payload, [Header("Authorization")] string authorization); + + [Get("")] + Task> ReadAll([Query]int page,[Header("Authorization")] string authorization); + + [Get("/{key}")] + Task ReadOne(TKey key, [Header("Authorization")] string authorization); + + [Put("")] + Task Update([Body] T payload, [Header("Authorization")] string authorization); + [Put("")] + Task Update([Body] TDto payload, [Header("Authorization")] string authorization); + + [Delete("/{key}")] + Task Delete(TKey key, [Header("Authorization")] string authorization); + +} \ No newline at end of file diff --git a/DocuMed.PWA/Services/RestServices/IRestWrapper.cs b/DocuMed.PWA/Services/RestServices/IRestWrapper.cs new file mode 100644 index 0000000..a3778a1 --- /dev/null +++ b/DocuMed.PWA/Services/RestServices/IRestWrapper.cs @@ -0,0 +1,10 @@ +namespace DocuMed.PWA.Services.RestServices; + +public interface IRestWrapper +{ + public ICrudApiRest CrudApiRest(string address) where T : class; + public ICrudDtoApiRest CrudDtoApiRest(string address) where T : class where TDto : class; + + + public IAuthRestApi AuthRestApi { get; } +} \ No newline at end of file diff --git a/DocuMed.PWA/Services/RestServices/RestWrapper.cs b/DocuMed.PWA/Services/RestServices/RestWrapper.cs new file mode 100644 index 0000000..540abaf --- /dev/null +++ b/DocuMed.PWA/Services/RestServices/RestWrapper.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +namespace DocuMed.PWA.Services.RestServices; + +public class RestWrapper : IRestWrapper +{ + + private static RefitSettings setting = new RefitSettings(new NewtonsoftJsonContentSerializer(new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, + + })); + + public ICrudApiRest CrudApiRest(string address) where T : class + { + return RestService.For>(address, setting); + } + public ICrudDtoApiRest CrudDtoApiRest(string address) where T : class where TDto : class + { + return RestService.For>(address, setting); + } + public IAuthRestApi AuthRestApi => RestService.For(Address.AuthController, setting); +} \ No newline at end of file diff --git a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor index e4caf52..b4f1261 100644 --- a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor +++ b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryItemTemplate.razor @@ -1,25 +1,26 @@ +@using DocuMed.Domain.Dtos.SmallDtos
-

@MedicalHistory.Name

+

@MedicalHistory.FullName

-

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

+

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

- @MedicalHistory.Aag ساله + @MedicalHistory.Age ساله - @MedicalHistory.Gender.ToString() + مرد @@ -38,6 +39,6 @@ @code { [Parameter] - public MedicalHistory MedicalHistory { get; set; } = new(); + public MedicalHistorySDto MedicalHistory { get; set; } = new(); } \ No newline at end of file diff --git a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryQuestionTemplateItemTemplate.razor b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryQuestionTemplateItemTemplate.razor index fd9c6f0..040447b 100644 --- a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryQuestionTemplateItemTemplate.razor +++ b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryQuestionTemplateItemTemplate.razor @@ -2,10 +2,10 @@
-

@Question.Title

+

@Question.Question

- @Question.Type.ToString(); + @Question.QuestionType.ToDisplay()
diff --git a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor index bcb13b2..6838725 100644 --- a/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor +++ b/DocuMed.PWA/Shared/ItemTemplates/MedicalHistoryTemplateItemTemplate.razor @@ -1,10 +1,10 @@  -

@MedicalHistoryTemplate.CC

+

@MedicalHistoryTemplate.ChiefComplaint

-

بخش @MedicalHistoryTemplate.Section

+

بخش @MedicalHistoryTemplate.ChiefComplaint

@@ -12,8 +12,8 @@ @code { [Parameter] - public MedicalHistoryTemplate MedicalHistoryTemplate { get; set; } = new(); + public MedicalHistoryTemplateSDto MedicalHistoryTemplate { get; set; } = new(); [Parameter] - public EventCallback Clicked { get; set; } + public EventCallback Clicked { get; set; } } diff --git a/DocuMed.PWA/Shared/Originals/BaseButtonUi.razor b/DocuMed.PWA/Shared/Originals/BaseButtonUi.razor index 2a05b7e..849066e 100644 --- a/DocuMed.PWA/Shared/Originals/BaseButtonUi.razor +++ b/DocuMed.PWA/Shared/Originals/BaseButtonUi.razor @@ -2,23 +2,34 @@ Color="@Color" @onclick="OnClickCallback" @attributes="CapturedAttributes" + Disabled="IsProcessing" DisableElevation="true" class="rounded-md"> -
- @if (Variant == Variant.Filled) - { -
- -
- } - else - { -
- -
- } -

@Content

-
+ @if (IsProcessing) + { +
+ +

منتظر بمانید

+
+ } + else + { +
+ @if (Variant == Variant.Filled) + { +
+ +
+ } + else + { +
+ +
+ } +

@Content

+
+ } @code { @@ -33,6 +44,9 @@ [Parameter] public string Icon { get; set; } = string.Empty; + [Parameter] + public bool IsProcessing { get; set; } = false; + [Parameter] public EventCallback OnClickCallback { get; set; } diff --git a/DocuMed.PWA/Utilities/IUserUtility.cs b/DocuMed.PWA/Utilities/IUserUtility.cs new file mode 100644 index 0000000..3a2df9f --- /dev/null +++ b/DocuMed.PWA/Utilities/IUserUtility.cs @@ -0,0 +1,7 @@ +namespace DocuMed.PWA.Utilities; + +public interface IUserUtility +{ + public Task GetBearerTokenAsync(); + public Task SetBearerTokenAsync(string token); +} \ No newline at end of file diff --git a/DocuMed.PWA/Utilities/UserUtility.cs b/DocuMed.PWA/Utilities/UserUtility.cs new file mode 100644 index 0000000..206e89a --- /dev/null +++ b/DocuMed.PWA/Utilities/UserUtility.cs @@ -0,0 +1,20 @@ +using DocuMed.Common.Models.Claims; + +namespace DocuMed.PWA.Utilities; + +public class UserUtility : IUserUtility +{ + private readonly ILocalStorageService _localStorageService; + + public UserUtility(ILocalStorageService localStorageService) + { + _localStorageService = localStorageService; + } + + public async Task GetBearerTokenAsync() => await _localStorageService.GetItemAsStringAsync(LocalStorageKeys.Token); + public async Task SetBearerTokenAsync(string token) => await _localStorageService.SetItemAsStringAsync(LocalStorageKeys.Token,token); + + //public AccessToken? AccessToken { get; set; } + //public List UserClaims => AccessToken == null ? new List() : AccessToken.Permissions; + //public bool HasPermissionTo(string permission) => UserClaims.Any(c => c == permission); +} \ No newline at end of file diff --git a/DocuMed.PWA/Utilities/UtilityWrapper.cs b/DocuMed.PWA/Utilities/UtilityWrapper.cs new file mode 100644 index 0000000..ca2fdc7 --- /dev/null +++ b/DocuMed.PWA/Utilities/UtilityWrapper.cs @@ -0,0 +1,11 @@ +namespace DocuMed.PWA.Utilities; + +public class UtilityWrapper +{ + private static UtilityWrapper? _instance; + public static UtilityWrapper Instance + { + get { return _instance ??= new UtilityWrapper(); } + } + +} \ No newline at end of file diff --git a/DocuMed.PWA/wwwroot/css/app.min.css b/DocuMed.PWA/wwwroot/css/app.min.css index 1ab255a..39de4c3 100644 --- a/DocuMed.PWA/wwwroot/css/app.min.css +++ b/DocuMed.PWA/wwwroot/css/app.min.css @@ -563,6 +563,9 @@ video { .-mb-8 { margin-bottom: -2rem; } +.-ml-4 { + margin-left: -1rem; +} .-ml-6 { margin-left: -1.5rem; } diff --git a/DocuMed.PWA/wwwroot/css/app.output.css b/DocuMed.PWA/wwwroot/css/app.output.css index 101b707..124905d 100644 --- a/DocuMed.PWA/wwwroot/css/app.output.css +++ b/DocuMed.PWA/wwwroot/css/app.output.css @@ -632,6 +632,10 @@ video { margin-bottom: -2rem; } +.-ml-4 { + margin-left: -1rem; +} + .-ml-6 { margin-left: -1.5rem; } diff --git a/DocuMed.Repository/Migrations/20231019180057_init.Designer.cs b/DocuMed.Repository/Migrations/20231019180057_init.Designer.cs new file mode 100644 index 0000000..c599dc6 --- /dev/null +++ b/DocuMed.Repository/Migrations/20231019180057_init.Designer.cs @@ -0,0 +1,722 @@ +// +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("20231019180057_init")] + partial class init + { + /// + 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.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("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("Section") + .IsRequired() + .HasColumnType("text"); + + 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.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("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .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("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.HasKey("Id"); + + 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("Section") + .IsRequired() + .HasColumnType("text"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + 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("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.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.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.User.ApplicationUser", b => + { + b.HasOne("DocuMed.Domain.Entities.City.University", "University") + .WithMany() + .HasForeignKey("UniversityId"); + + 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.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/20231019180057_init.cs b/DocuMed.Repository/Migrations/20231019180057_init.cs new file mode 100644 index 0000000..8d5ece8 --- /dev/null +++ b/DocuMed.Repository/Migrations/20231019180057_init.cs @@ -0,0 +1,489 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DocuMed.Repository.Migrations +{ + /// + public partial class init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "public"); + + migrationBuilder.CreateTable( + name: "Cities", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cities", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "MedicalHistories", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ChiefComplaint = table.Column(type: "text", nullable: false), + Section = table.Column(type: "text", nullable: false), + FirstName = table.Column(type: "text", nullable: false), + LastName = table.Column(type: "text", nullable: false), + FatherName = table.Column(type: "text", nullable: false), + NationalId = table.Column(type: "text", nullable: false), + Age = table.Column(type: "integer", nullable: false), + BirthDate = table.Column(type: "timestamp without time zone", nullable: false), + PresentIllnessDetail = table.Column(type: "text", nullable: false), + PastDiseasesHistoryDetail = table.Column(type: "text", nullable: false), + PastSurgeryHistoryDetail = table.Column(type: "text", nullable: false), + FamilyHistoryDetail = table.Column(type: "text", nullable: false), + AllergyDetail = table.Column(type: "text", nullable: false), + DrugHistoryDetail = table.Column(type: "text", nullable: false), + AddictionHistoryDetail = table.Column(type: "text", nullable: false), + SystemReviewDetail = table.Column(type: "text", nullable: false), + VitalSignDetail = table.Column(type: "text", nullable: false), + SystolicBloodPressure = table.Column(type: "integer", nullable: false), + DiastolicBloodPressure = table.Column(type: "integer", nullable: false), + PulseRate = table.Column(type: "integer", nullable: false), + SPO2 = table.Column(type: "integer", nullable: false), + Temperature = table.Column(type: "integer", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MedicalHistories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "MedicalHistoryTemplates", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ChiefComplaint = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MedicalHistoryTemplates", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Roles", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Description = table.Column(type: "text", nullable: false), + EnglishName = table.Column(type: "text", nullable: false), + PersianName = table.Column(type: "text", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Roles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Universities", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Address = table.Column(type: "text", nullable: false), + CityId = 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), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Universities", x => x.Id); + table.ForeignKey( + name: "FK_Universities_Cities_CityId", + column: x => x.CityId, + principalSchema: "public", + principalTable: "Cities", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "MedicalHistoryAnswers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Answer = table.Column(type: "text", nullable: false), + Question = table.Column(type: "text", nullable: false), + Part = table.Column(type: "integer", nullable: false), + QuestionType = table.Column(type: "integer", nullable: false), + MedicalHistoryId = 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), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MedicalHistoryAnswers", x => x.Id); + table.ForeignKey( + name: "FK_MedicalHistoryAnswers_MedicalHistories_MedicalHistoryId", + column: x => x.MedicalHistoryId, + principalSchema: "public", + principalTable: "MedicalHistories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "MedicalHistoryQuestions", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Question = table.Column(type: "text", nullable: false), + Part = table.Column(type: "integer", nullable: false), + QuestionType = table.Column(type: "integer", 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), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MedicalHistoryQuestions", x => x.Id); + table.ForeignKey( + name: "FK_MedicalHistoryQuestions_MedicalHistoryTemplates_MedicalHist~", + column: x => x.MedicalHistoryTemplateId, + principalSchema: "public", + principalTable: "MedicalHistoryTemplates", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "RoleClaims", + schema: "public", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_RoleClaims_Roles_RoleId", + column: x => x.RoleId, + principalSchema: "public", + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Users", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + FirstName = table.Column(type: "text", nullable: false), + LastName = table.Column(type: "text", nullable: false), + NationalId = table.Column(type: "text", nullable: false), + Section = table.Column(type: "text", nullable: false), + BirthDate = table.Column(type: "timestamp without time zone", nullable: false), + Gender = table.Column(type: "integer", nullable: false), + SignUpStatus = table.Column(type: "integer", nullable: false), + UniversityId = table.Column(type: "uuid", nullable: true), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + table.ForeignKey( + name: "FK_Users_Universities_UniversityId", + column: x => x.UniversityId, + principalSchema: "public", + principalTable: "Universities", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Claims", + schema: "public", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Claims", x => x.Id); + table.ForeignKey( + name: "FK_Claims_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Logins", + schema: "public", + columns: table => new + { + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Logins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_Logins_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Tokens", + schema: "public", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_Tokens_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "UserRoles", + schema: "public", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + RoleId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_UserRoles_Roles_RoleId", + column: x => x.RoleId, + principalSchema: "public", + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserRoles_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_Claims_UserId", + schema: "public", + table: "Claims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Logins_UserId", + schema: "public", + table: "Logins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_MedicalHistoryAnswers_MedicalHistoryId", + schema: "public", + table: "MedicalHistoryAnswers", + column: "MedicalHistoryId"); + + migrationBuilder.CreateIndex( + name: "IX_MedicalHistoryQuestions_MedicalHistoryTemplateId", + schema: "public", + table: "MedicalHistoryQuestions", + column: "MedicalHistoryTemplateId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleClaims_RoleId", + schema: "public", + table: "RoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + schema: "public", + table: "Roles", + column: "NormalizedName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Universities_CityId", + schema: "public", + table: "Universities", + column: "CityId"); + + migrationBuilder.CreateIndex( + name: "IX_UserRoles_RoleId", + schema: "public", + table: "UserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + schema: "public", + table: "Users", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_Users_UniversityId", + schema: "public", + table: "Users", + column: "UniversityId"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + schema: "public", + table: "Users", + column: "NormalizedUserName", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Claims", + schema: "public"); + + migrationBuilder.DropTable( + name: "Logins", + schema: "public"); + + migrationBuilder.DropTable( + name: "MedicalHistoryAnswers", + schema: "public"); + + migrationBuilder.DropTable( + name: "MedicalHistoryQuestions", + schema: "public"); + + migrationBuilder.DropTable( + name: "RoleClaims", + schema: "public"); + + migrationBuilder.DropTable( + name: "Tokens", + schema: "public"); + + migrationBuilder.DropTable( + name: "UserRoles", + schema: "public"); + + migrationBuilder.DropTable( + name: "MedicalHistories", + schema: "public"); + + migrationBuilder.DropTable( + name: "MedicalHistoryTemplates", + schema: "public"); + + migrationBuilder.DropTable( + name: "Roles", + schema: "public"); + + migrationBuilder.DropTable( + name: "Users", + schema: "public"); + + migrationBuilder.DropTable( + name: "Universities", + schema: "public"); + + migrationBuilder.DropTable( + name: "Cities", + schema: "public"); + } + } +} diff --git a/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs b/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs new file mode 100644 index 0000000..8cfe567 --- /dev/null +++ b/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -0,0 +1,719 @@ +// +using System; +using DocuMed.Repository.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DocuMed.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + partial class ApplicationContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(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.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("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("Section") + .IsRequired() + .HasColumnType("text"); + + 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.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("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .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("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.HasKey("Id"); + + 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("Section") + .IsRequired() + .HasColumnType("text"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + 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("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.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.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.User.ApplicationUser", b => + { + b.HasOne("DocuMed.Domain.Entities.City.University", "University") + .WithMany() + .HasForeignKey("UniversityId"); + + 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.MedicalHistory.MedicalHistory", b => + { + b.Navigation("Answers"); + }); + + modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => + { + b.Navigation("Questions"); + }); +#pragma warning restore 612, 618 + } + } +}