Added new controller for getting observation by patient id and hl7 id
This commit is contained in:
parent
c14a26f020
commit
0b596cdc37
@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SimpleLIS.DTO;
|
||||
using SimpleLIS.Models;
|
||||
using SimpleLIS.Services;
|
||||
|
||||
@ -41,6 +42,16 @@ public class PatientsController : ControllerBase
|
||||
return Ok(patientDto);
|
||||
}
|
||||
|
||||
[HttpGet("{id}/observations")]
|
||||
public async Task<IActionResult> GetPatientObservationById(string id){
|
||||
List<Observation> observations;
|
||||
if(int.TryParse(id, out int patientId))
|
||||
observations = await _patientService.GetPatientObservationById(patientId);
|
||||
else
|
||||
observations = await _patientService.GetPatientObservationByHL7PatientId(id);
|
||||
return Ok(_mapper.Map<List<ObservationDTO>>(observations));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> ListPatients()
|
||||
{
|
||||
|
||||
@ -26,6 +26,16 @@ public class PatientService
|
||||
.FirstOrDefaultAsync(p => p.PatientId == id);
|
||||
}
|
||||
|
||||
public async Task<List<Observation>> GetPatientObservationById(int id){
|
||||
return await _context.Observations.Include(observation=>observation.Message)
|
||||
.Where(observation=>observation.Message.PatientId==id).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<Observation>> GetPatientObservationByHL7PatientId(string id){
|
||||
return await _context.Observations.Include(observation => observation.Message)
|
||||
.Where(observation => observation.Message.Patient.HL7PatientId == id).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Patient>> ListPatientsAsync()
|
||||
{
|
||||
return await _context.Patients.ToListAsync();
|
||||
|
||||
BIN
hl7.db-shm
BIN
hl7.db-shm
Binary file not shown.
BIN
hl7.db-wal
BIN
hl7.db-wal
Binary file not shown.
Loading…
Reference in New Issue
Block a user