public async Task <IActionResult> UpdatePatientLabTest(int patientId, int id, [FromBody] PatientLabTestForUpdateDto labTestForUpdate) { if (labTestForUpdate == null) { ModelState.AddModelError("Message", "Unable to locate payload for new request"); return(BadRequest(ModelState)); } var command = new ChangeLabTestDetailsCommand(patientId, id, labTestForUpdate.LabTest, labTestForUpdate.TestDate, labTestForUpdate.TestResultCoded, labTestForUpdate.TestResultValue, labTestForUpdate.TestUnit, labTestForUpdate.ReferenceLower, labTestForUpdate.ReferenceUpper, labTestForUpdate.Attributes.ToDictionary(x => x.Id, x => x.Value)); _logger.LogInformation( "----- Sending command: ChangeLabTestDetailsCommand - {patientId}: {patientLabTestId}", command.PatientId, command.PatientLabTestId); var commandResult = await _mediator.Send(command); if (!commandResult) { return(BadRequest("Command not created")); } return(Ok()); }
public async Task <IActionResult> CreatePatientLabTest(int patientId, [FromBody] PatientLabTestForUpdateDto labTestForUpdate) { if (labTestForUpdate == null) { ModelState.AddModelError("Message", "Unable to locate payload for new labTest"); return(BadRequest(ModelState)); } var command = new AddLabTestToPatientCommand(patientId, labTestForUpdate.LabTest, labTestForUpdate.TestDate, labTestForUpdate.TestResultCoded, labTestForUpdate.TestResultValue, labTestForUpdate.TestUnit, labTestForUpdate.ReferenceLower, labTestForUpdate.ReferenceUpper, labTestForUpdate.Attributes.ToDictionary(x => x.Id, x => x.Value)); _logger.LogInformation( "----- Sending command: AddLabTestToPatientCommand - {LabTest}", command.LabTest); var commandResult = await _mediator.Send(command); if (commandResult == null) { return(BadRequest("Command not created")); } return(CreatedAtAction("GetPatientLabTestByIdentifier", new { patientId, id = commandResult.Id }, commandResult)); }