Skip to main content

Documentation 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.

The 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

MethodPathRolesDescription
GET/Patients/IndexMedicoPatient list page
POST/Patients/InitializePatientsMedicoDataTables server-side data feed
GET/Patients/CreateMedicoReturns _Create partial view
POST/Patients/CreateMedicoInserts a new patient
GET/Patients/Edit/{id}MedicoReturns _Edit partial view
PUT/Patients/EditMedicoUpdates an existing patient
GET/Patients/Details/{id}MedicoPatient detail view

GET /Patients/Index

Renders the patient list page. The controller calls getPatient.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 from Columns[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 Requestapplication/x-www-form-urlencoded
draw
string
required
DataTables draw counter echoed back verbatim in the response.
start
integer
required
Zero-based offset for pagination.
length
integer
required
Page size. Pass 0 or omit to receive all records.
Columns[1][search][value]
string
Free-text search term applied against patient name and DNI. An empty string returns all patients.
order[0][column]
integer
Index of the column to sort by.
order[0][dir]
string
Sort direction: asc or desc.
Response200 OK, application/json
{
  "draw": "2",
  "recordsFiltered": 3,
  "recordsTotal": 3,
  "data": [
    {
      "id": "c1d2e3f4-0000-1111-2222-333344445555",
      "name": "Juan Pérez",
      "dni": 28456789,
      "birthDate": "15/03/1990",
      "socialWork": "Swiss Medical",
      "affiliateNumber": "SM-00123456"
    }
  ]
}
Response fields
draw
string
Echo of the request’s draw counter.
recordsFiltered
integer
Total number of records after applying the search filter (equals recordsTotal since filtering happens at the service layer).
recordsTotal
integer
Total number of records in the result set before pagination.
data
PatientDTO[]
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 if ModelState is invalid. Required roles: Medico Requestapplication/x-www-form-urlencoded or application/json
Name
string
required
Patient’s full name. Maximum display label: "Nombre".
Dni
string
required
National identity number (DNI). Must be between 6 and 10 characters.
BirthDate
string (date)
required
Date of birth. Formatted as dd/MM/yyyy for display; stored as DateTime.
SocialWork
string
Health insurance / obra social name.
AffiliateNumber
string
Insurance affiliate number.
BloodType
integer
Integer value of the BloodType enum: 0 = A+, 1 = A-, 2 = B+, 3 = B-, 4 = AB+, 5 = AB-, 6 = O+, 7 = O-.
ContactInfo
object
Nested contact details object (ContactInfo entity). Fields depend on the ContactInfo model’s own properties.
Responses
StatusMeaning
200 OKPatient created successfully.
400 Bad RequestModelState validation failed.
409 ConflictAn 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
id
string (GUID)
required
The Patient.Id to edit.
Response: Partial view _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).
Id
string (GUID)
required
The Patient.Id (base-class BaseEntity.Id) to update.
Responses
StatusMeaning
200 OKPatient updated successfully.
400 Bad RequestModelState validation failed.
409 ConflictAn exception was thrown during update.

GET /Patients/Details/

Returns the full patient detail view. The controller loads both the Patient 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
id
string (GUID)
required
The Patient.Id to display.
Response: HTML view Details with the Patient model, or 404 Not Found. ViewBag values set:
KeyTypeContent
ParentsDataParentsDataGuardian/parent record for the patient, if one exists.
AgestringComputed age string (e.g. "5 años", "4 meses", "12 días").

Build docs developers (and LLMs) love