Class DischargeController
- Namespace
- adas_core.Controllers
- Assembly
- adas-core.dll
[Route("discharges")]
[ApiController]
public class DischargeController : ControllerBase
- Inheritance
-
DischargeController
- Inherited Members
- Extension Methods
Constructors
DischargeController(IDischargeService, IPatientService)
public DischargeController(IDischargeService dischargeService, IPatientService patientService)
Parameters
dischargeServiceIDischargeServicepatientServiceIPatientService
Methods
DeleteDischargeById(string)
Deletes a discharge record by its identifier. Validates the id format, retrieves the discharge and its associated patient, and only removes the discharge when the patient's Altable option type is Altable; otherwise the operation is rejected as a conflict.
[HttpDelete("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> DeleteDischargeById(string id)
Parameters
idstringThe string representation of the discharge's identifier to be parsed and deleted.
Returns
- Task<IActionResult>
An IActionResult representing the result of the delete operation.
Exceptions
- BadRequestException
Thrown when the provided
idis not a valid ObjectId format.- ConflictException
Thrown when the patient's
Altableoption type is notAltable, preventing the deletion.
DischargePatient(Discharge)
Records the discharge of a patient by associating the provided discharge data with the corresponding patient record. Requires the caller to hold the authorized role and the permission for the specified source and display ID.
[HttpPost("patient")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> DischargePatient(Discharge discharge)
Parameters
dischargeDischargeThe discharge information, including the patient identifier, to be persisted.
Returns
- Task<IActionResult>
An IActionResult that returns an OK response when the discharge is successfully recorded.
Exceptions
- BadRequestException
Thrown when the
dischargeparameter is null, indicating missing required parameters.
GetAllDischarges()
Retrieves all discharge records available in the system.
[HttpGet]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetAllDischarges()
Returns
- Task<IActionResult>
An IActionResult containing the collection of discharges with an HTTP 200 OK response.
GetDischargebyId(string)
Retrieves a discharge record by its identifier, applying role-based and source permission authorization. Validates the format of the provided id before delegating the lookup to the discharge service.
[HttpGet("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetDischargebyId(string id)
Parameters
idstringThe string identifier of the discharge to retrieve, expected to be a valid ObjectId.
Returns
- Task<IActionResult>
An IActionResult containing the discharge data when found.
Exceptions
- BadRequestException
Thrown when the provided
idcannot be parsed as a valid ObjectId.
InsertDischarge(Discharge)
Inserts a new discharge record by delegating to the discharge service. Validates that the supplied discharge payload is not null before processing and returns the created discharge on success.
[HttpPost]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> InsertDischarge(Discharge discharge)
Parameters
dischargeDischargeThe discharge entity to insert, provided in the request body.
Returns
- Task<IActionResult>
An IActionResult containing the inserted discharge wrapped in an HTTP 200 OK response.
Exceptions
- BadRequestException
Thrown when the
dischargeparameter is null, indicating missing required parameters.
UpdateDischarge(Discharge)
Updates an existing discharge record, preserving the existing UnitId when the incoming payload omits it.
[HttpPut]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateDischarge(Discharge discharge)
Parameters
dischargeDischargeThe discharge entity supplied in the request body, identified by its
Id.
Returns
- Task<IActionResult>
An IActionResult that yields an
Okresponse on successful update.
Exceptions
- BadRequestException
Thrown when the supplied
dischargepayload isnull.