public async Task <IActionResult> UpdatePatientClinicalEvent(int patientId, int id, [FromBody] PatientClinicalEventForUpdateDto clinicalEventForUpdate) { if (clinicalEventForUpdate == null) { ModelState.AddModelError("Message", "Unable to locate payload for new request"); return(BadRequest(ModelState)); } var command = new ChangeClinicalEventDetailsCommand(patientId, id, clinicalEventForUpdate.SourceDescription, clinicalEventForUpdate.SourceTerminologyMedDraId, clinicalEventForUpdate.OnsetDate, clinicalEventForUpdate.ResolutionDate, clinicalEventForUpdate.Attributes.ToDictionary(x => x.Id, x => x.Value)); _logger.LogInformation( "----- Sending command: ChangeClinicalEventDetailsCommand - {patientId}: {patientClinicalEventId}", command.PatientId, command.PatientClinicalEventId); var commandResult = await _mediator.Send(command); if (!commandResult) { return(BadRequest("Command not created")); } return(Ok()); }
public async Task <IActionResult> CreatePatientClinicalEvent(int patientId, [FromBody] PatientClinicalEventForUpdateDto clinicalEventForUpdate) { if (clinicalEventForUpdate == null) { ModelState.AddModelError("Message", "Unable to locate payload for new clinical event"); return(BadRequest(ModelState)); } var command = new AddClinicalEventToPatientCommand(patientId, clinicalEventForUpdate.PatientIdentifier, clinicalEventForUpdate.SourceDescription, clinicalEventForUpdate.SourceTerminologyMedDraId, clinicalEventForUpdate.OnsetDate, clinicalEventForUpdate.ResolutionDate, clinicalEventForUpdate.Attributes.ToDictionary(x => x.Id, x => x.Value)); _logger.LogInformation( "----- Sending command: AddClinicalEventToPatientCommand - {sourceDescription}", command.SourceDescription); var commandResult = await _mediator.Send(command); if (commandResult == null) { return(BadRequest("Command not created")); } return(CreatedAtAction("GetPatientClinicalEventByIdentifier", new { patientId, id = commandResult.Id }, commandResult)); }