Skip to main content

3.2.9 PatRx

The PatRx table in Supabase stores all prescriptions for each patient case. Each medication is linked to a patient via pat_id and receives a unique rx_id. The table supports storage of up to three medications, with metadata including the medication name, Pharmazentralnummer (PZN), and an internal rx_key.

Table Structure

ColumnFormatTypeDescription
pat_idbigintnumberInternal ID of the patient receiving the prescription (as in PatBase)
rx_idbigintnumberUnique prescription ID
data-0jsonbjsonMetadata for medication 1 (e.g., pzn, name, rx_key)
data-1jsonbjsonMetadata for medication 2 (e.g., pzn, name, rx_key)
data-2jsonbjsonMetadata for medication 3 (e.g., pzn, name, rx_key)
rx_key-0textstringInternal medication key for medication 1
rx_key-1textstringInternal medication key for medication 2
rx_key-2textstringInternal medication key for medication 3

Example medication metadata:

{
"pzn": "6718342",
"name": "Paracetamol 500 mg (Tabl)",
"rx_key": "6718342"
}

Integration within the System

Medications are added to the PatRx table using the addRx function in logic_server.js. Medication metadata includes pzn and rx_key, which are matched to RMP_PZN and RMP_KEY in the bfarm_ref_med table in Supabase. Each prescription is linked to the correct patient case via pat_id.