Patient Management & EMR

v0.1.0

Encrypted PHI at-rest, systemic medical alerts, emergency contacts, and digital informed consent governance.

Patient Management & Electronic Medical Records (EMR)

The Patient & EMR bounded context manages patient demographics, protected health information (PHI), clinical medical alerts, emergency contacts, and chairside informed consent governance.

Every patient record is treated as an aggregate root, enforcing strict data confidentiality under HIPAA Security Rule (45 CFR § 164.312) and GDPR Article 32.


The Patient Aggregate Root

The Patient model represents the primary clinical subject within the dental domain:

+--------------------------------------------------------------+
|                           Patient                            |
+--------------------------------------------------------------+
| id: int / uuid                                               |
| medical_record_number: string (unique)                       |
| first_name: string (encrypted)                               |
| last_name: string (encrypted)                                |
| date_of_birth: date                                          |
| ssn: string (encrypted, redacted in logs)                    |
| phone: string (encrypted)                                    |
| email: string (encrypted)                                    |
| address: json (encrypted)                                    |
| is_active: boolean                                           |
+------------------------------+-------------------------------+
                               |
       +-----------------------+-----------------------+
       |                       |                       |
+------v-------+        +------v-------+        +------v-------+
| MedicalAlert |        | Emergency    |        | ConsentRecord|
| (Prophylaxis/|        | Contact      |        | (Digital     |
| Anticoagulant)        |              |        | Signatures)  |
+--------------+        +--------------+        +--------------+

Protected Health Information (PHI) Encryption

When compliance.encrypt_phi is enabled in configuration, all sensitive demographic and clinical fields are encrypted before database persistence using authenticated AES-256-CBC / AES-256-GCM encryption.

  • Encrypted Fields: first_name, last_name, ssn, phone, email, address, notes.
  • Searchable Identifiers: medical_record_number (MRN) is hashed or indexed as a unique non-PHI identifier for rapid clinical lookup.
  • Zero-PHI Audit Logging: Audit log entries store only actor IDs, resource IDs, and action verbs—never unencrypted PHI payloads.

Systemic Medical Health Alerts

Dental surgical interventions require real-time visibility into systemic health conditions. Obelawium Dental classifies medical alerts by clinical severity and tracks high-risk medical invariants:

use Obelaw\Ium\Dental\Enums\AlertSeverity;

enum AlertSeverity: string
{
    case LOW = 'low';
    case MEDIUM = 'medium';
    case HIGH = 'high';
    case CRITICAL = 'critical';
}

Critical Medical Invariants

  1. Antibiotic Prophylaxis (requires_antibiotic_prophylaxis = true): Required for patients with prosthetic cardiac valves, prior infective endocarditis, or complex congenital heart disease. Clinicians receive automated warnings prior to invasive periodontal probing or surgical extractions.
  2. Anticoagulant Therapy (anticoagulant_flag = true): Flags patients on blood thinners (Warfarin, Eliquis, Clopidogrel) to prevent uncontrollable intraoral hemorrhages during restorative and surgical encounters.

Obelawium Dental enforces legally binding, digital informed consent captured chairside via touch-screen or stylus tablets:

use Obelaw\Ium\Dental\Enums\ConsentType;

enum ConsentType: string
{
    case TREATMENT = 'treatment';
    case BILLING = 'billing';
    case IMAGING_CLOUD_SYNC = 'imaging_cloud_sync';
    case THIRD_PARTY_PAYMENT = 'third_party_payment';
}
Consent TypeDescriptionMandatory Gating Rule
TREATMENTInformed consent for planned dental procedures.Treatment plans cannot be moved to APPROVED or executed chairside without a signed token.
BILLINGAuthorization to bill insurance and generate invoices.External QuickBooks invoice generation is blocked without active billing consent.
IMAGING_CLOUD_SYNCConsent to upload diagnostic DICOM studies to off-site cloud storage.If missing, DICOM files must remain air-gapped on local clinic PACS storage.
THIRD_PARTY_PAYMENTAuthorization for external financial clearinghouses.Blocking gate for merchant and third-party dental financing integrations.

Fluent Service Operations

All patient operations are handled through ium()->dental()->patients():

1. Registering a Patient

use Obelaw\Ium\Dental\Data\CreatePatientDto;
use DateTimeImmutable;

$patient = ium()->dental()->patients()->create(CreatePatientDto::from([
    'medical_record_number' => 'MRN-2026-00482',
    'first_name' => 'Eleanor',
    'last_name' => 'Vance',
    'date_of_birth' => new DateTimeImmutable('1988-04-12'),
    'ssn' => '123-45-6789',
    'phone' => '+1-555-0144',
    'email' => '[email protected]',
    'address' => [
        'street' => '742 Evergreen Terrace',
        'city' => 'Springfield',
        'state' => 'IL',
        'postal_code' => '62704',
    ],
    'actor_id' => 'USER-FRONTDESK-01',
]));

2. Adding Systemic Medical Alerts

use Obelaw\Ium\Dental\Data\CreateMedicalAlertDto;
use Obelaw\Ium\Dental\Enums\AlertSeverity;

$alert = ium()->dental()->patients()->addMedicalAlert(
    patientId: $patient->id,
    dto: CreateMedicalAlertDto::from([
        'alert_type' => 'cardiovascular',
        'allergen_condition' => 'Prosthetic Mitral Valve Replacement',
        'severity' => AlertSeverity::CRITICAL,
        'requires_antibiotic_prophylaxis' => true,
        'anticoagulant_flag' => true,
        'notes' => 'Patient requires 2g Amoxicillin 1 hour prior to invasive procedures.',
        'actor_id' => 'DR-MARTINEZ',
    ])
);
use Obelaw\Ium\Dental\Data\RecordConsentDto;
use Obelaw\Ium\Dental\Enums\ConsentType;

$consent = ium()->dental()->patients()->recordConsent(
    patientId: $patient->id,
    dto: RecordConsentDto::from([
        'patient_id' => $patient->id,
        'consent_type' => ConsentType::TREATMENT,
        'signature_blob' => 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0...',
        'ip_address' => '192.168.1.145',
        'device_info' => 'Apple iPad Pro 12.9 (Chairside Operatory 02)',
        'actor_id' => 'DR-MARTINEZ',
    ])
);
use Obelaw\Ium\Dental\Enums\ConsentType;

// Returns true only if consent was granted and has not been withdrawn
$canSyncQuickBooks = ium()->dental()->patients()->hasActiveConsent(
    patientId: $patient->id,
    type: ConsentType::BILLING
);

if (! $canSyncQuickBooks) {
    // Prohibit transmission to external accounting ledger
}

Under GDPR and HIPAA, patients may withdraw consent at any time. Revocation is recorded immutably:

ium()->dental()->patients()->withdrawConsent(
    consentId: $consent->id,
    actorId: 'USER-COMPLIANCE-01'
);

Emitted Domain Events

Event ClassTriggerPayload
PatientRegisteredDispatched after atomic creation of patient record.Patient $patient, ?string $actorId
MedicalAlertAddedDispatched when a new alert or allergy is attached.MedicalAlert $alert, ?string $actorId
ConsentGrantedDispatched when a patient signs digital consent.ConsentRecord $consent, ?string $actorId
ConsentWithdrawnDispatched when a consent record is revoked.ConsentRecord $consent, ?string $actorId