RedM documentation

Murphy's Doctor

Getting Started

Database


murphy_doctor stores its data in 14 MySQL tables, all prefixed murphy_doctor_, through oxmysql. They are created automatically on start (CREATE TABLE IF NOT EXISTS), and older installs are upgraded on start. database.sql, at the root of the resource, contains the same schema for reference or manual provisioning. All tables use InnoDB and utf8mb4.

Identifiers

Every identifier, *_identifier, doctor_id, patient_id, victim_id, attacker_id and deceased_id column stores the character id, never the player license:

Framework Value stored
REDEM:RP 2023 citizenid
VORP charIdentifier (as text)
RSG-Core citizenid

Every dispensary_id column stores the logical dispensary id: the id field of an entry of Config.Dispensaries (shared/config_dispensary.lua). It is not the id primary key of the murphy_doctor_dispensary table.

Tables at a glance

Table Created One row per Written by
murphy_doctor_health always character health system
murphy_doctor_coma always character currently in a coma coma system
murphy_doctor_reports always medical report treatment, autopsy
murphy_doctor_members always doctor and dispensary dispensary board, staff commands
murphy_doctor_dispensary always dispensary dispensary board
murphy_doctor_metabolism_layout always character HUD editor
murphy_doctor_duty Config.Duty.Enabled character duty clock
murphy_doctor_treasury Config.Nurse.Treasury.Enabled dispensary treasury
murphy_doctor_treasury_log Config.Nurse.Treasury.Enabled treasury movement treasury
murphy_doctor_invoices Config.Billing.Enabled invoice billing
murphy_doctor_addictions Config.Addiction.Enabled character and substance addiction system
murphy_doctor_incidents Config.Incidents.Enabled coma incident records
murphy_doctor_records Config.Records.Enabled is not false character medical file
murphy_doctor_certificates Config.Autopsy.Enabled is not false death certificate autopsy

All modules are enabled in the default configuration. A table of a disabled module is simply not created; enabling the module later creates it at the next start.

Core tables

These six are created by server/sv_main.lua on every start.

murphy_doctor_health

The persisted medical state of each character. Written regularly while the player plays (Config.Metabolism.SaveInterval, 120 s by default), at disconnect and when the resource stops.

Column Type Content
id INT, auto increment Primary key
identifier VARCHAR(60), unique Character id
health INT, default 100 Health points
max_health INT, default 100 Maximum health
hunger FLOAT, default 100 Hunger, 0 to 100
thirst FLOAT, default 100 Thirst, 0 to 100
temperature FLOAT, default 37 Body temperature (°C)
injuries JSON Injuries by body part
conditions JSON Active conditions (bleeding, poisoned...)
diseases JSON Active diseases (id to state)
immunities JSON Disease immunities (id to expiry, epoch seconds)
alcohol_wear FLOAT, default 0 Liver wear, 0 to 100
last_update TIMESTAMP Last save
created_at TIMESTAMP Creation

murphy_doctor_coma

One row per character currently in a coma. It is what puts a player back in a coma after a disconnect or a server restart. The row is deleted when the player is revived or gets up after the timer.

Column Type Content
id INT, auto increment Primary key
identifier VARCHAR(60), unique Character id
cause VARCHAR(255), default Unknown Coma cause key
cooldown INT, default 120 Coma duration in seconds
start_time INT Start of the coma, epoch seconds
created_at TIMESTAMP Creation

murphy_doctor_reports

The medical reports shown in the archives: signed treatment reports, and the report written with each death certificate.

Column Type Content
id INT, auto increment Primary key
report_id VARCHAR(20), unique Public report number
patient_identifier VARCHAR(60) Patient's character id
patient_name / patient_surname VARCHAR(100) Patient's first and last name
doctor_identifier VARCHAR(60) Author's character id
doctor_name VARCHAR(100) Author's name
notes TEXT Doctor's notes
constants JSON Vitals read during the exam
symptoms JSON Symptoms
prescriptions JSON Prescribed medications and doses
cause_of_coma VARCHAR(255) Filled when the patient was in a coma
signature TEXT Doctor's drawn signature
signed TINYINT, default 0 1 once signed
dispensary_id INT Logical dispensary id
created_at / updated_at TIMESTAMP Creation and last change

Indexes on patient_identifier and doctor_identifier.

murphy_doctor_members

The doctor roster. It is the table read by the "database" doctor detection mode, and the one edited from the dispensary board and with doc_addchief, doc_adddoctor and doc_wipedispensary. A character can belong to several dispensaries (one row each).

Column Type Content
id INT, auto increment Primary key
dispensary_id INT, default 1 Logical dispensary id
identifier VARCHAR(60) Character id
name VARCHAR(100) Character name
rank VARCHAR(50), default Intern Free text rank
is_chief TINYINT, default 0 1 = chief of that dispensary
status VARCHAR(16), default present Status set on the board: present, away, busy, break
created_at TIMESTAMP Recruitment date

