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

ExportReturnsNotes
CreatePrescription(src, { uses = n }, drugKey)booleanGives src a ready-to-use medication item. GivePlayerMedication is the same function. drugKey must exist in the catalog
WritePrescription(props)Rx number or nilWrites a paper script into the doctor record, pharmacy history, and the writer's inventory. See below
LookupPrescriptionByRx(rxNumber)row or nilThe doctor record for that Rx number
RevokePrescription(rxNumber, revokedBy)booleanRevokes 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)booleanAdds 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?)booleanAdds 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

ExportReturnsNotes
GetPharmacyStock(jobName){ [item] = count }The job's stock room
AddPharmacyStock(jobName, item, count)true, newCount, or falseAdds stock. count must be a whole number of 1 or more
ConsumePharmacyStock(jobName, itemOrDrug, count)booleanRemoves stock. Pass a medication key to remove its whole recipe, scaled by count. false if there is not enough

Insurance

ExportReturnsNotes
GetInsurance(src)row or falseThe active coverage row
GetInsuranceStatus(src)booleanWhether they have active coverage
GetInsuranceCard(src)table or nilData for the insurance card view
ReturnInsuredRate(src, amount)numberWhat the patient pays after their copay. Returns amount unchanged when uninsured
PurchaseInsurance(src, tier)booleanBuys 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)booleanEnds coverage. false if they have none

Overdose and treatment

ExportReturnsNotes
ReverseOverdose(src, targetSrc?)booleanClears an overdose on targetSrc (or src when no target is given)
TriggerMedicationTreatment(src, targetSrc, treatmentType, context)booleanFires 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.

On this page