Your Patient Journey Data Template
Your Patient Journey Data Template
- Recommended clinical attributes
- Essential process milestones
- MEDITECH extraction guidance
Patient Journey Attributes
| Name | Description | ||
|---|---|---|---|
| Activity Name ActivityName | The specific clinical or administrative action performed. | ||
| Description This attribute represents the name of the event or task occurring within the patient journey. It captures the distinct steps such as 'Patient Registered', 'Medication Administered', or 'Discharge Order Written'. Correct identification of activities is crucial for mapping the process flow. These values are often derived from transaction codes, order statuses, or documented interventions within the electronic health record. Why it matters Defines the steps of the process and is required to visualize the process map. Where to get Derived from various transaction logs (OE Orders, NUR Interventions, ADM Events). Examples Patient RegisteredTriage CompletedMedication AdministeredDiagnostic Result Verified | |||
| Event Timestamp EventTimestamp | The specific date and time when the activity occurred. | ||
| Description This attribute records the exact moment an activity took place. It is used to sequence events chronologically and calculate duration metrics between process steps. High-precision timestamps are necessary for accurate analysis of wait times, such as the duration between triage and assessment, or the turnaround time for diagnostic results. Why it matters Required to order events and calculate cycle times and throughput. Where to get Transaction date/time columns in source tables. Examples 2023-10-15T08:30:00Z2023-10-15T09:15:22Z2023-10-16T14:45:00Z | |||
| Last Data Update LastDataUpdate | The timestamp when the data was last extracted or refreshed. | ||
| Description Indicates when the record was last processed or loaded into the process mining tool. This helps in auditing data freshness and ensuring that the analysis reflects the most current state of the system. It is distinct from the Event Timestamp, as it reflects the technical data pipeline time rather than the clinical event time. Why it matters Critical for data governance and ensuring analysis is performed on up-to-date data. Where to get System date at time of ETL execution. Examples 2023-11-01T00:00:00Z2023-11-02T12:00:00Z | |||
| Patient Episode PatientEpisode | The unique identifier for a specific period of patient care or visit. | ||
| Description The Patient Episode acts as the central case identifier for the process analysis. It groups all clinical, administrative, and financial events related to a single hospital stay or outpatient visit into one cohesive journey. In MEDITECH systems, this often correlates to the Account Number or Visit ID. This attribute is fundamental for reconstructing the patient journey from registration to discharge, allowing for the calculation of length of stay and the analysis of clinical pathways. Why it matters It is the mandatory case key required to link disparate events into a single process instance. Where to get MEDITECH Admissions or Registration module; typically the Account Number field. Examples V100938475AC29384755E993847211O229384711 | |||
| Source System SourceSystem | The identifier of the system where the data originated. | ||
| Description Identifies the MEDITECH instance or specific module from which the event data was extracted. In multi-hospital environments, this helps distinguish between data from different facilities or system versions. This attribute is static for a single-system extraction but critical when merging data from creating a unified view across a hospital network. Why it matters Ensures data lineage and traceability in multi-system environments. Where to get Hardcoded during extraction or system ID configuration. Examples MEDITECH_ExpanseMEDITECH_6.1Hospital_A_Main | |||
| Attending Provider AttendingProvider | The primary clinician or provider responsible for the activity. | ||
| Description Records the name or ID of the physician, nurse, or technician performing the task or overseeing the care. This attribute supports the 'Treatment Plan Development Velocity' dashboard by attributing speed and efficiency metrics to specific staff or roles. It enables resource analysis to balance workloads and identify training needs among clinical staff. Why it matters Allows for resource performance analysis and workload balancing. Where to get Provider or User fields in activity logs. Examples Dr. SmithRN JonesTech Adams | |||
| Discharge Disposition DischargeDisposition | The destination or status of the patient upon discharge. | ||
| Description Indicates where the patient went after the episode, such as 'Home', 'Skilled Nursing Facility', 'Home Health', or 'Expired'. This is a key outcome metric for the 'Discharge Planning Optimization' dashboard. Analyzing this helps identify if delays in securing post-acute care placements are contributing to longer lengths of stay. Why it matters Key outcome metric for analyzing length of stay and readmission risk. Where to get Discharge abstraction or registration screens. Examples Discharged to HomeTransferred to Short Term General HospitalExpiredLeft Against Medical Advice | |||
| Hospital Department HospitalDepartment | The specific unit or department where the activity occurred. | ||
| Description Identifies the functional unit, such as 'Emergency', 'Radiology', 'ICU', or 'General Ward', responsible for the activity. This attribute is vital for the 'Departmental Resource Throughput' dashboard. It allows for the segmentation of performance metrics by unit, helping to pinpoint bottlenecks in internal transfers and resource utilization. Why it matters Key for organizational analysis and identifying bottlenecks in specific units. Where to get Location or Department fields in transaction tables. Examples Emergency DepartmentRadiologyIntensive Care UnitSurgical Ward 3 | |||
| Is Readmission IsReadmission | Flag indicating if this episode occurred within 30 days of a previous discharge. | ||
| Description A boolean attribute that returns true if the patient's current registration date is within 30 days of a previous episode's discharge date. This supports the 'Readmission and Care Quality' dashboard. Identifying readmissions allows analysts to trace back to the previous episode to find gaps in discharge planning or follow-up care. Why it matters Critical quality metric impacting reimbursement and patient outcomes. Where to get Calculated by comparing current StartTime with previous Case EndTime for same MedicalRecordNumber. Examples truefalse | |||
| Length Of Stay LengthOfStay | Total duration of the patient episode from admission to discharge. | ||
| Description A calculated metric representing the total time elapsed between the registration/admission start time and the discharge time. This is the primary metric for the 'Length Of Stay Trend Analysis' dashboard. It serves as a high-level efficiency indicator and is often used to normalize comparisons between different departments or diagnosis groups. Why it matters Primary efficiency KPI for hospital operations. Where to get Calculated from StartTime of Registration vs Discharge. Examples 4 days 2 hours45 minutes12 days | |||
| Medical Record Number MedicalRecordNumber | A unique identifier for the patient across all visits. | ||
| Description The Medical Record Number (MRN) uniquely identifies a patient within the healthcare organization, distinct from the episode-specific ID. It allows analysts to link multiple episodes involving the same patient over time. This attribute is essential for the 'Readmission and Care Quality' dashboard, enabling the detection of patients returning to the hospital within 30 days of discharge. Why it matters Enables cross-episode analysis and patient-centric views. Where to get Patient master index or registration table. Examples MRN-100293MRN-55928388291002 | |||
| Patient Type PatientType | Categorization of the patient visit (e.g., Inpatient, Outpatient, Emergency). | ||
| Description Classifies the nature of the hospital visit. Common values include 'Inpatient', 'Outpatient', 'Emergency', or 'Observation'. This classification is fundamental for filtering and comparing processes, as the standard of care and expected duration differ significantly by type. This field helps in the 'Discharge Planning Optimization' dashboard by segmenting length of stay expectations. Why it matters Fundamental segmentation for process comparison (Inpatient vs Outpatient). Where to get Admission or Visit tables (e.g., AdmVisits.Status). Examples InpatientEmergencyOutpatient SurgeryObservation | |||
| Primary Diagnosis PrimaryDiagnosis | The main medical condition identified for the patient episode. | ||
| Description Contains the ICD-10 code or description of the primary reason for the encounter. This is the cornerstone of the 'Clinical Pathway Variant Analysis'. By grouping cases by Primary Diagnosis, clinical managers can compare actual treatment paths against the ideal clinical pathway for that specific condition. Why it matters Essential for grouping cases to analyze clinical pathways. Where to get Medical Records or Abstracting module. Examples J18.9 - PneumoniaI21.9 - Acute Myocardial InfarctionS72.0 - Fracture of Femur | |||
| Triage Acuity Level TriageAcuityLevel | The severity rating assigned to a patient during triage. | ||
| Description Indicates the urgency of the patient's condition, typically on a scale (e.g., 1-5, where 1 is critical). This attribute is central to the 'Emergency Department Flow Analysis'. It allows analysts to correlate wait times with patient severity, ensuring that the most critical patients are being prioritized effectively. Why it matters Critical for analyzing ED prioritization and safety compliance. Where to get ED or Triage nursing assessment screens. Examples 1 - Resuscitation2 - Emergent3 - Urgent4 - Less Urgent | |||
| Admit Source AdmitSource | Where the patient came from (e.g., Home, Transfer, Referral). | ||
| Description Describes the origin of the patient admission, such as 'Physician Referral', 'Emergency Room', or 'Transfer from other Hospital'. This provides context on how patients enter the system. It is useful for understanding inflow patterns and their impact on 'Emergency Department Flow Analysis' and resource planning. Why it matters Provides context on patient inflow and demand channels. Where to get Admissions registration data. Examples Emergency RoomClinic ReferralTransfer from SNF | |||
| Charge Amount ChargeAmount | The financial value associated with a specific activity or service. | ||
| Description Represents the cost or charge posted for a specific event, such as a test or room charge. While primarily financial, it relates to resource intensity. When aggregated, it helps understand the financial impact of process variations, although the primary focus of the requested view is clinical flow. Why it matters Adds financial dimension to process analysis. Where to get Billing or BAR (Billing/Accounts Receivable) module. Examples 150.001200.5045.00 | |||
| Is Adherence Violation IsAdherenceViolation | Flag indicating if the case deviated from the standard clinical pathway. | ||
| Description A boolean flag set to true if the sequence of activities does not match the defined reference model for the patient's Primary Diagnosis. This supports 'Clinical Pathway Variant Analysis'. It allows for rapid filtering of 'non-conformant' cases to investigate why the standard of care was not followed. Why it matters Quickly identifies process deviations and variance. Where to get Calculated by conformance checking algorithms. Examples truefalse | |||
| Medication Name MedicationName | The name of the pharmaceutical administered. | ||
| Description Captures the specific drug involved in 'Medication Administered' events. This is required for the 'Medication Administration Compliance' dashboard. It allows nursing leadership to verify that specific high-risk or time-critical medications (like antibiotics for sepsis) are delivered within the appropriate therapeutic windows. Why it matters Required for clinical compliance and safety analysis. Where to get Pharmacy (PHA) or Bedside Verification (BMV) modules. Examples AcetaminophenVancomycinHeparinInsulin | |||
| Order Category OrderCategory | Classification of clinical orders (e.g., Lab, Radiology, Consult). | ||
| Description Groups orders into broader categories such as 'Laboratory', 'Radiology', 'Dietary', or 'Consult'. This is essential for the 'Diagnostic Services Turnaround' dashboard. It enables the separation of workflows to analyze cycle times specific to imaging versus blood work, which often have different bottlenecks. Why it matters Segments diagnostic and treatment workflows. Where to get Order Entry (OE) module category fields. Examples LaboratoryRadiologyNursingPharmacy | |||
| Triage Wait Time TriageWaitTime | Time duration between registration and triage completion. | ||
| Description The calculated duration between the 'Patient Registered' event and the 'Triage Completed' event. This directly feeds the 'Average Triage Throughput Time' KPI. Monitoring this duration helps ED managers adjust staffing during peak hours to ensure patient safety standards are met. Why it matters Key operational metric for Emergency Departments. Where to get Calculated difference between specific activity timestamps. Examples 15 minutes1 hour 20 minutes | |||
Patient Journey Activities
| Activity | Description | ||
|---|---|---|---|
| Diagnosis Documented | The point where a clinician enters a coded diagnosis (ICD-10) into the patient record. This often triggers specific clinical pathways. | ||
| Why it matters Enables 'Clinical Pathway Variant Analysis' by categorizing the case. Critical for grouping patients for comparison. Where to get MEDITECH ABS (Abstracting) or Medical Records. Captured when diagnosis codes are associated with the account. Capture Logged when transaction Diagnosis Enter is executed Event type explicit | |||
| Diagnostic Result Verified | Indicates that a diagnostic test (Lab or Radiology) has been performed and the results have been signed off by a technician or radiologist. This effectively closes the loop on a diagnostic order. | ||
| Why it matters The end-point for 'Diagnostic Services Turnaround'. Essential for analyzing bottlenecks in ancillary departments. Where to get MEDITECH LAB or ITS (Imaging and Therapeutic Services) modules. Captured from result status changes to Verified or Signed. Capture Logged when status field changes to Verified Event type explicit | |||
| Discharge Order Written | The timestamp when the physician signs the order authorizing patient discharge. This marks the start of the 'Discharge Planning' phase. | ||
| Why it matters Baselines 'Discharge Planning Lead Time'. The gap between this and actual departure represents operational inefficiency. Where to get MEDITECH OE (Order Entry). Filter Orders for Category = Discharge. Capture Logged when transaction Order Enter is executed Event type explicit | |||
| Medication Administered | Records the actual delivery of medication to the patient by nursing staff. Usually captured via barcode scanning at the bedside. | ||
| Why it matters Supports 'Medication Administration Compliance'. Identifies safety risks and workflow interruptions in nursing units. Where to get MEDITECH PHA (Pharmacy) or eMAR (Electronic Medication Administration Record). The 'AdminDateTime' in administration history. Capture Logged when transaction Med Admin is executed Event type explicit | |||
| Order Placed | Records the request for a service, medication, or diagnostic test by a clinician. This is the trigger event for downstream clinical activities. | ||
| Why it matters Baselines the 'Diagnostic Services Turnaround' KPI. Comparing this to execution time identifies delays in service delivery. Where to get MEDITECH OE (Order Entry) module. Captured from the 'OeOrders' table using the Order Date/Time field. Capture Logged when transaction Order Enter is executed Event type explicit | |||
| Patient Discharged | The administrative closure of the visit. The patient has physically left and the bed is released. | ||
| Why it matters The formal end of the process. Used to calculate final Length of Stay and define the 30-day readmission window. Where to get MEDITECH ADM (Admissions). The 'DischargeDateTime' field in the visit record. Capture Logged when transaction Discharge Patient is executed Event type explicit | |||
| Patient Registered | This event marks the administrative creation of the patient episode or visit record in the system. It captures the initial point of entry into the MEDITECH ADM (Admissions) module. | ||
| Why it matters Establishes the start of the patient journey and cycle time calculations. Essential for calculating Total Length of Stay. Where to get MEDITECH ADM module. Sourced from the 'Admissions' table, specifically the 'AdmitDateTime' or transaction log creation timestamp. Capture Logged when transaction New Visit is executed Event type explicit | |||
| Patient Transferred | Indicates the physical movement of a patient from one location (Unit/Room/Bed) to another. Tracks flow through the hospital. | ||
| Why it matters Key for 'Internal Transfer Bottlenecks'. High transfer durations indicate resource contention or portering delays. Where to get MEDITECH ADM (Admissions). Captured from the 'Location History' or 'RoomBed' transaction logs. Capture Logged when transaction Transfer Patient is executed Event type explicit | |||
| Triage Completed | Indicates the completion of the initial nursing assessment in the Emergency Department. This defines the acuity level and severity score for the patient. | ||
| Why it matters Critical for the Emergency Department Flow Analysis dashboard to measure throughput and waiting times. Where to get MEDITECH EDM (Emergency Department Management) module. Derived from status changes in the EDM tracker or timestamp of the Triage Assessment document. Capture Logged when status field changes to Triaged Event type explicit | |||
| Care Plan Initiated | Represents the creation or assignment of a specific nursing or interdisciplinary plan of care. This corresponds to the 'Treatment Plan Developed' concept. | ||
| Why it matters Measures 'Treatment Plan Development Velocity'. Delays here suggest gaps in clinical decision making. Where to get MEDITECH PCS (Patient Care System) or Care Manager. Timestamp of when a standard Plan of Care is applied to the patient. Capture Logged when transaction Care Plan Add is executed Event type explicit | |||
| Consult Request Sent | A specific type of order requesting a specialist opinion. This starts the clock on the 'Specialist Consultation Response' dashboard. | ||
| Why it matters Identifies bottlenecks in multi-disciplinary care coordination. High wait times here extend length of stay. Where to get MEDITECH OE (Order Entry). Identified by filtering 'OeOrders' for Category = Consult. Capture Logged when transaction Order Enter is executed Event type explicit | |||
| Consultation Completed | The completion of the specialist assessment. Often inferred from the filing of a specific document type (e.g., 'Cardiology Consult Note'). | ||
| Why it matters The end-point for measuring specialist responsiveness. Critical for ensuring timely care progression. Where to get MEDITECH PCM (Provider Order Management) or EMR. Inferred from document creation timestamps with specific titles. Capture Compare status field before and after Event type inferred | |||
| Follow-up Booked | The scheduling of a future appointment for the patient. This activity supports post-discharge continuity of care. | ||
| Why it matters Supports 'Follow-up Appointment Scheduling' analysis. Correlates with lower readmission rates. Where to get MEDITECH SCH (Scheduling). Inferred by linking a new Appointment record created near the discharge date to the patient ID. Capture Derive from comparing field Appointment Created Date to Discharge Date Event type inferred | |||
| Specimen Collected | Marks the physical collection of a biological sample for laboratory analysis. This activity bridges the gap between ordering and processing. | ||
| Why it matters Granular step often responsible for delays in the diagnostic lifecycle. Helpful for separating nursing delays from lab delays. Where to get MEDITECH LAB module. Usually captured when a phlebotomist scans the barcode or updates the specimen status to Collected. Capture Logged when transaction Collect Specimen is executed Event type explicit | |||
Extraction Guides
Steps
Identify the Data Repository Server: Locate the Microsoft SQL Server instance hosting your MEDITECH Data Repository (DR). This is distinct from the transactional M-AT or file-based database. You will need read-only credentials (typically a service account).
Determine the Schema Version: MEDITECH DR structures vary slightly between Magic, Client/Server (6.x), and Expanse. The query below uses standard naming conventions (e.g., AdmVisits, OeOrders). Verify these table names in your local SQL Server Management Studio (SSMS) Object Explorer.
Define the Scope: Identify the primary table for patient visits. This is usually named AdmVisits, RegAcct, or AbstractData depending on your specific DR configuration. The query uses AdmVisits as the anchor for the Patient Episode.
Prepare the SQL Environment: Open SSMS and connect to the DR. Open a new query window. Ensure you are context-switched to the correct database (often named livedb or similar).
Configure Parameters: In the provided SQL script, replace the placeholders for date ranges (e.g., '2023-01-01') and facility identifiers if your DR hosts multiple sites.
Execute the Extraction: Run the complete T-SQL script. It utilizes Common Table Expressions (CTEs) to first define the population of interest and then UNION ALL multiple data sources to create a standardized event log.
Handle NULL Attributes: The query includes logic to handle potential NULLs in timestamps (using COALESCE where appropriate) and ensures that critical joining keys (SourceID/VisitID) are present.
Verify Triage and Emergency Data: MEDITECH stores ED data in specific modules. Ensure the EdVisits or NurInterventions tables are populated if you are analyzing Emergency workflows.
Validate Order Categories: The query separates general orders, consults, and discharge orders based on Category urns or mnemonics. You may need to adjust the specific WHERE clauses to match your facility's specific Mnemonic dictionary.
Export Data: Once the results return, right-click the results grid in SSMS and select Save Results As CSV. Ensure headers are included.
Final Formatting: Open the CSV to verify date formats are ISO 8601 compliant (YYYY-MM-DD HH:MM:SS) before importing into ProcessMind.
Configuration
- Database Access: Requires db_datareader permissions on the MEDITECH DR SQL database.
- Date Range: Recommended extraction window is 3 to 6 months of discharged patients to ensure completed cycles.
- Facility Filtering: If the DR contains multi-facility data, filter the BaseVisits CTE by FacilityID or SourceSystemID.
- Episode Definition: The script uses the unique VisitID (often called Account Number or Episode Number) as the Case ID.
- Performance: The query uses a CTE anchor to limit the scan range. Ensure indexes exist on AdmitDate and DischargeDate in the AdmVisits table for optimal performance.
- Latency: Data Repository transfers can have a latency of 15 minutes to 24 hours depending on the site configuration. Confirm the LastDataUpdate timestamp.
a Sample Query sql
/* MEDITECH Data Repository T-SQL Extraction for ProcessMind */
/* Process: Patient Journey */
/* Dialect: T-SQL */
WITH BaseVisits AS (
/* Define the population: Discharged patients within a date range */
SELECT
V.VisitID,
V.PatientID,
V.AccountNumber AS MedicalRecordNumber,
V.AdmitDateTime,
V.DischargeDateTime,
V.FacilityID,
V.PatientType,
V.AttendingProviderID,
V.DischargeDisposition,
NULLIF(DATEDIFF(MINUTE, V.AdmitDateTime, V.DischargeDateTime), 0) / 1440.0 AS LengthOfStay,
/* Flag readmissions logic would go here, simplified as 0 for base script */
0 AS IsReadmission
FROM
[YourDatabaseName].[dbo].[AdmVisits] V
WHERE
V.DischargeDateTime >= '2023-01-01'
AND V.DischargeDateTime < '2023-04-01'
AND V.Status = 'DIS' /* Discharged Status */
),
PatientDiagnoses AS (
/* Helper CTE for Primary Diagnosis to avoid duplicates in joins */
SELECT
D.VisitID,
MAX(D.ICDCode) AS PrimaryDiagnosis
FROM
[YourDatabaseName].[dbo].[AbsDiagnoses] D
WHERE
D.Rank = 1 /* Primary Diagnosis Rank */
GROUP BY
D.VisitID
),
TriageData AS (
/* Helper CTE for Triage Acuity */
SELECT
T.VisitID,
MAX(T.AcuityLevel) AS TriageAcuityLevel
FROM
[YourDatabaseName].[dbo].[EdTriage] T
GROUP BY
T.VisitID
)
/* 1. Patient Registered */
SELECT
V.VisitID AS PatientEpisode,
'Patient Registered' AS ActivityName,
V.AdmitDateTime AS EventTimestamp,
'MEDITECH_ADM' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
V.FacilityID AS HospitalDepartment,
V.AttendingProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
BaseVisits V
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
V.AdmitDateTime IS NOT NULL
UNION ALL
/* 2. Triage Completed */
SELECT
V.VisitID AS PatientEpisode,
'Triage Completed' AS ActivityName,
ED.TriageDateTime AS EventTimestamp,
'MEDITECH_ED' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
'Emergency Department' AS HospitalDepartment,
ED.TriageNurseID AS AttendingProvider,
V.PatientType,
ED.AcuityLevel AS TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[EdTriage] ED
INNER JOIN BaseVisits V ON ED.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
WHERE
ED.TriageDateTime IS NOT NULL
UNION ALL
/* 3. Order Placed (General) */
SELECT
V.VisitID AS PatientEpisode,
'Order Placed' AS ActivityName,
O.OrderDateTime AS EventTimestamp,
'MEDITECH_OE' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
O.Department AS HospitalDepartment,
O.OrderingProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[OeOrders] O
INNER JOIN BaseVisits V ON O.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
O.Category NOT IN ('CONSULT', 'DISCHARGE') /* Exclude specific types handled elsewhere */
UNION ALL
/* 4. Specimen Collected */
SELECT
V.VisitID AS PatientEpisode,
'Specimen Collected' AS ActivityName,
L.CollectionDateTime AS EventTimestamp,
'MEDITECH_LAB' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
'Laboratory' AS HospitalDepartment,
L.CollectedBy AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[LabSpecimens] L
INNER JOIN BaseVisits V ON L.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
L.CollectionDateTime IS NOT NULL
UNION ALL
/* 5. Diagnostic Result Verified */
SELECT
V.VisitID AS PatientEpisode,
'Diagnostic Result Verified' AS ActivityName,
R.VerifiedDateTime AS EventTimestamp,
'MEDITECH_LAB' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
'Laboratory' AS HospitalDepartment,
R.VerifiedBy AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[LabResults] R
INNER JOIN BaseVisits V ON R.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
R.VerifiedDateTime IS NOT NULL
UNION ALL
/* 6. Diagnosis Documented */
SELECT
V.VisitID AS PatientEpisode,
'Diagnosis Documented' AS ActivityName,
DX.EntryDateTime AS EventTimestamp,
'MEDITECH_ABS' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
V.FacilityID AS HospitalDepartment,
DX.ProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[AbsDiagnoses] DX
INNER JOIN BaseVisits V ON DX.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
DX.EntryDateTime IS NOT NULL
UNION ALL
/* 7. Care Plan Initiated */
SELECT
V.VisitID AS PatientEpisode,
'Care Plan Initiated' AS ActivityName,
N.CreateDateTime AS EventTimestamp,
'MEDITECH_NUR' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
N.NurseUnit AS HospitalDepartment,
N.NurseID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[NurPlan] N
INNER JOIN BaseVisits V ON N.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
N.CreateDateTime IS NOT NULL
UNION ALL
/* 8. Medication Administered */
SELECT
V.VisitID AS PatientEpisode,
'Medication Administered' AS ActivityName,
M.AdminDateTime AS EventTimestamp,
'MEDITECH_PHA' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
M.AdminLocation AS HospitalDepartment,
M.AdministeredBy AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[PhaMedAdmin] M
INNER JOIN BaseVisits V ON M.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
M.Status = 'ADMINISTERED'
UNION ALL
/* 9. Consult Request Sent */
SELECT
V.VisitID AS PatientEpisode,
'Consult Request Sent' AS ActivityName,
O.OrderDateTime AS EventTimestamp,
'MEDITECH_OE' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
O.Department AS HospitalDepartment,
O.OrderingProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[OeOrders] O
INNER JOIN BaseVisits V ON O.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
O.Category = 'CONSULT'
UNION ALL
/* 10. Consultation Completed */
SELECT
V.VisitID AS PatientEpisode,
'Consultation Completed' AS ActivityName,
O.CompletedDateTime AS EventTimestamp,
'MEDITECH_OE' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
O.Department AS HospitalDepartment,
O.OrderingProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[OeOrders] O
INNER JOIN BaseVisits V ON O.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
O.Category = 'CONSULT'
AND O.Status = 'COMPLETED'
AND O.CompletedDateTime IS NOT NULL
UNION ALL
/* 11. Patient Transferred */
SELECT
V.VisitID AS PatientEpisode,
'Patient Transferred' AS ActivityName,
TX.TransferDateTime AS EventTimestamp,
'MEDITECH_ADM' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
TX.ToLocation AS HospitalDepartment,
NULL AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[AdmRoomTx] TX
INNER JOIN BaseVisits V ON TX.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
TX.TransferDateTime IS NOT NULL
UNION ALL
/* 12. Discharge Order Written */
SELECT
V.VisitID AS PatientEpisode,
'Discharge Order Written' AS ActivityName,
O.OrderDateTime AS EventTimestamp,
'MEDITECH_OE' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
O.Department AS HospitalDepartment,
O.OrderingProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[OeOrders] O
INNER JOIN BaseVisits V ON O.VisitID = V.VisitID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
O.Category = 'DISCHARGE'
OR O.Mnemonic LIKE '%DISCHARGE%'
UNION ALL
/* 13. Patient Discharged */
SELECT
V.VisitID AS PatientEpisode,
'Patient Discharged' AS ActivityName,
V.DischargeDateTime AS EventTimestamp,
'MEDITECH_ADM' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
V.FacilityID AS HospitalDepartment,
V.AttendingProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
BaseVisits V
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
V.DischargeDateTime IS NOT NULL
UNION ALL
/* 14. Follow-up Booked */
SELECT
V.VisitID AS PatientEpisode,
'Follow-up Booked' AS ActivityName,
S.BookDateTime AS EventTimestamp,
'MEDITECH_SCH' AS SourceSystem,
GETDATE() AS LastDataUpdate,
V.MedicalRecordNumber,
S.ApptDepartment AS HospitalDepartment,
S.ProviderID AS AttendingProvider,
V.PatientType,
T.TriageAcuityLevel,
D.PrimaryDiagnosis,
V.DischargeDisposition,
V.LengthOfStay,
V.IsReadmission
FROM
[YourDatabaseName].[dbo].[SchAppt] S
INNER JOIN BaseVisits V ON S.PatientID = V.PatientID
LEFT JOIN PatientDiagnoses D ON V.VisitID = D.VisitID
LEFT JOIN TriageData T ON V.VisitID = T.VisitID
WHERE
S.BookDateTime > V.AdmitDateTime
AND S.BookDateTime <= DATEADD(day, 30, V.DischargeDateTime) /* Logic to link appt to episode */
AND S.Status NOT IN ('CANCELLED', 'NOSHOW');