TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pabloeferreyra/Turnero/llms.txt
Use this file to discover all available pages before exploring further.
PatientsController manages the patient registry in Turnero. It provides a searchable, paginated list view backed by a DataTables server-side data feed, full create and update operations for patient records, and a detail page that surfaces the patient’s personal data together with parents/guardian information. Every action in this controller requires the Medico role — patient records are considered clinical information and are not accessible to reception (Ingreso) or administrative (Admin) staff.
The Patient model extends BaseEntity (which contributes an auto-generated Guid primary key) and carries demographic fields, blood type, contact information, and a foreign-key collection linking the patient to all other medical history sub-records (visits, allergies, vaccines, etc.).
Endpoint summary
| Method | Path | Roles | Description |
|---|---|---|---|
GET | /Patients/Index | Medico | Patient list page |
POST | /Patients/InitializePatients | Medico | DataTables server-side data feed |
GET | /Patients/Create | Medico | Returns _Create partial view |
POST | /Patients/Create | Medico | Inserts a new patient |
GET | /Patients/Edit/{id} | Medico | Returns _Edit partial view |
PUT | /Patients/Edit | Medico | Updates an existing patient |
GET | /Patients/Details/{id} | Medico | Patient detail view |
GET /Patients/Index
Renders the patient list page. The controller callsgetPatient.GetPatients() on load (result is unused server-side; the actual data is delivered via InitializePatients). The view loads a DataTables-powered table that calls POST /Patients/InitializePatients for its rows.
Required roles: Medico
Response: HTML view Index
POST /Patients/InitializePatients
Server-side DataTables endpoint for the patient list. The search term read fromColumns[1][search][value] is passed directly to the SearchPatients service method, which queries the database for matching records by name or DNI. The result set is then sorted and paginated before being serialised to JSON.
Required roles: Medico
Request — application/x-www-form-urlencoded
DataTables draw counter echoed back verbatim in the response.
Zero-based offset for pagination.
Page size. Pass
0 or omit to receive all records.Free-text search term applied against patient name and DNI. An empty string returns all patients.
Index of the column to sort by.
Sort direction:
asc or desc.200 OK, application/json
Echo of the request’s draw counter.
Total number of records after applying the search filter (equals
recordsTotal since filtering happens at the service layer).Total number of records in the result set before pagination.
The page of patient records. Each entry contains
id, name, dni, birthDate, socialWork, and affiliateNumber.GET /Patients/Create
Returns the_Create partial view. The BloodType enum values are projected into a SelectListItem list using their Display attribute name (e.g. "A+", "O-") and bound to ViewBag.Bloodtype for the blood group dropdown.
Required roles: Medico
Response: Partial view _Create
POST /Patients/Create
Inserts a new patient record. Model validation is checked before any database write; a bad request is returned immediately ifModelState is invalid.
Required roles: Medico
Request — application/x-www-form-urlencoded or application/json
Patient’s full name. Maximum display label:
"Nombre".National identity number (DNI). Must be between 6 and 10 characters.
Date of birth. Formatted as
dd/MM/yyyy for display; stored as DateTime.Health insurance / obra social name.
Insurance affiliate number.
Integer value of the
BloodType enum: 0 = A+, 1 = A-, 2 = B+, 3 = B-, 4 = AB+, 5 = AB-, 6 = O+, 7 = O-.Nested contact details object (
ContactInfo entity). Fields depend on the ContactInfo model’s own properties.| Status | Meaning |
|---|---|
200 OK | Patient created successfully. |
400 Bad Request | ModelState validation failed. |
409 Conflict | An exception was thrown during insertion (e.g. duplicate DNI constraint). |
GET /Patients/Edit/
Returns the_Edit partial view pre-populated with the specified patient’s data. The BloodType dropdown list is rebuilt the same way as for the Create form. Returns 404 Not Found when the patient does not exist.
Required roles: Medico
The
Patient.Id to edit._Edit with the Patient model, or 404 Not Found.
PUT /Patients/Edit
Persists changes to an existing patient record. This action requires a valid anti-forgery token ([ValidateAntiForgeryToken]), which the partial view embed injects automatically.
Required roles: Medico
Request body — same fields as POST /Patients/Create, plus Id (required).
The
Patient.Id (base-class BaseEntity.Id) to update.| Status | Meaning |
|---|---|
200 OK | Patient updated successfully. |
400 Bad Request | ModelState validation failed. |
409 Conflict | An exception was thrown during update. |
GET /Patients/Details/
Returns the full patient detail view. The controller loads both thePatient entity and the associated ParentsData record (guardian information) in parallel, placing the latter in ViewBag.ParentsData. It also calculates a human-friendly age string from the patient’s BirthDate (e.g. "3 años", "8 meses", "2 semanas") and exposes it as ViewBag.Age.
The response is never cached — the action is decorated with [ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)] to ensure the page always reflects the latest database state.
Required roles: Medico
The
Patient.Id to display.Details with the Patient model, or 404 Not Found.
ViewBag values set:
| Key | Type | Content |
|---|---|---|
ParentsData | ParentsData | Guardian/parent record for the patient, if one exists. |
Age | string | Computed age string (e.g. "5 años", "4 meses", "12 días"). |