PrescriptionsExports
Server exports
Server exports for Prescriptions. src is a player server id.
In-development version. These docs cover the testing build of Prescriptions. The official release is still documented on the GitBook linked in its README.
Call them as exports.MrNewbPrescriptions:Name(...) from a server script. src is a player server id.
Prescriptions
| Export | Returns | Notes |
|---|---|---|
CreatePrescription(src, { uses = n }, drugKey) | boolean | Gives src a ready-to-use medication item. GivePlayerMedication is the same function. drugKey must exist in the catalog |
WritePrescription(props) | Rx number or nil | Writes a paper script into the doctor record, pharmacy history, and the writer's inventory. See below |
LookupPrescriptionByRx(rxNumber) | row or nil | The doctor record for that Rx number |
RevokePrescription(rxNumber, revokedBy) | boolean | Revokes it so it can no longer be filled at any counter. false if the Rx number is unknown or already revoked. The tablet's Dispensing History does the same |
SearchDoctorRecords(term, { flaggedOnly = false }) | table[] | Matches patient, doctor, medication, Rx, and note. { staffJob = 'ambulance' } limits it to that clinic's records plus forged ones |
SearchPharmacyAudit(jobName, term, limit) | table[] | Audit events for a pharmacy. limit is 1 to 100, default 50 |
RegisterPrescription(id, prescription) | boolean | Adds a catalog medication at runtime and registers its item use. name is required. Passing an id that exists updates the fields you give. See Medications and effects |
RegisterEffect(id, label, handler?) | boolean | Adds a custom effect label. Refuses a premade id, stop and overdose. See Medications and effects |
WritePrescription takes src (the doctor), drugKey, targetSrc, doses, and note, and optionally patientName, dob, patientIdentifier, time, gender, rxNumber, allergies, refills and manualPatient. With targetSrc, the patient name, date of birth, and identifier are filled in from that player. It returns nil if the drug is not in the catalog, the doses are out of range, the doctor is under the controlled medication rank for a controlled medication, the name or date of birth is empty, or the paper cannot be carried.
Pharmacy stock
| Export | Returns | Notes |
|---|---|---|
GetPharmacyStock(jobName) | { [item] = count } | The job's stock room |
AddPharmacyStock(jobName, item, count) | true, newCount, or false | Adds stock. count must be a whole number of 1 or more |
ConsumePharmacyStock(jobName, itemOrDrug, count) | boolean | Removes stock. Pass a medication key to remove its whole recipe, scaled by count. false if there is not enough |
Insurance
| Export | Returns | Notes |
|---|---|---|
GetInsurance(src) | row or false | The active coverage row |
GetInsuranceStatus(src) | boolean | Whether they have active coverage |
GetInsuranceCard(src) | table or nil | Data for the insurance card view |
ReturnInsuredRate(src, amount) | number | What the patient pays after their copay. Returns amount unchanged when uninsured |
PurchaseInsurance(src, tier) | boolean | Buys or switches plan. tier is a plan key from the Plans page. Charges full price, or only the difference on an upgrade. Notifies the player and returns false on failure, including when they already have that plan |
CancelInsurance(src) | boolean | Ends coverage. false if they have none |
Overdose and treatment
| Export | Returns | Notes |
|---|---|---|
ReverseOverdose(src, targetSrc?) | boolean | Clears an overdose on targetSrc (or src when no target is given) |
TriggerMedicationTreatment(src, targetSrc, treatmentType, context) | boolean | Fires MrNewbPrescriptions:MedicationTreatment so ambulance bridges can heal or revive. treatmentType is an effect id such as clearinjuries, clearbleeds, health, or revive, or overdose to end an overdose on the patient. Both players must be online. Returns false otherwise |
Examples
-- charge a patient their insured price
local pay = exports.MrNewbPrescriptions:ReturnInsuredRate(source, 500)
-- write a prescription for a nearby patient
local rx = exports.MrNewbPrescriptions:WritePrescription({
src = doctorSrc,
targetSrc = patientSrc,
drugKey = 'mollis',
doses = 3,
note = 'One tablet daily.',
})
if not rx then print('could not write prescription') end
-- revoke one
exports.MrNewbPrescriptions:RevokePrescription('1234567890', 'Dr. Smith')
-- stock a pharmacy from another script
exports.MrNewbPrescriptions:AddPharmacyStock('pharmacy', 'emptybottle', 20)
-- clear an overdose
exports.MrNewbPrescriptions:ReverseOverdose(source)Client exports: Client exports. Events and hooks: Events and hooks.
