Table of Contents

Class AdmissionController

Namespace
adas_core.Controllers
Assembly
adas-core.dll

Provides API endpoints for managing patient admission records in the ADAS system.

[Route("admissions")]
[ApiController]
public class AdmissionController : ControllerBase
Inheritance
AdmissionController
Inherited Members
Extension Methods

Constructors

AdmissionController(ILogger<AdmissionController>, IAdmissionService, IPatientService, IUnitService)

Initializes a new instance of the AdmissionController class.

public AdmissionController(ILogger<AdmissionController> logger, IAdmissionService admissionService, IPatientService patientService, IUnitService unitService)

Parameters

logger ILogger<AdmissionController>

The logger instance used to log diagnostic information for the controller.

admissionService IAdmissionService

The service responsible for handling admission-related business logic.

patientService IPatientService

The service responsible for managing patient-related operations.

unitService IUnitService

The service responsible for managing unit-related operations.

Exceptions

ArgumentNullException

Thrown when any of the parameters logger, admissionService, patientService, or unitService is null.

Methods

AdmitNewPatient(Admission)

Admits a new patient by updating the admission record and registering the patient in the specified unit, provided the unit is configured for manual admission.

[HttpPost("admit/new-patient")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> AdmitNewPatient(Admission admission)

Parameters

admission Admission

The admission details, including the target unit identifier and patient health number (NHC), used to update the admission and locate the patient.

Returns

Task<IActionResult>

An IActionResult containing the admitted patient information when the operation succeeds.

Exceptions

BadRequestException

Thrown when the admission parameter is null.

NotFoundException

Thrown when no unit configuration is found for the specified unit identifier.

ConflictException

Thrown when the target unit operates in automatic census mode, or when the patient cannot be retrieved after the admission is registered.

AdmitPatient(string)

Admits a patient identified by the admission identifier, ensuring the admission exists, belongs to a unit with manual admit enabled, and that a matching patient record is available.

[HttpPost("{id}/admission")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> AdmitPatient(string id)

Parameters

id string

The string identifier of the admission; must be a valid ObjectId.

Returns

Task<IActionResult>

An IActionResult containing the admitted patient when the operation succeeds.

Exceptions

BadRequestException

Thrown when id is not a valid ObjectId format.

NotFoundException

Thrown when no admission exists for the given id, or when the admission's unit configuration cannot be found.

ConflictException

Thrown when the unit's configuration has manual admit disabled, or when no patient record matches the admission's patient number.

CreateNewAdmission(Admission)

Creates a new admission record by validating the input and inserting it via the admission service. Throws a bad request exception if the admission payload is missing or the required NHC identifier is empty.

[HttpPost]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> CreateNewAdmission(Admission admission)

Parameters

admission Admission

The admission data to create, provided in the request body.

Returns

Task<IActionResult>

An IActionResult containing the newly created admission wrapped in an OK response.

Exceptions

BadRequestException

Thrown when admission is null or when its NHC field is null or empty.

DeleteAdmissionById(string)

Deletes an admission record identified by the specified id, after validating the id format and confirming the resource exists.

[HttpDelete("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> DeleteAdmissionById(string id)

Parameters

id string

The string identifier of the admission to delete; expected to be a valid ObjectId.

Returns

Task<IActionResult>

An IActionResult that returns OK when the admission is successfully deleted.

Exceptions

BadRequestException

Thrown when the provided id cannot be parsed as a valid ObjectId.

NotFoundException

Thrown when no admission is found for the specified id.

GetAdmissionbyId(string)

Retrieves an admission by its identifier, validating the ID format and returning the admission record if it exists.

[HttpGet("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetAdmissionbyId(string id)

Parameters

id string

The string identifier of the admission to retrieve.

Returns

Task<IActionResult>

An IActionResult containing the admission details when found.

Exceptions

BadRequestException

Thrown when the provided id is not a valid ObjectId format.

NotFoundException

Thrown when no admission matching the provided id is found.

GetAllAdmissions()

Retrieves all admissions records.

[HttpGet]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetAllAdmissions()

Returns

Task<IActionResult>

An IActionResult containing the collection of admissions with an HTTP 200 OK response.

ReturnPatientToAdmission(string)

Returns a patient to the admissions list by processing the patient-to-admission transition for the given patient id. Validates the id format, resolves the patient's unit configuration, and blocks the operation when the unit operates in automatic (non-manual-move) mode.

[HttpPost("{id}/patient-to-admission")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> ReturnPatientToAdmission(string id)

Parameters

id string

The string representation of the patient's identifier used to locate the patient record.

Returns

Task<IActionResult>

An IActionResult representing an HTTP 200 OK response when the patient is successfully returned to admissions.

Exceptions

BadRequestException

Thrown when the provided id is not a valid identifier format.

NotFoundException

Thrown when no unit configuration is found for the patient's unit.

ConflictException

Thrown when the unit's configuration has manual move disabled, indicating the census is in automatic mode.

ReturnPatientToAdmission(string, string)

Handles a GET request to return a patient to admission by searching admission records associated with the specified patient number and unit. Validates the unit identifier format before delegating the search to the admission service.

[HttpGet("{patientNumber}/{unitId}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> ReturnPatientToAdmission(string patientNumber, string unitId)

Parameters

patientNumber string

The unique identifier of the patient to be returned to admission.

unitId string

The identifier of the unit used to scope the admission search; must be a valid ObjectId.

Returns

Task<IActionResult>

An IActionResult containing the matching admission records returned by the service.

Exceptions

BadRequestException

Thrown when unitId is not a valid ObjectId format.

ReturnToAdmissionFromTemporalBed(Admission, string)

Handles the process of returning a patient from a temporal bed back to their admission record. Validates the provided patient identifier format and delegates the transfer operation to the admission service.

[HttpPost("{id}/temporal-bed")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> ReturnToAdmissionFromTemporalBed(Admission admission, string id)

Parameters

admission Admission

The admission data containing the details required to restore the patient to the admissions list.

id string

The string representation of the patient's identifier from the route, expected to be a valid ObjectId.

Returns

Task<IActionResult>

An IActionResult that returns HTTP 200 (OK) when the patient is successfully returned to admissions.

Exceptions

BadRequestException

Thrown when the provided id is not in a valid ObjectId format.

UpdateAdmission(Admission)

Updates an existing admission record using the provided data, after validating the NHC identifier.

[HttpPut]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateAdmission(Admission admission)

Parameters

admission Admission

The admission entity containing the updated information to persist.

Returns

Task<IActionResult>

An IActionResult indicating the outcome of the update operation.

Exceptions

BadRequestException

Thrown when the admission's NHC is null or empty.