Skip to content

How To: Implement Modeling, from Patient model to Device simulation

Ibi Keller edited this page Sep 29, 2021 · 1 revision

To create new types of tracings/waveforms on the Patient model:

II.Patient (Classes/Patient.cs)

  • Timer: need to define a Timer to trigger the modeling w/ event .Tick
    • Utilize a Baseline timer (for isoelectric lines) and an Additional timer for unique events
      • e.g. Atrial or Ventricular contractions
    • Add the Timer to:
      • Dispose()
      • ProcessTimers()
      • InitTimers(): attach a function as a delegate to run every time Timer.Tick is triggered
      • SetTimers()
      • StopTimers()
  • PatientEventTypes: Add a corresponding event type to enum PatientEventTypes
  • Function (e.g. OnCardiac_Atrial()): Add a function that the Timer.Tick event is attached to in InitTimers()
    • Triggers PatientEvent event (with args including enum PatientEventType)
      • This is where all simulated clinical devices will subscribe to and be triggered from
    • Logic here adjusts the Timer's interval and/or resets the Timer to replicate clinical realism
      • May implement additional timers or counters to adjust for aberrancy and variance

II_Avalonia.PatientEditor (Windows/PatientEditor.cs)

  • Is the parent Window for all clinical Devices
    • When creating and spawning the Device Window, subscribes a Device function to Patient.PatientEvent
      • e.g. App.Patient.PatientEvent += App.Device_ECG.OnPatientEvent;
      • This creates the connection between the Patient model to the simulated Device

II_Avalonia.Device (Windows/Device, e.g. DeviceECG)

  • Function OnPatientEvent() will be triggered every time a PatientEvent occurs
    • Need to switch (e.EventType) and only process logic on desired PatientEventTypes
    • Cycles through all Numerics and Tracings and calls appropriate functions to model event response
      • Direct updates to UI will need to be called via Dispatcher to ensure thread safety
      • This is where Tracings.Strip will be called to update tracings based on clinical events

II.Rhythm.Strip (Classes/Rhythm.Strip.cs)

  • Individual functions here will modify tracing strips to replicate clinical realism
    • Can call Concatenate(), Replace(), Underwrite() to draw directly to tracing Strip
    • Can call static drawing functions in II.Rhythms (Rhythms.cs) to process drawing logic for many similar rhythms
      • e.g. II.Cardiac_Rhythms differentiates all the cardiac rhythms and draws appropriate clinical simulation
    • Can call II.Waveform.Draw (Waveform.Draw.cs) static functions() to plot pre-made waves onto Strip
      • e.g. for waveforms that are generally uniform and waveform shape not specifically dependent on rhythms
        • e.g. SpO2, IABP, ABP, pacemaker spikes, defibrillation