add table certificate

This commit is contained in:
Kittapath 2023-07-05 19:41:40 +07:00
parent 0a626fb393
commit 55a5914967
4 changed files with 10631 additions and 32 deletions

View file

@ -1,5 +1,6 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Placement;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
@ -135,9 +136,24 @@ namespace BMA.EHR.Placement.Service.Controllers
{
PersonalId = x.Id,
IdCard = x.CitizenId,
Prefix = x.Prefix == null ? null : x.Prefix.Name,
PrefixId = x.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Prefix.Id,
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
Firstname = x.Firstname,
Lastname = x.Lastname,
Nationality = x.Nationality,
Race = x.Race,
DateOfBirth = x.DateOfBirth,
Age = x.DateOfBirth == null ? null : x.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
Telephone = x.Telephone,
Gender = x.Gender == null ? null : x.Gender.Name,
GenderId = x.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Gender.Id,
Relationship = x.Relationship == null ? null : x.Relationship.Name,
RelationshipId = x.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Relationship.Id,
BloodGroup = x.BloodGroup == null ? null : x.BloodGroup.Name,
BloodGroupId = x.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.BloodGroup.Id,
Religion = x.Religion == null ? null : x.Religion.Name,
ReligionId = x.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Religion.Id,
Address = $"{x.RegistAddress}" +
(x.RegistSubDistrict == null ? null : " แขวง") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.Name) +
(x.RegistDistrict == null ? null : " เขต") + (x.RegistDistrict == null ? null : x.RegistDistrict.Name) +
@ -145,6 +161,7 @@ namespace BMA.EHR.Placement.Service.Controllers
(x.RegistSubDistrict == null ? null : " ") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.ZipCode),
Education = x.PlacementEducations.Select(p => new
{
Id = p.Id,
EducationLevel = p.EducationLevel == null ? null : p.EducationLevel.Name,
Major = p.Major,
Scores = p.Scores,
@ -152,6 +169,46 @@ namespace BMA.EHR.Placement.Service.Controllers
DurationStart = p.DurationStart,
DurationEnd = p.DurationEnd,
}),
RegistSubDistrict = x.RegistSubDistrict == null ? null : x.RegistSubDistrict.Name,
RegistSubDistrictId = x.RegistSubDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistSubDistrict.Id,
RegistZipCode = x.RegistSubDistrict == null ? null : x.RegistSubDistrict.ZipCode,
RegistDistrict = x.RegistDistrict == null ? null : x.RegistDistrict.Name,
RegistDistrictId = x.RegistDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistDistrict.Id,
RegistProvince = x.RegistProvince == null ? null : x.RegistProvince.Name,
RegistProvinceId = x.RegistProvince == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistProvince.Id,
CurrentSubDistrict = x.CurrentSubDistrict == null ? null : x.CurrentSubDistrict.Name,
CurrentSubDistrictId = x.CurrentSubDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentSubDistrict.Id,
CurrentZipCode = x.CurrentSubDistrict == null ? null : x.CurrentSubDistrict.ZipCode,
CurrentDistrict = x.CurrentDistrict == null ? null : x.CurrentDistrict.Name,
CurrentDistrictId = x.CurrentDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentDistrict.Id,
CurrentProvince = x.CurrentProvince == null ? null : x.CurrentProvince.Name,
CurrentProvinceId = x.CurrentProvince == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentProvince.Id,
RegistSame = x.RegistSame,
MarryPrefix = x.MarryPrefix == null ? null : x.MarryPrefix.Name,
MarryPrefixId = x.MarryPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.MarryPrefix.Id,
Couple = x.Marry,
MarryFirstName = x.MarryFirstName,
MarryLastName = x.MarryLastName,
MarryOccupation = x.MarryOccupation,
FatherPrefix = x.FatherPrefix == null ? null : x.FatherPrefix.Name,
FatherPrefixId = x.FatherPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.FatherPrefix.Id,
FatherFirstName = x.FatherFirstName,
FatherLastName = x.FatherLastName,
FatherOccupation = x.FatherOccupation,
MotherPrefix = x.MotherPrefix == null ? null : x.MotherPrefix.Name,
MotherPrefixId = x.MotherPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.MotherPrefix.Id,
MotherFirstName = x.MotherFirstName,
MotherLastName = x.MotherLastName,
MotherOccupation = x.MotherOccupation,
Certificates = x.PlacementCertificates.Select(p => new
{
Id = p.Id,
CertificateNo = p.CertificateNo,
Issuer = p.Issuer,
IssueDate = p.IssueDate,
ExpireDate = p.ExpireDate,
CertificateType = p.CertificateType,
}),
PointA = x.PointA,
PointB = x.PointB,
PointC = x.PointC,
@ -346,7 +403,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("information/{personalId:length(36)}")]
[HttpPut("information/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateInformation([FromBody] PersonInformationRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -414,7 +471,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("address/{personalId:length(36)}")]
[HttpPut("address/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateAddress([FromBody] PersonAddressRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -480,7 +537,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("family/{personalId:length(36)}")]
[HttpPut("family/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateFamily([FromBody] PersonFamilyRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -568,6 +625,7 @@ namespace BMA.EHR.Placement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementCertificates.AddAsync(data);
}
else
{