using System; using System.Collections.Generic; using System.Text; namespace IndianHealthService.BMXNet { /// /// Access to local services are access through this interface. /// public interface LocalEventService { /// /// Subscribe to the local event named anEventName. /// /// /// To receive published events, handle the ApplicationEvent. If you explicity subscript /// to the "REFRESH" event then both RefreshRequested and ApplicationEvent will be triggers. /// /// The name of the event. This name should be shared and wellknown between many components. void Subscribe(String anEventName); /// /// Checks to see there are any subscriptions for this event. /// /// /// If publishing an event, there is no need to first check if there are subscribers unless there is a /// performance hit for the application to Trigger the event. /// /// The name of the event checking to see if it's been subscribed already. /// bool HasSubscribers(String anEventName); /// /// Unscribe scribes from the event. It is not mandatory to unsubscribe from this event at the end of /// your object's lifecycle but you should either subsubscribe or remote the event handler. /// /// The name of the event unsubscribing from. /// void Unsubscribe(String anEventName); /// /// This commonly broadcasted event is request to refresh content. /// /// /// In the EHR, this is equivalent to the "REFRESH" event. The WinFramework also uses "REFRESH" as the /// event name for triggering a refresh request. /// /// /// The following code from Well Child Module's Growth Chart shows registering for the Refresh event /// at startup: /// /// public void Startup() /// { /// this.LocalSession.EventServices.RefreshRequested += new EventHandler(Session_RefreshRequested); /// } /// /// void Session_RefreshRequested(object sender, EventArgs e) /// { /// this.RefreshAll(); /// } /// /// /// event EventHandler RefreshRequested; /// /// Local event subscribers will have this event triggered. /// /// /// The "REFRESH" event is filtered out and is triggered using the RefreshRequested event /// /// /// The Well Child Module growth chart displays Height and Weight. When the EHR vitals component adds /// new Heights and Weights it publishes a LocalEvent with an EventType PCC*MSR. If the growth chart detects /// the Vitals update event it then refreshes the growth chart: /// /// public void Startup() /// { /// this.LocalSession.EventServices.ApplicationEvent+= new EventHandler<LocalEventArgs>(Session_ApplicationEvent); /// } /// /// /// void Session_ApplicationEvent(object sender, LocalEventArgs e) /// { /// if (this.IsVitalsUpdatedEvent(e)) /// { /// this.RefreshAll(); /// } /// } /// /// protected bool IsVitalsUpdatedEvent(LocalEventArgs anEvent) /// { /// return anEvent.EventType.StartsWith("PCC") && anEvent.EventType.EndsWith("MSR"); /// } /// /// event EventHandler ApplicationEvent; /// /// To publish an event call TriggerEvent with the event name and optional details. There is no /// restriction on what local events that can be triggered. A "REFRESH" event can be broadcast as /// well as any other application specific or well-known loal event. /// /// The event name. This is normally a well-known event that multiple components used for event-driven communications. /// An arbitrary string containing event specific data void TriggerEvent(String anEventName, String someDetails); } }