The server keeps the roster in memory and reloads it after every change made through the script. After editing this table by hand, restart murphy_doctor so the change is read.

murphy_doctor_dispensary

One row per dispensary, holding the notes of its board.

Column Type Content
id INT, auto increment Primary key
dispensary_id INT, unique Logical dispensary id
name VARCHAR(100) Dispensary name
notes TEXT Board notes
created_at / updated_at TIMESTAMP Creation and last change

On every start, one row is inserted for each entry of Config.Dispensaries, and name is updated from the config. Existing notes are kept.

murphy_doctor_metabolism_layout

One row per character: the positions of the HUD indicators, saved when the player moves them (/edithud).

Column Type Content
id INT, auto increment Primary key
identifier VARCHAR(60), unique Character id
positions JSON Indicator positions
created_at / updated_at TIMESTAMP Creation and last change

Module tables

murphy_doctor_duty

Created by server/sv_duty.lua when Config.Duty.Enabled. The duty clock and uncollected pay of each doctor.

Column Type Content
identifier VARCHAR(60), primary key Character id
on_duty TINYINT, default 0 1 while clocked in
dispensary_id INT Dispensary of the current shift
accrued DECIMAL(12,2), default 0 Pay earned and not collected yet
weekly_seconds INT, default 0 Time on duty this week
week_start VARCHAR(10) Start of the current week
updated_at DATETIME Last change

murphy_doctor_treasury

Created by server/sv_treasury.lua when Config.Nurse.Treasury.Enabled. One balance per dispensary.

Column Type Content
dispensary_id INT, primary key Logical dispensary id
balance DECIMAL(12,2), default 0 Current balance
updated_at DATETIME Last change

murphy_doctor_treasury_log

The ledger of every treasury movement, shown on the board.

Column Type Content
id INT, auto increment Primary key
dispensary_id INT Logical dispensary id
kind VARCHAR(20) nurse, invoice, withdraw, salary or refund
amount DECIMAL(12,2) Signed amount: positive = credit, negative = debit
actor VARCHAR(100) Name of the person behind the movement
created_at DATETIME Date

Index on (dispensary_id, created_at).

murphy_doctor_invoices

Created by server/sv_billing.lua when Config.Billing.Enabled.

Column Type Content
id INT, auto increment Primary key, the invoice number
dispensary_id INT Logical dispensary id
doctor_id / doctor_name VARCHAR Issuing doctor
patient_id / patient_name VARCHAR Patient
amount DECIMAL(10,2) Amount
reason VARCHAR(255) Reason written by the doctor
status VARCHAR(12), default unpaid unpaid, paid or cancelled
tax DECIMAL(10,2), default 0 Municipal tax taken at payment (murphy_politics)
created_at DATETIME Issue date
paid_at DATETIME Payment date
settled TINYINT, default 1 0 = paid, but the doctor has not been credited yet (treasury off and doctor offline; credited at their next login)

Indexes on (patient_id, status) and (dispensary_id, status).

murphy_doctor_addictions

Created by server/sv_addiction.lua when Config.Addiction.Enabled.

Column Type Content
identifier VARCHAR(60) Character id
substance VARCHAR(32) Substance key of Config.Addiction.Substances (alcohol, tobacco, opiates)
level FLOAT, default 0 Dependence level
last_use INT, default 0 Last use, epoch seconds
updated_at INT, default 0 Last change, epoch seconds

Primary key (identifier, substance).

murphy_doctor_incidents

Created by server/sv_incidents.lua when Config.Incidents.Enabled. One row per coma, read with /incidents by doctors, staff and law jobs.

Column Type Content
id INT, auto increment Primary key
victim_id / victim_name VARCHAR Victim
cause VARCHAR(40) Coma cause key
weapon VARCHAR(60) Weapon, when known
attacker_id / attacker_name VARCHAR Attacker, when a player
attacker_npc TINYINT, default 0 1 when the attacker was an NPC
zone VARCHAR(60) Area name
x, y, z FLOAT Position
created_at DATETIME Date

Indexes on victim_id, attacker_id and created_at.

murphy_doctor_records

Created by server/sv_records.lua unless Config.Records.Enabled = false. The medical file doctors write for a patient (the "Medical file" tab of a report in the archives).

Column Type Content
identifier VARCHAR(60), primary key Character id
blood_type VARCHAR(4) Blood type
allergies VARCHAR(255) Allergies
conditions VARCHAR(500) Chronic conditions
notes TEXT Notes
updated_by VARCHAR(100) Name of the last doctor who edited it
updated_at TIMESTAMP Last change

murphy_doctor_certificates

Created by server/sv_autopsy.lua unless Config.Autopsy.Enabled = false. One row per death certificate written after an autopsy, read with /certificates. Each certificate also adds a signed report to murphy_doctor_reports.

