entity user {}
entity doctor { ... }
relation patient @patient
: Doctors can be associated with multiple patients.relation group @group
: Doctors can also be linked to groups (e.g., medical teams or departments).doctor
entity models a healthcare professional who can have multiple patients assigned to them and can belong to groups. Relationships help manage permissions for accessing patient-related data or participating in group-based activities.entity partner { ... }
relation admin @user
: The admin of the partner is a user.relation member @user
: Members of the partner are also users.permission edit = admin
: Users who are admins can edit.permission view = edit or member
: Members can view, and admins have inherited view access from the edit permission.entity group { ... }
relation partner @partner
: A group is associated with a partner.relation doctor @doctor
: Groups can include doctors.permission edit = partner.edit or doctor
: If a partner has edit access, or if a doctor is linked, then the group can be edited.permission view = edit or partner.view
: The view permission is granted if a user has edit access or if the partner can view.entity state { ... }
attribute age_limit integer
: The state entity has an age_limit
attribute of type integer.rule check_age(age integer) { this.age_limit > age }
: This rule checks if the state’s age limit is greater than a specified age.entity patient { ... }
relation primary_doctor @doctor
: A patient has a primary doctor.relation consultant @doctor
: A patient can have consultant doctors.relation group @group
: Patients can be linked to groups (e.g., departments).relation state @state
: Patients have a state, potentially linked to age-based permissions.relation owner @user
: An owner (usually a guardian or caregiver) is associated with the patient.relation guardian @user
: A guardian can also be linked to a patient.attribute age integer
: Represents the patient’s age.permission parent_access = state.check_age(age)
: The permission for parent access is granted if the state’s check_age
rule is met.permission edit = owner or group.edit or primary_doctor or consultant
: Editing permissions are granted to the owner, group members with edit rights, or the doctors.permission view = edit or group.view or guardian
: View permissions extend to anyone who can edit, group members who can view, or the guardian.entity medical_record { ... }
relation patient @patient
: Links the medical record to a patient.relation doctor @doctor
: Associates the medical record with a doctor.action view = doctor.patient or patient or patient.guardian
: The record can be viewed by doctors associated with the patient, the patient themselves, or their guardian.action create = doctor.patient
: Only doctors who are associated with the patient can create the record.action update = doctor.patient
: Updating the record is limited to the patient’s doctor.action delete = doctor.patient
: Deleting the record is also restricted to the doctor.entity hospital { ... }
relation doctor @doctor
: Doctors associated with the hospital.relation patient @patient
: Patients associated with the hospital.relation group @group
: Groups linked to the hospital (e.g., medical departments).action admit_patient = doctor
: Doctors can admit patients.action discharge_patient = doctor
: Doctors can discharge patients.action view_patient_records = doctor or patient.guardian or group.view
: Allows doctors, patient guardians, or group members with view access to see patient records.entity appointment { ... }
relation doctor @doctor
: Associates the appointment with a doctor.relation patient @patient
: Associates the appointment with a patient.action create = patient or doctor
: Both patients and doctors can create appointments.action update = patient or doctor.patient
: Either the patient or their associated doctor can update the appointment.action delete = doctor.patient
: Only doctors associated with the patient can delete the appointment.appointment
entity handles scheduling activities, linking patients with doctors and defining who can create, update, or delete appointments.entity claims { ... }
relation group @group
: Claims can be linked to a group.relation patient @patient
: Claims can be associated with a patient.action edit = patient.edit or group.edit
: Claims can be edited by those with patient edit permissions or group edit permissions.action view = edit or patient.view or group.view
: View permissions are granted to those who can edit or have patient or group view permissions.action parent_access = patient.parent_access
: Parent access to claims follows the parent access permissions for the patient.