0% found this document useful (0 votes)
4 views

clc02_htkhoi_fp12

The document outlines a comprehensive Health Care System designed to digitize healthcare operations using a microservices architecture. It details various functionalities for different user roles, including patients, doctors, nurses, administrators, pharmacists, insurance providers, and lab technicians, along with their respective use cases. The system aims to improve efficiency, communication, and management of healthcare services while addressing common challenges in the industry.

Uploaded by

phuongyuki2410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

clc02_htkhoi_fp12

The document outlines a comprehensive Health Care System designed to digitize healthcare operations using a microservices architecture. It details various functionalities for different user roles, including patients, doctors, nurses, administrators, pharmacists, insurance providers, and lab technicians, along with their respective use cases. The system aims to improve efficiency, communication, and management of healthcare services while addressing common challenges in the industry.

Uploaded by

phuongyuki2410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 64

POSTS AND TELECOMMUNICATIONS INSTITUTE OF

TECHNOLOGY

Final project
Subject: Software Architecture & Design

Student: Hoàng Trọng Khôi (B21DCVT026)


Class: E21CNPM02
Teacher: Trần Đình Quế

Ha Noi, 04/2025
HEALTH CARE SYSTEM

CHAPTER 1: Requirements and Analysis of a Health Care System

1.1 System description

The Healthcare System is a comprehensive, microservices-based platform


designed to digitize and streamline healthcare operations across multiple
touchpoints. This system integrates various healthcare workflows into a
cohesive digital ecosystem, serving diverse stakeholders including patients,
medical professionals, administrative staff, and external entities such as
insurance providers.

The system aims to address several key challenges in modern healthcare


delivery:
 Fragmentation of patient information across different departments and
specialties
 Manual, paper-based processes that introduce inefficiencies and potential
errors
 Communication barriers between healthcare providers, patients, and
support services
 Complex scheduling and resource management for healthcare facilities
 Administrative overhead in billing, insurance processing, and compliance
reporting

Built on a microservices architecture using Django, the system consists of


several independent yet interconnected services that handle specific domains of
healthcare management:

 Authentication and authorization with role-based access control


 Patient information management for comprehensive medical records
 Appointment scheduling and management
 Doctor and medical staff management
 Pharmacy operations and medication management
 Billing and insurance processing
 Laboratory test ordering and result management
 Notifications and communications
 Administrative dashboards and reporting

The frontend is structured to support multiple user roles with role-specific


interfaces, ensuring that each stakeholder has access to the tools and
information relevant to their responsibilities. The system integrates an API
gateway to facilitate secure communication between the frontend and various
backend microservices.
Future enhancements include the integration of an AI-powered assistant to
provide support, guidance, and information to both patients and healthcare
providers, further improving user experience and operational efficiency.

1.2. Actor Analysis

Actor Role Use Cases


• Register/Login
• Book/Cancel appointments
• View medical records
Patient End-user who seeks medical services • Receive prescriptions
• Pay medical bills
• View lab test reports
• Update personal information
• Schedule/Manage appointments
• Access patient history
• Diagnose & prescribe treatments
Medical professional who provides • Order lab tests
Doctor
healthcare services • Write medical reports
• View lab test results
• Communicate with patients &
staff
Nurse Healthcare professional who supports • Assist in patient care
patient care • Record & update patient vitals
• Administer medications
• Assist doctors in diagnosis &
treatment
Actor Role Use Cases
• Update patient records
• Manage users & access rights
• Maintain system security &
compliance
• Schedule doctors & nurses
Administrator System and facility manager • Manage billing & insurance
processing
• Generate reports & analytics
• Maintain hospital inventory &
resources
• Verify & dispense medications
• Manage pharmacy inventory
Pharmacist Medication dispenser and advisor • Process prescriptions
• Communicate with doctors &
patients
• Verify patient insurance details
• Process insurance claims
Third-party payer for healthcare • Communicate with patients &
Insurance Provider
services administrators
• Approve/reject insurance
requests
• Conduct medical tests
• Upload test results
Laboratory
Diagnostic test specialist • Notify doctors & patients of test
Technician
reports
• Maintain lab equipment & data

1.3. Functions with respect to actors

1.3.1. Patient

Use Case Name Description Precondition Postcondition

Register/Login Patient creates a new For registration: Patient is not Patient gains access to
account or registered the system with
authenticates with For login: Patient has valid appropriate
Use Case Name Description Precondition Postcondition

existing credentials credentials permissions

Patient schedules a Appointment is


Book medical appointment Patient is authenticated created and visible to
Appointment with a healthcare Doctor availability exists both patient and
provider doctor

Appointment is
Patient cancels a
Cancel Patient is authenticated marked as canceled
previously scheduled
Appointment Appointment exists and removed from
appointment
schedules

Patient accesses their Patient can see their


View Medical personal health medical history,
Patient is authenticated
Records information, history, diagnoses, and
and diagnoses treatments

Patient can see


Patient views
View Patient is authenticated medication details,
medications
Prescriptions Prescription exists dosage, and
prescribed by doctors
instructions

Patient reviews and Payment is processed


Pay Medical Patient is authenticated
makes payments for and bill is marked as
Bills Outstanding bills exist
healthcare services paid

Patient modifies their


Update Personal contact details, Patient information is
Patient is authenticated
Information insurance information, updated in the system
etc.

1.3.2. Doctor
Use Case
Description Precondition Postcondition
Name

Doctor sets availability Doctor's schedule is


Schedule
and manages Doctor is authenticated updated and available
Appointments
appointment calendar for booking

Doctor reviews Doctor has information


Access Patient Doctor is authenticated
patient's past medical needed for diagnosis
History Patient record exists
records and treatments and treatment

Doctor examines Diagnosis is


Diagnose Doctor is authenticated
patient and records documented in patient's
Patient Patient appointment is active
diagnosis medical record

Doctor creates Prescription is created


Prescribe Doctor is authenticated
medication orders and and accessible to
Treatment Diagnosis is complete
treatment plans patient and pharmacist

Doctor requests
Lab test order is created
laboratory
Order Lab Tests Doctor is authenticated and sent to laboratory
examinations for a
technician
patient

Doctor documents
Doctor is authenticated
Write Medical patient visits, Medical report is added
Patient examination is
Reports treatments, and to patient's record
complete
outcomes

Doctor accesses and Doctor is authenticated Doctor can analyze


View Lab
reviews patient Lab tests have been results and determine
Results
laboratory test results conducted treatment

1.3.3. Nurse
Use Case
Description Precondition Postcondition
Name

Nurse provides support


Assist in Patient receives
for patient health Nurse is authenticated
Patient Care appropriate care
management

Nurse measures and Vital signs are recorded


Record Patient Nurse is authenticated
documents patient vital in patient's medical
Vitals Patient is present
signs record

Nurse provides Medication


Administer Nurse is authenticated
prescribed medications administration is
Medications Valid prescription exists
to patients recorded

Nurse supports doctors


Nurse is authenticated Doctor receives
Assist Doctors during examinations
Doctor is treating patient necessary assistance
and procedures

Nurse adds Patient record is


Update Patient
information to patient's Nurse is authenticated updated with current
Records
health documentation information

1.3.4. Admin

Use Case
Description Precondition Postcondition
Name

Administrator creates,
User accounts are
Manage Users updates, or deactivates Administrator is authenticated
appropriately modified
user accounts

Administrator assigns
Manage Access Users have appropriate
and modifies system Administrator is authenticated
Rights access levels
permissions
Use Case
Description Precondition Postcondition
Name

Administrator creates
Staff schedules are
Schedule Staff work schedules for Administrator is authenticated
created and distributed
doctors and nurses

