diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index fca6ea0d..34597431 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -397,6 +397,50 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(new List()); } + [HttpGet("exam-probation/{citizenId:length(13)}")] + public async Task> GetDataExamByPlacement(string citizenId) + { + var dateAppoint = string.Empty; + var apiUrl = $"{_configuration["API"]}/org/profile/citizenid/position/{citizenId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + var json = JObject.Parse(_result); + var dateAppointToken = json["result"]?["dateAppoint"]; + if (dateAppointToken != null) + { + dateAppoint = dateAppointToken.ToString(); + } + } + } + + var placementProfile = await _context.PlacementProfiles + .Include(x => x.Placement) + .Select(x => new + { + fullName = $"{x.Prefix}{x.Firstname} {x.Lastname}", + citizenId = x.CitizenId, + examName = x.Placement.Name, + }) + .Where(x => x.citizenId == citizenId.ToString()) + .FirstOrDefaultAsync(); + + var data = new + { + fullName = placementProfile != null ? placementProfile.fullName : "", + citizenId = placementProfile != null ? placementProfile.citizenId : "", + examName = placementProfile != null ? placementProfile.examName : "", + dateAppoint = dateAppoint + }; + return Success(data); + } + [HttpGet("personal/{personalId:length(36)}")] public async Task> GetProfileByUser(Guid personalId) {