Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Imjuanisss/proyecto-melika/llms.txt

Use this file to discover all available pages before exploring further.

MELIKA maintains a curated medications catalog that serves as the reference source for prescriptions written inside clinical records. Every medication is classified as either over-the-counter (OTC) or prescription-only (Rx), linked to a medical specialty via id_especialidad, and searchable by commercial name or active ingredient. When a doctor prescribes during a consultation, the prescription text is stored in the medicamentos_recetados JSONB field of the historias_clinicas record, while structured per-drug rows go into the separate recetas_medicas table.

Medication Types

OTC — Over the Counter

Medications available without a prescription. Visible to all authenticated users in the catalog. Examples include common analgesics, antipyretics, and supplements.

Rx — Prescription Only

Medications that require a doctor’s prescription. Typically specialized or controlled substances. Only dispensed through a formal clinical record prescription.

Medication Data Model

FieldTypeDescription
idintegerUnique medication identifier
nombre_comercialvarcharBrand / commercial name (e.g., "Advil")
principio_activovarcharActive pharmaceutical ingredient (e.g., "Ibuprofeno")
laboratoriovarcharManufacturing laboratory or pharmaceutical company
tipoenum'OTC' or 'Rx'
descripciontextTherapeutic description and indications
presentacionestextAvailable forms and dosages (e.g., "Tabletas 200mg, 400mg, 600mg")
imagen_urlvarcharURL to the medication’s product image
id_especialidadintegerFK linking the medication to a medical specialty
activobooleanWhen FALSE, excluded from catalog and availability queries

Querying the Medications Catalog

Filtered Listing

The main catalog endpoint supports three independent, combinable query parameters:
GET /medicamentos?tipo=Rx&id_especialidad=1&buscar=losartan
Return only OTC or only Rx medications. The tipo parameter is validated against the set ['OTC', 'Rx'] — any other value is ignored.
GET /medicamentos?tipo=OTC
GET /medicamentos?tipo=Rx

Single Medication

Retrieve full details for a specific active medication by ID:
GET /medicamentos/:id
Example response:
{
  "id": 12,
  "nombre_comercial": "Losartán Normon",
  "principio_activo": "Losartán potásico",
  "laboratorio": "Normon S.A.",
  "tipo": "Rx",
  "descripcion": "Antagonista de los receptores de angiotensina II. Indicado en hipertensión arterial e insuficiencia cardíaca.",
  "presentaciones": "Comprimidos recubiertos 50mg, 100mg",
  "imagen_url": "https://storage.melika.app/medicamentos/losartan.jpg",
  "id_especialidad": 1,
  "activo": true
}
Returns 404 if the medication does not exist or has activo = FALSE.

Specialty Categories Listing

Returns the distinct specialty names that have at least one active medication linked to them. Use this to populate specialty-based filter labels in the catalog UI.
GET /medicamentos/categorias
The endpoint queries especialidades.nombre dynamically via a JOIN on medicamentos.id_especialidad. Only specialties with at least one medication where activo = TRUE appear. Example response:
[
  "Cardiología",
  "Medicina General",
  "Neurología",
  "Psiquiatría",
  "Urología"
]
This endpoint returns specialty names as plain strings, not full specialty objects. Use GET /especialidades when you need full specialty records including id, precio_base, and imagen_url.

Sample Medications in the Catalog

The following are representative medications available across the platform’s specialties:
Nombre ComercialPrincipio ActivoTipoSpecialty
Acetaminofén jarabeParacetamolOTCMedicina General
Ácido fólicoÁcido fólicoOTCGinecología
AmoxicilinaAmoxicilinaRxMedicina General
AtorvastatinaAtorvastatina cálcicaRxCardiología
IbuprofenoIbuprofenoOTCMedicina General
LosartánLosartán potásicoRxCardiología
MetforminaMetformina clorhidratoRxMedicina General
GabapentinaGabapentinaRxNeurología
TamsulosinaTamsulosina clorhidratoRxUrología

Medications in Clinical Records

When a doctor prescribes during a consultation, prescriptions are captured in two complementary ways:
  1. medicamentos_recetados (JSONB on historias_clinicas) — stores a free-text prescription summary as { "texto": "..." }.
  2. recetas_medicas table — stores structured per-drug rows submitted via the recetas array in POST /historias.
Each row in recetas_medicas contains:
FieldDescription
medicamentoDrug name
dosisDose amount
frecuenciaDosing frequency
duracionTreatment duration
via_administracionRoute of administration (optional)
indicacionesSpecial instructions (optional)
When building the prescription editor, pre-filter the medication picker using id_especialidad matching the current appointment’s specialty. This surfaces the most clinically relevant drugs first and reduces the search space for the prescribing doctor.

Admin Management

Administrators manage the medications catalog through standard CRUD endpoints. No separate /admin/ path prefix is used.
MethodEndpointAction
GET/medicamentos/adminRetrieve the full catalog including inactive medications
POST/medicamentosCreate a new medication entry
PUT/medicamentos/:idUpdate all fields of an existing medication
Deactivating a medication (activo = FALSE) removes it from GET /medicamentos and GET /medicamentos/categorias responses, but does not retroactively affect existing clinical records where it was already prescribed. Historical prescription data in recetas_medicas and medicamentos_recetados is preserved as-is.

Build docs developers (and LLMs) love