Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop

This commit is contained in:
Kittapath 2024-06-25 09:49:16 +07:00
commit 41474b407d
29 changed files with 39708 additions and 3703 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,14 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Responses.Organizations;
using BMA.EHR.Application.Responses.Profiles;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System.Security.Cryptography;
namespace BMA.EHR.Application.Repositories
{
@ -60,6 +61,70 @@ namespace BMA.EHR.Application.Repositories
return data;
}
public async Task<List<GetProfileByRootIdDto>> GetOfficerProfileByRootIdAsync(Guid rootId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/root/officer/{rootId}";
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
//var data = await _dbContext.Set<Profile>().AsQueryable()
// .Include(p => p.Prefix)
// .Include(p => p.Position)
// .Include(p => p.PositionLevel)
// .Include(p => p.Salaries)
// .FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
//return data;
}
catch
{
throw;
}
}
public async Task<List<GetProfileByRootIdDto>> GetEmployeeProfileByRootIdAsync(Guid rootId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/root/employee/{rootId}";
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
//var data = await _dbContext.Set<Profile>().AsQueryable()
// .Include(p => p.Prefix)
// .Include(p => p.Position)
// .Include(p => p.PositionLevel)
// .Include(p => p.Salaries)
// .FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
//return data;
}
catch
{
throw;
}
}
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
{
try
@ -266,7 +331,7 @@ namespace BMA.EHR.Application.Repositories
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak";
var apiPath = $"{_configuration["API"]}/org/dotnet/user-fullname/{keycloakId}";
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult.Result != null)
@ -349,6 +414,102 @@ namespace BMA.EHR.Application.Repositories
}
}
public GetOrganizationResponseDTO? GetOc(Guid ocId, int level, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/find/all";
var body = new
{
nodeId = ocId,
node = level
};
var apiResult = PostExternalAPIAsync(apiPath, accessToken ?? "", body).Result;
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetOrganizationResponseResultDTO>(apiResult);
if (raw != null && raw.Result != null)
{
return raw.Result;
}
}
return null;
}
catch
{
throw;
}
}
public GetProfileByIdDto GetOfficerProfileById(Guid id, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/profile/{id}";
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult.Result != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public GetProfileByIdDto GetEmployeeProfileById(Guid id, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/profile-employee/{id}";
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult.Result != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public GetProfileByIdDto GetOfficerProfileByCitizenId(string citizenId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/citizenId/{citizenId}";
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult.Result != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -21,7 +21,9 @@ namespace BMA.EHR.Application.Requests
public string LastInsignia { get; set; }
public Guid? LastInsigniaId { get; set; }
public Guid PosNo { get; set; }
//public Guid PosNo { get; set; }
public string PosNo { get; set; }
public InsigniaItem RequestInsignia { get; set; }

View file

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Application.Responses.Organizations
{
public class GetOrganizationResponseDTO
{
public Guid? RootId { get; set; }
public string? Root { get; set; }
public string? RootShortName { get; set; }
public Guid? Child1Id { get; set; }
public string? Child1 { get; set; }
public string? Child1ShortName { get; set; }
public Guid? Child2Id { get; set; }
public string? Child2 { get; set; }
public string? Child2ShortName { get; set; }
public Guid? Child3Id { get; set; }
public string? Child3 { get; set; }
public string? Child3ShortName { get; set; }
public Guid? Child4Id { get; set; }
public string? Child4 { get; set; }
public string? Child4ShortName { get; set; }
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Application.Responses.Organizations
{
public class GetOrganizationResponseResultDTO
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public GetOrganizationResponseDTO? Result { get; set; }
}
}

View file

@ -0,0 +1,42 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByIdDto
{
public Guid Id { get; set; }
public string? Prefix { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? CitizenId { get; set; }
public DateTime BirthDate { get; set; } = DateTime.MinValue;
public DateTime? DateStart { get; set; } = DateTime.MinValue;
public DateTime? DateAppoint { get; set; } = DateTime.MinValue;
public string? Position { get; set; }
public Guid? OcId { get; set; }
public PosType? PosType { get; set; }
public PosLevel? PosLevel { get; set; }
public string? Oc { get; set; }
public List<ProfileSalaryResult>? ProfileSalary { get; set; }
public List<ProfileInsignia>? ProfileInsignia { get; set; }
public Guid? Keycloak { get; set; }
public string? PosNo { get; set; }
public string? PosNoEmployee { get; set; }
public string? Gender { get; set; }
public string ProfileType { get; set; } = string.Empty;
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByIdResultDto
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public GetProfileByIdDto? Result { get; set; }
}
}

View file

@ -27,14 +27,18 @@ namespace BMA.EHR.Application.Responses.Profiles
public string? Oc { get; set; }
public List<ProfileSalary> Salaries { get; set; } = new();
public ProfileSalaryResult? ProfileSalary { get; set; }
public Guid? Keycloak { get; set; }
public ProfileInsignia? ProfileInsignia { get; set; }
public Guid? Keycloak { get; set; }
public string? PosNo { get; set; }
public string? PosNoEmployee { get; set; }
public string? Gender { get; set; }
}
public class PosLevel
@ -61,4 +65,45 @@ namespace BMA.EHR.Application.Responses.Profiles
public string LastUpdateFullName { get; set; }
public string PosTypeName { get; set; }
}
public class ProfileSalaryResult
{
public Guid? Id { get; set; }
public DateTime? CreatedAt { get; set; }
public Guid? CreatedUserId { get; set; }
public DateTime? LastUpdatedAt { get; set; }
public Guid? LastUpdateUserId { get; set; }
public string? CreatedFullName { get; set; }
public string? LastUpdateFullName { get; set; }
public string PosNo { get; set; } = string.Empty;
public double? Amount { get; set; }
public double? PositionSalaryAmount { get; set; }
public double? MouthSalaryAmount { get; set; }
public int Order { get; set; }
public DateTime? Date { get; set; }
public string PositionLevel { get; set; } = string.Empty;
public string PositionType { get; set; } = string.Empty;
}
public class ProfileInsignia
{
public Guid? Id { get; set; }
public DateTime? CreatedAt { get; set; }
public Guid? CreatedUserId { get; set; }
public DateTime? LastUpdatedAt { get; set; }
public Guid? LastUpdateUserId { get; set; }
public string? CreatedFullName { get; set; }
public string? LastUpdateFullName { get; set; }
public int? Year { get; set; }
public Guid? InsigniaId { get; set; }
}
}

View file

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByRootIdDto
{
public Guid Id { get; set; }
public string? Prefix { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? CitizenId { get; set; }
public DateTime BirthDate { get; set; } = DateTime.MinValue;
public DateTime? DateStart { get; set; } = DateTime.MinValue;
public DateTime? DateAppoint { get; set; } = DateTime.MinValue;
public string? Position { get; set; }
public Guid? OcId { get; set; }
public PosType? PosType { get; set; }
public PosLevel? PosLevel { get; set; }
public string? Oc { get; set; }
public List<ProfileSalaryResult>? ProfileSalary { get; set; }
public List<ProfileInsignia>? ProfileInsignia { get; set; }
public Guid? Keycloak { get; set; }
public string? PosNo { get; set; }
public string? PosNoEmployee { get; set; }
public string? Gender { get; set; }
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByRootIdResultDto
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public List<GetProfileByRootIdDto> Result { get; set; }
}
}