Administrator oversees Billing records are


Manage Billing billing processes and Administrator is authenticated accurate and up-to-
financial transactions date

Administrator creates
Generate Reports are available
statistical and Administrator is authenticated
Reports for review and analysis
operational reports

Administrator manages Resource records are


Maintain
hospital inventory and Administrator is authenticated accurate and up-to-
Resources
equipment date

1.3.5. Pharmacist

Use Case
Description Precondition Postcondition
Name

Pharmacist reviews
Prescription is
Verify prescriptions for Pharmacist is authenticated
approved or rejected
Prescriptions accuracy and Prescription exists
with reason
appropriateness

Pharmacist provides Medication is


Dispense Pharmacist is authenticated
prescribed medications dispensed and
Medications Valid prescription exists
to patients recorded

Manage Pharmacist tracks Pharmacist is authenticated Pharmacy inventory is


Inventory medication stock and accurately maintained
Use Case
Description Precondition Postcondition
Name

orders supplies

Pharmacist handles
Process Payment is processed
financial transactions Pharmacist is authenticated
Payments and recorded
for medications

Pharmacist consults
Communicate Prescription issues are
with doctors about Pharmacist is authenticated
with Doctors resolved
prescription issues

1.3.6. Insurance provider

Use Case
Description Precondition Postcondition
Name

Insurance provider Insurance provider is


Verify confirms patient authenticated Insurance status is
Insurance coverage and Patient has insurance verified and recorded
eligibility information

Insurance provider is
Insurance provider
authenticated Claim is processed with
Process Claims reviews and processes
Medical service has been approval or rejection
payment claims
provided

Communicate Insurance provider


Insurance provider is Billing and insurance
with exchanges information
authenticated matters are clarified
Administration with hospital staff

Insurance provider Insurance provider is Coverage decision is


Approve/Reject
determines eligibility authenticated recorded and
Coverage
for specific treatments Treatment request exists communicated
1.3.7. Lab technician

Use Case Name Description Precondition Postcondition


Laboratory technician Technician is
Conduct Medical
performs requested authenticated Tests are completed
Tests
diagnostic tests Test order exists
Laboratory technician Technician is Test results are
Upload Results records test outcomes authenticated available in the
in the system Tests are completed system
Laboratory technician Technician is Doctor and patient
Notify Stakeholders communicates test authenticated are notified of
completion Results are uploaded available results
Laboratory technician
Laboratory
ensures proper Technician is
Maintain Equipment equipment is
functioning of lab authenticated
operational
equipment

1.4. Use case diagram


1.5. System modules/services
1.5.1. Auth Service
Functions Function Details

Handles the creation of new user accounts with proper validation, secure
User Registration password hashing, and initial role assignment based on user type (patient,
doctor, nurse, etc.)

Manages login processes using username/password credentials, validates


User Authentication
user identity, and issues JWT tokens for authenticated sessions

Issues, validates, and refreshes JSON Web Tokens (JWT) for maintaining
Token Management
secure authenticated sessions across microservices

Password Provides functionality for password reset, recovery via email verification,
Management and password change operations with proper security measures

Role-based Access Implements and enforces permission systems based on user roles,
Control determining what actions and resources each user can access

Multi-factor Offers additional security layer through verification codes sent via SMS or
Authentication email for sensitive operations

Session Tracks active user sessions, handles session timeouts, and provides session
Management termination capabilities

Enables authentication through third-party providers (Google, Facebook,


OAuth Integration
etc.) for streamlined user registration and login

Records authentication events, login attempts, password changes, and


Audit Logging
other security-related activities for compliance and security monitoring

1.5.2. Patient Service


Functions Function Details

Patient Profile Handles creation, retrieval, updating, and deletion of patient demographic
Functions Function Details

Management information, contact details, and preferences

Medical History Maintains comprehensive patient medical history including past conditions,
Records surgeries, allergies, and family medical history

Insurance Stores and validates patient insurance details, policy numbers, coverage
Information limits, and provider information

Emergency Contacts Manages patient emergency contact information for urgent situations

Document Handles patient document uploads such as ID proofs, insurance cards, and
Management previous medical records

Provides advanced search functionality to find patients by various


Patient Search
identifiers including name, ID, phone number, and date of birth

Manages patient access to their own medical information through secure


Patient Portal Access
authentication mechanisms

Allows authorized export of patient records in standard formats (PDF,


Data Export
HL7, FHIR) for external use

Tracks and manages patient consent for data sharing, procedures, and
Consent Management
research participation

1.5.3. Doctor Service


Functions Function Details

Doctor Profile Manages professional profiles including credentials, specializations,


Management experiences, and contact information

Specialization and Tracks medical specialties, subspecialties, and areas of expertise for
Functions Function Details

Expertise appropriate patient matching

Availability Handles doctor working hours, leave schedules, and availability slots
Management for appointment booking

Associates patients with primary or specialist doctors for continuity of


Patient Assignment
care

Qualification Validates and stores medical licenses, board certifications, and


Verification educational qualifications

Tracks key performance indicators such as patient satisfaction,


Performance Metrics
treatment outcomes, and appointment efficiency

Collaborative Care Facilitates doctor-to-doctor consultations and patient case discussions

Monitors and records continuing medical education credits and


Continuing Education
certification renewals

Referral Management Handles outbound and inbound patient referrals between specialists

1.5.4. Appointment Service


Functions Function Details

Schedule Manages the creation, modification, and cancellation of appointments


Management across the healthcare facility

Synchronizes appointments with doctor and facility calendars,


Calendar Integration
preventing double-bookings
Functions Function Details

Availability Identifies and presents available time slots based on doctor schedules,
Checking room availability, and equipment requirements

Appointment Sends automated reminders to patients and healthcare providers before


Reminders scheduled appointments

Check-in Processing Handles patient arrival registration and waiting room management

Facilitates appointment time changes with minimum disruption to


Rescheduling
schedules

Recurring Supports scheduling of regular recurring appointments for treatments


Appointments like physical therapy or dialysis

Enables urgent appointment booking that overrides standard availability


Priority Scheduling
for emergency cases

Wait List Maintains lists of patients waiting for earlier appointments and fills
Management cancellations automatically

1.5.5. Pharmacy Service


Functions Function Details

Prescription Processes and validates electronic prescriptions from healthcare


Management providers

Manages the process of preparing and distributing prescribed


Medication Dispensing
medications to patients

Tracks medication stock levels, expiration dates, and automatically


Inventory Management
generates purchase orders for low stock items
Functions Function Details

Drug Interaction Analyzes potential interactions between prescribed medications and


Checking patient's existing medications

Assists in calculating proper medication dosages based on patient


Dosage Calculation
characteristics (age, weight, kidney function)

Checks insurance coverage for prescribed medications and calculates


Insurance Verification
patient copayments

Handles prescription refill requests and obtains necessary


Refill Processing
authorizations from prescribing doctors

Patient Medication Maintains comprehensive medication records including current and


History past prescriptions

Controlled Substance Implements special handling and reporting for controlled substances
Tracking according to regulations

1.5.6. Lab Service


Functions Function Details

Processes laboratory test orders from healthcare providers and


Test Order Management
manages workflow

Tracks specimen collection including labeling, handling instructions,


Sample Collection
and chain of custody

Captures and stores test results from laboratory equipment or manual


Result Recording
entry

Creates standardized reports for test results with reference ranges and
Report Generation
interpretations

Critical Value Alerting Immediately notifies healthcare providers about abnormal results
Functions Function Details

requiring urgent attention

