Skip to content

Instantly share code, notes, and snippets.

@balteravishay
Created October 25, 2021 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balteravishay/6f91a37a23cbd29673cfe41aa74c09c2 to your computer and use it in GitHub Desktop.
Save balteravishay/6f91a37a23cbd29673cfe41aa74c09c2 to your computer and use it in GitHub Desktop.
Create a FHIR patient
[HttpPost]
[Authorize(Policy = "OwnerOrAdmin")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(Patient))]
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(Error))]
[ProducesResponseType(StatusCodes.Status422UnprocessableEntity, Type = typeof(UnprocessableInputException))]
public async Task<IActionResult> CreatePatient([FromBody] dynamic value)
{
Patient patient = _fhirParser.Parse<Patient>(value.ToString());
var user = ((User)HttpContext.Items["User"]);
patient = await _authorizedFhirService.CreateAsync(user, patient);
string createdPatientJson = await patient.ToJsonAsync();
return Content(createdPatientJson, MediaTypeNames.Application.Json);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment