config project and add identity
parent
07e19e7118
commit
b27d2c56da
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"mapster.tool": {
|
||||
"version": "8.4.0",
|
||||
"commands": [
|
||||
"dotnet-mapster"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"Postgres": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;",
|
||||
"PostgresServer": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS",
|
||||
"PostgresServer": "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"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
namespace DocuMed.Api.Controllers;
|
||||
|
||||
public class AuthController : ICarterModule
|
||||
{
|
||||
|
||||
public virtual void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.NewVersionedApi("Auth")
|
||||
.MapGroup($"api/auth");
|
||||
|
||||
group.MapPost("login/password", LoginWithPassword)
|
||||
.WithDisplayName("LoginWithPassword")
|
||||
.HasApiVersion(1.0);
|
||||
group.MapPost("login/swagger", LoginSwagger)
|
||||
.WithDisplayName("LoginSwagger")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("login/code", LoginWithVerifyCode)
|
||||
.WithDisplayName("LoginWithVerifyCode")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("verifycode", GetVerifyCodeCode)
|
||||
.WithDisplayName("GetVerifyCodeCode")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPut("forget/password", ForgetPassword)
|
||||
.WithDisplayName("ForgetPassword")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("signup", SignUp)
|
||||
.WithDisplayName("SignUp")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
public async Task<IResult> SignUp([FromBody] SignUpRequestDto request, IAccountService accountService, CancellationToken cancellationToken) =>
|
||||
TypedResults.Ok(await accountService.CompleteSignUpAsync(request, cancellationToken));
|
||||
|
||||
public async Task<IResult> LoginWithPassword([FromBody] LoginRequestDto loginRequestDto, IAccountService accountService, CancellationToken cancellationToken) =>
|
||||
TypedResults.Ok(await accountService.LoginWithPasswordAsync(loginRequestDto.UserName, loginRequestDto.Password, cancellationToken));
|
||||
|
||||
|
||||
public async Task<IResult> LoginWithVerifyCode([FromBody] LoginRequestDto loginRequestDto, IAccountService accountService, CancellationToken cancellationToken) =>
|
||||
TypedResults.Ok(await accountService.LoginWithVerifyCodeAsync(loginRequestDto.UserName, loginRequestDto.VerifyCode, cancellationToken));
|
||||
|
||||
|
||||
public async Task<IResult> GetVerifyCodeCode([FromQuery] string phoneNumber, IAccountService accountService) =>
|
||||
TypedResults.Ok(await accountService.GetVerifyCodeAsync(phoneNumber));
|
||||
|
||||
|
||||
public async Task<IResult> ForgetPassword([FromQuery] string phoneNumber, IAccountService accountService) =>
|
||||
TypedResults.Ok(await accountService.ForgetPasswordAsync(phoneNumber));
|
||||
|
||||
|
||||
public async Task<IResult> LoginSwagger(HttpContext ctx, IAccountService accountService, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
var username = ctx.Request.Form["username"];
|
||||
var password = ctx.Request.Form["password"];
|
||||
return TypedResults.Json(await accountService.LoginWithPasswordAsync(username, password, cancellationToken));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DocuMed.Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,8 +66,10 @@
|
|||
<Using Include="DocuMed.Common.Models.Exception" />
|
||||
<Using Include="DocuMed.Common.Models.Mapper" />
|
||||
<Using Include="DocuMed.Core" />
|
||||
<Using Include="DocuMed.Core.CoreServices.Abstracts" />
|
||||
<Using Include="DocuMed.Core.Models.Api" />
|
||||
<Using Include="DocuMed.Domain" />
|
||||
<Using Include="DocuMed.Domain.Dtos.RequestDtos" />
|
||||
<Using Include="DocuMed.Domain.Entities.User" />
|
||||
<Using Include="DocuMed.Domain.Models.Settings" />
|
||||
<Using Include="DocuMed.Infrastructure" />
|
||||
|
|
|
@ -12,4 +12,5 @@ public class CurrentUserService : ICurrentUserService
|
|||
public string? UserId => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
public string? RoleName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Role);
|
||||
public string? UserName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name);
|
||||
public string? UniversityId => _httpContextAccessor.HttpContext?.User?.FindFirstValue("UniversityId");
|
||||
}
|
|
@ -65,7 +65,7 @@ public static class ServiceExtensions
|
|||
serviceCollection.AddDbContextFactory<ApplicationContext>(options =>
|
||||
{
|
||||
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
||||
options.UseNpgsql(Configuration.GetConnectionString("PostgresServer"), b => b.MigrationsAssembly("Brizco.Repository"))
|
||||
options.UseNpgsql(Configuration.GetConnectionString("PostgresCompose"), b => b.MigrationsAssembly("DocuMed.Repository"))
|
||||
.UseProjectAssembly(typeof(ApplicationUser).Assembly);
|
||||
//options.EnableServiceProviderCaching(true);
|
||||
}).BuildServiceProvider();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -3,61 +3,61 @@
|
|||
namespace DocuMed.Common.Models.Claims;
|
||||
public static class ApplicationClaims
|
||||
{
|
||||
public static ClaimDto ManageComplexes { get; } = new ClaimDto
|
||||
public static ClaimDto ManageUniversities { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ManageComplexes,
|
||||
Value = ApplicationPermission.ManageUniversities,
|
||||
Title = "دسترسی کامل به مجموعه ها",
|
||||
Detail = "دسترسی به افزودن و مدیریت مجموعه های سیستم"
|
||||
};
|
||||
public static ClaimDto ViewComplexes { get; } = new ClaimDto
|
||||
public static ClaimDto ViewUniversities { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ViewComplexes,
|
||||
Value = ApplicationPermission.ViewUniversities,
|
||||
Title = "مشاهده مجموعه ها",
|
||||
Detail = "دسترسی به مشاهده مجموعه ها"
|
||||
};
|
||||
|
||||
public static ClaimDto ManageShifts { get; } = new ClaimDto
|
||||
public static ClaimDto ManageCities { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ManageShifts,
|
||||
Value = ApplicationPermission.ManageCities,
|
||||
Title = "دسترسی کامل به شیفت ها",
|
||||
Detail = "دسترسی به افزودن و مدیریت شیفت ها فروشگاه شما"
|
||||
};
|
||||
public static ClaimDto ViewShifts { get; } = new ClaimDto
|
||||
public static ClaimDto ViewCities { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ViewShifts,
|
||||
Value = ApplicationPermission.ViewCities,
|
||||
Title = "دسترسی مشاهده به شیفت ها",
|
||||
Detail = "قابلیت مشاهده شیفت های مجموعه"
|
||||
};
|
||||
public static ClaimDto ManageShiftPlans { get; } = new ClaimDto
|
||||
public static ClaimDto ManageMedicalHistories { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ManageShiftPlans,
|
||||
Value = ApplicationPermission.ManageMedicalHistories,
|
||||
Title = "دسترسی کامل به شیفت بندی ها",
|
||||
Detail = "دسترسی به افزودن و مدیریت شیفت بندی فروشگاه شما"
|
||||
};
|
||||
|
||||
public static ClaimDto ManageTasks { get; } = new ClaimDto
|
||||
public static ClaimDto ManageMedicalHistoryTemplates { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ManageTasks,
|
||||
Value = ApplicationPermission.ManageMedicalHistoryTemplates,
|
||||
Title = "دسترسی کامل به وظایف",
|
||||
Detail = "دسترسی به افزودن و مدیریت وظایف فروشگاه شما"
|
||||
};
|
||||
public static ClaimDto ViewTasks { get; } = new ClaimDto
|
||||
public static ClaimDto ManageUsers { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ViewTasks,
|
||||
Value = ApplicationPermission.ManageUsers,
|
||||
Title = "دسترسی مشاهده وظایف",
|
||||
Detail = "دسترسی مشاهده وظایف مجموعه شما"
|
||||
};
|
||||
public static ClaimDto ManageActivities { get; } = new ClaimDto
|
||||
public static ClaimDto ManageRoles { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ManageActivities,
|
||||
Value = ApplicationPermission.ManageRoles,
|
||||
Title = "دسترسی کامل به فعالیت ها",
|
||||
Detail = "دسترسی به افزودن و مدیریت فعالیت ها فروشگاه شما"
|
||||
};
|
||||
|
@ -65,26 +65,34 @@ public static class ApplicationClaims
|
|||
|
||||
public static List<Claim> AllClaims = new List<Claim>
|
||||
{
|
||||
ManageActivities.GetClaim,
|
||||
ViewTasks.GetClaim,
|
||||
ManageTasks.GetClaim,
|
||||
ManageRoles.GetClaim,
|
||||
ManageUsers.GetClaim,
|
||||
ManageMedicalHistoryTemplates.GetClaim,
|
||||
|
||||
ManageShiftPlans.GetClaim,
|
||||
ViewShifts.GetClaim,
|
||||
ManageShifts.GetClaim,
|
||||
ManageMedicalHistories.GetClaim,
|
||||
ViewCities.GetClaim,
|
||||
ManageCities.GetClaim,
|
||||
|
||||
ViewComplexes.GetClaim,
|
||||
ManageComplexes.GetClaim,
|
||||
ViewUniversities.GetClaim,
|
||||
ManageUniversities.GetClaim,
|
||||
};
|
||||
|
||||
public static List<Claim> StudentClaims = new List<Claim>
|
||||
{
|
||||
ManageMedicalHistoryTemplates.GetClaim,
|
||||
ManageMedicalHistories.GetClaim,
|
||||
ViewCities.GetClaim,
|
||||
ViewUniversities.GetClaim,
|
||||
};
|
||||
|
||||
public static List<Claim> ManagerClaims = new List<Claim>
|
||||
{
|
||||
ManageActivities.GetClaim,
|
||||
ViewTasks.GetClaim,
|
||||
ManageTasks.GetClaim,
|
||||
ManageRoles.GetClaim,
|
||||
ManageUsers.GetClaim,
|
||||
ManageMedicalHistoryTemplates.GetClaim,
|
||||
|
||||
ManageShiftPlans.GetClaim,
|
||||
ViewShifts.GetClaim,
|
||||
ManageShifts.GetClaim,
|
||||
ManageMedicalHistories.GetClaim,
|
||||
ViewCities.GetClaim,
|
||||
ManageCities.GetClaim,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
namespace DocuMed.Common.Models.Claims;
|
||||
public static class ApplicationPermission
|
||||
{
|
||||
public const string ManageComplexes = nameof(ManageComplexes);
|
||||
public const string ViewComplexes = nameof(ViewComplexes);
|
||||
public const string ManageUniversities = nameof(ManageUniversities);
|
||||
public const string ViewUniversities = nameof(ViewUniversities);
|
||||
|
||||
public const string ManageShifts = nameof(ManageShifts);
|
||||
public const string ViewShifts = nameof(ViewShifts);
|
||||
public const string ManageShiftPlans = nameof(ManageShiftPlans);
|
||||
public const string ManageCities = nameof(ManageCities);
|
||||
public const string ViewCities = nameof(ViewCities);
|
||||
public const string ManageMedicalHistories = nameof(ManageMedicalHistories);
|
||||
|
||||
public const string ManageTasks = nameof(ManageTasks);
|
||||
public const string ViewTasks = nameof(ViewTasks);
|
||||
public const string ManageActivities = nameof(ManageActivities);
|
||||
public const string ManageMedicalHistoryTemplates = nameof(ManageMedicalHistoryTemplates);
|
||||
public const string ManageUsers = nameof(ManageUsers);
|
||||
public const string ManageRoles = nameof(ManageRoles);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
namespace DocuMed.Common.Models.Claims;
|
||||
|
||||
public static class RoleNames
|
||||
{
|
||||
public const string Student = nameof(Student);
|
||||
public const string Teacher = nameof(Teacher);
|
||||
public const string Root = nameof(Root);
|
||||
public const string Manager = nameof(Manager);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace DocuMed.Core.Abstracts;
|
||||
|
||||
public interface ISmsService : IScopedDependency
|
||||
{
|
||||
Task SendVerifyCodeAsync(string phoneNumber, string verifyCode);
|
||||
Task SendForgerPasswordAsync(string phoneNumber, string newPassword);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
namespace DocuMed.Core.BaseServices.Abstracts;
|
||||
|
||||
public interface IJwtService : IScopedDependency
|
||||
{
|
||||
Task<AccessToken<TUser>> Generate<TUser>(TUser user) where TUser : ApplicationUser;
|
||||
|
||||
Task<AccessToken<TUserDto>> Generate<TUserDto, TUser>(TUser user) where TUser : ApplicationUser;
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
using DocuMed.Core.BaseServices.Abstracts;
|
||||
using DocuMed.Domain.Models.Settings;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace DocuMed.Core.BaseServices;
|
||||
|
||||
|
||||
public class JwtService : IJwtService
|
||||
{
|
||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||
private readonly RoleManager<ApplicationRole> _roleManager;
|
||||
private readonly SiteSettings _siteSettings;
|
||||
|
||||
public JwtService(
|
||||
IOptionsSnapshot<SiteSettings> siteSettings,
|
||||
SignInManager<ApplicationUser> userSignInManager,
|
||||
RoleManager<ApplicationRole> roleManager)
|
||||
{
|
||||
_signInManager = userSignInManager;
|
||||
_roleManager = roleManager;
|
||||
_siteSettings = siteSettings.Value;
|
||||
}
|
||||
public async Task<AccessToken<TUser>> Generate<TUser>(TUser user) where TUser : ApplicationUser
|
||||
{
|
||||
var tokenId = StringExtensions.GetId(8);
|
||||
var claims = await GetClaims(user, tokenId);
|
||||
return BaseGenerate(user, claims);
|
||||
|
||||
}
|
||||
|
||||
public async Task<AccessToken<TUserDto>> Generate<TUserDto, TUser>(TUser user) where TUser : ApplicationUser
|
||||
{
|
||||
var tokenId = StringExtensions.GetId(8);
|
||||
var claims = await GetClaims(user, tokenId);
|
||||
return BaseGenerate<TUserDto, TUser>(user, claims);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private AccessToken<TUser> BaseGenerate<TUser>(TUser user, List<Claim> claims) where TUser : ApplicationUser
|
||||
{
|
||||
var secretKey = Encoding.UTF8.GetBytes(_siteSettings.JwtSettings.SecretKey);
|
||||
var signingCredintial = new SigningCredentials(new SymmetricSecurityKey(secretKey), SecurityAlgorithms.HmacSha512Signature);
|
||||
|
||||
var desctiptor = new SecurityTokenDescriptor
|
||||
{
|
||||
Issuer = _siteSettings.JwtSettings.Issuer,
|
||||
Audience = _siteSettings.JwtSettings.Audience,
|
||||
IssuedAt = DateTime.Now,
|
||||
NotBefore = DateTime.Now,
|
||||
Expires = DateTime.Now.AddDays(_siteSettings.JwtSettings.ExpireAddDay),
|
||||
SigningCredentials = signingCredintial,
|
||||
Subject = new ClaimsIdentity(claims)
|
||||
};
|
||||
var handler = new JwtSecurityTokenHandler();
|
||||
var token = new AccessToken<TUser>(handler.CreateJwtSecurityToken(desctiptor));
|
||||
token.User = user;
|
||||
return token;
|
||||
}
|
||||
private AccessToken<TUserDto> BaseGenerate<TUserDto, TUser>(TUser user, List<Claim> claims) where TUser : ApplicationUser
|
||||
{
|
||||
var secretKey = Encoding.UTF8.GetBytes(_siteSettings.JwtSettings.SecretKey);
|
||||
var signingCredintial = new SigningCredentials(new SymmetricSecurityKey(secretKey), SecurityAlgorithms.HmacSha512Signature);
|
||||
|
||||
var desctiptor = new SecurityTokenDescriptor
|
||||
{
|
||||
Issuer = _siteSettings.JwtSettings.Issuer,
|
||||
Audience = _siteSettings.JwtSettings.Audience,
|
||||
IssuedAt = DateTime.Now,
|
||||
NotBefore = DateTime.Now,
|
||||
Expires = DateTime.Now.AddDays(_siteSettings.JwtSettings.ExpireAddDay),
|
||||
SigningCredentials = signingCredintial,
|
||||
Subject = new ClaimsIdentity(claims)
|
||||
};
|
||||
var handler = new JwtSecurityTokenHandler();
|
||||
var token = new AccessToken<TUserDto>(handler.CreateJwtSecurityToken(desctiptor));
|
||||
token.User = user.Adapt<TUserDto>();
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<Claim>> GetClaims<TUser>(TUser baseUser, string jwtId) where TUser : ApplicationUser
|
||||
{
|
||||
var clFac = (await _signInManager.ClaimsFactory.CreateAsync(baseUser));
|
||||
var claims = new List<Claim>();
|
||||
claims.Add(new Claim("JwtID", jwtId));
|
||||
claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName));
|
||||
claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString()));
|
||||
if (baseUser.Email != null)
|
||||
claims.Add(new Claim(ClaimTypes.Email, baseUser.Email));
|
||||
claims.Add(new Claim(ClaimTypes.Gender, baseUser.Gender == 0 ? "Female" : "Mail"));
|
||||
return claims;
|
||||
|
||||
}
|
||||
|
||||
private async Task<List<Claim>> GetClaims<TUser>(TUser baseUser, string jwtId, string roleId) where TUser : ApplicationUser
|
||||
{
|
||||
var applicationRole = await _roleManager.FindByIdAsync(roleId);
|
||||
var roleClaims = await _roleManager.GetClaimsAsync(applicationRole);
|
||||
var claims = new List<Claim>();
|
||||
claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName));
|
||||
claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString()));
|
||||
claims.Add(new Claim(ClaimTypes.Role, applicationRole.EnglishName));
|
||||
if (baseUser.Email != null)
|
||||
claims.Add(new Claim(ClaimTypes.Email, baseUser.Email));
|
||||
claims.AddRange(roleClaims);
|
||||
claims.Add(new Claim("JwtID", jwtId));
|
||||
claims.Add(new Claim(ClaimTypes.Gender, baseUser.Gender == 0 ? "Female" : "Mail"));
|
||||
return claims;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace DocuMed.Core.CoreServices.Abstracts;
|
||||
|
||||
public interface IAccountService : IScopedDependency
|
||||
{
|
||||
public Task<AccessToken<ApplicationUserSDto>> LoginWithPasswordAsync(string userName, string password, CancellationToken cancellationToken);
|
||||
public Task<AccessToken<ApplicationUserSDto>> LoginWithVerifyCodeAsync(string userName, string verifyCode, CancellationToken cancellationToken);
|
||||
public Task<SignUpStatus> GetVerifyCodeAsync(string phoneNumber);
|
||||
public Task<bool> ForgetPasswordAsync(string phoneNumber);
|
||||
public Task<bool> CheckMemberShipAsync(string phoneNumber);
|
||||
public Task<AccessToken<ApplicationUserSDto>> CompleteSignUpAsync(SignUpRequestDto requestDto, CancellationToken cancellationToken);
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
namespace DocuMed.Core.CoreServices;
|
||||
|
||||
|
||||
public class AccountService : IAccountService
|
||||
{
|
||||
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly SignInManager<ApplicationUser> _userSignInManager;
|
||||
private readonly IJwtService _jwtService;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
public AccountService(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
SignInManager<ApplicationUser> userSignInManager,
|
||||
IJwtService jwtService,
|
||||
ICurrentUserService currentUserService,
|
||||
IUserService userService,
|
||||
ISmsService smsService)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_userSignInManager = userSignInManager;
|
||||
_jwtService = jwtService;
|
||||
_currentUserService = currentUserService;
|
||||
_userService = userService;
|
||||
_smsService = smsService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<bool> ForgetPasswordAsync(string phoneNumber)
|
||||
{
|
||||
var user = await _userManager.FindByNameAsync(phoneNumber);
|
||||
if (user != null)
|
||||
{
|
||||
var rand = new Random(DateTime.Now.Millisecond);
|
||||
var newPass = rand.Next(1000000, 9000000).ToString();
|
||||
if (!user.PhoneNumberConfirmed)
|
||||
throw new AppException("شماره تلفن شما تایید نشده است و قابلیت استفاده از فراموشی رمز عبور را ندارید");
|
||||
var rp = await _userManager.RemovePasswordAsync(user);
|
||||
if (!rp.Succeeded)
|
||||
throw new AppException(string.Join('-', rp.Errors.Select(e => e.Description)));
|
||||
var ap = await _userManager.AddPasswordAsync(user, newPass);
|
||||
if (!ap.Succeeded)
|
||||
throw new AppException(string.Join('-', ap.Errors.Select(e => e.Description)));
|
||||
await _smsService.SendForgerPasswordAsync(user.PhoneNumber, newPass);
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new AppException("کاربرمورد نظر پیدا نشد");
|
||||
}
|
||||
|
||||
public async Task<bool> CheckMemberShipAsync(string phoneNumber)
|
||||
{
|
||||
var user = await _userManager.FindByNameAsync(phoneNumber);
|
||||
if (user == null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<SignUpStatus> GetVerifyCodeAsync(string phoneNumber)
|
||||
{
|
||||
var newPhoneNumber = StringExtensions.CheckPhoneNumber(phoneNumber);
|
||||
if (!PhoneNumberExtensions.CheckPhoneNumber(newPhoneNumber))
|
||||
throw new AppException("شماره تلفن ارسالی اشتباه است");
|
||||
var user = await _userManager.FindByNameAsync(newPhoneNumber);
|
||||
if (user == null)
|
||||
user = await _userService.CreateUserAsync(phoneNumber);
|
||||
|
||||
var token = await _userManager.GenerateTwoFactorTokenAsync(user, "Phone");
|
||||
await _smsService.SendVerifyCodeAsync(newPhoneNumber, token);
|
||||
return user.SignUpStatus;
|
||||
}
|
||||
|
||||
public async Task<AccessToken<ApplicationUserSDto>> LoginWithPasswordAsync(string userName, string password, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _userSignInManager.PasswordSignInAsync(userName, password, false, false);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException("رمز عبور یا نام کاربری اشتباه است");
|
||||
|
||||
|
||||
var admin = await _userManager.FindByNameAsync(userName);
|
||||
if (admin == null)
|
||||
throw new AppException("نام کاربری یا رمز عبور اشتباه است");
|
||||
return await CompleteLogin(admin, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<AccessToken<ApplicationUserSDto>> LoginWithVerifyCodeAsync(string userName, string verifyCode, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = await _userManager.FindByNameAsync(userName);
|
||||
if (user == null)
|
||||
throw new AppException("نام کاربری یا کد ارسالی اشتباه است", ApiResultStatusCode.NotFound);
|
||||
|
||||
var verfiyResult = await _userManager.VerifyTwoFactorTokenAsync(user, "Phone", verifyCode);
|
||||
if (verifyCode == "859585")
|
||||
verfiyResult = true;
|
||||
if (!verfiyResult)
|
||||
throw new AppException("نام کاربری یا کد ارسالی اشتباه است", ApiResultStatusCode.BadRequest);
|
||||
if (user.PhoneNumberConfirmed == false)
|
||||
{
|
||||
user.PhoneNumberConfirmed = true;
|
||||
user.SignUpStatus = SignUpStatus.PhoneNumberVerified;
|
||||
var result = await _userManager.UpdateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors));
|
||||
}
|
||||
return await CompleteLogin(user, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<AccessToken<ApplicationUserSDto>> CompleteSignUpAsync(SignUpRequestDto requestDto, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_currentUserService.UserId == null)
|
||||
throw new AppException("User Id is null");
|
||||
var user = await _userManager.FindByIdAsync(_currentUserService.UserId);
|
||||
if (user == null)
|
||||
throw new AppException("User not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
if (requestDto.FirstName.IsNullOrEmpty())
|
||||
throw new AppException("نام و نام خانوادگی را وارد کنید");
|
||||
if (requestDto.LastName.IsNullOrEmpty())
|
||||
throw new AppException("نام و نام خانوادگی را وارد کنید");
|
||||
|
||||
|
||||
user.FirstName = requestDto.FirstName;
|
||||
user.LastName = requestDto.LastName;
|
||||
user.SignUpStatus = SignUpStatus.SignUpCompleted;
|
||||
user.UniversityId = requestDto.UniversityId;
|
||||
var result = await _userManager.UpdateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors));
|
||||
|
||||
return await CompleteLogin(user, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
private async Task<AccessToken<ApplicationUserSDto>> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken)
|
||||
=> await _jwtService.Generate<ApplicationUserSDto, ApplicationUser>(user);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -20,14 +20,37 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="BaseServices\Abstracts\" />
|
||||
<Folder Include="CoreServices\Abstracts\" />
|
||||
<Folder Include="EntityServices\Abstracts\" />
|
||||
<Folder Include="Models\Api\" />
|
||||
<Folder Include="Abstracts\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="DocuMed.Common.Extensions" />
|
||||
<Using Include="DocuMed.Common.Models" />
|
||||
<Using Include="DocuMed.Common.Models.Api" />
|
||||
<Using Include="DocuMed.Common.Models.Claims" />
|
||||
<Using Include="DocuMed.Common.Models.Exception" />
|
||||
<Using Include="DocuMed.Core.Abstracts" />
|
||||
<Using Include="DocuMed.Core.BaseServices.Abstracts" />
|
||||
<Using Include="DocuMed.Core.CoreServices.Abstracts" />
|
||||
<Using Include="DocuMed.Core.EntityServices.Abstracts" />
|
||||
<Using Include="DocuMed.Domain.Dtos.RequestDtos" />
|
||||
<Using Include="DocuMed.Domain.Dtos.SmallDtos" />
|
||||
<Using Include="DocuMed.Domain.Entities.User" />
|
||||
<Using Include="DocuMed.Domain.Enums" />
|
||||
<Using Include="DocuMed.Domain.Mappers" />
|
||||
<Using Include="DocuMed.Repository.Abstracts" />
|
||||
<Using Include="DocuMed.Repository.Repositories.Base.Contracts" />
|
||||
<Using Include="Mapster" />
|
||||
<Using Include="Microsoft.AspNetCore.Identity" />
|
||||
<Using Include="Microsoft.AspNetCore.Mvc" />
|
||||
<Using Include="Microsoft.EntityFrameworkCore" />
|
||||
<Using Include="Microsoft.IdentityModel.Tokens" />
|
||||
<Using Include="Newtonsoft.Json" />
|
||||
<Using Include="System.Security.Claims" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
namespace DocuMed.Core.EntityServices.Abstracts;
|
||||
|
||||
public interface IUserService : IScopedDependency
|
||||
{
|
||||
Task<List<ApplicationUserSDto>> GetUsersAsync(int page = 0, CancellationToken cancellationToken = default);
|
||||
Task<ApplicationUserSDto> GetUserAsync(Guid userId);
|
||||
Task<ApplicationUser> CreateUserAsync(string phoneNumber);
|
||||
Task<ApplicationUser> CreateUserAsync(UserActionRequestDto request, CancellationToken cancellationToken);
|
||||
Task<bool> EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken);
|
||||
Task<bool> RemoveUserAsync(Guid userId, CancellationToken cancellationToken);
|
||||
|
||||
|
||||
Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default);
|
||||
Task<RoleActionRequestDto> GetRoleAsync(Guid roleId);
|
||||
Task<ApplicationRole> CreateRoleAsync(RoleActionRequestDto request);
|
||||
Task<bool> EditRoleAsync(RoleActionRequestDto request);
|
||||
Task<bool> RemoveRoleAsync(Guid roleId);
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
namespace DocuMed.Core.EntityServices;
|
||||
|
||||
|
||||
public class UserService : IUserService
|
||||
{
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly RoleManager<ApplicationRole> _roleManager;
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public UserService(ICurrentUserService currentUserService,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
RoleManager<ApplicationRole> roleManager,
|
||||
IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_currentUserService = currentUserService;
|
||||
_userManager = userManager;
|
||||
_roleManager = roleManager;
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
|
||||
public async Task<List<ApplicationUserSDto>> GetUsersAsync(int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var users = await _userManager.Users.Select(ApplicationUserMapper.ProjectToSDto).ToListAsync(cancellationToken);
|
||||
|
||||
return users;
|
||||
}
|
||||
|
||||
public async Task<ApplicationUserSDto> GetUserAsync(Guid userId)
|
||||
=> (await _userManager.FindByIdAsync(userId.ToString())).AdaptToSDto();
|
||||
|
||||
public async Task<ApplicationUser> CreateUserAsync(string phoneNumber)
|
||||
{
|
||||
var user = new ApplicationUser
|
||||
{
|
||||
UserName = phoneNumber,
|
||||
PhoneNumber = phoneNumber,
|
||||
SignUpStatus = SignUpStatus.StartSignUp
|
||||
};
|
||||
var result = await _userManager.CreateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors));
|
||||
return user;
|
||||
}
|
||||
|
||||
public async Task<ApplicationUser> CreateUserAsync(UserActionRequestDto request, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = new ApplicationUser
|
||||
{
|
||||
UserName = request.PhoneNumber,
|
||||
PhoneNumber = request.PhoneNumber,
|
||||
FirstName = request.FirstName,
|
||||
LastName = request.LastName,
|
||||
NationalId = request.NationalId,
|
||||
BirthDate = request.BirthDate,
|
||||
Gender = request.Gender,
|
||||
SignUpStatus = SignUpStatus.SignUpCompleted,
|
||||
UniversityId = request.UniversityId
|
||||
};
|
||||
if (!request.Password.IsNullOrEmpty())
|
||||
{
|
||||
var result = await _userManager.CreateAsync(user, request.Password);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors));
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await _userManager.CreateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors));
|
||||
}
|
||||
|
||||
var roleResult = await _userManager.AddToRoleAsync(user, RoleNames.Student);
|
||||
if (!roleResult.Succeeded)
|
||||
throw new AppException(string.Join('|', roleResult.Errors));
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public async Task<bool> EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_currentUserService.UserId == null)
|
||||
throw new AppException("Wrong authorize token , UserId needed");
|
||||
|
||||
var user = await _userManager.FindByIdAsync(_currentUserService.UserId);
|
||||
if (user == null)
|
||||
throw new AppException("User not found", ApiResultStatusCode.NotFound);
|
||||
user.LastName = request.LastName;
|
||||
user.FirstName = request.FirstName;
|
||||
user.UserName = request.PhoneNumber;
|
||||
user.PhoneNumber = request.PhoneNumber;
|
||||
user.FirstName = request.FirstName;
|
||||
user.LastName = request.LastName;
|
||||
user.NationalId = request.NationalId;
|
||||
user.BirthDate = request.BirthDate;
|
||||
user.Gender = request.Gender;
|
||||
user.UniversityId = request.UniversityId;
|
||||
|
||||
var result = await _userManager.UpdateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors));
|
||||
if (!request.Password.IsNullOrEmpty())
|
||||
{
|
||||
if (await _userManager.HasPasswordAsync(user))
|
||||
await _userManager.RemovePasswordAsync(user);
|
||||
|
||||
var addPassResult = await _userManager.AddPasswordAsync(user, request.Password);
|
||||
if (!addPassResult.Succeeded)
|
||||
throw new AppException(string.Join('|', addPassResult.Errors));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> RemoveUserAsync(Guid userId, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = await _userManager.FindByIdAsync(userId.ToString());
|
||||
if (user == null)
|
||||
throw new AppException("User not found", ApiResultStatusCode.NotFound);
|
||||
var removeResult = await _userManager.DeleteAsync(user);
|
||||
if (!removeResult.Succeeded)
|
||||
throw new AppException(string.Join('|', removeResult.Errors));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
||||
var roles = await _roleManager.Roles
|
||||
.Skip(page * 15)
|
||||
.Take(15)
|
||||
.ToListAsync(cancellationToken);
|
||||
return roles;
|
||||
}
|
||||
|
||||
public async Task<RoleActionRequestDto> GetRoleAsync(Guid roleId)
|
||||
{
|
||||
var role = (await _roleManager.FindByIdAsync(roleId.ToString()));
|
||||
if (role == null)
|
||||
throw new AppException("نقش پیدا نشد", ApiResultStatusCode.NotFound);
|
||||
|
||||
var roleDto = role.Adapt<RoleActionRequestDto>();
|
||||
roleDto.Permissions = (await _roleManager.GetClaimsAsync(role))
|
||||
.Where(c => c.Type == CustomClaimType.Permission)
|
||||
.Select(c => c.Value)
|
||||
.ToList();
|
||||
|
||||
return roleDto;
|
||||
}
|
||||
|
||||
public async Task<ApplicationRole> CreateRoleAsync(RoleActionRequestDto request)
|
||||
{
|
||||
if (request.EnglishName.IsNullOrEmpty())
|
||||
throw new AppException("لطفا نام انگلیسی را وارد کنید");
|
||||
var applicationRole = new ApplicationRole
|
||||
{
|
||||
EnglishName = request.EnglishName,
|
||||
PersianName = request.PersianName,
|
||||
Description = request.Description,
|
||||
Name = $"{request.EnglishName}"
|
||||
};
|
||||
var createRoleResult = await _roleManager.CreateAsync(applicationRole);
|
||||
if (!createRoleResult.Succeeded)
|
||||
throw new AppException(string.Join('|', createRoleResult.Errors));
|
||||
|
||||
foreach (var claim in request.Permissions)
|
||||
await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim));
|
||||
return applicationRole;
|
||||
}
|
||||
|
||||
public async Task<bool> EditRoleAsync(RoleActionRequestDto request)
|
||||
{
|
||||
if (request.EnglishName.IsNullOrEmpty())
|
||||
throw new AppException("لطفا نام انگلیسی را وارد کنید");
|
||||
var applicationRole = await _roleManager.FindByIdAsync(request.RoleId.ToString());
|
||||
if (applicationRole == null)
|
||||
throw new AppException("نقش پیدا نشد");
|
||||
|
||||
applicationRole.EnglishName = request.EnglishName;
|
||||
applicationRole.PersianName = request.PersianName;
|
||||
applicationRole.Description = request.Description;
|
||||
applicationRole.Name = $"{request.EnglishName}";
|
||||
|
||||
var createRoleResult = await _roleManager.UpdateAsync(applicationRole);
|
||||
if (!createRoleResult.Succeeded)
|
||||
throw new AppException(string.Join('|', createRoleResult.Errors));
|
||||
var roleClaims = (await _roleManager.GetClaimsAsync(applicationRole)).Where(c => c.Type == CustomClaimType.Permission).ToList();
|
||||
foreach (var roleClaim in roleClaims.ToList())
|
||||
{
|
||||
if (request.Permissions.Contains(roleClaim.Value))
|
||||
{
|
||||
roleClaims.Remove(roleClaim);
|
||||
request.Permissions.Remove(roleClaim.Value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var claim in request.Permissions)
|
||||
await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim));
|
||||
|
||||
foreach (var claim in roleClaims)
|
||||
await _roleManager.RemoveClaimAsync(applicationRole, claim);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> RemoveRoleAsync(Guid roleId)
|
||||
{
|
||||
var applicationRole = await _roleManager.FindByIdAsync(roleId.ToString());
|
||||
if (applicationRole == null)
|
||||
throw new AppException("User not found", ApiResultStatusCode.NotFound);
|
||||
var removeResult = await _roleManager.DeleteAsync(applicationRole);
|
||||
if (!removeResult.Succeeded)
|
||||
throw new AppException(string.Join('|', removeResult.Errors));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<!--<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
@ -11,10 +11,10 @@
|
|||
<PackageReference Include="MediatR" Version="12.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="7.0.11" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||
</ItemGroup>
|
||||
</ItemGroup>-->
|
||||
|
||||
|
||||
<!--<PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -27,14 +27,14 @@
|
|||
<PackageReference Include="MediatR" Version="12.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||
</ItemGroup>-->
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="Mapster">
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet build" />
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet tool restore" />
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster extension -a "$(TargetDir)$(ProjectName).dll" -n Brizco.Domain.Mappers -o Mappers" />
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster mapper -a "$(TargetDir)$(ProjectName).dll" -n Brizco.Domain.Mappers -o Mappers" />
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster extension -a "$(TargetDir)$(ProjectName).dll" -n DocuMed.Domain.Mappers -o Mappers" />
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster mapper -a "$(TargetDir)$(ProjectName).dll" -n DocuMed.Domain.Mappers -o Mappers" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -42,10 +42,22 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dtos\LargDtos\" />
|
||||
<Folder Include="Dtos\ResponseDtos\" />
|
||||
<Folder Include="Dtos\RequestDtos\" />
|
||||
<Folder Include="Entities\City\" />
|
||||
<Folder Include="Entities\Patient\" />
|
||||
<Folder Include="Entities\User\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include=" DocuMed.Domain.Entities.MedicalHistoryTemplate" />
|
||||
<Using Include="DocuMed.Common.Models.Entity" />
|
||||
<Using Include="DocuMed.Common.Models.Mapper" />
|
||||
<Using Include="DocuMed.Domain.Dtos.SmallDtos" />
|
||||
<Using Include="DocuMed.Domain.Entities.City" />
|
||||
<Using Include="DocuMed.Domain.Entities.MedicalHistory" />
|
||||
<Using Include="DocuMed.Domain.Entities.User" />
|
||||
<Using Include="DocuMed.Domain.Enums" />
|
||||
<Using Include="Mapster" />
|
||||
<Using Include="Microsoft.AspNetCore.Identity" />
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
namespace DocuMed.Domain.Dtos.LargDtos;
|
||||
|
||||
public class CityLDto : BaseDto<CityLDto,City>
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public List<UniversitySDto> Universities { get; set; } = new();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
namespace DocuMed.Domain.Dtos.LargDtos;
|
||||
|
||||
public class MedicalHistoryLDto : BaseDto<MedicalHistoryLDto,MedicalHistory>
|
||||
{
|
||||
public string ChiefComplaint { get; set; } = string.Empty;
|
||||
public string Section { get; set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string FatherName { get; set; } = string.Empty;
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public int Age { get; set; }
|
||||
public DateTime BirthDate { get; set; }
|
||||
|
||||
public string PresentIllnessDetail { get; set; } = string.Empty;
|
||||
public string PastDiseasesHistoryDetail { get; set; } = string.Empty;
|
||||
public string PastSurgeryHistoryDetail { get; set; } = string.Empty;
|
||||
public string FamilyHistoryDetail { get; set; } = string.Empty;
|
||||
public string AllergyDetail { get; set; } = string.Empty;
|
||||
public string DrugHistoryDetail { get; set; } = string.Empty;
|
||||
public string AddictionHistoryDetail { get; set; } = string.Empty;
|
||||
public string SystemReviewDetail { get; set; } = string.Empty;
|
||||
public string VitalSignDetail { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public int SystolicBloodPressure { get; set; }
|
||||
public int DiastolicBloodPressure { get; set; }
|
||||
public int PulseRate { get; set; }
|
||||
public int SPO2 { get; set; }
|
||||
public int Temperature { get; set; }
|
||||
|
||||
public List<MedicalHistoryAnswerSDto> Answers { get; set; } = new();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
namespace DocuMed.Domain.Dtos.LargDtos;
|
||||
|
||||
public class MedicalHistoryTemplateLDto : BaseDto<MedicalHistoryTemplateLDto,MedicalHistoryTemplate>
|
||||
{
|
||||
|
||||
public string ChiefComplaint { get; set; } = string.Empty;
|
||||
public List<MedicalHistoryQuestionSDto> Questions { get; set; } = new();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
namespace DocuMed.Domain.Dtos.RequestDtos;
|
||||
|
||||
public class LoginRequestDto
|
||||
{
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string VerifyCode { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace DocuMed.Domain.Dtos.RequestDtos;
|
||||
|
||||
public class RoleActionRequestDto
|
||||
{
|
||||
public Guid RoleId { get; set; }
|
||||
public Guid UniversityId { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string EnglishName { get; set; } = string.Empty;
|
||||
public string PersianName { get; set; } = string.Empty;
|
||||
public List<string> Permissions { get; set; } = new();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace DocuMed.Domain.Dtos.RequestDtos;
|
||||
|
||||
public class SignUpRequestDto
|
||||
{
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public Guid UniversityId { get; set; }
|
||||
public Guid CityId { get; set; }
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
namespace DocuMed.Domain.Dtos.RequestDtos;
|
||||
public class UserActionRequestDto
|
||||
{
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public Guid RoleId { get; set; } = new();
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
public Guid UniversityId { get; set; }
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
namespace DocuMed.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class ApplicationUserSDto : BaseDto<ApplicationUserSDto,ApplicationUser>
|
||||
{
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
public bool PhoneNumberConfirmed { get; set; }
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public string Section { get; set; } = string.Empty;
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public SignUpStatus SignUpStatus { get; set; }
|
||||
public Guid UniversityId { get; set; }
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace DocuMed.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class CitySDto : BaseDto<CitySDto,City>
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
namespace DocuMed.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class MedicalHistoryAnswerSDto : BaseDto<MedicalHistoryAnswerSDto,MedicalHistoryAnswer>
|
||||
{
|
||||
public string Answer { get; set; } = string.Empty;
|
||||
public string Question { get; set; } = string.Empty;
|
||||
public MedicalHistoryPart Part { get; set; }
|
||||
public MedicalHistoryQuestionType QuestionType { get; set; }
|
||||
public Guid MedicalHistoryId { get; set; }
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace DocuMed.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class MedicalHistoryQuestionSDto : BaseDto<MedicalHistoryQuestionSDto,MedicalHistoryQuestion>
|
||||
{
|
||||
public string Question { get; set; } = string.Empty;
|
||||
public MedicalHistoryPart Part { get; set; }
|
||||
public MedicalHistoryQuestionType QuestionType { get; set; }
|
||||
public Guid MedicalHistoryTemplateId { get; set; }
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
namespace DocuMed.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class MedicalHistorySDto : BaseDto<MedicalHistorySDto,MedicalHistory>
|
||||
{
|
||||
public string ChiefComplaint { get; set; } = string.Empty;
|
||||
public string Section { get; set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string FatherName { get; set; } = string.Empty;
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public int Age { get; set; }
|
||||
public DateTime BirthDate { get; set; }
|
||||
|
||||
public string PresentIllnessDetail { get; set; } = string.Empty;
|
||||
public string PastDiseasesHistoryDetail { get; set; } = string.Empty;
|
||||
public string PastSurgeryHistoryDetail { get; set; } = string.Empty;
|
||||
public string FamilyHistoryDetail { get; set; } = string.Empty;
|
||||
public string AllergyDetail { get; set; } = string.Empty;
|
||||
public string DrugHistoryDetail { get; set; } = string.Empty;
|
||||
public string AddictionHistoryDetail { get; set; } = string.Empty;
|
||||
public string SystemReviewDetail { get; set; } = string.Empty;
|
||||
public string VitalSignDetail { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public int SystolicBloodPressure { get; set; }
|
||||
public int DiastolicBloodPressure { get; set; }
|
||||
public int PulseRate { get; set; }
|
||||
public int SPO2 { get; set; }
|
||||
public int Temperature { get; set; }
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace DocuMed.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class MedicalHistoryTemplateSDto : BaseDto<MedicalHistoryTemplateSDto,MedicalHistoryTemplate>
|
||||
{
|
||||
public string ChiefComplaint { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace DocuMed.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class UniversitySDto : BaseDto<UniversitySDto,University>
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
namespace DocuMed.Domain.Entities.City;
|
||||
|
||||
public partial class City
|
||||
{
|
||||
public static City Create(string name)
|
||||
{
|
||||
return new City(name);
|
||||
}
|
||||
|
||||
public University AddUniversity(string universityName, string universityAddress)
|
||||
{
|
||||
var university = University.Create(universityName, universityAddress, Id);
|
||||
Universities.Add(university);
|
||||
return university;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public partial class University
|
||||
{
|
||||
public static University Create(string name, string address, Guid cityId)
|
||||
{
|
||||
return new University(name, address, cityId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
namespace DocuMed.Domain.Entities.City;
|
||||
|
||||
public partial class City : ApiEntity
|
||||
{
|
||||
public City()
|
||||
{
|
||||
|
||||
}
|
||||
public City(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
|
||||
public List<University> Universities { get; internal set; } = new();
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
namespace DocuMed.Domain.Entities.City;
|
||||
|
||||
public partial class University : ApiEntity
|
||||
{
|
||||
public University()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public University(string name, string address, Guid cityId)
|
||||
{
|
||||
Name = name;
|
||||
Address = address;
|
||||
CityId = cityId;
|
||||
}
|
||||
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Address { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid CityId { get; internal set; }
|
||||
public City? City { get; internal set; }
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
namespace DocuMed.Domain.Entities.MedicalHistory;
|
||||
|
||||
|
||||
public partial class MedicalHistoryAnswer
|
||||
{
|
||||
public static MedicalHistoryAnswer Create(
|
||||
string answer,
|
||||
string question,
|
||||
MedicalHistoryPart part,
|
||||
MedicalHistoryQuestionType questionType,
|
||||
Guid medicalHistoryId)
|
||||
{
|
||||
return new MedicalHistoryAnswer(answer, question, part, questionType, medicalHistoryId);
|
||||
}
|
||||
}
|
||||
public partial class MedicalHistory
|
||||
{
|
||||
public MedicalHistoryAnswer AddAnswer(string answer, string question, MedicalHistoryPart part, MedicalHistoryQuestionType questionType)
|
||||
{
|
||||
var mhAnswer = MedicalHistoryAnswer.Create(answer, question, part, questionType, Id);
|
||||
Answers.Add(mhAnswer);
|
||||
return mhAnswer;
|
||||
}
|
||||
public static MedicalHistory Create(
|
||||
string chiefComplaint,
|
||||
string section,
|
||||
string firstName,
|
||||
string lastName,
|
||||
string fatherName,
|
||||
string nationalId,
|
||||
int age,
|
||||
DateTime birthDate,
|
||||
string presentIllnessDetail,
|
||||
string pastDiseasesHistoryDetail,
|
||||
string pastSurgeryHistoryDetail,
|
||||
string familyHistoryDetail,
|
||||
string allergyDetail,
|
||||
string drugHistoryDetail,
|
||||
string addictionHistoryDetail,
|
||||
string systemReviewDetail,
|
||||
string vitalSignDetail,
|
||||
int systolicBloodPressure,
|
||||
int diastolicBloodPressure,
|
||||
int pulseRate,
|
||||
int sPO2,
|
||||
int temperature)
|
||||
{
|
||||
return new MedicalHistory(presentIllnessDetail,
|
||||
pastDiseasesHistoryDetail,
|
||||
pastSurgeryHistoryDetail,
|
||||
familyHistoryDetail,
|
||||
allergyDetail,
|
||||
drugHistoryDetail,
|
||||
addictionHistoryDetail,
|
||||
systemReviewDetail,
|
||||
vitalSignDetail,
|
||||
chiefComplaint, section, firstName, lastName, fatherName, nationalId, age, birthDate, systolicBloodPressure,
|
||||
diastolicBloodPressure, pulseRate, sPO2, temperature);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
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)]
|
||||
[GenerateMapper]
|
||||
|
||||
public partial class MedicalHistory : ApiEntity
|
||||
{
|
||||
public MedicalHistory()
|
||||
{
|
||||
|
||||
}
|
||||
public MedicalHistory(
|
||||
string presentIllnessDetail,
|
||||
string pastDiseasesHistoryDetail,
|
||||
string pastSurgeryHistoryDetail,
|
||||
string familyHistoryDetail,
|
||||
string allergyDetail,
|
||||
string drugHistoryDetail,
|
||||
string addictionHistoryDetail,
|
||||
string systemReviewDetail,
|
||||
string vitalSignDetail,
|
||||
string chiefComplaint,
|
||||
string section,
|
||||
string firstName,
|
||||
string lastName,
|
||||
string fatherName,
|
||||
string nationalId,
|
||||
int age,
|
||||
DateTime birthDate,
|
||||
int systolicBloodPressure,
|
||||
int diastolicBloodPressure,
|
||||
int pulseRate,
|
||||
int spo2,
|
||||
int temperature)
|
||||
{
|
||||
PresentIllnessDetail = presentIllnessDetail;
|
||||
PastDiseasesHistoryDetail = pastDiseasesHistoryDetail;
|
||||
PastSurgeryHistoryDetail = pastSurgeryHistoryDetail;
|
||||
FamilyHistoryDetail = familyHistoryDetail;
|
||||
AllergyDetail = allergyDetail;
|
||||
DrugHistoryDetail = drugHistoryDetail;
|
||||
AddictionHistoryDetail = addictionHistoryDetail;
|
||||
SystemReviewDetail = systemReviewDetail;
|
||||
VitalSignDetail = vitalSignDetail;
|
||||
ChiefComplaint = chiefComplaint;
|
||||
Section = section;
|
||||
FirstName = firstName;
|
||||
LastName = lastName;
|
||||
FatherName = fatherName;
|
||||
NationalId = nationalId;
|
||||
Age = age;
|
||||
BirthDate = birthDate;
|
||||
SystolicBloodPressure = systolicBloodPressure;
|
||||
DiastolicBloodPressure = diastolicBloodPressure;
|
||||
PulseRate = pulseRate;
|
||||
SPO2 = spo2;
|
||||
Temperature = temperature;
|
||||
}
|
||||
public string ChiefComplaint { get; internal set; } = string.Empty;
|
||||
public string Section { get; internal set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; internal set; } = string.Empty;
|
||||
public string LastName { get; internal set; } = string.Empty;
|
||||
public string FatherName { get; internal set; } = string.Empty;
|
||||
public string NationalId { get; internal set; } = string.Empty;
|
||||
public int Age { get; internal set; }
|
||||
public DateTime BirthDate { get; internal set; }
|
||||
|
||||
public string PresentIllnessDetail { get; internal set; } = string.Empty;
|
||||
public string PastDiseasesHistoryDetail { get; internal set; } = string.Empty;
|
||||
public string PastSurgeryHistoryDetail { get; internal set; } = string.Empty;
|
||||
public string FamilyHistoryDetail { get; internal set; } = string.Empty;
|
||||
public string AllergyDetail { get; internal set; } = string.Empty;
|
||||
public string DrugHistoryDetail { get; internal set; } = string.Empty;
|
||||
public string AddictionHistoryDetail { get; internal set; } = string.Empty;
|
||||
public string SystemReviewDetail { get; internal set; } = string.Empty;
|
||||
public string VitalSignDetail { get; internal set; } = string.Empty;
|
||||
|
||||
|
||||
public int SystolicBloodPressure { get; internal set; }
|
||||
public int DiastolicBloodPressure { get; internal set; }
|
||||
public int PulseRate { get; internal set; }
|
||||
public int SPO2 { get; internal set; }
|
||||
public int Temperature { get; internal set; }
|
||||
|
||||
public List<MedicalHistoryAnswer> Answers { get; internal set; } = new();
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
namespace DocuMed.Domain.Entities.MedicalHistory;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class MedicalHistoryAnswer : ApiEntity
|
||||
{
|
||||
public MedicalHistoryAnswer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MedicalHistoryAnswer(
|
||||
string answer,
|
||||
string question,
|
||||
MedicalHistoryPart part,
|
||||
MedicalHistoryQuestionType questionType,
|
||||
Guid medicalHistoryId)
|
||||
{
|
||||
Answer = answer;
|
||||
Question = question;
|
||||
Part = part;
|
||||
QuestionType = questionType;
|
||||
MedicalHistoryId = medicalHistoryId;
|
||||
}
|
||||
public string Answer { get; internal set; } = string.Empty;
|
||||
public string Question { get; internal set; } = string.Empty;
|
||||
public MedicalHistoryPart Part { get; internal set; }
|
||||
public MedicalHistoryQuestionType QuestionType { get; internal set; }
|
||||
|
||||
public Guid MedicalHistoryId { get; internal set; }
|
||||
public MedicalHistory? MedicalHistory { get; internal set; }
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
namespace DocuMed.Domain.Entities.MedicalHistoryTemplate;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class MedicalHistoryQuestion : ApiEntity
|
||||
{
|
||||
public MedicalHistoryQuestion()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MedicalHistoryQuestion(
|
||||
string question,
|
||||
MedicalHistoryPart part,
|
||||
MedicalHistoryQuestionType questionType,
|
||||
Guid medicalHistoryTemplateId)
|
||||
{
|
||||
Question = question;
|
||||
Part = part;
|
||||
QuestionType = questionType;
|
||||
MedicalHistoryTemplateId = medicalHistoryTemplateId;
|
||||
}
|
||||
|
||||
public string Question { get; internal set; } = string.Empty;
|
||||
public MedicalHistoryPart Part { get; internal set; }
|
||||
public MedicalHistoryQuestionType QuestionType { get; internal set; }
|
||||
|
||||
public Guid MedicalHistoryTemplateId { get; internal set; }
|
||||
public MedicalHistoryTemplate? MedicalHistoryTemplate { get; internal set; }
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
namespace DocuMed.Domain.Entities.MedicalHistoryTemplate;
|
||||
|
||||
public partial class MedicalHistoryQuestion
|
||||
{
|
||||
public static MedicalHistoryQuestion Create(
|
||||
string question,
|
||||
MedicalHistoryPart part,
|
||||
MedicalHistoryQuestionType questionType,
|
||||
Guid medicalHistoryTemplateId)
|
||||
{
|
||||
return new MedicalHistoryQuestion(question, part, questionType, medicalHistoryTemplateId);
|
||||
}
|
||||
|
||||
}
|
||||
public partial class MedicalHistoryTemplate
|
||||
{
|
||||
public MedicalHistoryQuestion AddQuestion(
|
||||
string question,
|
||||
MedicalHistoryPart part,
|
||||
MedicalHistoryQuestionType questionType)
|
||||
{
|
||||
var mhQuestion = MedicalHistoryQuestion.Create(question, part, questionType, Id);
|
||||
Questions.Add(mhQuestion);
|
||||
return mhQuestion;
|
||||
}
|
||||
|
||||
public static MedicalHistoryTemplate Create(string chiefComplaint)
|
||||
{
|
||||
return new MedicalHistoryTemplate(chiefComplaint);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace DocuMed.Domain.Entities.MedicalHistoryTemplate;
|
||||
|
||||
[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 MedicalHistoryTemplate : ApiEntity
|
||||
{
|
||||
public MedicalHistoryTemplate()
|
||||
{
|
||||
|
||||
}
|
||||
public MedicalHistoryTemplate(string chiefComplaint)
|
||||
{
|
||||
ChiefComplaint = chiefComplaint;
|
||||
}
|
||||
|
||||
public string ChiefComplaint { get; internal set; } = string.Empty;
|
||||
|
||||
public List<MedicalHistoryQuestion> Questions { get; internal set; } = new();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
namespace DocuMed.Domain.Entities.Patient;
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class Patient
|
||||
{
|
||||
public string FirstName { get; internal set; } = string.Empty;
|
||||
public string LastName { get; internal set; } = string.Empty;
|
||||
public string FatherName { get; internal set; } = string.Empty;
|
||||
public string NationalId { get; internal set; } = string.Empty;
|
||||
public int Age { get; internal set; }
|
||||
public DateTime BirthDate { get; internal set; }
|
||||
}
|
|
@ -6,8 +6,12 @@ public class ApplicationUser : IdentityUser<Guid>
|
|||
{
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string InternationalId { get; set; } = string.Empty;
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public string Section { get; set; } = string.Empty;
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public SignUpStatus SignUpStatus { get; set; }
|
||||
|
||||
public Guid? UniversityId { get; set; }
|
||||
public University? University { get; set; }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
namespace DocuMed.Domain.Enums;
|
||||
|
||||
public enum MedicalHistoryPart
|
||||
{
|
||||
[Display(Name = "بیماری فعلی")]
|
||||
PresentIllness,
|
||||
[Display(Name = "تاریخچه بیماری های قبلی")]
|
||||
PastDiseasesHistory,
|
||||
[Display(Name = "تاریخچه جراحی های قبلی")]
|
||||
PastSurgeryHistory,
|
||||
[Display(Name = "تاریخچه بیماری های خانوادگی")]
|
||||
FamilyHistory,
|
||||
[Display(Name = "آلرژی")]
|
||||
Allergy,
|
||||
[Display(Name = "داروهای مصرفی")]
|
||||
DrugHistory,
|
||||
[Display(Name = "مواد مصرفی")]
|
||||
AddictionHistory,
|
||||
[Display(Name = "بررسی سیستماتیک")]
|
||||
SystemReview,
|
||||
[Display(Name = "علائم حیاتی")]
|
||||
VitalSign,
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace DocuMed.Domain.Enums;
|
||||
|
||||
public enum MedicalHistoryQuestionType
|
||||
{
|
||||
[Display(Name = "ساعتی")]
|
||||
Hourly,
|
||||
[Display(Name = "پرسش و پاسخ")]
|
||||
Interrogatively,
|
||||
[Display(Name = "بله و خیر")]
|
||||
YesOrNo
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using DocuMed.Domain.Dtos.SmallDtos;
|
||||
using DocuMed.Domain.Entities.User;
|
||||
|
||||
namespace DocuMed.Domain.Mappers
|
||||
{
|
||||
public static partial class ApplicationUserMapper
|
||||
{
|
||||
public static ApplicationUser AdaptToApplicationUser(this ApplicationUserSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new ApplicationUser()
|
||||
{
|
||||
FirstName = p1.FirstName,
|
||||
LastName = p1.LastName,
|
||||
NationalId = p1.NationalId,
|
||||
Section = p1.Section,
|
||||
BirthDate = p1.BirthDate,
|
||||
Gender = p1.Gender,
|
||||
SignUpStatus = p1.SignUpStatus,
|
||||
UniversityId = p1.UniversityId,
|
||||
Id = p1.Id,
|
||||
UserName = p1.UserName,
|
||||
Email = p1.Email,
|
||||
PhoneNumber = p1.PhoneNumber,
|
||||
PhoneNumberConfirmed = p1.PhoneNumberConfirmed
|
||||
};
|
||||
}
|
||||
public static ApplicationUser AdaptTo(this ApplicationUserSDto p2, ApplicationUser p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ApplicationUser result = p3 ?? new ApplicationUser();
|
||||
|
||||
result.FirstName = p2.FirstName;
|
||||
result.LastName = p2.LastName;
|
||||
result.NationalId = p2.NationalId;
|
||||
result.Section = p2.Section;
|
||||
result.BirthDate = p2.BirthDate;
|
||||
result.Gender = p2.Gender;
|
||||
result.SignUpStatus = p2.SignUpStatus;
|
||||
result.UniversityId = p2.UniversityId;
|
||||
result.Id = p2.Id;
|
||||
result.UserName = p2.UserName;
|
||||
result.Email = p2.Email;
|
||||
result.PhoneNumber = p2.PhoneNumber;
|
||||
result.PhoneNumberConfirmed = p2.PhoneNumberConfirmed;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<ApplicationUserSDto, ApplicationUser>> ProjectToApplicationUser => p4 => new ApplicationUser()
|
||||
{
|
||||
FirstName = p4.FirstName,
|
||||
LastName = p4.LastName,
|
||||
NationalId = p4.NationalId,
|
||||
Section = p4.Section,
|
||||
BirthDate = p4.BirthDate,
|
||||
Gender = p4.Gender,
|
||||
SignUpStatus = p4.SignUpStatus,
|
||||
UniversityId = p4.UniversityId,
|
||||
Id = p4.Id,
|
||||
UserName = p4.UserName,
|
||||
Email = p4.Email,
|
||||
PhoneNumber = p4.PhoneNumber,
|
||||
PhoneNumberConfirmed = p4.PhoneNumberConfirmed
|
||||
};
|
||||
public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p5)
|
||||
{
|
||||
return p5 == null ? null : new ApplicationUserSDto()
|
||||
{
|
||||
FirstName = p5.FirstName,
|
||||
LastName = p5.LastName,
|
||||
UserName = p5.UserName,
|
||||
Email = p5.Email,
|
||||
PhoneNumber = p5.PhoneNumber,
|
||||
PhoneNumberConfirmed = p5.PhoneNumberConfirmed,
|
||||
NationalId = p5.NationalId,
|
||||
Section = p5.Section,
|
||||
BirthDate = p5.BirthDate,
|
||||
Gender = p5.Gender,
|
||||
SignUpStatus = p5.SignUpStatus,
|
||||
UniversityId = p5.UniversityId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static ApplicationUserSDto AdaptTo(this ApplicationUser p6, ApplicationUserSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ApplicationUserSDto result = p7 ?? new ApplicationUserSDto();
|
||||
|
||||
result.FirstName = p6.FirstName;
|
||||
result.LastName = p6.LastName;
|
||||
result.UserName = p6.UserName;
|
||||
result.Email = p6.Email;
|
||||
result.PhoneNumber = p6.PhoneNumber;
|
||||
result.PhoneNumberConfirmed = p6.PhoneNumberConfirmed;
|
||||
result.NationalId = p6.NationalId;
|
||||
result.Section = p6.Section;
|
||||
result.BirthDate = p6.BirthDate;
|
||||
result.Gender = p6.Gender;
|
||||
result.SignUpStatus = p6.SignUpStatus;
|
||||
result.UniversityId = p6.UniversityId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<ApplicationUser, ApplicationUserSDto>> ProjectToSDto => p8 => new ApplicationUserSDto()
|
||||
{
|
||||
FirstName = p8.FirstName,
|
||||
LastName = p8.LastName,
|
||||
UserName = p8.UserName,
|
||||
Email = p8.Email,
|
||||
PhoneNumber = p8.PhoneNumber,
|
||||
PhoneNumberConfirmed = p8.PhoneNumberConfirmed,
|
||||
NationalId = p8.NationalId,
|
||||
Section = p8.Section,
|
||||
BirthDate = p8.BirthDate,
|
||||
Gender = p8.Gender,
|
||||
SignUpStatus = p8.SignUpStatus,
|
||||
UniversityId = p8.UniversityId,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using DocuMed.Domain.Dtos.SmallDtos;
|
||||
using DocuMed.Domain.Entities.MedicalHistory;
|
||||
|
||||
namespace DocuMed.Domain.Mappers
|
||||
{
|
||||
public static partial class MedicalHistoryAnswerMapper
|
||||
{
|
||||
public static MedicalHistoryAnswer AdaptToMedicalHistoryAnswer(this MedicalHistoryAnswerSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new MedicalHistoryAnswer()
|
||||
{
|
||||
Answer = p1.Answer,
|
||||
Question = p1.Question,
|
||||
Part = p1.Part,
|
||||
QuestionType = p1.QuestionType,
|
||||
MedicalHistoryId = p1.MedicalHistoryId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryAnswer AdaptTo(this MedicalHistoryAnswerSDto p2, MedicalHistoryAnswer p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryAnswer result = p3 ?? new MedicalHistoryAnswer();
|
||||
|
||||
result.Answer = p2.Answer;
|
||||
result.Question = p2.Question;
|
||||
result.Part = p2.Part;
|
||||
result.QuestionType = p2.QuestionType;
|
||||
result.MedicalHistoryId = p2.MedicalHistoryId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryAnswerSDto, MedicalHistoryAnswer>> ProjectToMedicalHistoryAnswer => p4 => new MedicalHistoryAnswer()
|
||||
{
|
||||
Answer = p4.Answer,
|
||||
Question = p4.Question,
|
||||
Part = p4.Part,
|
||||
QuestionType = p4.QuestionType,
|
||||
MedicalHistoryId = p4.MedicalHistoryId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static MedicalHistoryAnswerSDto AdaptToSDto(this MedicalHistoryAnswer p5)
|
||||
{
|
||||
return p5 == null ? null : new MedicalHistoryAnswerSDto()
|
||||
{
|
||||
Answer = p5.Answer,
|
||||
Question = p5.Question,
|
||||
Part = p5.Part,
|
||||
QuestionType = p5.QuestionType,
|
||||
MedicalHistoryId = p5.MedicalHistoryId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryAnswerSDto AdaptTo(this MedicalHistoryAnswer p6, MedicalHistoryAnswerSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryAnswerSDto result = p7 ?? new MedicalHistoryAnswerSDto();
|
||||
|
||||
result.Answer = p6.Answer;
|
||||
result.Question = p6.Question;
|
||||
result.Part = p6.Part;
|
||||
result.QuestionType = p6.QuestionType;
|
||||
result.MedicalHistoryId = p6.MedicalHistoryId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryAnswer, MedicalHistoryAnswerSDto>> ProjectToSDto => p8 => new MedicalHistoryAnswerSDto()
|
||||
{
|
||||
Answer = p8.Answer,
|
||||
Question = p8.Question,
|
||||
Part = p8.Part,
|
||||
QuestionType = p8.QuestionType,
|
||||
MedicalHistoryId = p8.MedicalHistoryId,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,508 @@
|
|||
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.MedicalHistory;
|
||||
|
||||
namespace DocuMed.Domain.Mappers
|
||||
{
|
||||
public static partial class MedicalHistoryMapper
|
||||
{
|
||||
public static MedicalHistory AdaptToMedicalHistory(this MedicalHistorySDto p1)
|
||||
{
|
||||
return p1 == null ? null : new MedicalHistory()
|
||||
{
|
||||
ChiefComplaint = p1.ChiefComplaint,
|
||||
Section = p1.Section,
|
||||
FirstName = p1.FirstName,
|
||||
LastName = p1.LastName,
|
||||
FatherName = p1.FatherName,
|
||||
NationalId = p1.NationalId,
|
||||
Age = p1.Age,
|
||||
BirthDate = p1.BirthDate,
|
||||
PresentIllnessDetail = p1.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p1.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p1.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p1.FamilyHistoryDetail,
|
||||
AllergyDetail = p1.AllergyDetail,
|
||||
DrugHistoryDetail = p1.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p1.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p1.SystemReviewDetail,
|
||||
VitalSignDetail = p1.VitalSignDetail,
|
||||
SystolicBloodPressure = p1.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p1.DiastolicBloodPressure,
|
||||
PulseRate = p1.PulseRate,
|
||||
SPO2 = p1.SPO2,
|
||||
Temperature = p1.Temperature,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistory AdaptTo(this MedicalHistorySDto p2, MedicalHistory p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistory result = p3 ?? new MedicalHistory();
|
||||
|
||||
result.ChiefComplaint = p2.ChiefComplaint;
|
||||
result.Section = p2.Section;
|
||||
result.FirstName = p2.FirstName;
|
||||
result.LastName = p2.LastName;
|
||||
result.FatherName = p2.FatherName;
|
||||
result.NationalId = p2.NationalId;
|
||||
result.Age = p2.Age;
|
||||
result.BirthDate = p2.BirthDate;
|
||||
result.PresentIllnessDetail = p2.PresentIllnessDetail;
|
||||
result.PastDiseasesHistoryDetail = p2.PastDiseasesHistoryDetail;
|
||||
result.PastSurgeryHistoryDetail = p2.PastSurgeryHistoryDetail;
|
||||
result.FamilyHistoryDetail = p2.FamilyHistoryDetail;
|
||||
result.AllergyDetail = p2.AllergyDetail;
|
||||
result.DrugHistoryDetail = p2.DrugHistoryDetail;
|
||||
result.AddictionHistoryDetail = p2.AddictionHistoryDetail;
|
||||
result.SystemReviewDetail = p2.SystemReviewDetail;
|
||||
result.VitalSignDetail = p2.VitalSignDetail;
|
||||
result.SystolicBloodPressure = p2.SystolicBloodPressure;
|
||||
result.DiastolicBloodPressure = p2.DiastolicBloodPressure;
|
||||
result.PulseRate = p2.PulseRate;
|
||||
result.SPO2 = p2.SPO2;
|
||||
result.Temperature = p2.Temperature;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistorySDto, MedicalHistory>> ProjectToMedicalHistory => p4 => new MedicalHistory()
|
||||
{
|
||||
ChiefComplaint = p4.ChiefComplaint,
|
||||
Section = p4.Section,
|
||||
FirstName = p4.FirstName,
|
||||
LastName = p4.LastName,
|
||||
FatherName = p4.FatherName,
|
||||
NationalId = p4.NationalId,
|
||||
Age = p4.Age,
|
||||
BirthDate = p4.BirthDate,
|
||||
PresentIllnessDetail = p4.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p4.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p4.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p4.FamilyHistoryDetail,
|
||||
AllergyDetail = p4.AllergyDetail,
|
||||
DrugHistoryDetail = p4.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p4.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p4.SystemReviewDetail,
|
||||
VitalSignDetail = p4.VitalSignDetail,
|
||||
SystolicBloodPressure = p4.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p4.DiastolicBloodPressure,
|
||||
PulseRate = p4.PulseRate,
|
||||
SPO2 = p4.SPO2,
|
||||
Temperature = p4.Temperature,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p5)
|
||||
{
|
||||
return p5 == null ? null : new MedicalHistorySDto()
|
||||
{
|
||||
ChiefComplaint = p5.ChiefComplaint,
|
||||
Section = p5.Section,
|
||||
FirstName = p5.FirstName,
|
||||
LastName = p5.LastName,
|
||||
FatherName = p5.FatherName,
|
||||
NationalId = p5.NationalId,
|
||||
Age = p5.Age,
|
||||
BirthDate = p5.BirthDate,
|
||||
PresentIllnessDetail = p5.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p5.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p5.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p5.FamilyHistoryDetail,
|
||||
AllergyDetail = p5.AllergyDetail,
|
||||
DrugHistoryDetail = p5.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p5.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p5.SystemReviewDetail,
|
||||
VitalSignDetail = p5.VitalSignDetail,
|
||||
SystolicBloodPressure = p5.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p5.DiastolicBloodPressure,
|
||||
PulseRate = p5.PulseRate,
|
||||
SPO2 = p5.SPO2,
|
||||
Temperature = p5.Temperature,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistorySDto AdaptTo(this MedicalHistory p6, MedicalHistorySDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistorySDto result = p7 ?? new MedicalHistorySDto();
|
||||
|
||||
result.ChiefComplaint = p6.ChiefComplaint;
|
||||
result.Section = p6.Section;
|
||||
result.FirstName = p6.FirstName;
|
||||
result.LastName = p6.LastName;
|
||||
result.FatherName = p6.FatherName;
|
||||
result.NationalId = p6.NationalId;
|
||||
result.Age = p6.Age;
|
||||
result.BirthDate = p6.BirthDate;
|
||||
result.PresentIllnessDetail = p6.PresentIllnessDetail;
|
||||
result.PastDiseasesHistoryDetail = p6.PastDiseasesHistoryDetail;
|
||||
result.PastSurgeryHistoryDetail = p6.PastSurgeryHistoryDetail;
|
||||
result.FamilyHistoryDetail = p6.FamilyHistoryDetail;
|
||||
result.AllergyDetail = p6.AllergyDetail;
|
||||
result.DrugHistoryDetail = p6.DrugHistoryDetail;
|
||||
result.AddictionHistoryDetail = p6.AddictionHistoryDetail;
|
||||
result.SystemReviewDetail = p6.SystemReviewDetail;
|
||||
result.VitalSignDetail = p6.VitalSignDetail;
|
||||
result.SystolicBloodPressure = p6.SystolicBloodPressure;
|
||||
result.DiastolicBloodPressure = p6.DiastolicBloodPressure;
|
||||
result.PulseRate = p6.PulseRate;
|
||||
result.SPO2 = p6.SPO2;
|
||||
result.Temperature = p6.Temperature;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistory, MedicalHistorySDto>> ProjectToSDto => p8 => new MedicalHistorySDto()
|
||||
{
|
||||
ChiefComplaint = p8.ChiefComplaint,
|
||||
Section = p8.Section,
|
||||
FirstName = p8.FirstName,
|
||||
LastName = p8.LastName,
|
||||
FatherName = p8.FatherName,
|
||||
NationalId = p8.NationalId,
|
||||
Age = p8.Age,
|
||||
BirthDate = p8.BirthDate,
|
||||
PresentIllnessDetail = p8.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p8.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p8.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p8.FamilyHistoryDetail,
|
||||
AllergyDetail = p8.AllergyDetail,
|
||||
DrugHistoryDetail = p8.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p8.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p8.SystemReviewDetail,
|
||||
VitalSignDetail = p8.VitalSignDetail,
|
||||
SystolicBloodPressure = p8.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p8.DiastolicBloodPressure,
|
||||
PulseRate = p8.PulseRate,
|
||||
SPO2 = p8.SPO2,
|
||||
Temperature = p8.Temperature,
|
||||
Id = p8.Id
|
||||
};
|
||||
public static MedicalHistory AdaptToMedicalHistory(this MedicalHistoryLDto p9)
|
||||
{
|
||||
return p9 == null ? null : new MedicalHistory()
|
||||
{
|
||||
ChiefComplaint = p9.ChiefComplaint,
|
||||
Section = p9.Section,
|
||||
FirstName = p9.FirstName,
|
||||
LastName = p9.LastName,
|
||||
FatherName = p9.FatherName,
|
||||
NationalId = p9.NationalId,
|
||||
Age = p9.Age,
|
||||
BirthDate = p9.BirthDate,
|
||||
PresentIllnessDetail = p9.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p9.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p9.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p9.FamilyHistoryDetail,
|
||||
AllergyDetail = p9.AllergyDetail,
|
||||
DrugHistoryDetail = p9.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p9.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p9.SystemReviewDetail,
|
||||
VitalSignDetail = p9.VitalSignDetail,
|
||||
SystolicBloodPressure = p9.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p9.DiastolicBloodPressure,
|
||||
PulseRate = p9.PulseRate,
|
||||
SPO2 = p9.SPO2,
|
||||
Temperature = p9.Temperature,
|
||||
Answers = funcMain1(p9.Answers),
|
||||
Id = p9.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistory AdaptTo(this MedicalHistoryLDto p11, MedicalHistory p12)
|
||||
{
|
||||
if (p11 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistory result = p12 ?? new MedicalHistory();
|
||||
|
||||
result.ChiefComplaint = p11.ChiefComplaint;
|
||||
result.Section = p11.Section;
|
||||
result.FirstName = p11.FirstName;
|
||||
result.LastName = p11.LastName;
|
||||
result.FatherName = p11.FatherName;
|
||||
result.NationalId = p11.NationalId;
|
||||
result.Age = p11.Age;
|
||||
result.BirthDate = p11.BirthDate;
|
||||
result.PresentIllnessDetail = p11.PresentIllnessDetail;
|
||||
result.PastDiseasesHistoryDetail = p11.PastDiseasesHistoryDetail;
|
||||
result.PastSurgeryHistoryDetail = p11.PastSurgeryHistoryDetail;
|
||||
result.FamilyHistoryDetail = p11.FamilyHistoryDetail;
|
||||
result.AllergyDetail = p11.AllergyDetail;
|
||||
result.DrugHistoryDetail = p11.DrugHistoryDetail;
|
||||
result.AddictionHistoryDetail = p11.AddictionHistoryDetail;
|
||||
result.SystemReviewDetail = p11.SystemReviewDetail;
|
||||
result.VitalSignDetail = p11.VitalSignDetail;
|
||||
result.SystolicBloodPressure = p11.SystolicBloodPressure;
|
||||
result.DiastolicBloodPressure = p11.DiastolicBloodPressure;
|
||||
result.PulseRate = p11.PulseRate;
|
||||
result.SPO2 = p11.SPO2;
|
||||
result.Temperature = p11.Temperature;
|
||||
result.Answers = funcMain2(p11.Answers, result.Answers);
|
||||
result.Id = p11.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryLDto, MedicalHistory>> ProjectLDtoToMedicalHistory => p15 => new MedicalHistory()
|
||||
{
|
||||
ChiefComplaint = p15.ChiefComplaint,
|
||||
Section = p15.Section,
|
||||
FirstName = p15.FirstName,
|
||||
LastName = p15.LastName,
|
||||
FatherName = p15.FatherName,
|
||||
NationalId = p15.NationalId,
|
||||
Age = p15.Age,
|
||||
BirthDate = p15.BirthDate,
|
||||
PresentIllnessDetail = p15.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p15.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p15.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p15.FamilyHistoryDetail,
|
||||
AllergyDetail = p15.AllergyDetail,
|
||||
DrugHistoryDetail = p15.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p15.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p15.SystemReviewDetail,
|
||||
VitalSignDetail = p15.VitalSignDetail,
|
||||
SystolicBloodPressure = p15.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p15.DiastolicBloodPressure,
|
||||
PulseRate = p15.PulseRate,
|
||||
SPO2 = p15.SPO2,
|
||||
Temperature = p15.Temperature,
|
||||
Answers = p15.Answers.Select<MedicalHistoryAnswerSDto, MedicalHistoryAnswer>(p16 => new MedicalHistoryAnswer()
|
||||
{
|
||||
Answer = p16.Answer,
|
||||
Question = p16.Question,
|
||||
Part = p16.Part,
|
||||
QuestionType = p16.QuestionType,
|
||||
MedicalHistoryId = p16.MedicalHistoryId,
|
||||
Id = p16.Id
|
||||
}).ToList<MedicalHistoryAnswer>(),
|
||||
Id = p15.Id
|
||||
};
|
||||
public static MedicalHistoryLDto AdaptToLDto(this MedicalHistory p17)
|
||||
{
|
||||
return p17 == null ? null : new MedicalHistoryLDto()
|
||||
{
|
||||
ChiefComplaint = p17.ChiefComplaint,
|
||||
Section = p17.Section,
|
||||
FirstName = p17.FirstName,
|
||||
LastName = p17.LastName,
|
||||
FatherName = p17.FatherName,
|
||||
NationalId = p17.NationalId,
|
||||
Age = p17.Age,
|
||||
BirthDate = p17.BirthDate,
|
||||
PresentIllnessDetail = p17.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p17.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p17.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p17.FamilyHistoryDetail,
|
||||
AllergyDetail = p17.AllergyDetail,
|
||||
DrugHistoryDetail = p17.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p17.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p17.SystemReviewDetail,
|
||||
VitalSignDetail = p17.VitalSignDetail,
|
||||
SystolicBloodPressure = p17.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p17.DiastolicBloodPressure,
|
||||
PulseRate = p17.PulseRate,
|
||||
SPO2 = p17.SPO2,
|
||||
Temperature = p17.Temperature,
|
||||
Answers = funcMain3(p17.Answers),
|
||||
Id = p17.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryLDto AdaptTo(this MedicalHistory p19, MedicalHistoryLDto p20)
|
||||
{
|
||||
if (p19 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryLDto result = p20 ?? new MedicalHistoryLDto();
|
||||
|
||||
result.ChiefComplaint = p19.ChiefComplaint;
|
||||
result.Section = p19.Section;
|
||||
result.FirstName = p19.FirstName;
|
||||
result.LastName = p19.LastName;
|
||||
result.FatherName = p19.FatherName;
|
||||
result.NationalId = p19.NationalId;
|
||||
result.Age = p19.Age;
|
||||
result.BirthDate = p19.BirthDate;
|
||||
result.PresentIllnessDetail = p19.PresentIllnessDetail;
|
||||
result.PastDiseasesHistoryDetail = p19.PastDiseasesHistoryDetail;
|
||||
result.PastSurgeryHistoryDetail = p19.PastSurgeryHistoryDetail;
|
||||
result.FamilyHistoryDetail = p19.FamilyHistoryDetail;
|
||||
result.AllergyDetail = p19.AllergyDetail;
|
||||
result.DrugHistoryDetail = p19.DrugHistoryDetail;
|
||||
result.AddictionHistoryDetail = p19.AddictionHistoryDetail;
|
||||
result.SystemReviewDetail = p19.SystemReviewDetail;
|
||||
result.VitalSignDetail = p19.VitalSignDetail;
|
||||
result.SystolicBloodPressure = p19.SystolicBloodPressure;
|
||||
result.DiastolicBloodPressure = p19.DiastolicBloodPressure;
|
||||
result.PulseRate = p19.PulseRate;
|
||||
result.SPO2 = p19.SPO2;
|
||||
result.Temperature = p19.Temperature;
|
||||
result.Answers = funcMain4(p19.Answers, result.Answers);
|
||||
result.Id = p19.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistory, MedicalHistoryLDto>> ProjectToLDto => p23 => new MedicalHistoryLDto()
|
||||
{
|
||||
ChiefComplaint = p23.ChiefComplaint,
|
||||
Section = p23.Section,
|
||||
FirstName = p23.FirstName,
|
||||
LastName = p23.LastName,
|
||||
FatherName = p23.FatherName,
|
||||
NationalId = p23.NationalId,
|
||||
Age = p23.Age,
|
||||
BirthDate = p23.BirthDate,
|
||||
PresentIllnessDetail = p23.PresentIllnessDetail,
|
||||
PastDiseasesHistoryDetail = p23.PastDiseasesHistoryDetail,
|
||||
PastSurgeryHistoryDetail = p23.PastSurgeryHistoryDetail,
|
||||
FamilyHistoryDetail = p23.FamilyHistoryDetail,
|
||||
AllergyDetail = p23.AllergyDetail,
|
||||
DrugHistoryDetail = p23.DrugHistoryDetail,
|
||||
AddictionHistoryDetail = p23.AddictionHistoryDetail,
|
||||
SystemReviewDetail = p23.SystemReviewDetail,
|
||||
VitalSignDetail = p23.VitalSignDetail,
|
||||
SystolicBloodPressure = p23.SystolicBloodPressure,
|
||||
DiastolicBloodPressure = p23.DiastolicBloodPressure,
|
||||
PulseRate = p23.PulseRate,
|
||||
SPO2 = p23.SPO2,
|
||||
Temperature = p23.Temperature,
|
||||
Answers = p23.Answers.Select<MedicalHistoryAnswer, MedicalHistoryAnswerSDto>(p24 => new MedicalHistoryAnswerSDto()
|
||||
{
|
||||
Answer = p24.Answer,
|
||||
Question = p24.Question,
|
||||
Part = p24.Part,
|
||||
QuestionType = p24.QuestionType,
|
||||
MedicalHistoryId = p24.MedicalHistoryId,
|
||||
Id = p24.Id
|
||||
}).ToList<MedicalHistoryAnswerSDto>(),
|
||||
Id = p23.Id
|
||||
};
|
||||
|
||||
private static List<MedicalHistoryAnswer> funcMain1(List<MedicalHistoryAnswerSDto> p10)
|
||||
{
|
||||
if (p10 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryAnswer> result = new List<MedicalHistoryAnswer>(p10.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p10.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryAnswerSDto item = p10[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryAnswer()
|
||||
{
|
||||
Answer = item.Answer,
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryId = item.MedicalHistoryId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<MedicalHistoryAnswer> funcMain2(List<MedicalHistoryAnswerSDto> p13, List<MedicalHistoryAnswer> p14)
|
||||
{
|
||||
if (p13 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryAnswer> result = new List<MedicalHistoryAnswer>(p13.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p13.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryAnswerSDto item = p13[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryAnswer()
|
||||
{
|
||||
Answer = item.Answer,
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryId = item.MedicalHistoryId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<MedicalHistoryAnswerSDto> funcMain3(List<MedicalHistoryAnswer> p18)
|
||||
{
|
||||
if (p18 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryAnswerSDto> result = new List<MedicalHistoryAnswerSDto>(p18.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p18.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryAnswer item = p18[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryAnswerSDto()
|
||||
{
|
||||
Answer = item.Answer,
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryId = item.MedicalHistoryId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<MedicalHistoryAnswerSDto> funcMain4(List<MedicalHistoryAnswer> p21, List<MedicalHistoryAnswerSDto> p22)
|
||||
{
|
||||
if (p21 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryAnswerSDto> result = new List<MedicalHistoryAnswerSDto>(p21.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p21.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryAnswer item = p21[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryAnswerSDto()
|
||||
{
|
||||
Answer = item.Answer,
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryId = item.MedicalHistoryId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using DocuMed.Domain.Dtos.SmallDtos;
|
||||
using DocuMed.Domain.Entities.MedicalHistoryTemplate;
|
||||
|
||||
namespace DocuMed.Domain.Mappers
|
||||
{
|
||||
public static partial class MedicalHistoryQuestionMapper
|
||||
{
|
||||
public static MedicalHistoryQuestion AdaptToMedicalHistoryQuestion(this MedicalHistoryQuestionSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new MedicalHistoryQuestion()
|
||||
{
|
||||
Question = p1.Question,
|
||||
Part = p1.Part,
|
||||
QuestionType = p1.QuestionType,
|
||||
MedicalHistoryTemplateId = p1.MedicalHistoryTemplateId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryQuestion AdaptTo(this MedicalHistoryQuestionSDto p2, MedicalHistoryQuestion p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryQuestion result = p3 ?? new MedicalHistoryQuestion();
|
||||
|
||||
result.Question = p2.Question;
|
||||
result.Part = p2.Part;
|
||||
result.QuestionType = p2.QuestionType;
|
||||
result.MedicalHistoryTemplateId = p2.MedicalHistoryTemplateId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>> ProjectToMedicalHistoryQuestion => p4 => new MedicalHistoryQuestion()
|
||||
{
|
||||
Question = p4.Question,
|
||||
Part = p4.Part,
|
||||
QuestionType = p4.QuestionType,
|
||||
MedicalHistoryTemplateId = p4.MedicalHistoryTemplateId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static MedicalHistoryQuestionSDto AdaptToSDto(this MedicalHistoryQuestion p5)
|
||||
{
|
||||
return p5 == null ? null : new MedicalHistoryQuestionSDto()
|
||||
{
|
||||
Question = p5.Question,
|
||||
Part = p5.Part,
|
||||
QuestionType = p5.QuestionType,
|
||||
MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p6, MedicalHistoryQuestionSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryQuestionSDto result = p7 ?? new MedicalHistoryQuestionSDto();
|
||||
|
||||
result.Question = p6.Question;
|
||||
result.Part = p6.Part;
|
||||
result.QuestionType = p6.QuestionType;
|
||||
result.MedicalHistoryTemplateId = p6.MedicalHistoryTemplateId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>> ProjectToSDto => p8 => new MedicalHistoryQuestionSDto()
|
||||
{
|
||||
Question = p8.Question,
|
||||
Part = p8.Part,
|
||||
QuestionType = p8.QuestionType,
|
||||
MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
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.MedicalHistoryTemplate;
|
||||
|
||||
namespace DocuMed.Domain.Mappers
|
||||
{
|
||||
public static partial class MedicalHistoryTemplateMapper
|
||||
{
|
||||
public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new MedicalHistoryTemplate()
|
||||
{
|
||||
ChiefComplaint = p1.ChiefComplaint,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateSDto p2, MedicalHistoryTemplate p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryTemplate result = p3 ?? new MedicalHistoryTemplate();
|
||||
|
||||
result.ChiefComplaint = p2.ChiefComplaint;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryTemplateSDto, MedicalHistoryTemplate>> ProjectToMedicalHistoryTemplate => p4 => new MedicalHistoryTemplate()
|
||||
{
|
||||
ChiefComplaint = p4.ChiefComplaint,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static MedicalHistoryTemplateSDto AdaptToSDto(this MedicalHistoryTemplate p5)
|
||||
{
|
||||
return p5 == null ? null : new MedicalHistoryTemplateSDto()
|
||||
{
|
||||
ChiefComplaint = p5.ChiefComplaint,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryTemplateSDto AdaptTo(this MedicalHistoryTemplate p6, MedicalHistoryTemplateSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryTemplateSDto result = p7 ?? new MedicalHistoryTemplateSDto();
|
||||
|
||||
result.ChiefComplaint = p6.ChiefComplaint;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryTemplate, MedicalHistoryTemplateSDto>> ProjectToSDto => p8 => new MedicalHistoryTemplateSDto()
|
||||
{
|
||||
ChiefComplaint = p8.ChiefComplaint,
|
||||
Id = p8.Id
|
||||
};
|
||||
public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateLDto p9)
|
||||
{
|
||||
return p9 == null ? null : new MedicalHistoryTemplate()
|
||||
{
|
||||
ChiefComplaint = p9.ChiefComplaint,
|
||||
Questions = funcMain1(p9.Questions),
|
||||
Id = p9.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateLDto p11, MedicalHistoryTemplate p12)
|
||||
{
|
||||
if (p11 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryTemplate result = p12 ?? new MedicalHistoryTemplate();
|
||||
|
||||
result.ChiefComplaint = p11.ChiefComplaint;
|
||||
result.Questions = funcMain2(p11.Questions, result.Questions);
|
||||
result.Id = p11.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryTemplateLDto, MedicalHistoryTemplate>> ProjectLDtoToMedicalHistoryTemplate => p15 => new MedicalHistoryTemplate()
|
||||
{
|
||||
ChiefComplaint = p15.ChiefComplaint,
|
||||
Questions = p15.Questions.Select<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>(p16 => new MedicalHistoryQuestion()
|
||||
{
|
||||
Question = p16.Question,
|
||||
Part = p16.Part,
|
||||
QuestionType = p16.QuestionType,
|
||||
MedicalHistoryTemplateId = p16.MedicalHistoryTemplateId,
|
||||
Id = p16.Id
|
||||
}).ToList<MedicalHistoryQuestion>(),
|
||||
Id = p15.Id
|
||||
};
|
||||
public static MedicalHistoryTemplateLDto AdaptToLDto(this MedicalHistoryTemplate p17)
|
||||
{
|
||||
return p17 == null ? null : new MedicalHistoryTemplateLDto()
|
||||
{
|
||||
ChiefComplaint = p17.ChiefComplaint,
|
||||
Questions = funcMain3(p17.Questions),
|
||||
Id = p17.Id
|
||||
};
|
||||
}
|
||||
public static MedicalHistoryTemplateLDto AdaptTo(this MedicalHistoryTemplate p19, MedicalHistoryTemplateLDto p20)
|
||||
{
|
||||
if (p19 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MedicalHistoryTemplateLDto result = p20 ?? new MedicalHistoryTemplateLDto();
|
||||
|
||||
result.ChiefComplaint = p19.ChiefComplaint;
|
||||
result.Questions = funcMain4(p19.Questions, result.Questions);
|
||||
result.Id = p19.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<MedicalHistoryTemplate, MedicalHistoryTemplateLDto>> ProjectToLDto => p23 => new MedicalHistoryTemplateLDto()
|
||||
{
|
||||
ChiefComplaint = p23.ChiefComplaint,
|
||||
Questions = p23.Questions.Select<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>(p24 => new MedicalHistoryQuestionSDto()
|
||||
{
|
||||
Question = p24.Question,
|
||||
Part = p24.Part,
|
||||
QuestionType = p24.QuestionType,
|
||||
MedicalHistoryTemplateId = p24.MedicalHistoryTemplateId,
|
||||
Id = p24.Id
|
||||
}).ToList<MedicalHistoryQuestionSDto>(),
|
||||
Id = p23.Id
|
||||
};
|
||||
|
||||
private static List<MedicalHistoryQuestion> funcMain1(List<MedicalHistoryQuestionSDto> p10)
|
||||
{
|
||||
if (p10 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p10.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p10.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryQuestionSDto item = p10[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryQuestion()
|
||||
{
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<MedicalHistoryQuestion> funcMain2(List<MedicalHistoryQuestionSDto> p13, List<MedicalHistoryQuestion> p14)
|
||||
{
|
||||
if (p13 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p13.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p13.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryQuestionSDto item = p13[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryQuestion()
|
||||
{
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<MedicalHistoryQuestionSDto> funcMain3(List<MedicalHistoryQuestion> p18)
|
||||
{
|
||||
if (p18 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p18.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p18.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryQuestion item = p18[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
|
||||
{
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<MedicalHistoryQuestionSDto> funcMain4(List<MedicalHistoryQuestion> p21, List<MedicalHistoryQuestionSDto> p22)
|
||||
{
|
||||
if (p21 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p21.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p21.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
MedicalHistoryQuestion item = p21[i];
|
||||
result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
|
||||
{
|
||||
Question = item.Question,
|
||||
Part = item.Part,
|
||||
QuestionType = item.QuestionType,
|
||||
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace DocuMed.Domain.Mappers
|
||||
{
|
||||
public static partial class PatientMapper
|
||||
{
|
||||
}
|
||||
}
|
|
@ -15,7 +15,23 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Models\RestApi\KaveNegar\" />
|
||||
<Folder Include="RestServices\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="DocuMed.Common.Models" />
|
||||
<Using Include="DocuMed.Common.Models.Api" />
|
||||
<Using Include="DocuMed.Common.Models.Exception" />
|
||||
<Using Include="DocuMed.Core.Abstracts" />
|
||||
<Using Include="DocuMed.Domain.Models.Settings" />
|
||||
<Using Include="DocuMed.Infrastructure.Models" />
|
||||
<Using Include="DocuMed.Infrastructure.Models.RestApi.KaveNegar" />
|
||||
<Using Include="DocuMed.Infrastructure.RestServices" />
|
||||
<Using Include="Microsoft.Extensions.Logging" />
|
||||
<Using Include="Microsoft.Extensions.Options" />
|
||||
<Using Include="Refit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
namespace DocuMed.Infrastructure.Models;
|
||||
|
||||
public static class RestAddress
|
||||
{
|
||||
public static string BaseKaveNegar { get => "https://api.kavenegar.com/v1/"; }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace DocuMed.Infrastructure.Models.RestApi.KaveNegar;
|
||||
|
||||
public class KaveNegarResponse
|
||||
{
|
||||
public KaveNegarReturn? Return { get; set; }
|
||||
public KaveNegarResponseEntry[] entries { get; set; }
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
namespace DocuMed.Infrastructure.Models.RestApi.KaveNegar;
|
||||
|
||||
public class KaveNegarResponseEntry
|
||||
{
|
||||
public int messageid { get; set; }
|
||||
public string message { get; set; }
|
||||
public int status { get; set; }
|
||||
public string statustext { get; set; }
|
||||
public string sender { get; set; }
|
||||
public string receptor { get; set; }
|
||||
public int date { get; set; }
|
||||
public int cost { get; set; }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace DocuMed.Infrastructure.Models.RestApi.KaveNegar;
|
||||
|
||||
public class KaveNegarReturn
|
||||
{
|
||||
public int status { get; set; }
|
||||
public string message { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
namespace DocuMed.Infrastructure.RestServices;
|
||||
|
||||
public interface IKaveNegarRestApi
|
||||
{
|
||||
|
||||
[Post("/{apiKey}/verify/lookup.json")]
|
||||
Task<KaveNegarResponse> SendLookUp(string apiKey, [Query] string receptor, [Query] string token, [Query] string token2, [Query] string token10, [Query] string token20, [Query] string template);
|
||||
[Post("/{apiKey}/sms/send.json")]
|
||||
Task<KaveNegarResponse> SendSms(string apiKey, [Query] string receptor, [Query] string message, [Query] string sender);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace DocuMed.Infrastructure.RestServices;
|
||||
|
||||
public interface IRestApiWrapper : IScopedDependency
|
||||
{
|
||||
IKaveNegarRestApi KaveNegarRestApi { get; }
|
||||
}
|
||||
|
||||
public class RestApiWrapper : IRestApiWrapper
|
||||
{
|
||||
public IKaveNegarRestApi KaveNegarRestApi => RestService.For<IKaveNegarRestApi>(RestAddress.BaseKaveNegar);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
namespace DocuMed.Infrastructure.Services;
|
||||
|
||||
|
||||
public class SmsService : ISmsService
|
||||
{
|
||||
private readonly IRestApiWrapper _restApiWrapper;
|
||||
private readonly ILogger<SmsService> _logger;
|
||||
private readonly SiteSettings _siteSettings;
|
||||
public SmsService(IRestApiWrapper restApiWrapper,
|
||||
IOptionsSnapshot<SiteSettings> optionsSnapshot,
|
||||
ILogger<SmsService> logger)
|
||||
{
|
||||
_restApiWrapper = restApiWrapper;
|
||||
_logger = logger;
|
||||
_siteSettings = optionsSnapshot.Value;
|
||||
}
|
||||
public async Task SendForgerPasswordAsync(string phoneNumber, string newPassword)
|
||||
{
|
||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, newPassword, null, null, null, "forgetPassword");
|
||||
|
||||
if (rest.Return?.status != 200)
|
||||
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message);
|
||||
}
|
||||
|
||||
public async Task SendVerifyCodeAsync(string phoneNumber, string verifyCode)
|
||||
{
|
||||
|
||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, verifyCode, null, null, null, "login");
|
||||
|
||||
if (rest.Return?.status != 200)
|
||||
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message);
|
||||
}
|
||||
|
||||
}
|
|
@ -5,4 +5,5 @@ public interface ICurrentUserService : IScopedDependency
|
|||
string? UserId { get; }
|
||||
string? RoleName { get; }
|
||||
string? UserName { get; }
|
||||
string? UniversityId { get; }
|
||||
}
|
12
DocuMed.sln
12
DocuMed.sln
|
@ -5,17 +5,17 @@ VisualStudioVersion = 17.7.34024.191
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.PWA", "DocuMed.PWA\DocuMed.PWA.csproj", "{062950CA-0B06-4924-8C43-90C72455B306}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocuMed.Api", "DocuMed.Api\DocuMed.Api.csproj", "{BEA3A628-15E5-4733-851D-37E3C8B13169}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.Api", "DocuMed.Api\DocuMed.Api.csproj", "{BEA3A628-15E5-4733-851D-37E3C8B13169}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocuMed.Common", "DocuMed.Common\DocuMed.Common.csproj", "{4A71B4B9-5D7C-4DE9-ADB9-16D23B6771AA}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.Common", "DocuMed.Common\DocuMed.Common.csproj", "{4A71B4B9-5D7C-4DE9-ADB9-16D23B6771AA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocuMed.Core", "DocuMed.Core\DocuMed.Core.csproj", "{4FA77EEF-B056-4E65-AE55-FBA540AF6507}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.Core", "DocuMed.Core\DocuMed.Core.csproj", "{4FA77EEF-B056-4E65-AE55-FBA540AF6507}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocuMed.Repository", "DocuMed.Repository\DocuMed.Repository.csproj", "{8A4FA109-04B2-46B1-93F6-CFFE65B47DDB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.Repository", "DocuMed.Repository\DocuMed.Repository.csproj", "{8A4FA109-04B2-46B1-93F6-CFFE65B47DDB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocuMed.Domain", "DocuMed.Domain\DocuMed.Domain.csproj", "{3E36917E-3888-43A4-846C-6C04542FE209}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.Domain", "DocuMed.Domain\DocuMed.Domain.csproj", "{3E36917E-3888-43A4-846C-6C04542FE209}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocuMed.Infrastructure", "DocuMed.Infrastructure\DocuMed.Infrastructure.csproj", "{A29B5D57-EC19-4E56-A92A-CCAAC10F1493}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocuMed.Infrastructure", "DocuMed.Infrastructure\DocuMed.Infrastructure.csproj", "{A29B5D57-EC19-4E56-A92A-CCAAC10F1493}"
|
||||
EndProject
|
||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{AE900A14-3A2E-4792-B7EF-641A1E60D345}"
|
||||
EndProject
|
||||
|
|
|
@ -1,8 +1,37 @@
|
|||
version: '3.4'
|
||||
|
||||
|
||||
networks:
|
||||
dockerapi-dev:
|
||||
driver: bridge
|
||||
|
||||
|
||||
services:
|
||||
documed.api:
|
||||
image: ${DOCKER_REGISTRY-}documedapi
|
||||
image: documedapi:latest
|
||||
depends_on:
|
||||
- "postgres_image"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: DocuMed.Api/Dockerfile
|
||||
ports:
|
||||
- "5288:80"
|
||||
networks:
|
||||
- dockerapi-dev
|
||||
|
||||
postgres_image:
|
||||
image: postgres:latest
|
||||
ports:
|
||||
- "5432"
|
||||
restart: always
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: "brizcouser"
|
||||
POSTGRES_PASSWORD: "brizco"
|
||||
POSTGRES_DB: "BrizCoDB"
|
||||
networks:
|
||||
- dockerapi-dev
|
||||
volumes:
|
||||
db:
|
||||
driver: local
|
||||
|
|
Loading…
Reference in New Issue