Test Catalog Maintains database of available tests, their requirements, costs, and
Management processing times

Monitors laboratory test quality through control samples and


Quality Control
calibration checks

Result History Maintains historical test results for trend analysis and comparison

Facilitates sending tests to and receiving results from external


External Lab Integration
laboratory facilities

1.5.7. Billing Service


Functions Function Details

Records billable services, procedures, and items provided to


Charge Capture
patients

Insurance Claim Prepares and submits claims to insurance companies for provided
Processing services

Handles patient payments through various methods including credit


Payment Processing
cards, bank transfers, and cash

Creates detailed invoices for patients showing services rendered,


Invoice Generation
insurance coverage, and patient responsibility

Account Receivable Tracks outstanding balances and manages collection processes for
Management unpaid accounts

Insurance Verification Validates patient insurance coverage and benefits before service
Functions Function Details

provision

Monitors submitted claims through the adjudication process and


Claim Status Tracking
handles denials or partial payments

Records payments received from insurance companies and patients


Payment Posting
against outstanding balances

Generates financial reports including revenue analysis, collection


Financial Reporting
rates, and aging accounts

1.5.8. Notification Service


Functions Function Details

Sends transactional and informational emails to patients and staff regarding


Email Notifications
appointments, test results, etc.

Delivers time-sensitive information through text messages for


SMS Alerts
appointments and urgent notifications

Sends alerts to mobile devices for users of the healthcare system's mobile
Push Notifications
application

Template Maintains customizable message templates for various types of


Management communications

Delivery Status Monitors whether notifications were successfully delivered, opened, or


Tracking failed

Scheduled Sets up automated messages to be sent at specified times or triggered by


Notifications specific events

Batch Processing Handles bulk messaging for announcements, health campaigns, or system
Functions Function Details

maintenance alerts

Respects user communication preferences regarding which channels to use


Channel Preferences
for different notification types

Failed Delivery Implements retry logic and alternative delivery methods when primary
Handling notification fails

1.5.9. API Gateway Service


Functions Function Details

Directs incoming requests to appropriate microservices based on


Request Routing
request path and parameters

Verifies JWT tokens and ensures users are authenticated before


Authentication Validation
allowing access to protected resources

Prevents abuse by limiting the number of requests a client can


Rate Limiting
make within a specific time period

Request/Response Modifies request or response data formats to ensure


Transformation compatibility between client and services

Dynamically locates service instances to enable load balancing


Service Discovery
and fault tolerance

Distributes incoming requests across multiple instances of


Load Balancing
services to optimize performance

Prevents cascading failures by stopping requests to failing


Circuit Breaking
services and providing fallback responses

Logging and Monitoring Records API usage patterns, error rates, and performance metrics
Functions Function Details

for system health monitoring

Provides Swagger/OpenAPI documentation of available


API Documentation
endpoints for developer reference

1.5.10. Admin Service


Functions Function Details

Provides administrative tools for creating, modifying, and deactivating


User Management
user accounts across all roles

Manages role definitions and permission assignments throughout the


Role Configuration
system

System Controls global system settings, operating hours, and behavior


Configuration parameters

Maintains comprehensive logs of all administrative actions for security


Audit Trail
and compliance purposes

Analytics Presents key performance indicators and operational metrics for


Dashboard administrative decision making

Resource Oversees allocation and scheduling of physical resources like


Management examination rooms and equipment

Manages work schedules for healthcare professionals including shift


Staff Scheduling
assignments and rotation planning

Generates administrative reports for regulatory compliance, operational


Reporting
efficiency, and strategic planning
Functions Function Details

Backup and Manages data backup processes and provides tools for system recovery
Recovery in case of failures

1.5.11. AI Assistant Service (Future integration)


Functions Function Details

Natural Language Interprets and understands user queries expressed in natural


Processing language

Medical Query Provides accurate responses to common health-related questions


Answering based on verified medical information

Helps patients find available slots and schedule appointments


Appointment Assistance
through conversational interface

Offers automated reminders and information about medication


Medication Reminders
schedules and instructions

Conducts preliminary symptom evaluation to guide patients toward


Symptom Assessment
appropriate care

Delivers contextual health information and educational content


Health Education
based on patient conditions

Guides users through available healthcare services and helps them


Service Navigation
find appropriate resources

Provides assistance in multiple languages to accommodate diverse


Multi-language Support
patient populations

Improves response accuracy over time through machine learning


Continuous Learning
from interactions and feedback

1.6. Activity diagrams


1.6.1. Patient Booking an Appointment

1.6.2. Doctor Diagnosing and Prescribing Treatment


1.6.3. Laboratory Technician Conducting and Uploading Test Results
1.6.4. Pharmacist Dispensing Medication

1.6.5. Administrator Managing User Roles


1.6.6. Insurance Provider Processing a Claim
CHAPTER 2: Design system in Microservice Approach and Django

1. Overall system component architecture

The Healthcare System implements a distributed architecture where each


microservice manages its own database and exposes functionality through
REST APIs. The API Gateway serves as the central entry point, routing
requests to appropriate services and managing cross-cutting concerns.

REST API connection diagram:

Database and Service Integration Components


Component Description Connections

Central entry point that routes client requests to


• Connects to all microservices
appropriate microservices. Handles
• Receives all client requests
API Gateway authentication verification, request
• Forwards authenticated
transformation, and serves as a unified
requests to appropriate services
interface for frontend applications.

Auth Service Stores user credentials, roles, permissions, and • Direct connection only with
Component Description Connections

authentication tokens. Maintains the source of Auth Service


DB
truth for user identity and access control. • No direct external access

• Reads/writes to Auth Service


Manages user authentication, authorization, DB
Auth Service and session management. Issues JWTs for • Connected to API Gateway
authenticated sessions. • Provides authentication
validation to other services

Stores patient demographic information, • Direct connection only with


Patient Service
medical histories, consent records, and related Patient Service
DB
patient data. • No direct external access

• Reads/writes to Patient
Service DB
Manages all patient-related operations and
• Connected to API Gateway
Patient Service serves as the system of record for patient
• Interacts with Doctor,
information.
Appointment, and Lab
Services

• Direct connection only with


Doctor Service Maintains doctor profiles, specializations,
Doctor Service
DB availability schedules, and credentials.
• No direct external access

• Reads/writes to Doctor
Handles all doctor-related operations including Service DB
Doctor Service schedule management and professional • Connected to API Gateway
information. • Interacts with Appointment
and Patient Services

• Direct connection only with


Appointment Stores appointment records, scheduling rules,
Appointment Service
Service DB and facility availability information.
• No direct external access
Component Description Connections

• Reads/writes to Appointment
Service DB
Appointment Manages scheduling, rescheduling, and
• Connected to API Gateway
Service cancellation of appointments.
• Interacts with Doctor, Patient,
and Notification Services

• Direct connection only with


Pharmacy Stores medication inventory, prescription
Pharmacy Service
Service DB records, and dispensing history.
• No direct external access

• Reads/writes to Pharmacy
Service DB
Pharmacy Handles prescription processing, medication
• Connected to API Gateway
Service dispensing, and inventory management.
• Interacts with Patient and
Billing Services

• Direct connection only with


Lab Service Maintains laboratory test orders, results, and
Lab Service
DB equipment calibration records.
• No direct external access

• Reads/writes to Lab Service


DB
Manages laboratory testing workflow from
Lab Service • Connected to API Gateway
order to result reporting.
• Interacts with Doctor, Patient,
and Notification Services

• Direct connection only with


Billing Service Stores financial transactions, insurance claims,
Billing Service
DB and payment records.
• No direct external access

Billing Service Handles all financial aspects including • Reads/writes to Billing


insurance processing and payment collection. Service DB
• Connected to API Gateway
• Interacts with Patient,
Component Description Connections

Pharmacy, and Lab Services

• Direct connection only with


Notification Stores message templates, delivery logs, and
Notification Service
Service DB notification preferences.
• No direct external access

• Reads/writes to Notification
Service DB
Notification Manages all types of communications to users
• Connected to API Gateway
Service through various channels.
• Receives requests from all
other services

• Direct connection only with


Admin Service Maintains system configuration, administrative
Admin Service
DB settings, and reporting data.
• No direct external access

• Reads/writes to Admin
Service DB
Provides system administration capabilities and
Admin Service • Connected to API Gateway
operational oversight.
• May request data from all
other services

Facilitates asynchronous communication • Connects to all microservices


Message
between services, ensuring reliable message • Enables event-driven
Queue
delivery. architecture

Key Data Flows


1. Authentication Flow
o Client submits credentials to API Gateway
o Gateway routes authentication request to Auth Service
o Auth Service validates credentials against Auth DB
o Upon success, JWT is generated and returned
o Subsequent requests include JWT for validation
2. Patient Record Access Flow
o Authenticated request arrives at API Gateway
o Gateway validates JWT with Auth Service
o Request routed to Patient Service
o Patient Service checks permissions
o Patient Service retrieves data from its database
o Response returns through API Gateway to client
3. Appointment Booking Flow
o Request arrives through API Gateway
o Appointment Service checks doctor availability with Doctor Service
o Doctor Service queries its database for schedule
o Appointment Service verifies patient with Patient Service
o Patient Service confirms patient status
o Appointment Service creates appointment record in its database
o Appointment Service publishes appointment event to Message Queue
o Notification Service consumes event and sends confirmations
4. Prescription Processing Flow
o Doctor creates prescription through API Gateway
o Request routed to Pharmacy Service
o Pharmacy Service validates prescription with Doctor Service
o Pharmacy Service checks inventory in its database
o Pharmacy Service creates prescription record
o Notification event published to Message Queue
o Notification Service alerts patient of prescription readiness
5. Billing Transaction Flow
o Service event (appointment completion, lab test, medication
dispensing) triggers billing
o Event published to Message Queue
o Billing Service consumes event
o Billing Service creates transaction record
o Billing Service retrieves insurance information from Patient Service
o Insurance claim processed and stored in Billing database
o Payment notification sent through Notification Service

Database Isolation and Consistency


Each microservice owns its data domain and maintains its own database, ensuring:

 Service Autonomy: Services can deploy, scale, and evolve independently


 Data Encapsulation: Direct data access only through owning service
 Eventual Consistency: Service-to-service communication ensures data
synchronization
 Failure Isolation: Database issues in one service don't affect others

2. Database Models of Each Classes in the Services

2.1. Auth Service


Model Fields Description

• id (UUID, PK)
• username (CharField, unique)
• email (EmailField, unique)
Central user entity that
• password (PasswordField, hashed)
stores core identity
• first_name (CharField)
information. All actors
User • last_name (CharField)
in the system have a
• date_joined (DateTimeField)
User record as their
• last_login (DateTimeField)
base identity.
• is_active (BooleanField)
• is_staff (BooleanField)
• phone_number (CharField)

Defines different user


roles in the system
• id (UUID, PK)
(Patient, Doctor, Nurse,
Role • name (CharField, unique)
Administrator, etc.).
• description (TextField)
Used for role-based
access control.

• id (UUID, PK) Associates users with


• user (ForeignKey → User) their roles. Many-to-
UserR
• role (ForeignKey → Role) many relationship
ole
• assigned_at (DateTimeField) allowing users to have
• assigned_by (ForeignKey → User) multiple roles if needed.

Permis • id (UUID, PK) Granular permissions


sion • name (CharField, unique) that define specific
• code_name (CharField, unique) actions users can
Model Fields Description

• description (TextField) perform in the system.

Maps permissions to
RolePe • id (UUID, PK)
roles, defining what
rmissio • role (ForeignKey → Role)
actions are allowed for
n • permission (ForeignKey → Permission)
each role.

• id (UUID, PK)
• user (ForeignKey → User)
Stores refresh tokens for
• token (CharField, unique)
Token maintaining long-lived
• created_at (DateTimeField)
sessions securely.
• expires_at (DateTimeField)
• is_revoked (BooleanField)

• id (UUID, PK)
• user (ForeignKey → User)
Passwo
• token (CharField, unique) Manages password reset
rdRese
• created_at (DateTimeField) requests and tokens.
t
• expires_at (DateTimeField)
• is_used (BooleanField)

• id (UUID, PK)
• user (ForeignKey → User, null=True) Records login attempts
Login
• ip_address (GenericIPAddressField) for security monitoring
Attem
• user_agent (TextField) and brute-force
pt
• timestamp (DateTimeField) protection.
• success (BooleanField)

2.2. Patient Service


Model Fields Description

Patient • id (UUID, PK) Extends the core


• user_id (UUID, unique) User model with
• date_of_birth (DateField) patient-specific
Model Fields Description

• gender (CharField)
• blood_type (CharField)
• address (TextField)
• emergency_contact_name (CharField) information.
• emergency_contact_phone (CharField)
• created_at (DateTimeField)
• updated_at (DateTimeField)

• id (UUID, PK)
• patient (ForeignKey → Patient)
• condition (CharField)
• diagnosed_date (DateField) Records patient's
Medical
• treatment (TextField) past and current
History
• is_chronic (BooleanField) medical conditions.
• notes (TextField)
• created_at (DateTimeField)
• updated_at (DateTimeField)

• id (UUID, PK)
• patient (ForeignKey → Patient)
• allergen (CharField) Documents patient
Allergy • reaction (TextField) allergies and adverse
• severity (CharField) reactions.
• diagnosed_date (DateField)
• notes (TextField)

Medicat • id (UUID, PK) Tracks current and


ion • patient (ForeignKey → Patient) past medications
• name (CharField) taken by patients.
• dosage (CharField)
• frequency (CharField)
• start_date (DateField)
• end_date (DateField, nullable)
• prescriber (CharField)
Model Fields Description

• notes (TextField)

• id (UUID, PK)
• patient (ForeignKey → Patient)
• provider_name (CharField)
• policy_number (CharField)
Stores patient
Insuran • group_number (CharField)
insurance details for
ceInfo • coverage_start_date (DateField)
billing purposes.
• coverage_end_date (DateField, nullable)
• primary_holder_name (CharField)
• relationship_to_holder (CharField)
• verification_status (CharField)

• id (UUID, PK)
• patient (ForeignKey → Patient)
Manages patient-
Patient • document_type (CharField)
uploaded documents
Docume • file (FileField)
like ID cards,
nt • name (CharField)
previous records, etc.
• upload_date (DateTimeField)
• notes (TextField)

• id (UUID, PK)
• patient (ForeignKey → Patient)
Tracks patient
• consent_type (CharField)
consent for various
Consent • given_date (DateTimeField)
purposes (e.g., data
• expiry_date (DateTimeField, nullable)
sharing, research).
• document (FileField, nullable)
• is_active (BooleanField)

2.3. Doctor Service


Model Fields Description

Doctor • id (UUID, PK) Extends the core


• user_id (UUID, unique) User model with
Model Fields Description

• license_number (CharField, unique)


• specialization (CharField)
• qualification (TextField)
doctor-specific
• biography (TextField)
professional
• years_of_experience (IntegerField)
information.
• consultation_fee (DecimalField)
• created_at (DateTimeField)
• updated_at (DateTimeField)

Defines medical
• id (UUID, PK)
Specializa specialties that
• name (CharField, unique)
tion doctors can be
• description (TextField)
associated with.

• id (UUID, PK)
Associates
DoctorSp • doctor (ForeignKey → Doctor)
doctors with their
ecializatio • specialization (ForeignKey → Specialization)
medical
n • certification_date (DateField)
specialties.
• certification_number (CharField)

• id (UUID, PK)
Tracks
• doctor (ForeignKey → Doctor)
educational and
Qualificat • degree (CharField)
professional
ion • institution (CharField)
qualifications of
• year_of_completion (IntegerField)
doctors.
• certificate (FileField, nullable)

• id (UUID, PK)
• doctor (ForeignKey → Doctor)
Defines regular
• day_of_week (IntegerField)
Schedule working hours for
• start_time (TimeField)
doctors.
• end_time (TimeField)
• is_active (BooleanField)
Model Fields Description

• id (UUID, PK)
• doctor (ForeignKey → Doctor) Records doctor
• start_date (DateField) leave periods that
Leave • end_date (DateField) affect
• reason (TextField) appointment
• status (CharField) scheduling.
• created_at (DateTimeField)

• id (UUID, PK)
• doctor (ForeignKey → Doctor) Stores patient
DoctorRa • patient_id (UUID) feedback and
ting • rating (IntegerField) ratings for
• comment (TextField, nullable) doctors.
• created_at (DateTimeField)

2.4. Appointment Service


Model Fields Description

• id (UUID, PK)
• patient_id (UUID)
• doctor_id (UUID)
• date (DateField)
• start_time (TimeField) Core appointment
Appointme • end_time (TimeField) entity linking patients
nt • status (CharField) and doctors at specific
• type (CharField) times.
• reason (TextField)
• notes (TextField)
• created_at (DateTimeField)
• updated_at (DateTimeField)

Appointme • id (UUID, PK) Tracks status changes


ntStatus • appointment (ForeignKey → Appointment) for appointments
Model Fields Description

• status (CharField)
• changed_at (DateTimeField) (scheduled, confirmed,
• changed_by (UUID) completed, canceled).
• notes (TextField)

• id (UUID, PK)
Defines different types
• name (CharField, unique)
Appointme of appointments
• description (TextField)
ntType (consultation, follow-
• duration_minutes (IntegerField)
up, procedure).
• color_code (CharField)

• id (UUID, PK)
• name (CharField)
Manages physical
• floor (CharField)
locations where
Room • building (CharField)
appointments take
• capacity (IntegerField)
place.
• equipment (TextField)
• is_active (BooleanField)

• id (UUID, PK) Associates


Appointme
• appointment (ForeignKey → Appointment) appointments with
ntRoom
• room (ForeignKey → Room) specific rooms.

• id (UUID, PK)
• patient_id (UUID)
• doctor_id (UUID)
• start_date (DateField) Defines recurring
Recurring
• end_date (DateField) appointments (e.g.,
Appointme
• day_of_week (IntegerField) weekly therapy,
nt
• start_time (TimeField) monthly check-ups).
• end_time (TimeField)
• frequency (CharField)
• reason (TextField)
2.5. Pharmacy Service
Model Fields Description

• id (UUID, PK)
• name (CharField)
• generic_name (CharField)
• description (TextField) Catalog of
Medicatio • dosage_form (CharField) medications
n • strength (CharField) available in the
• manufacturer (CharField) pharmacy.
• require_prescription (BooleanField)
• created_at (DateTimeField)
• updated_at (DateTimeField)

• id (UUID, PK)
• medication (ForeignKey → Medication)
• batch_number (CharField)
• stock_quantity (IntegerField) Tracks medication
Inventory • unit_price (DecimalField) stock levels and
• cost_price (DecimalField) inventory details.
• expiration_date (DateField)
• reorder_level (IntegerField)
• last_restock_date (DateField)

• id (UUID, PK)
• patient_id (UUID)
• doctor_id (UUID) Documents
Prescriptio • date_prescribed (DateTimeField) medication orders
n • status (CharField) from doctors to
• notes (TextField) patients.
• is_recurring (BooleanField)
• created_at (DateTimeField)

Prescriptio • id (UUID, PK) Individual


nItem • prescription (ForeignKey → Prescription) medications within a
Model Fields Description

• medication (ForeignKey → Medication)


• dosage (CharField)
• frequency (CharField)
• duration (CharField)
prescription with
• quantity (IntegerField)
specific instructions.
• instructions (TextField)
• is_dispensed (BooleanField)
• dispensed_date (DateTimeField, nullable)
• dispensed_by (UUID, nullable)

• id (UUID, PK)
• prescription (ForeignKey → Prescription)
Records of
Dispensati • pharmacist_id (UUID)
medications
on • dispensed_date (DateTimeField)
dispensed to patients.
• status (CharField)
• notes (TextField)

• id (UUID, PK)
Individual
• dispensation (ForeignKey → Dispensation)
medications
Dispensati • prescription_item (ForeignKey → PrescriptionItem)
dispensed with
onItem • inventory (ForeignKey → Inventory)
specific inventory
• quantity_dispensed (IntegerField)
batch details.
• notes (TextField)

• id (UUID, PK)
• name (CharField)
• contact_person (CharField) Information about
Supplier • email (EmailField) medication suppliers
• phone (CharField) and distributors.
• address (TextField)
• is_active (BooleanField)

PurchaseO • id (UUID, PK) Purchase orders for


rder • supplier (ForeignKey → Supplier) medication
Model Fields Description

• order_date (DateTimeField)
• expected_delivery_date (DateField)
• status (CharField) restocking.
• total_amount (DecimalField)
• notes (TextField)

2.6. Lab Service


Model Fields Description

• id (UUID, PK)
• name (CharField, unique)
• description (TextField)
• preparation_instructions (TextField) Catalog of available
TestType
• normal_range (CharField) laboratory tests.
• units (CharField)
• turnaround_time_hours (IntegerField)
• price (DecimalField)

• id (UUID, PK)
• patient_id (UUID)
• doctor_id (UUID)
Test requests ordered
• ordered_date (DateTimeField)
TestOrder by doctors for
• required_date (DateField, nullable)
patients.
• status (CharField)
• clinical_notes (TextField)
• priority (CharField)

• id (UUID, PK)
• test_order (ForeignKey → TestOrder)
TestOrder Individual tests
• test_type (ForeignKey → TestType)
Item within an order.
• status (CharField)
• notes (TextField)
Model Fields Description

• id (UUID, PK)
• test_order_item (ForeignKey → TestOrderItem)
• sample_type (CharField) Biological samples
Sample • collection_date (DateTimeField) collected for
• collected_by (UUID) laboratory testing.
• status (CharField)
• barcode (CharField, unique)

• id (UUID, PK)
• test_order_item (ForeignKey → TestOrderItem)
• performed_by (UUID)
• verified_by (UUID, nullable)
Test outcomes and
TestResult • performed_date (DateTimeField)
interpretations.
• result_value (CharField)
• is_abnormal (BooleanField)
• interpretation (TextField)
• report_file (FileField, nullable)

• id (UUID, PK)
• name (CharField)
• model (CharField)
• serial_number (CharField, unique) Laboratory
Equipment • manufacturer (CharField) equipment used for
• purchase_date (DateField) conducting tests.
• last_maintenance_date (DateField)
• next_maintenance_date (DateField)
• status (CharField)

• id (UUID, PK)
TestEquip Associates tests with
• test_type (ForeignKey → TestType)
ment required equipment.
• equipment (ForeignKey → Equipment)

QualityCo • id (UUID, PK) Records of quality


ntrol • equipment (ForeignKey → Equipment) control procedures
Model Fields Description

• test_type (ForeignKey → TestType)


• performed_by (UUID)
• date (DateTimeField)
for lab accuracy.
• result (CharField)
• is_passed (BooleanField)
• notes (TextField)

2.7. Billing Service


Model Fields Description

• id (UUID, PK)
• patient_id (UUID)
• generated_date (DateTimeField)
• due_date (DateField)
Financial documents
• status (CharField)
Invoice detailing charges for
• subtotal (DecimalField)
healthcare services.
• tax_amount (DecimalField)
• discount_amount (DecimalField)
• total_amount (DecimalField)
• notes (TextField)

• id (UUID, PK)
• invoice (ForeignKey → Invoice)
• service_type (CharField)
• description (TextField)
InvoiceIte Individual line items
• service_date (DateField)
m within an invoice.
• quantity (IntegerField)
• unit_price (DecimalField)
• total_price (DecimalField)
• reference_id (UUID, nullable)

Payment • id (UUID, PK) Records of financial


• invoice (ForeignKey → Invoice) transactions from
Model Fields Description

• amount (DecimalField)
• payment_date (DateTimeField)
• payment_method (CharField)
• transaction_id (CharField, nullable) patients.
• status (CharField)
• notes (TextField)
• received_by (UUID)

• id (UUID, PK)
• provider_name (CharField)
• contact_person (CharField)
Insurance company
• email (EmailField)
Insurance information for
• phone (CharField)
claims processing.
• address (TextField)
• website (URLField)
• is_active (BooleanField)

• id (UUID, PK)
• invoice (ForeignKey → Invoice)
• insurance (ForeignKey → Insurance)
• patient_id (UUID)
Insurance
Insurance • policy_number (CharField)
reimbursement
Claim • claim_date (DateTimeField)
requests.
• status (CharField)
• claimed_amount (DecimalField)
• approved_amount (DecimalField, nullable)
• rejection_reason (TextField, nullable)

• id (UUID, PK)
Bundled service
PricingPa • name (CharField)
offerings with special
ckage • description (TextField)
pricing.
• is_active (BooleanField)

PricingIte • id (UUID, PK) Standard pricing for


Model Fields Description

• service_code (CharField, unique)


• service_name (CharField)
• service_type (CharField) individual healthcare
m
• base_price (DecimalField) services.
• is_taxable (BooleanField)
• tax_rate (DecimalField)

• id (UUID, PK)
• package (ForeignKey → PricingPackage)
PricingPa Services included in
• pricing_item (ForeignKey → PricingItem)
ckageItem pricing packages.
• quantity (IntegerField)
• discount_percent (DecimalField)

2.8. Notification Service


Model Fields Description

• id (UUID, PK) Categories of


• name (CharField, unique) notifications
NotificationTy
• description (TextField) (appointment
pe
• default_template (TextField) reminder, test result,
• is_active (BooleanField) etc.).

• id (UUID, PK)
Communication
• name (CharField, unique)
Channel methods (email, SMS,
• description (TextField)
in-app, push).
• is_active (BooleanField)

NotificationTe • id (UUID, PK) Message templates for


mplate • notification_type (ForeignKey → different notification
NotificationType) types and channels.
• channel (ForeignKey → Channel)
• subject (CharField)
Model Fields Description

• body_template (TextField)
• language_code (CharField)
• is_active (BooleanField)
• last_updated (DateTimeField)

• id (UUID, PK)
• user_id (UUID)
• notification_type (ForeignKey → User settings for how
UserPreferenc
NotificationType) they want to receive
e
• channel (ForeignKey → Channel) different notifications.
• is_enabled (BooleanField)
• updated_at (DateTimeField)

• id (UUID, PK)
• user_id (UUID)
• notification_type (ForeignKey →
NotificationType)
Record of notifications
Notification • title (CharField)
sent to users.
• message (TextField)
• data (JSONField)
• is_read (BooleanField)
• created_at (DateTimeField)

• id (UUID, PK)
• notification (ForeignKey → Notification)
• channel (ForeignKey → Channel) Tracking information
DeliveryAttem
• attempt_time (DateTimeField) for notification
pt
• status (CharField) delivery attempts.
• error_message (TextField, nullable)
• delivery_id (CharField, nullable)

ScheduledNoti • id (UUID, PK) Future notifications


fication • user_id (UUID) scheduled for delivery.
• notification_type (ForeignKey →
Model Fields Description

NotificationType)
• scheduled_time (DateTimeField)
• data (JSONField)
• status (CharField)
• created_at (DateTimeField)

2.9. Admin Service


Model Fields Description

• id (UUID, PK)
• key (CharField, unique)
• value (TextField)
Global configuration
SystemConfi • description (TextField)
parameters for the
g • is_encrypted (BooleanField)
system.
• created_at (DateTimeField)
• updated_at (DateTimeField)
• updated_by (UUID)

• id (UUID, PK)
• user_id (UUID, nullable)
• action (CharField)
• entity_type (CharField) Comprehensive audit
AuditLog • entity_id (CharField) trail of system
• timestamp (DateTimeField) activities.
• ip_address (GenericIPAddressField)
• user_agent (TextField)
• details (JSONField)

Announceme • id (UUID, PK) System-wide


nt • title (CharField) announcements for
• content (TextField) staff or patients.
• start_date (DateTimeField)
• end_date (DateTimeField)
Model Fields Description

• target_roles (CharField)
• is_active (BooleanField)
• created_by (UUID)
• created_at (DateTimeField)

• id (UUID, PK)
• name (CharField)
• address (TextField)
• phone (CharField) Healthcare facility
FacilityInfo • email (EmailField) details for display and
• website (URLField) contact purposes.
• operating_hours (JSONField)
• description (TextField)
• logo (ImageField)

• id (UUID, PK)
• name (CharField, unique)
Organizational
• description (TextField)
Department structure of the
• manager_id (UUID, nullable)
healthcare facility.
• parent_department (ForeignKey → self,
nullable)

• id (UUID, PK)
• name (CharField)
• description (TextField) Saved report
• query (TextField) definitions for
Report
• parameters (JSONField) administrative
• created_by (UUID) reporting.
• created_at (DateTimeField)
• is_active (BooleanField)

ReportSched • id (UUID, PK) Automated report


ule • report (ForeignKey → Report) generation and
• frequency (CharField) distribution
• recipients (JSONField) schedules.
Model Fields Description

• next_run_time (DateTimeField)
• last_run_time (DateTimeField, nullable)
• is_active (BooleanField)

• id (UUID, PK)
Categories of hospital
ResourceTyp • name (CharField, unique)
resources (equipment,
e • description (TextField)
supplies, etc.).
• category (CharField)

• id (UUID, PK)
• resource_type (ForeignKey → ResourceType)
• name (CharField)
Tracking of hospital
• quantity (IntegerField)
Resource resources and their
• location (CharField)
status.
• status (CharField)
• last_maintenance (DateField, nullable)
• next_maintenance (DateField, nullable)

3. Design classes and methods in components/services

This section details the key classes, methods, and relationships within each
microservice component of the Healthcare System. The design follows object-
oriented principles and implements the Domain-Driven Design approach to
ensure clear separation of concerns and maintainable code architecture.

3.1. Auth Service

3.1.1. User Management

Class Methods Description

UserManager • create_user(username, email, password, Custom user


**extra_fields) manager that
• create_superuser(username, email, password, handles user
Class Methods Description

creation with
proper
**extra_fields)
password
• get_by_natural_key(username)
hashing and
validation

• register_user(user_data)
Business
• update_user(user_id, user_data)
logic for user
UserService • deactivate_user(user_id)
account
• change_password(user_id, old_password,
operations
new_password)

• assign_role(user_id, role_id) Manages role


• remove_role(user_id, role_id) assignments
RoleService
• get_user_roles(user_id) and
• get_role_permissions(role_id) permissions

3.1.2. Authentication
Class Methods Description

Core
• authenticate(username, password)
authentication
• generate_tokens(user)
functions
AuthService • refresh_token(refresh_token)
including
• validate_token(token)
JWT token
• revoke_token(token)
generation

Handles
• create_reset_token(email) secure
PasswordResetService • validate_reset_token(token) password
• reset_password(token, new_password) recovery
workflows

SecurityService • record_login_attempt(username, Security


Class Methods Description

ip_address, success) monitoring


• check_brute_force(username, and
ip_address) protection
• get_security_events(user_id) mechanisms

3.2. Patient Service


3.2.1. Patient Management
Class Methods Description

• create_patient(user_id, patient_data)
Core patient
• update_patient(patient_id, patient_data)
PatientService record
• get_patient(patient_id)
management
• search_patients(query)

• add_medical_history(patient_id,
Patient
history_data)
MedicalHistoryServic medical
• update_medical_history(history_id,
e history
history_data)
operations
• get_patient_history(patient_id)

• add_allergy(patient_id, allergy_data)
Allergy
• update_allergy(allergy_id, allergy_data)
AllergyService tracking and
• delete_allergy(allergy_id)
management
• get_patient_allergies(patient_id)

3.2.2. Insurance and Documents


Class Methods Description

• add_insurance(patient_id, insurance_data)
Insurance
Insuranc • update_insurance(insurance_id, insurance_data)
information
eService • verify_insurance(insurance_id)
management
• get_patient_insurance(patient_id)

Docume • upload_document(patient_id, file, document_type) Patient


Class Methods Description

• get_document(document_id)
• delete_document(document_id) document
ntService
• list_patient_documents(patient_id, management
document_type=None)

• record_consent(patient_id, consent_type,
expiry_date=None) Patient
ConsentS
• revoke_consent(consent_id) consent
ervice
• check_consent(patient_id, consent_type) tracking
• get_patient_consents(patient_id)

3.3. Doctor Service


3.3.1. Doctor Profile Management
Class Methods Description

• create_doctor(user_id, doctor_data)
Doctor
• update_doctor(doctor_id, doctor_data)
DoctorService profile
• get_doctor(doctor_id)
management
• search_doctors(criteria)

• add_specialization(doctor_id,
specialization_data)
• remove_specialization(doctor_id, Doctor
SpecializationServic
specialization_id) specialization
e
• get_doctor_specializations(doctor_id) management
• find_doctors_by_specialization(specializati
on_id)

QualificationService • add_qualification(doctor_id, Educational


qualification_data) and
• update_qualification(qualification_id, professional
qualification_data) credentials
• verify_qualification(qualification_id)
Class Methods Description

• get_doctor_qualifications(doctor_id)

3.3.2. Scheduling and Availability


Class Methods Description

• set_regular_hours(doctor_id, schedule_data)
Doctor
• update_schedule(schedule_id, schedule_data)
ScheduleServic working
• get_doctor_schedule(doctor_id)
e hours
• check_availability(doctor_id, date, start_time,
management
end_time)

• request_leave(doctor_id, leave_data) Doctor


• approve_leave(leave_id) leave and
LeaveService
• reject_leave(leave_id, reason) absence
• get_doctor_leaves(doctor_id) management

• add_rating(doctor_id, patient_id, rating_data) Patient


RatingService • get_doctor_ratings(doctor_id) feedback for
• get_average_rating(doctor_id) doctors

3.4. Appointment Service


3.4.1. Appointment Management
Class Methods Description

• create_appointment(patient_id,
doctor_id, appointment_data)
• reschedule_appointment(appoint
Core
ment_id, new_date, new_time)
AppointmentService appointment
• cancel_appointment(appointment
operations
_id, reason)
• complete_appointment(appointm
ent_id, notes)

AppointmentQueryService • get_patient_appointments(patient Appointment


Class Methods Description

_id, status=None,
from_date=None, to_date=None)
• get_doctor_appointments(doctor
retrieval and
_id, status=None,
filtering
from_date=None, to_date=None)
• get_daily_schedule(doctor_id,
date)

• create_recurring_appointment(pa
tient_id, doctor_id, recurring_data)
• update_recurring_pattern(recurri
Recurring
RecurringAppointmentServic ng_id, pattern_data)
appointment
e • cancel_recurring_series(recurrin
management
g_id)
• generate_appointments(recurring
_id, date_range)

3.4.2. Resource Management


Class Methods Description

• add_room(room_data)
• update_room(room_id,
room_data) Facility
RoomService • get_available_rooms(date, room
start_time, end_time) management
• assign_room(appointment_id,
room_id)

AppointmentStatusService • update_status(appointment_id, Appointment


new_status, notes=None) status
• get_status_history(appointment tracking
_id)
• get_status_counts(date_range,
Class Methods Description

doctor_id=None)

• validate_new_appointment(pati
ent_id, doctor_id, date,
Business rule
start_time, end_time)
AppointmentValidationServic validation
• check_conflicts(doctor_id, date,
e for
start_time, end_time)
appointments
• verify_doctor_availability(doct
or_id, date, start_time, end_time)

3.5. Pharmacy Service


3.5.1. Medication Management
Class Methods Description

• create_medication(medication_data)
• update_medication(medication_id, Medication
MedicationServic
medication_data) catalog
e
• search_medications(query) management
• get_medication_details(medication_id)

• add_inventory(medication_id, inventory_data)
• update_stock(inventory_id, quantity_change, Medication
InventoryService reason) inventory
• check_stock(medication_id) tracking
• get_low_stock_items()

• add_supplier(supplier_data)
Supplier and
• update_supplier(supplier_id, supplier_data)
SupplierService purchasing
• get_suppliers_for_medication(medication_id)
management
• create_purchase_order(supplier_id, items)
3.5.2. Prescription Management
Class Methods Description

• create_prescription(patient_id, doctor_id,
prescription_data)
Prescription
• add_prescription_item(prescription_id,
PrescriptionService creation and
medication_id, dosage_data)
management
• revoke_prescription(prescription_id, reason)
• get_active_prescriptions(patient_id)

• dispense_prescription(prescription_id,
pharmacist_id)
Medication
• dispense_item(prescription_item_id,
DispensationService dispensing
inventory_id, quantity)
workflow
• get_patient_dispensation_history(patient_id)
• verify_prescription(prescription_id)

• check_interactions(patient_id,
Drug safety
medication_id)
DrugInteractionServic and
• get_patient_current_medications(patient_id)
e interaction
• record_adverse_reaction(patient_id,
checking
medication_id, reaction_data)

3.6. Lab Service


3.6.1. Test Management
Class Methods Description

• create_test_type(test_data)
Laboratory
• update_test_type(test_type_id, test_data)
TestTypeService test catalog
• get_test_details(test_type_id)
management
• search_tests(query)

TestOrderService • create_test_order(patient_id, doctor_id, Test


test_order_data) ordering
• add_test_item(order_id, test_type_id, workflow
notes=None)
Class Methods Description

• cancel_test_order(order_id, reason)
• get_patient_test_orders(patient_id)

• register_sample(test_item_id, sample_data)
Biological
• update_sample_status(sample_id, status)
SampleService sample
• print_sample_label(sample_id)
management
• track_sample(sample_id)

