/** * Cliente TypeScript de la API de Abigail — GENERADO desde /api/openapi.json (no editar a mano). * Sin dependencias: usa fetch. Funciona en Node 18+ y navegadores. * * const api = new ApiClient({ baseUrl: 'https://su-servidor', apiKey: 'abi_test_…', clinicId: 12 }); * const pacientes = await api.patientsIndex({ per_page: 10 }); * await api.emergencyForm008Store({ … }, { idempotencyKey: crypto.randomUUID() }); */ export interface ApiEnvelope { success: boolean; message: string; data: T; request_id?: string; [k: string]: unknown } export interface ClientOptions { baseUrl: string; /** Llave de integración (abi_live_… / abi_test_…). */ apiKey?: string; /** Token personal (Bearer). */ token?: string; /** Clínica activa para tokens de usuario con varias clínicas (X-Clinic-ID). */ clinicId?: number; fetch?: typeof fetch; /** Reintentos ante 429/502/503/504 (respeta Retry-After). Solo si la operación es segura de repetir. Por defecto 2. */ maxRetries?: number; } export interface RequestOptions { idempotencyKey?: string; headers?: Record; signal?: AbortSignal } export class ApiError extends Error { constructor(public status: number, message: string, public requestId?: string, public errors?: Record) { super(message); this.name = 'ApiError'; } } export class ApiClient { private readonly f: typeof fetch; constructor(private readonly opts: ClientOptions) { this.f = opts.fetch ?? fetch; } private async request(method: string, path: string, o: { query?: Record; body?: unknown } & RequestOptions): Promise> { const url = new URL(this.opts.baseUrl.replace(/\/$/, '') + path); for (const [k, v] of Object.entries(o.query ?? {})) if (v !== undefined) url.searchParams.set(k, String(v)); const headers: Record = { Accept: 'application/json', ...(o.headers ?? {}) }; if (this.opts.apiKey) headers['X-API-Key'] = this.opts.apiKey; if (this.opts.token) headers['Authorization'] = `Bearer ${this.opts.token}`; if (this.opts.clinicId) headers['X-Clinic-ID'] = String(this.opts.clinicId); if (o.idempotencyKey) headers['Idempotency-Key'] = o.idempotencyKey; if (o.body !== undefined) headers['Content-Type'] = 'application/json'; const safeToRetry = method === 'GET' || !!o.idempotencyKey; const max = safeToRetry ? (this.opts.maxRetries ?? 2) : 0; for (let attempt = 0; ; attempt++) { const res = await this.f(url, { method, headers, body: o.body === undefined ? undefined : JSON.stringify(o.body), signal: o.signal }); if ([429, 502, 503, 504].includes(res.status) && attempt < max) { const wait = Number(res.headers.get('Retry-After')) || 2 ** attempt; await new Promise((r) => setTimeout(r, wait * 1000)); continue; } const json = (await res.json().catch(() => ({}))) as ApiEnvelope & { errors?: Record }; if (!res.ok) throw new ApiError(res.status, json.message ?? res.statusText, res.headers.get('X-Request-Id') ?? json.request_id, json.errors); return json; } } /** Appointments — Appointments — GET /api/mobile/v1/appointments */ generated::PSt4xodrBeIxv0dt(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/appointments`, { ...options }); } /** Iniciar sesión desde la app móvil y obtener un token — POST /api/mobile/v1/auth/login */ generated::DhN5gQmxjoybnQ1s(body: { email?: unknown; password?: unknown; device_name?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/mobile/v1/auth/login`, { body, ...options }); } /** Lab Results — Lab Results — GET /api/mobile/v1/clinical/lab-results */ generated::Ru7FqqH0MY3HTgd4(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/clinical/lab-results`, { ...options }); } /** Prescriptions — Prescriptions — GET /api/mobile/v1/clinical/prescriptions */ generated::JG4wep8pb0TxpQ01(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/clinical/prescriptions`, { ...options }); } /** Agenda — Agenda — GET /api/mobile/v1/doctor/agenda */ generated::tQyvUkam9A0fFIk9(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/doctor/agenda`, { ...options }); } /** Catálogos clínicos para construir formularios en la app (CIE10, exámenes de laboratorio e imagenología). — GET /api/mobile/v1/doctor/catalogs */ generated::imOmHNPDzRt30twc(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/doctor/catalogs`, { ...options }); } /** Crear una consulta de consulta externa (draft por defecto, o completed si se indica). — POST /api/mobile/v1/doctor/consultations */ generated::5LM69IzsiUxdBXtu(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/mobile/v1/doctor/consultations`, { body, ...options }); } /** Detalle de una consulta (secciones + órdenes vinculadas). — GET /api/mobile/v1/doctor/consultations/{consultation} */ generated::EHmEOBAVBDIJbtae(consultation: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/doctor/consultations/${encodeURIComponent(String(consultation))}`, { ...options }); } /** Ordenar estudios de imagenología vinculados a la consulta. — POST /api/mobile/v1/doctor/consultations/{consultation}/imaging-orders */ generated::fq09MZKbHHl3LYct(consultation: string | number, body: { items?: unknown; notes?: unknown; priority?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/mobile/v1/doctor/consultations/${encodeURIComponent(String(consultation))}/imaging-orders`, { body, ...options }); } /** Ordenar exámenes de laboratorio vinculados a la consulta. — POST /api/mobile/v1/doctor/consultations/{consultation}/lab-orders */ generated::N0Yg9Bp0DTKWRktC(consultation: string | number, body: { items?: unknown; notes?: unknown; priority?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/mobile/v1/doctor/consultations/${encodeURIComponent(String(consultation))}/lab-orders`, { body, ...options }); } /** Agregar recetas a una consulta existente (solo borradores o del propio doctor). — POST /api/mobile/v1/doctor/consultations/{consultation}/prescriptions */ generated::vn2mx2Bv7rbegHjU(consultation: string | number, body: { prescriptions?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/mobile/v1/doctor/consultations/${encodeURIComponent(String(consultation))}/prescriptions`, { body, ...options }); } /** Patients Today — Patients Today — GET /api/mobile/v1/doctor/patients-today */ generated::F9n8ylMaeZJoyKLl(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/doctor/patients-today`, { ...options }); } /** Get Current Patient I P S — Summary — GET /api/mobile/v1/ips/summary */ generated::yshScKMsabyFb0sw(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/ips/summary`, { ...options }); } /** Revoke the current access token (HIPAA: supports rapid credential invalidation). — DELETE /api/mobile/v1/tokens/current */ generated::WHda1ZC5cpNy4RTJ(options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/mobile/v1/tokens/current`, { ...options }); } /** Consultar user — GET /api/mobile/v1/user */ generated::qkRTbSoEx5VRF32B(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/mobile/v1/user`, { ...options }); } /** Obtener un token de acceso con permisos acotados — POST /api/tokens */ generated::rLBTkkY6JBTar8vD(body: { device_name?: unknown; email?: unknown; password?: unknown; abilities?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/tokens`, { body, ...options }); } /** Revocar el token actual (cerrar sesión) — DELETE /api/tokens/current */ generated::ey0hMdpypYXfelto(options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/tokens/current`, { ...options }); } /** Return SMART configuration JSON document. — GET /api/v1/.well-known/smart-configuration */ smartConfiguration(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/.well-known/smart-configuration`, { ...options }); } /** Expand — Expand — POST /api/v1/advancadimelco/expand */ advancadimelcoExpand(body: { text?: unknown; category?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/advancadimelco/expand`, { body, ...options }); } /** Parse — Parse — POST /api/v1/advancadimelco/parse */ advancadimelcoParse(body: { text?: unknown; category?: unknown; mode?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/advancadimelco/parse`, { body, ...options }); } /** Listar snippets — GET /api/v1/advancadimelco/snippets */ advancadimelcoSnippetsIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/advancadimelco/snippets`, { query, ...options }); } /** Crear snippets — POST /api/v1/advancadimelco/snippets */ advancadimelcoSnippetsStore(body: { trigger?: unknown; title?: unknown; body?: unknown; category?: unknown; language?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/advancadimelco/snippets`, { body, ...options }); } /** Actualizar snippets — PATCH /api/v1/advancadimelco/snippets/{advancadimelcoSnippet} */ advancadimelcoSnippetsUpdate(advancadimelcoSnippet: string | number, body: { trigger?: unknown; title?: unknown; body?: unknown; category?: unknown; language?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/advancadimelco/snippets/${encodeURIComponent(String(advancadimelcoSnippet))}`, { body, ...options }); } /** Eliminar snippets — DELETE /api/v1/advancadimelco/snippets/{advancadimelcoSnippet} */ advancadimelcoSnippetsDestroy(advancadimelcoSnippet: string | number, options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/v1/advancadimelco/snippets/${encodeURIComponent(String(advancadimelcoSnippet))}`, { ...options }); } /** Suggest — Suggest — GET /api/v1/advancadimelco/suggest */ advancadimelcoSuggest(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/advancadimelco/suggest`, { ...options }); } /** Listar terms — GET /api/v1/advancadimelco/terms */ advancadimelcoTermsIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/advancadimelco/terms`, { query, ...options }); } /** Crear terms — POST /api/v1/advancadimelco/terms */ advancadimelcoTermsStore(body: { code?: unknown; expansion?: unknown; description?: unknown; category?: unknown; language?: unknown; match_mode?: unknown; priority?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/advancadimelco/terms`, { body, ...options }); } /** Actualizar terms — PATCH /api/v1/advancadimelco/terms/{advancadimelcoTerm} */ advancadimelcoTermsUpdate(advancadimelcoTerm: string | number, body: { code?: unknown; expansion?: unknown; description?: unknown; category?: unknown; language?: unknown; match_mode?: unknown; priority?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/advancadimelco/terms/${encodeURIComponent(String(advancadimelcoTerm))}`, { body, ...options }); } /** Eliminar terms — DELETE /api/v1/advancadimelco/terms/{advancadimelcoTerm} */ advancadimelcoTermsDestroy(advancadimelcoTerm: string | number, options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/v1/advancadimelco/terms/${encodeURIComponent(String(advancadimelcoTerm))}`, { ...options }); } /** Generate Summary — Generate Summary — POST /api/v1/ai/generate-summary */ aiGenerateSummary(body: { notes?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/ai/generate-summary`, { body, ...options }); } /** Suggest Diagnoses — Suggest Diagnoses — POST /api/v1/ai/suggest-diagnoses */ aiSuggestDiagnoses(body: { reason?: unknown; physical_exam?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/ai/suggest-diagnoses`, { body, ...options }); } /** Suggest Dosage — Suggest Dosage — POST /api/v1/ai/suggest-dosage */ aiSuggestDosage(body: { medication?: unknown; reason?: unknown; illness?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/ai/suggest-dosage`, { body, ...options }); } /** Listar turnos de la agenda (filtros: practitioner_id, patient_id, status, date_from, date_to) — GET /api/v1/appointments */ integrationAppointmentsIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/appointments`, { query, ...options }); } /** Agendar un turno para un paciente con un profesional (sin doble reserva) — POST /api/v1/appointments */ integrationAppointmentsStore(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/appointments`, { body, ...options }); } /** Obtener un turno — GET /api/v1/appointments/{appointment} */ integrationAppointmentsShow(appointment: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/appointments/${encodeURIComponent(String(appointment))}`, { ...options }); } /** Confirmar llegada, cancelar o marcar inasistencia — PATCH /api/v1/appointments/{appointment}/status */ integrationAppointmentsStatus(appointment: string | number, body: { status?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/appointments/${encodeURIComponent(String(appointment))}/status`, { body, ...options }); } /** Obtener un token de acceso (iniciar sesión con usuario y contraseña) — POST /api/v1/auth/token */ authToken(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/auth/token`, { body, ...options }); } /** Search — Search — GET /api/v1/catalogs/{catalog}/search */ catalogsSearch(catalog: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/catalogs/${encodeURIComponent(String(catalog))}/search`, { ...options }); } /** Evaluate patient vital signs against NEWS2 and qSOFA predictive models. — POST /api/v1/clinical/prediction/sepsis-early-warning */ predictionSepsisEvaluate(body: { respiratory_rate?: unknown; oxygen_saturation?: unknown; supplemental_oxygen?: unknown; systolic_bp?: unknown; heart_rate?: unknown; consciousness?: unknown; temperature_celsius?: unknown; patient_id?: unknown; bed_code?: unknown; clinic_id?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/clinical/prediction/sepsis-early-warning`, { body, ...options }); } /** Listar diagnósticos CIE-10 (filtros: patient_id, code) — GET /api/v1/diagnoses */ integrationDiagnosesIndex(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/diagnoses`, { ...options }); } /** Listar form 008 — GET /api/v1/emergency/form-008 */ emergencyForm008Index(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/emergency/form-008`, { query, ...options }); } /** Crear form 008 — POST /api/v1/emergency/form-008 */ emergencyForm008Store(body: { header?: unknown; triage?: unknown; vitals?: unknown; clinical?: unknown; obgyn?: unknown; disposition?: unknown; professional?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/emergency/form-008`, { body, ...options }); } /** Obtener form 008 — GET /api/v1/emergency/form-008/{emergencyForm008} */ emergencyForm008Show(emergencyForm008: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/emergency/form-008/${encodeURIComponent(String(emergencyForm008))}`, { ...options }); } /** Actualizar form 008 — PATCH /api/v1/emergency/form-008/{emergencyForm008} */ emergencyForm008Update(emergencyForm008: string | number, body: { header?: unknown; triage?: unknown; vitals?: unknown; clinical?: unknown; obgyn?: unknown; disposition?: unknown; professional?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/emergency/form-008/${encodeURIComponent(String(emergencyForm008))}`, { body, ...options }); } /** Eliminar form 008 — DELETE /api/v1/emergency/form-008/{emergencyForm008} */ emergencyForm008Destroy(emergencyForm008: string | number, options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/v1/emergency/form-008/${encodeURIComponent(String(emergencyForm008))}`, { ...options }); } /** Print — Print — GET /api/v1/emergency/form-008/{emergencyForm008}/print */ emergencyForm008Print(emergencyForm008: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/emergency/form-008/${encodeURIComponent(String(emergencyForm008))}/print`, { ...options }); } /** Registrar una consulta completa (anamnesis, signos, diagnósticos, plan y prescripción) con un profesional responsable — POST /api/v1/encounters */ integrationEncountersStore(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/encounters`, { body, ...options }); } /** Listar consultas (filtros: patient_id, date_from, date_to) — GET /api/v1/encounters */ integrationEncountersIndex(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/encounters`, { ...options }); } /** Obtener una consulta completa — GET /api/v1/encounters/{consultation} */ integrationEncountersShow(consultation: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/encounters/${encodeURIComponent(String(consultation))}`, { ...options }); } /** Obtener la receta vigente de una consulta — GET /api/v1/encounters/{consultation}/recipe */ integrationEncountersRecipeShow(consultation: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/encounters/${encodeURIComponent(String(consultation))}/recipe`, { ...options }); } /** Emitir la receta de una consulta (solo el médico tratante) — POST /api/v1/encounters/{consultation}/recipe */ integrationEncountersRecipeIssue(consultation: string | number, body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/encounters/${encodeURIComponent(String(consultation))}/recipe`, { body, ...options }); } /** Process a FHIR transaction or batch Bundle (POST /api/v1/fhir). — POST /api/v1/fhir */ fhirBundle(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/fhir`, { body, ...options }); } /** Return SMART configuration JSON document. — GET /api/v1/fhir/.well-known/smart-configuration */ fhirSmartConfiguration(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/fhir/.well-known/smart-configuration`, { ...options }); } /** Obtener el CapabilityStatement del servidor FHIR — GET /api/v1/fhir/metadata */ fhirMetadata(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/fhir/metadata`, { ...options }); } /** Create — Fhir — POST /api/v1/fhir/{resourceType} */ fhirCreate(resourceType: string | number, body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/fhir/${encodeURIComponent(String(resourceType))}`, { body, ...options }); } /** Search or list resources by resource type. — GET /api/v1/fhir/{resourceType} */ fhirSearch(resourceType: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/fhir/${encodeURIComponent(String(resourceType))}`, { ...options }); } /** Operación $validate: valida el recurso sin persistir (200 información o — POST /api/v1/fhir/{resourceType}/$validate */ fhirValidate(resourceType: string | number, body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/fhir/${encodeURIComponent(String(resourceType))}/$validate`, { body, ...options }); } /** Actualizar fhir — PUT /api/v1/fhir/{resourceType}/{id} */ fhirUpdate(resourceType: string | number, id: string | number, body: Record, options: RequestOptions = {}): Promise> { return this.request('PUT', `/api/v1/fhir/${encodeURIComponent(String(resourceType))}/${encodeURIComponent(String(id))}`, { body, ...options }); } /** Read a specific resource by ID. — GET /api/v1/fhir/{resourceType}/{id} */ fhirRead(resourceType: string | number, id: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/fhir/${encodeURIComponent(String(resourceType))}/${encodeURIComponent(String(id))}`, { ...options }); } /** List active hospitalizations for current clinic. — GET /api/v1/hospitalization/active */ hospActive(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/hospitalization/active`, { ...options }); } /** Admit a patient. — POST /api/v1/hospitalization/admit */ hospAdmit(body: { patient_id?: unknown; bed_id?: unknown; admission_date?: unknown; admission_reason?: unknown; referral_source?: unknown; initial_notes?: unknown; diagnoses?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/hospitalization/admit`, { body, ...options }); } /** Print Pre-Anesthetic (Form 018) — GET /api/v1/hospitalization/pre-anesthetic-018/{form}/print */ hospPreanesthetic018Print(form: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/hospitalization/pre-anesthetic-018/${encodeURIComponent(String(form))}/print`, { ...options }); } /** Print Surgical Protocol (Form 017) — GET /api/v1/hospitalization/protocol-017/{protocol}/print */ hospProtocol017Print(protocol: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/hospitalization/protocol-017/${encodeURIComponent(String(protocol))}/print`, { ...options }); } /** Record discharge. — POST /api/v1/hospitalization/{hospitalization}/discharge */ hospDischarge(hospitalization: string | number, body: { discharge_date?: unknown; epicrisis_summary?: unknown; final_diagnoses?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/hospitalization/${encodeURIComponent(String(hospitalization))}/discharge`, { body, ...options }); } /** Add a medical evolution note. — POST /api/v1/hospitalization/{hospitalization}/evolution */ hospEvolution(hospitalization: string | number, body: { notes?: unknown; evolution_date?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/hospitalization/${encodeURIComponent(String(hospitalization))}/evolution`, { body, ...options }); } /** Generate PDF for the admission note. — GET /api/v1/hospitalization/{hospitalization}/print-admission */ hospPrintAdmission(hospitalization: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/hospitalization/${encodeURIComponent(String(hospitalization))}/print-admission`, { ...options }); } /** Print Anamnesis — Print Anamnesis — GET /api/v1/hospitalization/{hospitalization}/print-anamnesis */ hospPrintAnamnesis(hospitalization: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/hospitalization/${encodeURIComponent(String(hospitalization))}/print-anamnesis`, { ...options }); } /** Generate PDF for the Epicrisis. — GET /api/v1/hospitalization/{hospitalization}/print-epicrisis */ hospPrintEpicrisis(hospitalization: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/hospitalization/${encodeURIComponent(String(hospitalization))}/print-epicrisis`, { ...options }); } /** PATCH /api/v1/infrastructure/beds/{bed} — PATCH /api/v1/infrastructure/beds/{bed} */ infraBedsUpdate(bed: string | number, body: { name?: unknown; status?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/infrastructure/beds/${encodeURIComponent(String(bed))}`, { body, ...options }); } /** Overview of all rooms and bed availability for the current clinic. — GET /api/v1/infrastructure/overview */ infraOverview(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/infrastructure/overview`, { ...options }); } /** GET /api/v1/infrastructure/rooms — GET /api/v1/infrastructure/rooms */ infraRoomsIndex(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/infrastructure/rooms`, { ...options }); } /** POST /api/v1/infrastructure/rooms — POST /api/v1/infrastructure/rooms */ infraRoomsStore(body: { name?: unknown; type?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/infrastructure/rooms`, { body, ...options }); } /** PATCH /api/v1/infrastructure/rooms/{room} — PATCH /api/v1/infrastructure/rooms/{room} */ infraRoomsUpdate(room: string | number, body: { name?: unknown; type?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/infrastructure/rooms/${encodeURIComponent(String(room))}`, { body, ...options }); } /** DELETE /api/v1/infrastructure/rooms/{room} — DELETE /api/v1/infrastructure/rooms/{room} */ infraRoomsDestroy(room: string | number, options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/v1/infrastructure/rooms/${encodeURIComponent(String(room))}`, { ...options }); } /** GET /api/v1/infrastructure/rooms/{room}/beds — GET /api/v1/infrastructure/rooms/{room}/beds */ infraBedsIndex(room: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/infrastructure/rooms/${encodeURIComponent(String(room))}/beds`, { ...options }); } /** Send Fhir Patient — Patient — POST /api/v1/interoperability/fhir/patient */ interopFhirPatientSend(body: { resource?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/interoperability/fhir/patient`, { body, ...options }); } /** Get Fhir Patient — Patient — GET /api/v1/interoperability/fhir/patient/{id} */ interopFhirPatientGet(id: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/interoperability/fhir/patient/${encodeURIComponent(String(id))}`, { ...options }); } /** Ingest Hl7 — Ingest — POST /api/v1/interoperability/hl7/ingest */ interopHl7Ingest(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/interoperability/hl7/ingest`, { body, ...options }); } /** Send Hl7 — Send — POST /api/v1/interoperability/hl7/send */ interopHl7Send(body: { type?: unknown; patient?: unknown; message?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/interoperability/hl7/send`, { body, ...options }); } /** Map Fhir To Local — Patient — POST /api/v1/interoperability/map/fhir/patient */ interopMapFhirToLocal(body: { resource?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/interoperability/map/fhir/patient`, { body, ...options }); } /** Map Local To Fhir — Patient — GET /api/v1/interoperability/map/fhir/patient/{id} */ interopMapLocalToFhir(id: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/interoperability/map/fhir/patient/${encodeURIComponent(String(id))}`, { ...options }); } /** Test Fhir — Fhir — GET /api/v1/interoperability/test/fhir */ interopTestFhir(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/interoperability/test/fhir`, { ...options }); } /** Test Hl7 — Hl7 — GET /api/v1/interoperability/test/hl7 */ interopTestHl7(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/interoperability/test/hl7`, { ...options }); } /** Get Patient I P S — Patient — GET /api/v1/ips/patient/{id} */ ipsPatientSummary(id: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/ips/patient/${encodeURIComponent(String(id))}`, { ...options }); } /** Consultar me — GET /api/v1/me */ me(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/me`, { ...options }); } /** Consultar history — GET /api/v1/notifications/history */ notificationsHistory(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/notifications/history`, { ...options }); } /** Registrar register token — POST /api/v1/notifications/register-token */ notificationsRegister(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/notifications/register-token`, { body, ...options }); } /** Actualizar read — PATCH /api/v1/notifications/{notificationId}/read */ notificationsRead(notificationId: string | number, body: Record, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/notifications/${encodeURIComponent(String(notificationId))}/read`, { body, ...options }); } /** Display a listing of consultations. — GET /api/v1/outpatient/consultations */ outpatientConsultationsIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/outpatient/consultations`, { query, ...options }); } /** Display the specified consultation. — POST /api/v1/outpatient/consultations */ outpatientConsultationsStore(body: Record, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/outpatient/consultations`, { body, ...options }); } /** Display the specified consultation. — GET /api/v1/outpatient/consultations/{consultation} */ outpatientConsultationsShow(consultation: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/outpatient/consultations/${encodeURIComponent(String(consultation))}`, { ...options }); } /** Update the specified consultation. — PUT /api/v1/outpatient/consultations/{consultation} */ outpatientConsultationsUpdate(consultation: string | number, body: Record, options: RequestOptions = {}): Promise> { return this.request('PUT', `/api/v1/outpatient/consultations/${encodeURIComponent(String(consultation))}`, { body, ...options }); } /** Generate PDF for the consultation. — GET /api/v1/outpatient/consultations/{consultation}/print-anamnesis */ outpatientConsultationsPrintAnamnesis(consultation: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/outpatient/consultations/${encodeURIComponent(String(consultation))}/print-anamnesis`, { ...options }); } /** List history for a patient. — GET /api/v1/outpatient/patients/{patient}/history */ outpatientPatientsHistory(patient: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/outpatient/patients/${encodeURIComponent(String(patient))}/history`, { ...options }); } /** Listar y buscar pacientes (paginado) — GET /api/v1/patients */ patientsIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/patients`, { query, ...options }); } /** Registrar un paciente (409 si el documento ya existe en la clínica) — POST /api/v1/patients */ integrationPatientsStore(body: { document_number?: unknown; document_type?: unknown; given_names?: unknown; family_name?: unknown; second_family_name?: unknown; birth_date?: unknown; sex?: unknown; phone?: unknown; email?: unknown; address?: unknown; blood_type?: unknown; [k: string]: unknown }, query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/patients`, { query, body, ...options }); } /** Obtener la identificación de un paciente — GET /api/v1/patients/{patient} */ integrationPatientsShow(patient: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/patients/${encodeURIComponent(String(patient))}`, { ...options }); } /** Consultar si el paciente tiene consentimiento vigente y si la clínica lo exige — GET /api/v1/patients/{patient}/consents */ integrationPatientsConsentsShow(patient: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/patients/${encodeURIComponent(String(patient))}/consents`, { ...options }); } /** Registrar el consentimiento del paciente (solo personal de la clínica; una aplicación recibe 403) — POST /api/v1/patients/{patient}/consents */ integrationPatientsConsentsStore(patient: string | number, body: { type?: unknown; expires_at?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/patients/${encodeURIComponent(String(patient))}/consents`, { body, ...options }); } /** Retirar el consentimiento del paciente (rige desde la siguiente petición) — DELETE /api/v1/patients/{patient}/consents */ integrationPatientsConsentsDestroy(patient: string | number, options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/v1/patients/${encodeURIComponent(String(patient))}/consents`, { ...options }); } /** Expediente del paciente: consultas con anamnesis, diagnóstico, tratamiento y prescripción, y recetas emitidas — GET /api/v1/patients/{patient}/medical-record */ integrationPatientsMedicalRecord(patient: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/patients/${encodeURIComponent(String(patient))}/medical-record`, { ...options }); } /** Dispense medications to a patient. — POST /api/v1/pharmacy/dispense */ pharmacyDispense(body: { patient_id?: unknown; items?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/pharmacy/dispense`, { body, ...options }); } /** Display current inventory levels. — GET /api/v1/pharmacy/inventory */ pharmacyInventory(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/pharmacy/inventory`, { ...options }); } /** Comprobar que la API responde (no requiere credenciales) — GET /api/v1/ping */ ping(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/ping`, { ...options }); } /** Listar los profesionales de la clínica — GET /api/v1/practitioners */ integrationPractitionersIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/practitioners`, { query, ...options }); } /** Obtener un profesional — GET /api/v1/practitioners/{practitioner} */ integrationPractitionersShow(practitioner: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/practitioners/${encodeURIComponent(String(practitioner))}`, { ...options }); } /** Horarios libres de un profesional en una fecha — GET /api/v1/practitioners/{practitioner}/availability */ integrationPractitionersAvailability(practitioner: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/practitioners/${encodeURIComponent(String(practitioner))}/availability`, { ...options }); } /** Listar prescripciones: medicamento, dosis, frecuencia, duración, vía e indicaciones — GET /api/v1/prescriptions */ integrationPrescriptionsIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/prescriptions`, { query, ...options }); } /** Obtener una prescripción — GET /api/v1/prescriptions/{prescription} */ integrationPrescriptionsShow(prescription: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/prescriptions/${encodeURIComponent(String(prescription))}`, { ...options }); } /** Listar recetas emitidas (filtros: folio, status, patient_id) — GET /api/v1/recipes */ integrationRecipesIndex(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/recipes`, { ...options }); } /** Obtener una receta con sus medicamentos — GET /api/v1/recipes/{recipe} */ integrationRecipesShow(recipe: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/recipes/${encodeURIComponent(String(recipe))}`, { ...options }); } /** Registrar la dispensación de una receta (requiere el código de verificación impreso) — POST /api/v1/recipes/{recipe}/dispense */ integrationRecipesDispense(recipe: string | number, body: { verification_code?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/recipes/${encodeURIComponent(String(recipe))}/dispense`, { body, ...options }); } /** Listar settings — GET /api/v1/settings */ settingsIndex(query: { page?: string | number; per_page?: string | number; [k: string]: string | number | undefined } = {}, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/settings`, { query, ...options }); } /** Crear settings — POST /api/v1/settings */ settingsStore(body: { scope?: unknown; scope_id?: unknown; key?: unknown; value_json?: unknown; value_text?: unknown; value_type?: unknown; description?: unknown; is_sensitive?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/settings`, { body, ...options }); } /** Obtener settings — GET /api/v1/settings/{systemSetting} */ settingsShow(systemSetting: string | number, options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/settings/${encodeURIComponent(String(systemSetting))}`, { ...options }); } /** Actualizar settings — PATCH /api/v1/settings/{systemSetting} */ settingsUpdate(systemSetting: string | number, body: { value_json?: unknown; value_text?: unknown; value_type?: unknown; description?: unknown; is_sensitive?: unknown; is_active?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('PATCH', `/api/v1/settings/${encodeURIComponent(String(systemSetting))}`, { body, ...options }); } /** Eliminar settings — DELETE /api/v1/settings/{systemSetting} */ settingsDestroy(systemSetting: string | number, options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/v1/settings/${encodeURIComponent(String(systemSetting))}`, { ...options }); } /** Issue a scoped personal access token (HIPAA: restricts access to minimum necessary data). — POST /api/v1/tokens */ tokensStore(body: { device_name?: unknown; email?: unknown; password?: unknown; abilities?: unknown; [k: string]: unknown }, options: RequestOptions = {}): Promise> { return this.request('POST', `/api/v1/tokens`, { body, ...options }); } /** Revoke the current access token (HIPAA: supports rapid credential invalidation). — DELETE /api/v1/tokens/current */ tokensDestroy(options: RequestOptions = {}): Promise> { return this.request('DELETE', `/api/v1/tokens/current`, { ...options }); } /** Listar planes terapéuticos (filtro: patient_id) — GET /api/v1/treatments */ integrationTreatmentsIndex(options: RequestOptions = {}): Promise> { return this.request('GET', `/api/v1/treatments`, { ...options }); } }