Skip to main content

ObelioCore — Database Schema

:::info Auto-generated This page is generated automatically from the Table/*.xml files in obeliOmed/OftalmolBase on every merge to develop. Last updated: 2026-06-20. :::

Table overview

19 tables defined by this plugin.

TableColumnsConstraints
obelio_core_episodes148
obelio_core_expedients149
obelio_patient_specialty_history63
oft_file_attachments71
oft_file_attachments_links84
oft_filetypes72
oft_filetypes_validities31
oft_insurance_company51
oft_logs131
oft_notes113
oft_patients363
oft_printtemplates91
oft_reasons71
oft_reviews61
oft_specialists161
oft_specialities31
oft_tests41
oft_treatment_reasons23
oft_treatments103

:::note Naming conventions

  • Constraints follow ADR-027 prefix pattern: pk_ primary key, fk_ foreign key, uq_ unique, idx_ index.
  • Table names follow ADR-025 rename: obelio_<plugin>_* (legacy oft_* tables migrated during v2 refactor).

:::

Table details

obelio_core_episodes

ColumnTypeNullDefault
idserialYES
idExpedientintNO
idReasonintYES
titlevarchar(120)YES
descriptiontextYES
statusvarchar(20)NO
priorityvarchar(10)NO
openedAtdatetimeNOCURRENT_TIMESTAMP
modifiedAtdatetimeNOCURRENT_TIMESTAMP
closedAtdatetimeYES
idUserOpenedByvarchar(50)YES
idUserClosedByvarchar(50)YES
closureNotetextYES
idAssignedSpecialistintYES

Primary key: PRIMARY KEY (id)

Foreign keys:

  • obelio_core_episodes_idExpedient_fkey: FOREIGN KEY (idExpedient) REFERENCES obelio_core_expedients (id) ON DELETE CASCADE ON UPDATE CASCADE
  • obelio_core_episodes_idReason_fkey: FOREIGN KEY (idReason) REFERENCES oft_reasons (id) ON DELETE SET NULL ON UPDATE CASCADE
  • obelio_core_episodes_idUserOpenedBy_fkey: FOREIGN KEY (idUserOpenedBy) REFERENCES users (nick) ON DELETE SET NULL ON UPDATE CASCADE
  • obelio_core_episodes_idUserClosedBy_fkey: FOREIGN KEY (idUserClosedBy) REFERENCES users (nick) ON DELETE SET NULL ON UPDATE CASCADE
  • obelio_core_episodes_idAssignedSpecialist_fkey: FOREIGN KEY (idAssignedSpecialist) REFERENCES oft_specialists (id) ON DELETE SET NULL ON UPDATE CASCADE

obelio_core_expedients

ColumnTypeNullDefault
idserialYES
idPatientintNO
idSpecialityintNO
idEmpresaintYES
statusvarchar(20)NO
openedAtdatetimeNOCURRENT_TIMESTAMP
modifiedAtdatetimeNOCURRENT_TIMESTAMP
closedAtdatetimeYES
idUserOpenedByvarchar(50)YES
idUserClosedByvarchar(50)YES
idAssignedSpecialistintYES
closeReasontextYES
professionalPrivateNotestextYES
tagstextYES

Primary key: PRIMARY KEY (id)

Foreign keys:

  • obelio_core_expedients_idPatient_fkey: FOREIGN KEY (idPatient) REFERENCES oft_patients (idPatient) ON DELETE RESTRICT ON UPDATE CASCADE
  • obelio_core_expedients_idSpeciality_fkey: FOREIGN KEY (idSpeciality) REFERENCES oft_specialities (id) ON DELETE RESTRICT ON UPDATE CASCADE
  • obelio_core_expedients_idEmpresa_fkey: FOREIGN KEY (idEmpresa) REFERENCES empresas (idempresa) ON DELETE SET NULL ON UPDATE CASCADE
  • obelio_core_expedients_idUserOpenedBy_fkey: FOREIGN KEY (idUserOpenedBy) REFERENCES users (nick) ON DELETE SET NULL ON UPDATE CASCADE
  • obelio_core_expedients_idUserClosedBy_fkey: FOREIGN KEY (idUserClosedBy) REFERENCES users (nick) ON DELETE SET NULL ON UPDATE CASCADE
  • obelio_core_expedients_idAssignedSpecialist_fkey: FOREIGN KEY (idAssignedSpecialist) REFERENCES oft_specialists (id) ON DELETE SET NULL ON UPDATE CASCADE

Unique constraints:

  • obelio_core_expedients_idPatient_idSpeciality_idEmpresa_key: UNIQUE (idPatient, idSpeciality, idEmpresa)

obelio_patient_specialty_history

ColumnTypeNullDefault
idserialNO
idpatientintegerNO
codspecialtyvarchar(10)NO``
history_texttextYES
updated_attimestampYESCURRENT_TIMESTAMP
updated_byvarchar(50)YES

Primary key: PRIMARY KEY (id)

Foreign keys:

  • obelio_patient_specialty_history_idpatient_fkey: FOREIGN KEY (idpatient) REFERENCES oft_patients (idPatient) ON DELETE CASCADE ON UPDATE CASCADE

Unique constraints:

  • obelio_patient_specialty_history_idpatient_codspecialty_key: UNIQUE (idpatient, codspecialty)

oft_file_attachments

ColumnTypeNullDefault
idserialYES
fileNametextNO
filePathtextNO
fileTypevarchar(50)NO
uploadDatedatetimeNOCURRENT_TIMESTAMP
nickvarchar(50)NO
generalNotetextYES

Primary key: PRIMARY KEY (id)

ColumnTypeNullDefault
idserialYES
idFileintNO
idSpecialityintNO
idExpedientintYES
idPatientintNO
idFileTypevarchar(50)YES
idTestRecordintYES
idTestTypeintYES

Primary key: PRIMARY KEY (id)

Foreign keys:

  • fk_file_attachment_links_file_attachments: FOREIGN KEY (idFile) REFERENCES oft_file_attachments (id) ON DELETE CASCADE ON UPDATE CASCADE
  • oft_file_attachments_links_idExpedient_fkey: FOREIGN KEY (idExpedient) REFERENCES obelio_core_expedients (id) ON DELETE CASCADE ON UPDATE CASCADE
  • fk_file_attachments_links_patient: FOREIGN KEY (idPatient) REFERENCES oft_patients (idPatient) ON DELETE RESTRICT ON UPDATE CASCADE

oft_filetypes

ColumnTypeNullDefault
idserialYES
idSpecialityintNO
nickvarchar(50)NO
creationDatedatetimeNOCURRENT_TIMESTAMP
idValidityintYES
fileNamecharacter varying(100)NO
generalNotetextYES

Primary key: PRIMARY KEY (id)

Foreign keys:

  • oft_filetypes_validities_fk: FOREIGN KEY (idValidity) REFERENCES oft_filetypes_validities(id)

oft_filetypes_validities

ColumnTypeNullDefault
idserialYES
namevarchar(100)NO
durationvarchar(50)NO

Primary key: PRIMARY KEY (id)

oft_insurance_company

ColumnTypeNullDefault
idserialYES
idSpecialityintNO
nickvarchar(50)NO
creationDatedatetimeNOCURRENT_TIMESTAMP
companyNamecharacter varying(100)NO

Primary key: PRIMARY KEY (id)

oft_logs

ColumnTypeNullDefault
idserialNO
idPatientintegerNO
idExpedientintegerNO
idTestTypeintegerNO
modelcharacter varying(100)YES
nickcharacter varying(50)YES
channelcharacter varying(40)YES
levelcharacter varying(15)NO
ipcharacter varying(40)YES
messagetextYES
contexttextYES
timetimestampNO
uricharacter varying(200)YES

Primary key: PRIMARY KEY (id)

oft_notes

ColumnTypeNullDefault
idserialYES
idSpecialityintNO
idExpedientintNO
idEpisodeintYES
idNoteTypeintNO
nickvarchar(50)NO
creationDatedatetimeNOCURRENT_TIMESTAMP
modificationDatedatetimeNOCURRENT_TIMESTAMP
notetextNO
generalNotetextYES
profesionalNotetextYES

Primary key: PRIMARY KEY (id)

Foreign keys:

  • oft_notes_idExpedient_fkey: FOREIGN KEY (idExpedient) REFERENCES obelio_core_expedients (id) ON DELETE CASCADE ON UPDATE CASCADE
  • oft_notes_idEpisode_fkey: FOREIGN KEY (idEpisode) REFERENCES obelio_core_episodes (id) ON DELETE SET NULL ON UPDATE CASCADE

oft_patients

ColumnTypeNullDefault
idPatientserialYES
codclientevarchar(10)YES
idContactintYES
nickvarchar(50)NO
firstNamevarchar(60)YES
lastName1varchar(60)YES
lastName2varchar(60)YES
gendervarchar(1)YES
documentTypevarchar(10)YES
nifvarchar(10)YES
birthDateDateYES
ageintegerYES
idiomavarchar(5)YES
phoneNumbervarchar(20)YES
phoneNumber2varchar(20)YES
emailvarchar(120)YES
jobvarchar(120)YES
idInsuranceintYES
numInsurancevarchar(20)YES
insuranceCompanyNamevarchar(100)YES
allergiestextYES
diseasestextYES
medicationtextYES
surgeriestextYES
personalHistorytextYES
familyHistorytextYES
habitstextYES
emergencyContactNamevarchar(100)YES
emergencyContactPhonevarchar(20)YES
emergencyContactRelationvarchar(20)YES
observations_generaltextYES
professional_private_notestextYES
consentMarketingbooleanNOfalse
consentDataSharebooleanNOfalse
portalAccountEnabledbooleanNOfalse
portalLastLogintimestampYES

Primary key: PRIMARY KEY (idPatient)

Foreign keys:

  • oft_patients_idContact_fkey: FOREIGN KEY (idContact) REFERENCES contactos (idcontacto) ON DELETE SET NULL ON UPDATE CASCADE
  • oft_patients_idInsurance_fkey: FOREIGN KEY (idInsurance) REFERENCES oft_insurance_company (idInsurance) ON DELETE SET NULL ON UPDATE CASCADE

oft_printtemplates

ColumnTypeNullDefault
idserialNO
namecharacter varying(50)NO
labelcharacter varying(100)NO
paper_sizecharacter varying(20)YES
orientationcharacter varying(5)YES'P'
header_heightintegerYES
footer_heightintegerYES
left_marginintegerYES10
right_marginintegerYES10

Primary key: PRIMARY KEY (id)

oft_reasons

ColumnTypeNullDefault
idserialYES
idSpecialityintNO
nickvarchar(50)NO
creationDatedatetimeNOCURRENT_TIMESTAMP
OMScodetextYES
namecharacter varying(100)NO
descriptiontextYES

Primary key: PRIMARY KEY (id)

oft_reviews

ColumnTypeNullDefault
idserialYES
idSpecialityintNO
nickvarchar(50)NO
creationDatedatetimeNOCURRENT_TIMESTAMP
reviewNamecharacter varying(100)NO
generalNotetextYES

Primary key: PRIMARY KEY (id)

oft_specialists

ColumnTypeNullDefault
idserialNO
idSpecialityintegerNO
codAgenteintegerYES
creationDatedatetimeNOCURRENT_TIMESTAMP
namecharacter varying(100)NO
nifcharacter varying(10)YES
addresscharacter varying(100)YES
phoneNumberintYES
emailcharacter varying(100)YES
codpostalintegerYES
towncharacter varying(100)YES
provincecharacter varying(100)YES
numcolegiadocharacter varying(20)YES
colegioProfesionalcharacter varying(100)YES
signcharacter varying(100)YES
notescharacter varying(100)YES

Primary key: PRIMARY KEY (id)

oft_specialities

ColumnTypeNullDefault
idserialYES
idSpecialityvarchar(50)NO
specialityNamevarchar(75)NO

Primary key: PRIMARY KEY (id)

oft_tests

ColumnTypeNullDefault
idserialYES
idSpecialityintNO
testNamecharacter varying(100)NO
testTypeintNO

Primary key: PRIMARY KEY (id)

oft_treatment_reasons

ColumnTypeNullDefault
idTreatmentintNO
idReasonintNO

Primary key: PRIMARY KEY (idTreatment, idReason)

Foreign keys:

  • fk_oft_treatment_reasons_treatment: FOREIGN KEY (idTreatment) REFERENCES oft_treatments (id) ON DELETE CASCADE ON UPDATE CASCADE
  • fk_oft_treatment_reasons_reasons: FOREIGN KEY (idReason) REFERENCES oft_reasons (id) ON DELETE RESTRICT ON UPDATE CASCADE

oft_treatments

ColumnTypeNullDefault
idserialYES
idSpecialityintNO
idExpedientintNO
idReviewintYES
nickvarchar(50)NO
creationDatedatetimeNOCURRENT_TIMESTAMP
modificationDatedatetimeNOCURRENT_TIMESTAMP
treatmenttextNO
generalNotetextYES
profesionalNotetextYES

Primary key: PRIMARY KEY (id)

Foreign keys:

  • oft_treatments_idExpedient_fkey: FOREIGN KEY (idExpedient) REFERENCES obelio_core_expedients (id) ON DELETE RESTRICT ON UPDATE CASCADE
  • fk_oft_treatments_review: FOREIGN KEY (idReview) REFERENCES oft_reviews (id) ON DELETE SET NULL ON UPDATE CASCADE