3.6.2. Results and Quality


Class Methods Description

• record_result(test_item_id, result_data) Test result


• verify_result(result_id, verified_by) recording
TestResultService
• get_test_results(test_order_id) and
• flag_abnormal_results(result_id) management

• register_equipment(equipment_data)
• schedule_maintenance(equipment_id, date) Laboratory
EquipmentService • record_maintenance(equipment_id, equipment
maintenance_data) management
• get_equipment_history(equipment_id)

• schedule_qc(test_type_id, frequency)
• record_qc_result(equipment_id,
Quality
test_type_id, qc_data)
QualityControlService assurance
• get_qc_history(test_type_id)
processes
• verify_equipment_calibration(equipment_i
d)

3.7. Billing Service


3.7.1. Invoicing and Payments
Class Methods Description

InvoiceService • create_invoice(patient_id, service_items) Invoice


Class Methods Description

• add_invoice_item(invoice_id, item_data)
generation
• apply_discount(invoice_id, discount_type,
and
amount)
management
• finalize_invoice(invoice_id)

• record_payment(invoice_id, payment_data)
Payment
• process_credit_card(payment_data)
PaymentService processing
• issue_refund(payment_id, amount, reason)
and tracking
• get_payment_history(patient_id)

• get_service_price(service_code)
Service
• apply_package_pricing(patient_id, package_id)
PricingService pricing and
• calculate_total(invoice_id)
calculation
• apply_tax(invoice_id)

3.7.2. Insurance Processing


Class Methods Description

• create_claim(invoice_id, insurance_id)
• submit_claim(claim_id) Insurance
InsuranceClaim
• update_claim_status(claim_id, status, claim
Service
notes=None) workflow
• record_payment(claim_id, amount_paid)

• verify_coverage(patient_id, service_code)
Insurance
• check_eligibility(patient_id, insurance_id)
CoverageVerifi verification
• get_coverage_details(patient_id)
cationService and
• estimate_patient_responsibility(patient_id,
eligibility
service_codes)

ClaimSubmissi • prepare_claim_document(claim_id) Claim


onService • send_electronic_claim(claim_id) submission
• track_claim_status(claim_id) and
• handle_claim_rejection(claim_id,
Class Methods Description

rejection_reason) tracking

3.8. Notification Service


3.8.1. Message Management
Class Methods Description

• create_notification(user_id, notification_type, data) Core


Notification • mark_as_read(notification_id) notification
Service • get_user_notifications(user_id, read=None) creation and
• delete_notification(notification_id) management

• create_template(notification_type, channel,
template_data)
Message
TemplateSer • render_template(template_id, context_data)
template
vice • get_template(notification_type, channel,
management
language=None)
• update_template(template_id, template_data)

• schedule_notification(user_id, notification_type,
data, scheduled_time) Future
ScheduleSer
• cancel_scheduled(scheduled_id) notification
vice
• process_due_notifications() scheduling
• reschedule_notification(scheduled_id, new_time)

3.8.2. Delivery Management


Class Methods Description

• send_email(recipient, subject, body,


attachments=None)
Email channel
EmailService • verify_delivery(message_id)
implementation
• handle_bounce(message_id, reason)
• get_email_statistics(date_range)

SmsService • send_sms(phone_number, message) SMS channel


Class Methods Description

• verify_delivery(message_id)
• check_delivery_status(message_id) implementation
• get_sms_statistics(date_range)

• send_push(user_id, title, message,


Push
data=None)
PushNotificationServic notification
• register_device(user_id, device_token)
e channel
• remove_device(user_id, device_token)
implementation
• get_user_devices(user_id)

3.9. API Gateway


3.9.1. Request Management
Class Methods Description

• route_request(path, method, headers,


Request
body)
routing to
RouterService • resolve_service(path)
appropriate
• forward_request(service, request)
services
• handle_response(service_response)

• process_request(request) Authentication
AuthenticationMidd • validate_token(token) verification for
leware • refresh_session(refresh_token) incoming
• handle_unauthenticated() requests

• check_rate_limit(identifier, endpoint)
• increment_counter(identifier, Request rate
RateLimitingService endpoint) limiting
• get_current_limit(identifier) implementation
• handle_rate_exceeded()
3.9.2. Integration and Documentation
Class Methods Description

• register_service(service_name, url,
health_check_path) Service
ServiceRegistryS
• discover_service(service_name) discovery
ervice
• check_service_health(service_name) implementation
• unregister_service(service_name)

• track_request(service_name, success)
Circuit breaker
CircuitBreakerSe • check_circuit_state(service_name)
pattern for fault
rvice • open_circuit(service_name)
tolerance
• reset_circuit(service_name)

• generate_api_docs(service_name)
• aggregate_all_docs() API
DocumentationS
• get_endpoint_documentation(path, documentation
ervice
method) management
• update_documentation()

3.10. Admin Service


3.10.1. System Configuration
Clas
Methods Description
s

• get_config(key)
Conf System-wide
• set_config(key, value)
igSer configuration
• get_configuration_group(group)
vice management
• reload_configuration()

• log_action(user_id, action, entity_type, entity_id,


Audi details) Security and
tServ • search_audit_logs(criteria) activity
ice • get_user_activity(user_id) auditing
• export_audit_logs(date_range)
Clas
Methods Description
s

Anno
• create_announcement(announcement_data)
unce System
• publish_announcement(announcement_id)
ment announcement
• expire_announcement(announcement_id)
Servi management
• get_active_announcements(roles=None)
ce

3.10.2. Reporting and Analytics


Class Methods Description

• create_report(report_data)
• generate_report(report_id,
parameters)
Administrative
ReportService • schedule_report(report_id,
reporting tools
schedule_data)
• export_report(report_id,
format)

• get_appointment_statistics(dat
e_range)
• get_billing_summary(date_ran Business
AnalyticsService ge) intelligence
• get_patient_demographics() and analytics
• get_doctor_performance_metri
cs(doctor_id=None)

• add_resource(resource_data)
• update_resource_status(resour
Hospital
ce_id, status)
ResourceManagementService resource
• track_resource_usage(resource
tracking
_id, usage_data)
• get_resource_inventory()
3.11. AI Assistant Service
3.11.1. Conversation Management
Class Methods Description

• create_conversation(user_id)
Convers • add_message(conversation_id, message, Management
ationSer is_user=True) of chat
vice • get_conversation_history(conversation_id) conversations
• end_conversation(conversation_id)

• process_message(message, user_id,
Message conversation_id) Natural
Processi • detect_intent(message) language
ngServi • generate_response(intent, entities, processing
ce conversation_id) pipeline
• format_response(response_data)

• initialize_context(conversation_id, user_id)
Conversation
Context • update_context(conversation_id, context_data)
context
Service • get_current_context(conversation_id)
management
• clear_context(conversation_id)

3.11.2. Integration and Learning


Class Methods Description

Knowle • query_knowledge_base(query, max_results=5) Medical


dgeBas • add_knowledge_item(content, metadata) knowledge
eServic • update_knowledge_base() access and
e • validate_response(response) verification

• get_patient_appointments(patient_id)
Service Integration
• get_medication_information(medication_name)
Integrat with other
• check_doctor_availability(doctor_id, date)
ionServ system
• book_appointment(patient_id, doctor_id,
ice services
appointment_data)
Class Methods Description

• record_feedback(conversation_id, feedback_data)
Feedba Learning
• analyze_feedback(date_range=None)
ckServi from user
• improve_model(feedback_batch)
ce feedback
• track_response_quality(conversation_id, response_id)

You might also like