Column Type Content
id INT, auto increment Primary key
certificate_id VARCHAR(40) Public certificate number (DC-...)
deceased_id VARCHAR(60) Character id, empty for an NPC
deceased_name VARCHAR(100) Name of the deceased
cause VARCHAR(40) Cause of death
weapon VARCHAR(60) Weapon
wound VARCHAR(40) Fatal wound (body part)
time_of_death VARCHAR(60) Estimated time of death
place VARCHAR(60) Place
notes TEXT Doctor's notes
doctor_id / doctor_name VARCHAR Doctor
dispensary_id INT Logical dispensary id
created_at DATETIME Date

Indexes on deceased_id and created_at.

Automatic maintenance

Done by the resource, nothing to run by hand:

When What
Every start Missing tables are created
Every start Older tables are upgraded: murphy_doctor_reports.dispensary_id added and signature widened to TEXT; murphy_doctor_members.is_chief added and status changed from an enumeration to text; murphy_doctor_health.diseases, immunities and alcohol_wear added. Each change prints a Migration: line once
Every start Health rows whose max_health is empty, zero or below health are repaired (a repaired N health row(s) line is printed)
Every start Dispensary rows are created or renamed from Config.Dispensaries
Every start Incidents older than Config.Incidents.KeepDays (30) are deleted (0 keeps them all)
One minute after start Rows of deleted characters are removed (see below)
Every hour Unpaid invoices older than Config.Billing.ExpireDays (14) are set to cancelled (0 never cancels them)

Cleanup of deleted characters

With Config.CleanDeletedCharacters = true (default, shared/config.lua), one minute after each start the server compares the character ids of these tables with the characters that still exist in your framework, and deletes the rows of characters that are gone:

  • murphy_doctor_health
  • murphy_doctor_coma
  • murphy_doctor_metabolism_layout
  • murphy_doctor_duty
  • murphy_doctor_members
  • murphy_doctor_addictions

Reports, invoices, incidents, medical files and certificates are kept: they are the history of the dispensaries.

The framework table read is characters.citizenid (REDEM:RP), characters.charidentifier (VORP) or players.citizenid (RSG). Nothing is deleted when that table cannot be read or contains no character at all. When rows are removed, the console prints Removed N row(s) of deleted characters. Set the option to false to keep everything.

Safe maintenance

Make a backup first. Do these with the server (or at least murphy_doctor) stopped: health, coma, roster and duty data are kept in memory while the resource runs, and would be written back over your change or keep being served from memory.

To fix one connected player without a restart, edit their murphy_doctor_health row, then run doc_reloadhealth <serverId>: it drops the server's copy and sends the row again to the player.

Useful queries

Find a character's medical state:

sql
SELECT * FROM murphy_doctor_health WHERE identifier = 'CHARACTER_ID';

Take a character out of a stuck coma (server stopped):

sql
DELETE FROM murphy_doctor_coma WHERE identifier = 'CHARACTER_ID';

Clear every injury and condition of one character, keeping diseases and immunities:

sql
UPDATE murphy_doctor_health SET injuries = '{}', conditions = '{}' WHERE identifier = 'CHARACTER_ID';

List a dispensary's roster:

sql
SELECT identifier, name, `rank`, is_chief FROM murphy_doctor_members WHERE dispensary_id = 1;

Delete old signed reports (older than 180 days):

sql
DELETE FROM murphy_doctor_reports WHERE created_at < NOW() - INTERVAL 180 DAY;

Delete old treasury ledger lines (balances are not affected):

sql
DELETE FROM murphy_doctor_treasury_log WHERE created_at < NOW() - INTERVAL 90 DAY;

To empty one roster without SQL, use doc_wipedispensary <dispensaryId>.

Effect of emptying a table

Table Effect
murphy_doctor_coma Nobody is put back in a coma at login
murphy_doctor_metabolism_layout HUD positions return to default
murphy_doctor_incidents Incident history lost
murphy_doctor_addictions Every dependence cleared
murphy_doctor_treasury_log Ledger history lost, balances untouched
murphy_doctor_health Every character loses injuries, diseases, immunities, liver wear and saved hunger, thirst and temperature. A fresh row is created at the next login
murphy_doctor_reports All archives lost
murphy_doctor_records All medical files lost
murphy_doctor_certificates All death certificates lost (their copies in the archives stay)
murphy_doctor_invoices All debts and unsettled payments lost
murphy_doctor_duty On-duty states and uncollected pay lost
murphy_doctor_treasury All dispensary balances lost
murphy_doctor_members Nobody is a doctor any more in "database" mode. Name the chiefs again with doc_addchief
murphy_doctor_dispensary Board notes lost. Rows are re-created from Config.Dispensaries at the next start

Notes

  • Removing a dispensary from Config.Dispensaries does not delete its rows. Members, reports and balances filed under an id that is no longer configured stay in the database but are not shown.
  • Changing the id of a dispensary detaches it from its existing rows. Keep ids stable once the server is live.
  • With Config.Billing.Tax enabled, murphy_doctor reads the tax rate from murphy_politics_taxes, a table of murphy_politics. It never writes to it. See Integrations.
  • To remove all the data, see Installation.

Last updated: November 20, 2026