140 lines
5.6 KiB
C#
140 lines
5.6 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace adas_core.Controllers;
|
|
|
|
[Route("Recording")]
|
|
[ApiController]
|
|
public class RecordingController : ControllerBase
|
|
{
|
|
// TODO: ver donde ses usa este controlador para version 3 del modelo
|
|
|
|
// private readonly IRecordingService _recordingService;
|
|
// private readonly IPatientService _patientService;
|
|
// private readonly ISectionService _sectionService;
|
|
// private readonly ILogger<RecordingController> _logger;
|
|
//
|
|
// private readonly string? _url = string.Empty;
|
|
//
|
|
// public RecordingController(IPatientService patientService,
|
|
// IRecordingService recordingService,
|
|
// ISectionService sectionService,
|
|
// ILogger<RecordingController> logger)
|
|
// {
|
|
// LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true);
|
|
//
|
|
// _recordingService = recordingService;
|
|
// _patientService = patientService;
|
|
// _sectionService = sectionService;
|
|
// _logger = logger;
|
|
// }
|
|
//
|
|
// [HttpPost]
|
|
// [Route("{patientId}/stop")]
|
|
// public async Task<IActionResult> StopRecording([FromBody] ManualRecording manualRecording, string patientId)
|
|
// {
|
|
// try
|
|
// {
|
|
// if (!ObjectId.TryParse(patientId, out var patientIdParsed)) return BadRequest("patientId is not ObjectId");
|
|
//
|
|
// var patient = await _patientService.FindById(patientIdParsed);
|
|
// if (patient == null) return BadRequest($"User not found:{patientId}");
|
|
// var boxConfig = await _sectionService.FindBox(patient.Location);
|
|
// if (boxConfig == null) return BadRequest($"boxConfig not found:{patient.Location}");
|
|
//
|
|
// //await _recordingService.SendRecordingData(patient, boxConfig, manualRecording, start: false);
|
|
//
|
|
// return Ok($"[{_url}] -- {JsonConvert.SerializeObject(manualRecording)}");
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// _logger.LogError("Error saving the request: {exMessage} ", ex);
|
|
// return BadRequest($"ERROR:{ex.Message}");
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// [HttpPost]
|
|
// [Route("{patientId}/start")]
|
|
// public async Task<IActionResult> StartRecording([FromBody] ManualRecording manualRecording, string patientId) //TODO PASAR API REQUEST
|
|
// {
|
|
// try
|
|
// {
|
|
// if (!ObjectId.TryParse(patientId, out var patientIdParsed)) return BadRequest("patientId is not ObjectId");
|
|
//
|
|
// var patient = await _patientService.FindById(patientIdParsed);
|
|
// if (patient == null) return BadRequest($"User not found:{patientId}");
|
|
// var boxConfig = await _sectionService.FindBox(patient.Location);
|
|
// if (boxConfig == null) return BadRequest($"boxConfig not found:{patient.Location}");
|
|
//
|
|
// //encola el mensaje
|
|
// //await _recordingService.SendRecordingData(patient, boxConfig, manualRecording, start: true);
|
|
//
|
|
//
|
|
//
|
|
// return Ok($"[{_url}] -- {JsonConvert.SerializeObject(manualRecording)}");
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// Log.Warning("Error saving the request: " + ex);
|
|
// return BadRequest($"ERROR:{ex.Message}");
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
//
|
|
// [HttpPost]
|
|
// [Route("{patientId}/cancel")]
|
|
// public async Task<IActionResult> CancelRecording(string patientId)
|
|
// {
|
|
// try
|
|
// {
|
|
//
|
|
// if (!ObjectId.TryParse(patientId, out var patientIdParsed)) return BadRequest("patientId is not ObjectId");
|
|
//
|
|
// var patient = await _patientService.FindById(patientIdParsed);
|
|
// if (patient == null) return BadRequest($"User not found:{patientId}");
|
|
// var boxConfig = await _sectionService.FindBox(patient.Location);
|
|
// if (boxConfig == null) return BadRequest($"boxConfig not found:{patient.Location}");
|
|
//
|
|
// // var cancelRecordingSucessfully = await _recordingService.SendCancelRecordingToRecordingApi(patient, boxConfig);
|
|
// // return cancelRecordingSucessfully ? Ok() : StatusCode(500, "error canceling recording");
|
|
// return Ok();
|
|
//
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// _logger.LogError("Error saving the request: {exMessage} ", ex);
|
|
// throw;
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// [HttpPost]
|
|
// [Route("{patientId}/auto")]
|
|
// public async Task<IActionResult> AutomaticRecording([FromBody] RecordingData automaticRecording, string patientId)
|
|
// {
|
|
// try
|
|
// {
|
|
// if (!ObjectId.TryParse(patientId, out var patientIdParsed)) return BadRequest("patientId is not ObjectId");
|
|
//
|
|
// var patient = await _patientService.FindById(patientIdParsed);
|
|
// if (patient == null) return BadRequest($"User not found:{patientId}");
|
|
// var boxConfig = await _sectionService.FindBox(patient.Location);
|
|
// if (boxConfig == null) return BadRequest($"boxConfig not found:{patient.Location}");
|
|
//
|
|
// // var result = await _recordingService.SendAutoRecordingData(patient, boxConfig, automaticRecording);
|
|
//
|
|
// // if (result)
|
|
// // return Ok($"[{_url}] -- {JsonConvert.SerializeObject(automaticRecording)}");
|
|
// // else
|
|
// // return BadRequest($"[{_url}] -- {JsonConvert.SerializeObject(automaticRecording)}");
|
|
// return Ok();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// _logger.LogError("Error saving the request: {exMessage} ", ex);
|
|
// throw;
|
|
// }
|
|
//
|
|
// }
|
|
} |