Module

uCore

Path

C:\CPRS\CPRS30\uCore.pas

Last Modified

7/15/2014 3:26:44 PM

Comments

The core objects- patient, user, and encounter are defined here.  All other clinical objects
  in the GUI assume that these core objects exist.

Initialization Code

initialization
  uVistaMsg := 0;
  LoadURLMon;

Finalization Code

finalization
  ReleaseURLMon;
  ReleaseAppNotification;

end.

Units Used in Interface

Name Comments
rCore -
uCombatVet -
uConst -

Units Used in Implementation

Name Comments
rConsults -
rOrders -
rTIU -
uOrders -

Classes

Name Comments
TChangeItem -
TChanges -
TEncounter -
TNotifications -
TNotifyAppsThread -
TNotifyItem -
TPatient -
TRemoteReport -
TRemoteReportList -
TRemoteSite -
TRemoteSiteList -
TUser -

Procedures

Name Owner Declaration Scope Comments
Add TChanges procedure Add(ItemType: Integer; const AnID, ItemText, GroupName: string; SignState: Integer; AParentID: string = ''; User: int64 = 0; OrderDG: String = ''; DCOrder: Boolean = False; Delay: Boolean = False; ProblemAdded: Boolean = False); Public -
Add TNotifications procedure Add(const ADFN: string; AFollowUp: Integer; const ARecordID: string; AHighLightSection : string = ''); Public
DFN*  CB
DFN*
Add TRemoteReportList procedure Add(AReportList, AHandle: string); Public -
Add TRemoteSiteList procedure Add(ASite: string); Public -
AddUnsignedToChanges TChanges procedure AddUnsignedToChanges; Private Retrieves unsigned orders outside this session based on OR UNSIGNED ORDERS ON EXIT
ChangeOrderGrp TChanges procedure ChangeOrderGrp(const oldGrpName,newGrpName: string); Public -
ChangePatient TRemoteSiteList procedure ChangePatient(const DFN: string); Public -
Clear TChanges procedure Clear; Public -
Clear TEncounter procedure Clear; Public Clears all the fields of an Encounter (usually done upon patient selection
Clear TNotifications procedure Clear; Public -
Clear TPatient procedure Clear; Public
TPatient methods ------------------------------------------------------------------------- 

 clears all fields in the Patient object
Clear TRemoteReportList procedure Clear; Public -
Clear TRemoteSiteList procedure Clear; Public -
CreateSaved TEncounter procedure CreateSaved(Reason: string); Public -
Delete TNotifications procedure Delete; Public -
DeleteForCurrentUser TNotifications procedure DeleteForCurrentUser; Public -
EmptySaved TEncounter procedure EmptySaved(); procedure CreateSaved(Reason: string); function GetICDVersion: String; function NeedVisit: Boolean; property DateTime: TFMDateTime read FDateTime write SetDateTime; property Inpatient: Boolean read FInpatient write SetInpatient; property Location: Integer read FLocation write SetLocation; property LocationName: string read GetLocationName write FLocationName; property LocationText: string read GetLocationText write FLocationText; property Provider: Int64 read FProvider write SetProvider; property ProviderName: string read GetProviderName; property StandAlone: Boolean read FStandAlone write SetStandAlone; property VisitCategory: Char read GetVisitCategory write SetVisitCategory; property VisitStr: string read GetVisitStr; property Notifier: IORNotifier read FNotifier implements IORNotifier; property ICD10ImplDate: TFMDateTime read FICD10ImplDate; end; TChangeItem = class private FItemType: Integer; FID: String; FText: String; FGroupName: String; FSignState: Integer; FParentID: String; FUser: Int64; FOrderDG: String; FDCOrder: Boolean; FDelay: Boolean; constructor Create(AnItemType: Integer; const AnID, AText, AGroupName: string; ASignState: Integer; AParentID: string = ''; User: int64 = 0; OrderDG: string = ''; DCOrder: Boolean = False; Delay: Boolean = False); public property ItemType: Integer read FItemType; property ID: string read FID; property Text: string read FText; property GroupName: string read FGroupName; property SignState: Integer read FSignState write FSignState; property ParentID : string read FParentID; property User: Int64 read FUser write FUser; property OrderDG: string read FOrderDG write FOrderDG; property DCOrder: boolean read FDCOrder write FDCOrder; property Delay: boolean read FDelay write FDelay; function CSValue(): Boolean; end; TORRemoveChangesEvent = procedure(Sender: TObject; ChangeItem: TChangeItem) of object; {**RV**} TChanges = class private FCount: Integer; FDocuments: TList; fOrders: TList; FOrderGrp: TStringList; FPCE: TList; FPCEGrp: TStringList; FOnRemove: TORRemoveChangesEvent; {**RV**} FRefreshCoverPL: Boolean; FRefreshProblemList: Boolean; private procedure AddUnsignedToChanges; public constructor Create; destructor Destroy; override; procedure Add(ItemType: Integer; const AnID, ItemText, GroupName: string; SignState: Integer; AParentID: string = ''; User: int64 = 0; OrderDG: String = ''; DCOrder: Boolean = False; Delay: Boolean = False; ProblemAdded: Boolean = False); procedure Clear; function CanSign: Boolean; function Exist(ItemType: Integer; const AnID: string): Boolean; function ExistForOrder(const AnID: string): Boolean; function Locate(ItemType: Integer; const AnID: string): TChangeItem; procedure Remove(ItemType: Integer; const AnID: string); procedure ReplaceID(ItemType: Integer; const OldID, NewID: string); procedure ReplaceSignState(ItemType: Integer; const AnID: string; NewState: Integer); procedure ReplaceText(ItemType: Integer; const AnID, NewText: string); procedure ReplaceODGrpName(const AnODID, NewGrp: string); procedure ChangeOrderGrp(const oldGrpName,newGrpName: string); function RequireReview: Boolean; property Count: Integer read FCount; property Documents: TList read FDocuments; property OnRemove: TORRemoveChangesEvent read FOnRemove write FOnRemove; {**RV**} property Orders: TList read fOrders; property PCE: TList read FPCE; property OrderGrp: TStringList read FOrderGrp; property PCEGrp: TStringList read FPCEGrp; property RefreshCoverPL: Boolean read FRefreshCoverPL write FRefreshCoverPL; property RefreshProblemList: Boolean read FRefreshProblemList write FRefreshProblemList; end; TNotifyItem = class private DFN: string; FollowUp: Integer; Public
AlertData: string;
hds7591  Clinic/Ward movement.
AccessStatus: integer;
 put text in the global atom table
 broadcast 'VistA Domain Event - Clinical' to all main windows
SendMessage(HWND_BROADCAST, uVistaDomMsg, WPARAM(Application.MainForm.Handle), LPARAM(AnAtom));

Changed to SendMessageTimeout to prevent hang when other app unresponsive  (RV)
 researched
 after all windows have processed the message, remove the text from the table
 researched
 researched
 researched
 register the message with windows to get a unique message number (if not already registered)
 first send the domain version of the message
 for backward compatibility, send the message without the domain
 TUser methods ---------------------------------------------------------------------------- 
 create the User object for the currently logged in user 
 returns true if the current user has the given security key 
 TPatient methods ------------------------------------------------------------------------- 
 clears all fields in the Patient object 
 selects a patient and sets up the Patient object for the patient 
 TEncounter -------------------------------------------------------------------------------
EncounterSwitch TEncounter procedure EncounterSwitch(Loc: integer; LocName, LocText: string; DT: TFMDateTime; vCat: Char); Public -
Execute TNotifyAppsThread procedure Execute; override; Public -
FlushNotifierBuffer - procedure FlushNotifierBuffer; Interfaced -
GotoWebPage - procedure GotoWebPage(const URL: WideString); Interfaced -
LabClear TRemoteSite procedure LabClear; Public -
LoadURLMon - procedure LoadURLMon; Global -
Next TNotifications procedure Next; Public -
NotifyOtherApps - procedure NotifyOtherApps(const AppEvent, AppData: string); Interfaced -
Prior TNotifications procedure Prior; Public -
ProcessQueue - procedure ProcessQueue(ShortTimout: boolean); Global -
ReleaseAppNotification - procedure ReleaseAppNotification; Global -
ReleaseURLMon - procedure ReleaseURLMon; Global -
Remove TChanges procedure Remove(ItemType: Integer; const AnID: string); Public
Remove a change item from the appropriate list of changes (depending on type)
  this doesn't check groupnames, may leave a groupname without any associated items
ReplaceID TChanges procedure ReplaceID(ItemType: Integer; const OldID, NewID: string); Public -
ReplaceODGrpName TChanges procedure ReplaceODGrpName(const AnODID, NewGrp: string); Public -
ReplaceSignState TChanges procedure ReplaceSignState(ItemType: Integer; const AnID: string; NewState: Integer); Public -
ReplaceText TChanges procedure ReplaceText(ItemType: Integer; const AnID, NewText: string); Public -
ReportClear TRemoteSite procedure ReportClear; Public -
ResumeAndTerminate TNotifyAppsThread procedure ResumeAndTerminate; Public -
ResumeIfIdle TNotifyAppsThread procedure ResumeIfIdle; Public -
SetCurrentPrinter TUser procedure SetCurrentPrinter(Value: string); Public -
SetDateTime TEncounter procedure SetDateTime(Value: TFMDateTime); Private Sets the date/time for the encounter - causes the visit to be reset
SetDFN TPatient procedure SetDFN(const Value: string); Private
DFN*
 selects a patient and sets up the Patient object for the patient
SetIndOrderDisplay TNotifications procedure SetIndOrderDisplay(Value: Boolean); Private -
SetInpatient TEncounter procedure SetInpatient(Value: Boolean); Private Sets the inpatient flag for the encounter - causes the visit to be reset
SetLocation TEncounter procedure SetLocation(Value: Integer); Private Sets the location for the encounter - causes the visit to be reset
SetProvider TEncounter procedure SetProvider(Value: Int64); Private Sets the provider for the encounter - causes the visit to be reset
SetSelected TRemoteSite procedure SetSelected(Value: Boolean); Private -
SetStandAlone TEncounter procedure SetStandAlone(Value: Boolean); Private StandAlone should be true if this encounter isn't related to an appointment
SetVisitCategory TEncounter procedure SetVisitCategory(Value: Char); Private Sets the visit type for this encounter - causes to visit to be reset
SwitchToSaved TEncounter procedure SwitchToSaved(ShowInfoBox: boolean); Public -
TerminateOtherAppNotification - procedure TerminateOtherAppNotification; Interfaced -
UpdateText TEncounter procedure UpdateText; Private Retrieve external values for provider name, hospital location

Functions

Name Owner Declaration Scope Comments
AllowAccessToSensitivePatient - function AllowAccessToSensitivePatient(NewDFN: string; var AccessStatus: integer): boolean; Interfaced AccessStatus: integer;
AppNotificationEnabled - function AppNotificationEnabled: boolean; Global -
CanSign TChanges function CanSign: Boolean; Public Returns true if any items in the changes list can be signed by the user
CSValue TChangeItem function CSValue(): Boolean; end; TORRemoveChangesEvent = procedure(Sender: TObject; ChangeItem: TChangeItem) of object; {**RV**} TChanges = class private FCount: Integer; FDocuments: TList; fOrders: TList; FOrderGrp: TStringList; FPCE: TList; FPCEGrp: TStringList; FOnRemove: TORRemoveChangesEvent; {**RV**} FRefreshCoverPL: Boolean; FRefreshProblemList: Boolean; private procedure AddUnsignedToChanges; public constructor Create; destructor Destroy; override; procedure Add(ItemType: Integer; const AnID, ItemText, GroupName: string; SignState: Integer; AParentID: string = ''; User: int64 = 0; OrderDG: String = ''; DCOrder: Boolean = False; Delay: Boolean = False; ProblemAdded: Boolean = False); procedure Clear; function CanSign: Boolean; function Exist(ItemType: Integer; const AnID: string): Boolean; function ExistForOrder(const AnID: string): Boolean; function Locate(ItemType: Integer; const AnID: string): TChangeItem; procedure Remove(ItemType: Integer; const AnID: string); procedure ReplaceID(ItemType: Integer; const OldID, NewID: string); procedure ReplaceSignState(ItemType: Integer; const AnID: string; NewState: Integer); procedure ReplaceText(ItemType: Integer; const AnID, NewText: string); procedure ReplaceODGrpName(const AnODID, NewGrp: string); procedure ChangeOrderGrp(const oldGrpName,newGrpName: string); function RequireReview: Boolean; property Count: Integer read FCount; property Documents: TList read FDocuments; property OnRemove: TORRemoveChangesEvent read FOnRemove write FOnRemove; {**RV**} property Orders: TList read fOrders; property PCE: TList read FPCE; property OrderGrp: TStringList read FOrderGrp; property PCEGrp: TStringList read FPCEGrp; property RefreshCoverPL: Boolean read FRefreshCoverPL write FRefreshCoverPL; property RefreshProblemList: Boolean read FRefreshProblemList write FRefreshProblemList; end; TNotifyItem = class private DFN: string; FollowUp: Integer; Public
AlertData: string;
hds7591  Clinic/Ward movement.
AccessStatus: integer;
 put text in the global atom table
 broadcast 'VistA Domain Event - Clinical' to all main windows
SendMessage(HWND_BROADCAST, uVistaDomMsg, WPARAM(Application.MainForm.Handle), LPARAM(AnAtom));

Changed to SendMessageTimeout to prevent hang when other app unresponsive  (RV)
 researched
 after all windows have processed the message, remove the text from the table
 researched
 researched
 researched
 register the message with windows to get a unique message number (if not already registered)
 first send the domain version of the message
 for backward compatibility, send the message without the domain
 TUser methods ---------------------------------------------------------------------------- 
 create the User object for the currently logged in user 
 returns true if the current user has the given security key 
 TPatient methods ------------------------------------------------------------------------- 
 clears all fields in the Patient object 
 selects a patient and sets up the Patient object for the patient 
 TEncounter ------------------------------------------------------------------------------- 
 clears all the fields of an Encounter (usually done upon patient selection 
 returns abbreviated hospital location + room/bed (or date/time for appt) 
 returns external text value for hospital location 
 returns external text value for provider name 
 use VisitCategory property to insure non-null character
 if no Enc Dt or Historical, Hospitalization, or Daily Visit compare I-10 Impl dt with TODAY
 returns true if required fields for visit creation are present 
 added "<" to FDateTime check to trap "-1" visit dates - v23.12 (RV)
 sets the date/time for the encounter - causes the visit to be reset 
 sets the inpatient flag for the encounter - causes the visit to be reset 
 sets the location for the encounter - causes the visit to be reset 
 sets the provider for the encounter - causes the visit to be reset 
 StandAlone should be true if this encounter isn't related to an appointment 
 sets the visit type for this encounter - causes to visit to be reset 
 retrieve external values for provider name, hospital location 
 this references the Patient object which is assumed to be created 
 TChangeItem ------------------------------------------------------------------------------
Exist TChanges function Exist(ItemType: Integer; const AnID: string): Boolean; Public -
ExistForOrder TChanges function ExistForOrder(const AnID: string): Boolean; Public Returns TRUE if any item in the list of orders has matching order number (ignores action)
GetAlertData TNotifications function GetAlertData: string; Private -
GetCombatVet TPatient function GetCombatVet: TCombatVet; Private *DFN*
GetDateDied TPatient function GetDateDied: TFMDateTime; Private -
GetDFN TNotifications function GetDFN: string; Private
DFN*
DFN*
GetFollowUp TNotifications function GetFollowUp: Integer; Private -
GetHighLightSection TNotifications function GetHighLightSection: String; Private
CB
CB
GetICDVersion TEncounter function GetICDVersion: String; Public -
GetIndOrderDisplay TNotifications function GetIndOrderDisplay: Boolean; Private -
GetLocationName TEncounter function GetLocationName: string; Private Returns external text value for hospital location
GetLocationText TEncounter function GetLocationText: string; Private Returns abbreviated hospital location + room/bed (or date/time for appt)
GetProviderName TEncounter function GetProviderName: string; Private Returns external text value for provider name
GetRecordID TNotifications function GetRecordID: string; Private -
GetText TNotifications function GetText: string; Private -
GetVisitCategory TEncounter function GetVisitCategory: Char; Private -
GetVisitStr TEncounter function GetVisitStr: string; Private -
HasKey TUser function HasKey(const KeyName: string): Boolean; Public Returns true if the current user has the given security key
Locate TChanges function Locate(ItemType: Integer; const AnID: string): TChangeItem; Public -
NeedVisit TEncounter function NeedVisit: Boolean; Public Returns true if required fields for visit creation are present
QueuePending - function QueuePending: boolean; Global -
RequireReview TChanges function RequireReview: Boolean; Public Returns true if documents can be signed or if any orders exist in Changes
subtractMinutesFromDateTime - function subtractMinutesFromDateTime(Time1 : TDateTime;Minutes : extended) : TDateTime; Interfaced -

Global Variables

Name Type Declaration Comments
AnAtom Simple (unknown) AnAtom: ATOM = 0; -
Changes TChanges Changes: TChanges; -
Encounter TEncounter Encounter: TEncounter = nil; -
FlagList TStringList FlagList: TStringList; -
HasFlag Boolean HasFlag: boolean; -
HlinkNav HlinkNav: HlinkNavProc; -
Notifications TNotifications Notifications: TNotifications; -
Patient TPatient Patient: TPatient; -
RemoteReports TRemoteReportList RemoteReports: TRemoteReportList; -
RemoteSites TRemoteSiteList RemoteSites: TRemoteSiteList; -
SavedEncounter TEncounter SavedEncounter: TEncounter = nil; -
SavedEncounterDateTime TFMDateTime SavedEncounterDateTime: TFMDateTime; -
SavedEncounterLoc Integer SavedEncounterLoc: Integer; Used to Save Encounter Location when doing clinic meds/ivs
SavedEncounterLocName UnicodeString SavedEncounterLocName: string; -
SavedEncounterReason UnicodeString SavedEncounterReason: string; Used to store why it will be reverted to the saved value
SavedEncounterText UnicodeString SavedEncounterText: string; -
SavedEncounterVisitCat Char SavedEncounterVisitCat: Char; -
TempEncounterDateTime TFMDateTime TempEncounterDateTime: TFMDateTime; -
TempEncounterLoc Integer TempEncounterLoc: Integer;
Hds7591  Clinic/Ward movement.

 used to Save Encounter Location when user selected "Review Sign Changes" from "File"
TempEncounterLocName UnicodeString TempEncounterLocName: string; Since in the path PatientRefresh is done prior to checking if patient has been admitted while entering OPT orders.
TempEncounterText UnicodeString TempEncounterText: string; -
TempEncounterVistCat Char TempEncounterVistCat: Char; -
uNotifyAppsActive Boolean uNotifyAppsActive: boolean = TRUE; -
uNotifyAppsQueue TStringList uNotifyAppsQueue: TStringList = nil; -
uNotifyAppsThread TNotifyAppsThread uNotifyAppsThread: TNotifyAppsThread = nil; -
URLMonHandle THandle URLMonHandle: THandle = 0; -
User TUser User: TUser; -
uSynchronizer Simple (unknown) uSynchronizer: TMultiReadExclusiveWriteSynchronizer = nil; -
uVistaDomMsg Simple (unknown) uVistaMsg, uVistaDomMsg: UINT; -
uVistaMsg Simple (unknown) uVistaMsg, uVistaDomMsg: UINT; -

Constants

Name Declaration Scope Comments
LONG_BROADCAST_TIMEOUT 30000 Global 30 seconds
MSG_TYPE array[TMsgType] of String = ('V','D') Global -
mtVistaDomainMessage TMsgType Global -
mtVistaMessage TMsgType Global -
SHORT_BROADCAST_TIMEOUT 2000 Global 2 seconds


Module Source

1     unit uCore;
2     { The core objects- patient, user, and encounter are defined here.  All other clinical objects
3       in the GUI assume that these core objects exist. }
4     
5     {$OPTIMIZATION OFF}                              // REMOVE AFTER UNIT IS DEBUGGED
6     
7     interface
8     
9     uses SysUtils, Windows, Classes, Forms, ORFn, rCore, uConst, ORClasses, uCombatVet;
10    
11    type
12      TUser = class(TObject)
13      private
14        FDUZ:             Int64;                      // User DUZ (IEN in New Person file)
15        FName:            string;                     // User Name (mixed case)
16        FUserClass:       Integer;                    // User Class (based on OR keys for now)
17        FCanSignOrders:   Boolean;                    // Has ORES key
18        FIsProvider:      Boolean;                    // Has VA Provider key
19        FOrderRole:       Integer;
20        FNoOrdering:      Boolean;
21        FEnableVerify:    Boolean;
22        FDTIME:           Integer;
23        FCountDown:       Integer;
24        FCurrentPrinter:  string;
25        FNotifyAppsWM:    Boolean;
26        FDomain:          string;
27        FPtMsgHang:       Integer;
28        FService:         Integer;
29        FAutoSave:        Integer;
30        FInitialTab:      Integer;
31        FUseLastTab:      Boolean;
32        FWebAccess:       Boolean;
33        FIsRPL:           string;
34        FRPLList:         string;
35        FHasCorTabs:      Boolean;
36        FHasRptTab:       Boolean;
37        FIsReportsOnly:   Boolean;
38        FToolsRptEdit:    Boolean;
39        FDisableHold:     Boolean;
40        FGECStatus:       Boolean;
41        FStationNumber:   string;
42        FIsProductionAccount: boolean;
43      public
44        constructor Create;
45        function HasKey(const KeyName: string): Boolean;
46        procedure SetCurrentPrinter(Value: string);
47        property DUZ:             Int64   read FDUZ;
48        property Name:            string  read FName;
49        property UserClass:       Integer read FUserClass;
50        property CanSignOrders:   Boolean read FCanSignOrders;
51        property IsProvider:      Boolean read FIsProvider;
52        property OrderRole:       Integer read FOrderRole;
53        property NoOrdering:      Boolean read FNoOrdering;
54        property EnableVerify:    Boolean read FEnableVerify;
55        property DTIME:           Integer read FDTIME;
56        property CountDown:       Integer read FCountDown;
57        property PtMsgHang:       Integer read FPtMsgHang;
58        property Service:         Integer read FService;
59        property AutoSave:        Integer read FAutoSave;
60        property InitialTab:      Integer read FInitialTab;
61        property UseLastTab:      Boolean read FUseLastTab;
62        property WebAccess:       Boolean read FWebAccess;
63        property DisableHold:     Boolean read FDisableHold;
64        property IsRPL:           string  read FIsRPL;
65        property RPLList:         string  read FRPLList;
66        property HasCorTabs:      Boolean read FHasCorTabs;
67        property HasRptTab:       Boolean read FHasRptTab;
68        property IsReportsOnly:   Boolean read FIsReportsOnly;
69        property ToolsRptEdit:    Boolean read FToolsRptEdit;
70        property CurrentPrinter:  string  read FCurrentPrinter write SetCurrentPrinter;
71        property GECStatus:       Boolean read FGECStatus;
72        property StationNumber:   string  read FStationNumber;
73        property IsProductionAccount: boolean read FIsProductionAccount;
74      end;
75    
76      TPatient = class(TObject)
77      private
78        FDFN:        string;                         // Internal Entry Number in Patient file  //*DFN*
79        FICN:        string;                         // Integration Control Number from MPI
80        FName:       string;                         // Patient Name (mixed case)
81        FSSN:        string;                         // Patient Identifier (generally SSN)
82        FDOB:        TFMDateTime;                    // Date of Birth in Fileman format
83        FAge:        Integer;                        // Patient Age
84        FSex:        Char;                           // Male, Female, Unknown
85        FCWAD:       string;                         // chars identify if pt has CWAD warnings
86        FRestricted: Boolean;                        // True if this is a restricted record
87        FInpatient:  Boolean;                        // True if that patient is an inpatient
88        FStatus:     string;                         // Patient status indicator (Inpatient or Outpatient)
89        FLocation:   Integer;                        // IEN in Hosp Loc if inpatient
90        FWardService: string;
91        FSpecialty:  Integer;                        // IEN of the treating specialty if inpatient
92        FSpecialtySvc: string;                       // treating specialty service if inpatient                                                                               
93        FAdmitTime:  TFMDateTime;                    // Admit date/time if inpatient
94        FSrvConn:    Boolean;                        // True if patient is service connected
95        FSCPercent:  Integer;                        // Per Cent Service Connection
96        FPrimTeam:   string;                         // name of primary care team
97        FPrimProv:   string;                         // name of primary care provider
98        FAttending:  string;                         // if inpatient, name of attending
99        FAssociate:  string;                         // if inpatient, name of associate
100       FInProvider:  string;                        // if inpatient, name of inpatient provider
101       FMHTC:       string;                         // name of Mental Health Treatment Coordinator
102       FDateDied: TFMDateTime;                      // Date of Patient Death (<=0 or still alive)
103       FDateDiedLoaded: boolean;                    // Used to determine of DateDied has been loaded
104       fCombatVet : TCombatVet;                     // Object Holding CombatVet Data
105       procedure SetDFN(const Value: string);
106       function GetDateDied: TFMDateTime;
107       function GetCombatVet: TCombatVet;       // *DFN*
108     public
109       procedure Clear;
110       destructor Destroy; override;
111       property DFN:              string      read FDFN write SetDFN;  //*DFN*
112       property ICN:              string      read FICN;
113       property Name:             string      read FName;
114       property SSN:              string      read FSSN;
115       property DOB:              TFMDateTime read FDOB;
116       property Age:              Integer     read FAge;
117       property Sex:              Char        read FSex;
118       property CWAD:             string      read FCWAD;
119       property Inpatient:        Boolean     read FInpatient;
120       property Status:           string      read FStatus;
121       property Location:         Integer     read FLocation;
122       property WardService:      string      read FWardService;
123       property Specialty:        Integer     read FSpecialty;
124       property SpecialtySvc:     string      read FSpecialtySvc;
125       property AdmitTime:        TFMDateTime read FAdmitTime;
126       property DateDied:         TFMDateTime read GetDateDied;
127       property ServiceConnected: Boolean     read FSrvConn;
128       property SCPercent:        Integer     read FSCPercent;
129       property PrimaryTeam:      string      read FPrimTeam;
130       property PrimaryProvider:  string      read FPrimProv;
131       property Attending:        string      read FAttending;
132       property Associate:        string      read FAssociate;
133       property InProvider:        string     read FInProvider;
134       property MHTC:             string      read FMHTC;
135       property CombatVet:        TCombatVet  read GetCombatVet;
136     end;
137   
138     TEncounter = class(TObject, IORNotifier)
139     private
140       FChanged:       Boolean;                     // one or more visit fields have changed
141       FDateTime:      TFMDateTime;                 // date/time of encounter (appt, admission)
142       FInpatient:     Boolean;                     // true if this is an inpatient encounter
143       FLocation:      Integer;                     // IEN in Hospital Location file
144       FLocationName:  string;                      // Name in Hospital Location file
145       FLocationText:  string;                      // Name + Date/Time or Name + RoomBed
146       FProvider:      Int64  ;                     // IEN in New Person file
147       FProviderName:  string;                      // Name in New Person file
148       FVisitCategory: Char;                        // A=ambulatory,T=Telephone,H=inpt,E=historic
149       FStandAlone:    Boolean;                     // true if visit not related to appointment
150       FNotifier:      IORNotifier;                 // Event handlers for location changes
151       FICD10ImplDate:  TFMDateTime;                 // ICD-10-CM Activation Date
152       function GetLocationName: string;
153       function GetLocationText: string;
154       function GetProviderName: string;
155       function GetVisitCategory: Char;
156       function GetVisitStr: string;
157       procedure SetDateTime(Value: TFMDateTime);
158       procedure SetInpatient(Value: Boolean);
159       procedure SetLocation(Value: Integer);
160       procedure SetProvider(Value: Int64);
161       procedure SetStandAlone(Value: Boolean);
162       procedure SetVisitCategory(Value: Char);
163       procedure UpdateText;
164     public
165       constructor Create;
166       destructor Destroy; override;
167       procedure Clear;
168       procedure EncounterSwitch(Loc: integer; LocName, LocText: string; DT: TFMDateTime; vCat: Char);
169       procedure SwitchToSaved(ShowInfoBox: boolean);
170       procedure EmptySaved();
171       procedure CreateSaved(Reason: string);
172       function GetICDVersion: String;
173       function NeedVisit: Boolean;
174       property DateTime:        TFMDateTime read FDateTime  write SetDateTime;
175       property Inpatient:       Boolean     read FInpatient write SetInpatient;
176       property Location:        Integer     read FLocation  write SetLocation;
177       property LocationName:    string      read GetLocationName write FLocationName;
178       property LocationText:    string      read GetLocationText write FLocationText;
179       property Provider:        Int64       read FProvider  write SetProvider;
180       property ProviderName:    string      read GetProviderName;
181       property StandAlone:      Boolean     read FStandAlone write SetStandAlone;
182       property VisitCategory:   Char        read GetVisitCategory write SetVisitCategory;
183       property VisitStr:        string      read GetVisitStr;
184       property Notifier:        IORNotifier read FNotifier implements IORNotifier;
185       property ICD10ImplDate: TFMDateTime read FICD10ImplDate;
186     end;
187   
188     TChangeItem = class
189     private
190       FItemType:     Integer;
191       FID:           String;
192       FText:         String;
193       FGroupName:    String;
194       FSignState:    Integer;
195       FParentID:     String;
196       FUser:         Int64;
197       FOrderDG:      String;
198       FDCOrder:      Boolean;
199       FDelay:        Boolean;
200       constructor Create(AnItemType: Integer; const AnID, AText, AGroupName: string;
201         ASignState: Integer; AParentID: string = ''; User: int64 = 0; OrderDG: string = '';
202         DCOrder: Boolean = False; Delay: Boolean = False);
203     public
204       property ItemType:  Integer read FItemType;
205       property ID:        string  read FID;
206       property Text:      string  read FText;
207       property GroupName: string  read FGroupName;
208       property SignState: Integer read FSignState write FSignState;
209       property ParentID : string  read FParentID;
210       property User: Int64 read FUser write FUser;
211       property OrderDG: string read FOrderDG write FOrderDG;
212       property DCOrder: boolean read FDCOrder write FDCOrder;
213       property Delay: boolean read FDelay write FDelay;
214       function CSValue(): Boolean;
215     end;
216   
217     TORRemoveChangesEvent = procedure(Sender: TObject; ChangeItem: TChangeItem) of object;  {**RV**}
218   
219     TChanges = class
220     private
221       FCount:        Integer;
222       FDocuments:    TList;
223       fOrders:       TList;
224       FOrderGrp:     TStringList;
225       FPCE:          TList;
226       FPCEGrp:       TStringList;
227       FOnRemove:     TORRemoveChangesEvent;    {**RV**}
228       FRefreshCoverPL: Boolean;
229       FRefreshProblemList: Boolean;
230     private
231       procedure AddUnsignedToChanges;
232     public
233       constructor Create;
234       destructor Destroy; override;
235       procedure Add(ItemType: Integer; const AnID, ItemText, GroupName: string; SignState: Integer; AParentID: string = '';
236                     User: int64 = 0; OrderDG: String = ''; DCOrder: Boolean = False; Delay: Boolean = False; ProblemAdded: Boolean = False);
237       procedure Clear;
238       function CanSign: Boolean;
239       function Exist(ItemType: Integer; const AnID: string): Boolean;
240       function ExistForOrder(const AnID: string): Boolean;
241       function Locate(ItemType: Integer; const AnID: string): TChangeItem;
242       procedure Remove(ItemType: Integer; const AnID: string);
243       procedure ReplaceID(ItemType: Integer; const OldID, NewID: string);
244       procedure ReplaceSignState(ItemType: Integer; const AnID: string; NewState: Integer);
245       procedure ReplaceText(ItemType: Integer; const AnID, NewText: string);
246       procedure ReplaceODGrpName(const AnODID, NewGrp: string);
247       procedure ChangeOrderGrp(const oldGrpName,newGrpName: string);
248       function RequireReview: Boolean;
249       property Count:      Integer     read FCount;
250       property Documents:  TList       read FDocuments;
251       property OnRemove: TORRemoveChangesEvent read FOnRemove write FOnRemove;        {**RV**}
252       property Orders:     TList       read fOrders;
253       property PCE:        TList       read FPCE;
254       property OrderGrp: TStringList read FOrderGrp;
255       property PCEGrp:   TStringList read FPCEGrp;
256       property RefreshCoverPL: Boolean read FRefreshCoverPL write FRefreshCoverPL;
257       property RefreshProblemList: Boolean read FRefreshProblemList write FRefreshProblemList;
258     end;
259   
260     TNotifyItem = class
261     private
262       DFN: string;
263       FollowUp: Integer;
264       //AlertData: string;
265       RecordID: string;
266       HighLightSection: String;
267     end;
268   
269     TNotifications = class
270     private
271       FActive: Boolean;
272       FList: TList;
273       FCurrentIndex: Integer;
274       FNotifyItem: TNotifyItem;
275       FNotifIndOrders: boolean;
276       function GetDFN: string;  //*DFN*
277       function GetFollowUp: Integer;
278       function GetAlertData: string;
279       function GetHighLightSection: String; //CB
280       function GetIndOrderDisplay: Boolean;
281       function GetRecordID: string;
282       function GetText: string;
283       procedure SetIndOrderDisplay(Value: Boolean);
284     public
285       constructor Create;
286       destructor Destroy; override;
287       procedure Add(const ADFN: string; AFollowUp: Integer; const ARecordID: string; AHighLightSection : string = '');  //*DFN*  CB
288       procedure Clear;
289       procedure Next;
290       procedure Prior;
291       procedure Delete;
292       procedure DeleteForCurrentUser;
293       property Active:   Boolean read FActive;
294       property DFN:      string  read GetDFN;  //*DFN*
295       property FollowUp: Integer read GetFollowUp;
296       property AlertData: string read GetAlertData;
297       property RecordID: string  read GetRecordID;
298       property Text:     string  read GetText;
299       property HighLightSection: String read GetHighLightSection; //cb
300       property IndOrderDisplay:  Boolean read GetIndOrderDisplay write SetIndOrderDisplay;
301     end;
302   
303     TRemoteSite = class
304     private
305       FSiteID: string;
306       FSiteName: string;
307       FLastDate: TFMDateTime;
308       FSelected: Boolean;
309       FRemoteHandle: string;
310       FLabRemoteHandle: string;
311       FQueryStatus: string;
312       FLabQueryStatus: string;
313       FData: TStringList;
314       FLabData: TStringList;
315       FCurrentLabQuery: string;
316       FCurrentReportQuery: string;
317       procedure SetSelected(Value: Boolean);
318     public
319       destructor  Destroy; override;
320       constructor Create(ASite: string);
321       procedure ReportClear;
322       procedure LabClear;
323       property SiteID  : string        read FSiteID;
324       property SiteName: string        read FSiteName;
325       property LastDate: TFMDateTime   read FLastDate;
326       property Selected: boolean       read FSelected write SetSelected;
327       property RemoteHandle: string    read FRemoteHandle write FRemoteHandle;
328       property QueryStatus: string     read FQueryStatus write FQueryStatus;
329       property Data: TStringList       read FData write FData;
330       property LabRemoteHandle: string read FLabRemoteHandle write FLabRemoteHandle;
331       property LabQueryStatus: string  read FLabQueryStatus write FLabQueryStatus;
332       property LabData: TStringList    read FLabData write FLabData;
333       property CurrentLabQuery: string    read FCurrentLabQuery write FCurrentLabQuery;
334       property CurrentReportQuery: string read FCurrentReportQuery write FCurrentReportQuery;
335     end;
336   
337     TRemoteSiteList = class
338     private
339       FCount: integer;
340       FSiteList: TList;
341       FRemoteDataExists: Boolean;
342       FNoDataReason: string;
343     public
344       constructor Create;
345       destructor  Destroy; override;
346       procedure   Add(ASite: string);
347       procedure   ChangePatient(const DFN: string);
348       procedure   Clear;
349       property    Count           : integer     read FCount;
350       property    SiteList        : TList       read FSiteList;
351       property    RemoteDataExists: Boolean     read FRemoteDataExists;
352       property    NoDataReason    : string      read FNoDataReason;
353     end;
354   
355     TRemoteReport = class
356     private
357       FReport: string;
358       FHandle: string;
359     public
360       constructor Create(AReport: string);
361       destructor Destroy; override;
362       property Handle            :string     read FHandle write FHandle;
363       property Report            :string     read FReport write FReport;
364     end;
365   
366     TRemoteReportList = class
367     private
368       FCount: integer;
369       FReportList: TList;
370     public
371       constructor Create;
372       destructor  Destroy; override;
373       procedure   Add(AReportList, AHandle: string);
374       procedure   Clear;
375       property    Count           :integer     read FCount;
376       property    ReportList      :TList       read FReportList;
377     end;
378   
379     PReportTreeObject = ^TReportTreeObject;
380     TReportTreeObject = Record
381       ID       : String;         //Report ID
382       Heading  : String;         //Report Heading
383       Remote   : String;         //Remote Data Capable
384       RptType  : String;         //Report Type
385       Category : String;         //Report Category
386       RPCName  : String;         //Associated RPC
387       IFN      : String;         //IFN of report in file 101.24
388       HDR      : String;         //HDR is source of data if = 1
389     end;
390   
391   var
392     User: TUser;
393     Patient: TPatient;
394     Encounter: TEncounter = nil;
395     SavedEncounter: TEncounter = nil;
396     Changes: TChanges;
397     RemoteSites: TRemoteSiteList;
398     RemoteReports: TRemoteReportList;
399     Notifications: TNotifications;
400     HasFlag: boolean;
401     FlagList: TStringList;
402     //hds7591  Clinic/Ward movement.
403     TempEncounterLoc: Integer; // used to Save Encounter Location when user selected "Review Sign Changes" from "File"
404     TempEncounterLocName: string; // since in the path PatientRefresh is done prior to checking if patient has been admitted while entering OPT orders.
405     TempEncounterText: string;
406     TempEncounterDateTime: TFMDateTime;
407     TempEncounterVistCat: Char;
408     SavedEncounterLoc: Integer; // used to Save Encounter Location when doing clinic meds/ivs
409     SavedEncounterLocName: string;
410     SavedEncounterText: string;
411     SavedEncounterDateTime: TFMDateTime;
412     SavedEncounterVisitCat: Char;
413     SavedEncounterReason: string; //used to store why it will be reverted to the saved value
414   
415   procedure NotifyOtherApps(const AppEvent, AppData: string);
416   procedure FlushNotifierBuffer;
417   procedure TerminateOtherAppNotification;
418   procedure GotoWebPage(const URL: WideString);
419   function subtractMinutesFromDateTime(Time1 : TDateTime;Minutes : extended) : TDateTime;
420   function AllowAccessToSensitivePatient(NewDFN: string; var AccessStatus: integer): boolean;
421   
422   
423   implementation
424   
425   uses ORNet, rTIU, rOrders, rConsults, uOrders;
426   
427   type
428     HlinkNavProc = function(pUnk: IUnknown; szTarget: PWideChar): HResult; stdcall;
429   
430   var
431     uVistaMsg, uVistaDomMsg: UINT;
432     URLMonHandle: THandle = 0;
433     HlinkNav: HlinkNavProc;
434   
435   type
436     TNotifyAppsThread = class(TThread)
437     private
438       FRunning: boolean;
439     public
440       constructor CreateThread;
441       procedure ResumeIfIdle;
442       procedure ResumeAndTerminate;
443       procedure Execute; override;
444       property Running: boolean read FRunning;
445     end;
446   
447     TMsgType = (mtVistaMessage, mtVistaDomainMessage);
448   
449   var
450     uSynchronizer: TMultiReadExclusiveWriteSynchronizer = nil;
451     uNotifyAppsThread: TNotifyAppsThread = nil;
452     uNotifyAppsQueue: TStringList = nil;
453     uNotifyAppsActive: boolean = TRUE;
454     AnAtom: ATOM = 0;
455   
456   const
457     LONG_BROADCAST_TIMEOUT = 30000; // 30 seconds
458     SHORT_BROADCAST_TIMEOUT = 2000; // 2 seconds
459     MSG_TYPE: array[TMsgType] of String = ('V','D');
460   
461   function AllowAccessToSensitivePatient(NewDFN: string; var AccessStatus: integer): boolean;
462   const
463     TX_DGSR_ERR    = 'Unable to perform sensitive record checks';
464     TC_DGSR_ERR    = 'Error';
465     TC_DGSR_SHOW   = 'Restricted Record';
466     TC_DGSR_DENY   = 'Access Denied';
467     TX_DGSR_YESNO  = CRLF + 'Do you want to continue processing this patient record?';
468     TC_NEXT_NOTIF  = 'NEXT NOTIFICATION:  ';
469   var
470     //AccessStatus: integer;
471     AMsg, PrefixC, PrefixT: string;
472   begin
473     Result := TRUE;
474     if Notifications.Active then
475     begin
476       PrefixT := Piece(Notifications.RecordID, U, 1) + CRLF + CRLF;
477       PrefixC := TC_NEXT_NOTIF;
478     end
479     else
480     begin
481       PrefixT := '';
482       PrefixC := '';
483     end;
484     CheckSensitiveRecordAccess(NewDFN, AccessStatus, AMsg);
485     case AccessStatus of
486     DGSR_FAIL: begin
487                  InfoBox(PrefixT + TX_DGSR_ERR, PrefixC + TC_DGSR_ERR, MB_OK);
488                  Result := FALSE;
489                end;
490     DGSR_NONE: { Nothing - allow access to the patient. };
491     DGSR_SHOW: InfoBox(PrefixT + AMsg, PrefixC + TC_DGSR_SHOW, MB_OK);
492     DGSR_ASK:  if InfoBox(PrefixT + AMsg + TX_DGSR_YESNO, PrefixC + TC_DGSR_SHOW, MB_YESNO or MB_ICONWARNING or
493                  MB_DEFBUTTON2) = IDYES then LogSensitiveRecordAccess(NewDFN)
494                else Result := FALSE;
495     else       begin
496                  InfoBox(PrefixT + AMsg, PrefixC + TC_DGSR_DENY, MB_OK);
497                  if Notifications.Active then Notifications.DeleteForCurrentUser;
498                  Result := FALSE;
499                end;
500     end;
501   end;
502   
503   function QueuePending: boolean;
504   begin
505     uSynchronizer.BeginRead;
506     try
507       Result := (uNotifyAppsQueue.Count > 0);
508     finally
509       uSynchronizer.EndRead;
510     end;
511   end;
512   
513   procedure ProcessQueue(ShortTimout: boolean);
514   var
515     msg: String;
516     process: boolean;
517     AResult: LPDWORD;
518     MsgCode, timeout: UINT;
519     TypeCode: String;
520   
521   begin
522     if(not QueuePending) then exit;
523     uSynchronizer.BeginWrite;
524     try
525       process := (uNotifyAppsQueue.Count > 0);
526       if(process) then
527       begin
528         msg := uNotifyAppsQueue.Strings[0];
529         uNotifyAppsQueue.Delete(0);
530       end;
531     finally
532       uSynchronizer.EndWrite;
533     end;
534     if(process) then
535     begin
536       TypeCode := copy(msg,1,1);
537       delete(msg,1,1);
538       if(TypeCode = MSG_TYPE[mtVistaMessage]) then
539         MsgCode := uVistaMsg
540       else
541         MsgCode := uVistaDomMsg;
542   
543       if(ShortTimout) then
544         timeout := SHORT_BROADCAST_TIMEOUT
545       else
546         timeout := LONG_BROADCAST_TIMEOUT;
547   
548       // put text in the global atom table
549       AnAtom := GlobalAddAtom(PChar(msg));
550       if (AnAtom <> 0) then
551       begin
552         try
553           // broadcast 'VistA Domain Event - Clinical' to all main windows
554           //SendMessage(HWND_BROADCAST, uVistaDomMsg, WPARAM(Application.MainForm.Handle), LPARAM(AnAtom));
555           //
556           //Changed to SendMessageTimeout to prevent hang when other app unresponsive  (RV)
557           AResult := nil;
558   {$WARN SYMBOL_DEPRECATED OFF} // researched
559   {$WARN SYMBOL_PLATFORM OFF}
560           SendMessageTimeout(HWND_BROADCAST, MsgCode, WPARAM(Application.MainForm.Handle), LPARAM(AnAtom),
561                   SMTO_ABORTIFHUNG or SMTO_BLOCK, timeout, AResult^);
562   {$WARN SYMBOL_PLATFORM ON}
563   {$WARN SYMBOL_DEPRECATED ON}
564         finally
565         // after all windows have processed the message, remove the text from the table
566           GlobalDeleteAtom(AnAtom);
567           AnAtom := 0;
568         end;
569       end;
570     end;
571   end;
572   
573   constructor TNotifyAppsThread.CreateThread;
574   begin
575     inherited Create(TRUE);
576     FRunning := TRUE;
577   end;
578   
579   procedure TNotifyAppsThread.ResumeIfIdle;
580   begin
581     if(Suspended) then
582   {$WARN SYMBOL_DEPRECATED OFF} // researched
583       Resume;
584   {$WARN SYMBOL_DEPRECATED ON}
585   end;
586   
587   procedure TNotifyAppsThread.ResumeAndTerminate;
588   begin
589     Terminate;
590     if(Suspended) then
591   {$WARN SYMBOL_DEPRECATED OFF} // researched
592       Resume;
593   {$WARN SYMBOL_DEPRECATED ON}
594   end;
595   
596   procedure TNotifyAppsThread.Execute;
597   begin
598     while(not Terminated) do
599     begin
600       if(QueuePending) then
601         ProcessQueue(FALSE)
602       else if(not Terminated) then
603   {$WARN SYMBOL_DEPRECATED OFF} // researched
604         Suspend;
605   {$WARN SYMBOL_DEPRECATED ON}
606     end;
607     FRunning := FALSE;
608   end;
609   
610   function AppNotificationEnabled: boolean;
611   begin
612     Result := FALSE;
613     if(not uNotifyAppsActive) then exit;
614     if Application.MainForm = nil then Exit;
615     if User = nil then exit;
616     if not User.FNotifyAppsWM then Exit;
617     // register the message with windows to get a unique message number (if not already registered)
618     if uVistaMsg = 0    then uVistaMsg    := RegisterWindowMessage('VistA Event - Clinical');
619     if uVistaDomMsg = 0 then uVistaDomMsg := RegisterWindowMessage('VistA Domain Event - Clinical');
620     if (uVistaMsg = 0) or (uVistaDomMsg = 0) then Exit;
621     if(not assigned(uNotifyAppsQueue)) then
622       uNotifyAppsQueue := TStringList.Create;
623     if(not assigned(uSynchronizer)) then
624       uSynchronizer := TMultiReadExclusiveWriteSynchronizer.Create;
625     if(not assigned(uNotifyAppsThread)) then
626       uNotifyAppsThread := TNotifyAppsThread.CreateThread;
627     Result := TRUE;
628   end;
629   
630   procedure ReleaseAppNotification;
631   var
632     waitState: DWORD;
633   
634   begin
635     uNotifyAppsActive := FALSE;
636     if(assigned(uNotifyAppsThread)) then
637     begin
638       uNotifyAppsThread.ResumeAndTerminate;
639       sleep(10);
640       if(uNotifyAppsThread.Running) then
641       begin
642         waitState := WaitForSingleObject(uNotifyAppsThread.Handle, SHORT_BROADCAST_TIMEOUT);
643         if((waitState = WAIT_TIMEOUT) or
644            (waitState = WAIT_FAILED) or
645            (waitState = WAIT_ABANDONED)) then
646         begin
647           TerminateThread(uNotifyAppsThread.Handle, 0);
648           if(AnAtom <> 0) then
649           begin
650             GlobalDeleteAtom(AnAtom);
651             AnAtom := 0;
652           end;
653         end;
654       end;
655       FreeAndNil(uNotifyAppsThread);
656     end;
657     if(assigned(uSynchronizer)) and
658       (assigned(uNotifyAppsQueue)) then
659     begin
660       while(QueuePending) do
661         ProcessQueue(TRUE);
662     end;
663     FreeAndNil(uSynchronizer);
664     FreeAndNil(uNotifyAppsQueue);
665   end;
666   
667   procedure NotifyOtherApps(const AppEvent, AppData: string);
668   var
669     m1: string;
670     m2: string;
671   
672   begin
673     if(AppNotificationEnabled) then
674     begin
675       // first send the domain version of the message
676       m1 := MSG_TYPE[mtVistaDomainMessage] + AppEvent + U + 'CPRS;' + User.FDomain + U + Patient.DFN + U + AppData;
677       // for backward compatibility, send the message without the domain
678       m2 := MSG_TYPE[mtVistaMessage] + AppEvent + U + 'CPRS' + U + Patient.DFN + U + AppData;
679       uSynchronizer.BeginWrite;
680       try
681         uNotifyAppsQueue.Add(m1);
682         uNotifyAppsQueue.Add(m2);
683       finally
684         uSynchronizer.EndWrite;
685       end;
686       uNotifyAppsThread.ResumeIfIdle;
687     end;
688   end;
689   
690   procedure FlushNotifierBuffer;
691   begin
692     if(AppNotificationEnabled) then
693     begin
694       uSynchronizer.BeginWrite;
695       try
696         uNotifyAppsQueue.Clear;
697       finally
698         uSynchronizer.EndWrite;
699       end;
700     end;
701   end;
702   
703   procedure TerminateOtherAppNotification;
704   begin
705     ReleaseAppNotification;
706   end;
707   
708   { TUser methods ---------------------------------------------------------------------------- }
709   
710   constructor TUser.Create;
711   { create the User object for the currently logged in user }
712   var
713     UserInfo: TUserInfo;
714   begin
715     UserInfo := GetUserInfo;
716     FDUZ           := UserInfo.DUZ;
717     FName          := UserInfo.Name;
718     FUserClass     := UserInfo.UserClass;
719     FCanSignOrders := UserInfo.CanSignOrders;
720     FIsProvider    := UserInfo.IsProvider;
721     FOrderRole     := UserInfo.OrderRole;
722     FNoOrdering    := UserInfo.NoOrdering;
723     FEnableVerify  := UserInfo.EnableVerify;
724     FDTIME         := UserInfo.DTIME;
725     FCountDown     := UserInfo.CountDown;
726     FNotifyAppsWM  := UserInfo.NotifyAppsWM;
727     FDomain        := UserInfo.Domain;
728     FPtMsgHang     := UserInfo.PtMsgHang;
729     FService       := UserInfo.Service;
730     FAutoSave      := UserInfo.AutoSave;
731     FInitialTab    := UserInfo.InitialTab;
732     FUseLastTab    := UserInfo.UseLastTab;
733     if(URLMonHandle = 0) then
734       FWebAccess := FALSE
735     else
736       FWebAccess := UserInfo.WebAccess;
737     FDisableHold     := UserInfo.DisableHold;
738     FIsRPL           := UserInfo.IsRPL;
739     FRPLList         := UserInfo.RPLList;
740     FHasCorTabs      := UserInfo.HasCorTabs;
741     FHasRptTab       := UserInfo.HasRptTab;
742     FIsReportsOnly   := UserInfo.IsReportsOnly;
743     FToolsRptEdit    := UserInfo.ToolsRptEdit;
744     FCurrentPrinter  := GetDefaultPrinter(DUZ, 0);
745     FGECStatus       := UserInfo.GECStatusCheck;
746     FStationNumber   := UserInfo.StationNumber;
747     FIsProductionAccount := UserInfo.IsProductionAccount;
748   end;
749   
750   function TUser.HasKey(const KeyName: string): Boolean;
751   { returns true if the current user has the given security key }
752   begin
753     Result := HasSecurityKey(KeyName);
754   end;
755   
756   { TPatient methods ------------------------------------------------------------------------- }
757   
758   procedure TPatient.Clear;
759   { clears all fields in the Patient object }
760   begin
761     FDFN          := '';
762     FName         := '';
763     FSSN          := '';
764     FDOB          := 0;
765     FAge          := 0;
766     FSex          := 'U';
767     FCWAD         := '';
768     FRestricted   := False;
769     FInpatient    := False;
770     FStatus       := '';
771     FLocation     := 0;
772     FWardService  := '';
773     FSpecialty    := 0;
774     FSpecialtySvc := '';
775     FAdmitTime    := 0;
776     FSrvConn      := False;
777     FSCPercent    := 0;
778     FPrimTeam     := '';
779     FPrimProv     := '';
780     FAttending    := '';
781     FMHTC         := '';
782     FreeAndNil(fCombatVet);
783   end;
784   
785   destructor TPatient.Destroy;
786   begin
787     FreeAndNil(fCombatVet);
788     inherited;
789   end;
790   
791   function TPatient.GetCombatVet: TCombatVet;
792   begin
793     if fCombatVet = nil then
794       fCombatVet := TCombatVet.Create(FDFN);
795     Result := fCombatVet;
796   end;
797   
798   function TPatient.GetDateDied: TFMDateTime;
799   begin
800     if(not FDateDiedLoaded) then
801     begin
802       FDateDied := DateOfDeath(FDFN);
803       FDateDiedLoaded := TRUE;
804     end;
805     Result := FDateDied;
806   end;
807   
808   procedure TPatient.SetDFN(const Value: string);  //*DFN*
809   { selects a patient and sets up the Patient object for the patient }
810   var
811     PtSelect: TPtSelect;
812   begin
813     if (Value = '') or (Value = FDFN) then Exit;  //*DFN*
814     Clear;
815     SelectPatient(Value, PtSelect);
816     FDFN        := Value;
817     FName       := PtSelect.Name;
818     FICN        := PtSelect.ICN;
819     FSSN        := PtSelect.SSN;
820     FDOB        := PtSelect.DOB;
821     FAge        := PtSelect.Age;
822     FSex        := PtSelect.Sex;
823     FCWAD       := PtSelect.CWAD;
824     FRestricted := PtSelect.Restricted;
825     FInpatient  := Length(PtSelect.Location) > 0;
826     if FInpatient then FStatus := ' (INPATIENT)'
827     else FStatus := ' (OUTPATIENT)';
828     FWardService := PtSelect.WardService;
829     FLocation   := PtSelect.LocationIEN;
830     FSpecialty  := PtSelect.SpecialtyIEN;
831     FSpecialtySvc := PtSelect.SpecialtySvc;
832     FAdmitTime  := PtSelect.AdmitTime;
833     FSrvConn    := PtSelect.ServiceConnected;
834     FSCPercent  := PtSelect.SCPercent;
835     FPrimTeam   := PtSelect.PrimaryTeam;
836     FPrimProv   := PtSelect.PrimaryProvider;
837     FAttending  := PtSelect.Attending;
838     FAssociate  := PtSelect.Associate;
839     FInProvider := PtSelect.InProvider;
840     FMHTC       := PtSelect.MHTC
841   end;
842   
843   { TEncounter ------------------------------------------------------------------------------- }
844   
845   constructor TEncounter.Create;
846   begin
847     inherited;
848     FNotifier := TORNotifier.Create(Self, TRUE);
849     FICD10ImplDate := GetICD10ImplementationDate;
850   end;
851   
852   destructor TEncounter.Destroy;
853   begin
854     FNotifier := nil; // Frees instance
855     inherited;
856   end;
857   
858   procedure TEncounter.EncounterSwitch(Loc: integer; LocName, LocText: string; DT: TFMDateTime; vCat: Char);
859   begin
860    Encounter.Location := Loc;
861    Encounter.LocationName := LocName;
862    Encounter.LocationText := LocText;
863    Encounter.VisitCategory := vCat;
864    Encounter.DateTime := DT;;
865   end;
866   
867   procedure TEncounter.CreateSaved(Reason: string);
868   begin
869       SavedEncounterLoc := Encounter.Location;
870       SavedEncounterLocName := Encounter.LocationName;
871       SavedEncounterText := Encounter.LocationText;
872       SavedEncounterDateTime := Encounter.DateTime;
873       SavedEncounterVisitCat := Encounter.VisitCategory;
874       SavedEncounterReason := Reason;
875   end;
876   
877   procedure TEncounter.EmptySaved();
878   begin
879     SavedEncounterLoc := 0;
880     SavedEncounterLocName := '';
881     SavedEncounterText := '';
882     SavedEncounterDateTime := 0;
883     SavedEncounterVisitCat := #0;
884     SavedEncounterReason := '';
885   end;
886   
887   procedure TEncounter.SwitchToSaved(ShowInfoBox: boolean);
888   begin
889     if SavedEncounterLoc > 0 then
890     begin
891       if ShowInfoBox then InfoBox(SavedEncounterReason, 'Notice', MB_OK or MB_ICONWARNING);
892       EncounterSwitch(SavedEncounterLoc, SavedEncounterLocName, SavedEncounterText, SavedEncounterDateTime, SavedEncounterVisitCat);
893       EmptySaved();
894     end;
895   end;
896   
897   procedure TEncounter.Clear;
898   { clears all the fields of an Encounter (usually done upon patient selection }
899   begin
900     FChanged      := False;
901     FDateTime     := 0;
902     FInpatient    := False;
903     FLocationName := '';
904     FLocationText := '';
905     FProvider     := 0;
906     FProviderName := '';
907     FStandAlone   := False;
908     FVisitCategory := #0;
909     SetLocation(0); // Used to call Notifications - do it last so everything else is set
910   end;
911   
912   function TEncounter.GetLocationText: string;
913   { returns abbreviated hospital location + room/bed (or date/time for appt) }
914   begin
915     if FChanged then UpdateText;
916     Result := FLocationText;
917   end;
918   
919   function TEncounter.GetLocationName: string;
920   { returns external text value for hospital location }
921   begin
922     if FChanged then UpdateText;
923     Result := FLocationName;
924   end;
925   
926   function TEncounter.GetProviderName: string;
927   { returns external text value for provider name }
928   begin
929     if FChanged then UpdateText;
930     Result := FProviderName;
931   end;
932   
933   function TEncounter.GetVisitCategory: Char;
934   begin
935     Result := FVisitCategory;
936     if Result = #0 then Result := 'A';
937   end;
938   
939   function TEncounter.GetVisitStr: string;
940   begin
941     Result :=  IntToStr(FLocation) + ';' + FloatToStr(FDateTime) + ';' + VisitCategory;
942     // use VisitCategory property to insure non-null character
943   end;
944   
945   function TEncounter.GetICDVersion: String;
946   var
947     cd: TFMDateTime;  //compare date
948   begin
949     // if no Enc Dt or Historical, Hospitalization, or Daily Visit compare I-10 Impl dt with TODAY
950     if (FDateTime <= 0) or (FVisitCategory = 'E') or (FVisitCategory = 'H') then
951       cd := FMNow
952     else // otherwise compare I-10 Impl dt with Encounter date/time
953       cd := FDateTime;
954   
955     if (FICD10ImplDate > cd) then
956       Result := 'ICD^ICD-9-CM'
957     else
958       Result := '10D^ICD-10-CM';
959   end;
960   
961   function TEncounter.NeedVisit: Boolean;
962   { returns true if required fields for visit creation are present }
963   begin
964     // added "<" to FDateTime check to trap "-1" visit dates - v23.12 (RV)
965     if (FDateTime <= 0) or (FLocation = 0) then Result := True else Result := False;
966   end;
967   
968   procedure TEncounter.SetDateTime(Value: TFMDateTime);
969   { sets the date/time for the encounter - causes the visit to be reset }
970   begin
971     if Value <> FDateTime then
972     begin
973       FDateTime := Value;
974       FChanged := True;
975     end;
976   end;
977   
978   procedure TEncounter.SetInpatient(Value: Boolean);
979   { sets the inpatient flag for the encounter - causes the visit to be reset }
980   begin
981     if Value <> FInpatient then
982     begin
983       FInpatient := Value;
984       FChanged := True;
985     end;
986   end;
987   
988   procedure TEncounter.SetLocation(Value: Integer);
989   { sets the location for the encounter - causes the visit to be reset }
990   begin
991     if Value <> FLocation then
992     begin
993       FLocation := Value;
994       FChanged := True;
995       FNotifier.Notify(Self);
996     end;
997   end;
998   
999   procedure TEncounter.SetProvider(Value: Int64);
1000  { sets the provider for the encounter - causes the visit to be reset }
1001  begin
1002    if Value <> FProvider then
1003    begin
1004      FProvider := Value;
1005      FChanged := True;
1006    end;
1007  end;
1008  
1009  procedure TEncounter.SetStandAlone(Value: Boolean);
1010  { StandAlone should be true if this encounter isn't related to an appointment }
1011  begin
1012    if Value <> FStandAlone then
1013    begin
1014      FStandAlone := Value;
1015      FChanged := True;
1016    end;
1017  end;
1018  
1019  procedure TEncounter.SetVisitCategory(Value: Char);
1020  { sets the visit type for this encounter - causes to visit to be reset }
1021  begin
1022    if Value <> FVisitCategory then
1023    begin
1024      FVisitCategory := Value;
1025      FChanged := True;
1026    end;
1027  end;
1028  
1029  procedure TEncounter.UpdateText;
1030  { retrieve external values for provider name, hospital location }
1031  var
1032    EncounterText: TEncounterText;
1033  begin
1034    { this references the Patient object which is assumed to be created }
1035    EncounterText := GetEncounterText(Patient.DFN, FLocation, FProvider);
1036    with EncounterText do
1037    begin
1038      FLocationName := LocationName;
1039      if Length(LocationAbbr) > 0
1040        then FLocationText := LocationAbbr
1041        else FLocationText := LocationName;
1042      if Length(LocationName) > 0 then
1043      begin
1044        if (FVisitCategory = 'H') //FInpatient
1045          then FLocationText := FLocationText + ' ' + RoomBed
1046          else FLocationText := FLocationText + ' ' +
1047            FormatFMDateTime('mmm dd,yy hh:nn', FDateTime);
1048      end
1049      else FLocationText := '';
1050      if Length(ProviderName) > 0  // ProviderName is the field in EncounterText
1051        then FProviderName := ProviderName
1052        else FProviderName := '';
1053    end;
1054    FChanged := False;
1055  end;
1056  
1057  { TChangeItem ------------------------------------------------------------------------------ }
1058  
1059  constructor TChangeItem.Create(AnItemType: Integer; const AnID, AText, AGroupName: string;
1060    ASignState: Integer; AParentID: string; user: int64; OrderDG: string; DCOrder, Delay: Boolean);
1061  begin
1062    FItemType  := AnItemType;
1063    FID        := AnID;
1064    FText      := AText;
1065    FGroupName := AGroupName;
1066    FSignState := ASignState;
1067    FParentID  := AParentID;
1068    FUser      := User;
1069    FOrderDG   := OrderDG;
1070    FDCOrder   := DCOrder;
1071    FDelay     := Delay;
1072  end;
1073  
1074  function TChangeItem.CSValue(): boolean;
1075  var
1076    ret: string;
1077  begin
1078    ret := sCallV('ORDEA CSVALUE', [FID]);
1079    if ret = '1' then Result :=  True
1080    else Result := False;
1081  end;
1082  
1083  { TChanges --------------------------------------------------------------------------------- }
1084  
1085  constructor TChanges.Create;
1086  begin
1087    FDocuments          := TList.Create;
1088    fOrders             := TList.Create;
1089    FPCE                := TList.Create;
1090    FOrderGrp           := TStringList.Create;
1091    FPCEGrp             := TStringList.Create;
1092    FCount              := 0;
1093    FRefreshCoverPL     := False;
1094    FRefreshProblemList := False;
1095  end;
1096  
1097  destructor TChanges.Destroy;
1098  begin
1099    Clear;
1100    FDocuments.Free;
1101    fOrders.Free;
1102    FPCE.Free;
1103    FOrderGrp.Free;
1104    FPCEGrp.Free;
1105    inherited Destroy;
1106  end;
1107  
1108  procedure TChanges.Add(ItemType: Integer; const AnID, ItemText, GroupName: string;
1109    SignState: Integer; AParentID: string; User: int64; OrderDG: String;
1110    DCOrder, Delay, ProblemAdded: Boolean);
1111  var
1112    i: Integer;
1113    Found: Boolean;
1114    ChangeList: TList;
1115    NewChangeItem: TChangeItem;
1116  begin
1117    ChangeList := nil;
1118    case ItemType of
1119    CH_DOC: ChangeList := FDocuments;
1120    CH_SUM: ChangeList := FDocuments;  {*REV*}
1121    CH_CON: ChangeList := FDocuments;
1122    CH_SUR: ChangeList := FDocuments;
1123    CH_ORD: ChangeList := fOrders;
1124    CH_PCE: ChangeList := FPCE;
1125    end;
1126    FRefreshCoverPL := ProblemAdded;
1127    FRefreshProblemList := ProblemAdded;
1128    Found := False;
1129    if ChangeList <> nil then with ChangeList do for i := 0 to Count - 1 do
1130      with TChangeItem(Items[i]) do if ID = AnID then
1131      begin
1132        Found := True;
1133        // can't change ItemType, ID, or GroupName, must call Remove first
1134        FText := ItemText;
1135        FSignState := SignState;
1136      end;
1137    if not Found then
1138    begin
1139      NewChangeItem := TChangeItem.Create(ItemType, AnID, ItemText, GroupName, SignState, AParentID, User, OrderDG, DCOrder, Delay);
1140      case ItemType of
1141      CH_DOC: begin
1142                FDocuments.Add(NewChangeItem);
1143              end;
1144      CH_SUM: begin     {*REV*}
1145                FDocuments.Add(NewChangeItem);
1146              end;
1147      CH_CON: begin
1148                FDocuments.Add(NewChangeItem);
1149              end;
1150      CH_SUR: begin
1151                FDocuments.Add(NewChangeItem);
1152              end;
1153      CH_ORD: begin
1154                fOrders.Add(NewChangeItem);
1155                with FOrderGrp do if IndexOf(GroupName) < 0 then Add(GroupName);
1156              end;
1157      CH_PCE: begin
1158                FPCE.Add(NewChangeItem);
1159                with FPCEGrp do if IndexOf(GroupName) < 0 then Add(GroupName);
1160              end;
1161      end;
1162      Inc(FCount);
1163    end;
1164  end;
1165  
1166  function TChanges.CanSign: Boolean;
1167  { returns true if any items in the changes list can be signed by the user }
1168  var
1169    i: Integer;
1170  begin
1171    Result := False;
1172    with FDocuments do for i := 0 to Count - 1 do
1173      with TChangeItem(Items[i]) do if FSignState <> CH_SIGN_NA then
1174      begin
1175        Result := True;
1176        Exit;
1177      end;
1178    with fOrders do for i := 0 to Count - 1 do
1179      with TChangeItem(Items[i]) do if FSignState <> CH_SIGN_NA then
1180      begin
1181        Result := True;
1182        Exit;
1183      end;
1184    // don't have to worry about FPCE - it never requires signatures
1185  end;
1186  
1187  procedure TChanges.Clear;
1188  var
1189    i, ConsultIEN: Integer;
1190    DocIEN: Int64;
1191    OrderID: string;
1192  begin
1193    with FDocuments do for i := 0 to Count - 1 do
1194      begin
1195        DocIEN := StrToInt64Def(TChangeItem(Items[i]).ID, 0);
1196        UnlockDocument(DocIEN);
1197        ConsultIEN := GetConsultIENforNote(DocIEN);
1198        if ConsultIEN > -1 then
1199          begin
1200            OrderID := GetConsultOrderIEN(ConsultIEN);
1201            UnlockOrderIfAble(OrderID);
1202          end;
1203        TChangeItem(Items[i]).Free;
1204      end;
1205    with fOrders do for i := 0 to Count - 1 do TChangeItem(Items[i]).Free;
1206    with FPCE do for i := 0 to Count - 1 do TChangeItem(Items[i]).Free;
1207    FDocuments.Clear;
1208    fOrders.Clear;
1209    FPCE.Clear;
1210    FOrderGrp.Clear;
1211    FPCEGrp.Clear;
1212    FCount := 0;
1213  end;
1214  
1215  function TChanges.Exist(ItemType: Integer; const AnID: string): Boolean;
1216  var
1217    ChangeList: TList;
1218    i: Integer;
1219  begin
1220    Result := False;
1221    ChangeList := nil;
1222    case ItemType of
1223    CH_DOC: ChangeList := FDocuments;
1224    CH_SUM: ChangeList := FDocuments;   {*REV*}
1225    CH_CON: ChangeList := FDocuments;
1226    CH_SUR: ChangeList := FDocuments;
1227    CH_ORD: ChangeList := fOrders;
1228    CH_PCE: ChangeList := FPCE;
1229    end;
1230    if ChangeList <> nil then with ChangeList do
1231      for i := 0 to Count - 1 do if TChangeItem(Items[i]).ID = AnID then
1232      begin
1233        Result := True;
1234        Break;
1235      end;
1236  end;
1237  
1238  function TChanges.ExistForOrder(const AnID: string): Boolean;
1239  { returns TRUE if any item in the list of orders has matching order number (ignores action) }
1240  var
1241    i: Integer;
1242  begin
1243    Result := False;
1244    if fOrders <> nil then with fOrders do
1245      for i := 0 to Count - 1 do
1246        if Piece(TChangeItem(Items[i]).ID, ';', 1) = Piece(AnID, ';', 1) then
1247        begin
1248          Result := True;
1249          Break;
1250        end;
1251  end;
1252  
1253  function TChanges.Locate(ItemType: Integer; const AnID: string): TChangeItem;
1254  var
1255    ChangeList: TList;
1256    i: Integer;
1257  begin
1258    Result := nil;
1259    ChangeList := nil;
1260    case ItemType of
1261    CH_DOC: ChangeList := FDocuments;
1262    CH_SUM: ChangeList := FDocuments;   {*REV*}
1263    CH_CON: ChangeList := FDocuments;
1264    CH_SUR: ChangeList := FDocuments;
1265    CH_ORD: ChangeList := fOrders;
1266    CH_PCE: ChangeList := FPCE;
1267    end;
1268    if ChangeList <> nil then with ChangeList do
1269      for i := 0 to Count - 1 do if TChangeItem(Items[i]).ID = AnID then
1270      begin
1271        Result := TChangeItem(Items[i]);
1272        Break;
1273      end;
1274  end;
1275  
1276  procedure TChanges.Remove(ItemType: Integer; const AnID: string);
1277  { remove a change item from the appropriate list of changes (depending on type)
1278    this doesn't check groupnames, may leave a groupname without any associated items }
1279  var
1280    ChangeList: TList;
1281    i,j: Integer;
1282    needRemove: boolean;
1283  begin
1284    ChangeList := nil;
1285    case ItemType of
1286    CH_DOC: ChangeList := FDocuments;
1287    CH_SUM: ChangeList := FDocuments;
1288    CH_CON: ChangeList := FDocuments;
1289    CH_SUR: ChangeList := FDocuments;
1290    CH_ORD: ChangeList := fOrders;
1291    CH_PCE: ChangeList := FPCE;
1292    end;
1293    if ChangeList <> nil then with ChangeList do
1294      for i := Count - 1 downto 0 do if TChangeItem(Items[i]).ID = AnID then
1295      begin
1296        if Assigned(FOnRemove) then FOnRemove(Self, TChangeItem(Items[i]))    {**RV**}
1297          else TChangeItem(Items[i]).Free;                                    {**RV**}
1298        //TChangeItem(Items[i]).Free;                                         {**RV**}
1299        // set TChangeItem(Items[i]) = nil?
1300        Delete(i);
1301        Dec(FCount);
1302      end;
1303    if ItemType = CH_ORD then
1304    begin
1305      for i := OrderGrp.Count - 1 downto 0 do
1306      begin
1307        needRemove := True;
1308        for j := 0 to fOrders.Count - 1 do
1309          if (AnsiCompareText(TChangeItem(fOrders[j]).GroupName,OrderGrp[i]) = 0 ) then
1310            needRemove := False;
1311        if needRemove then
1312          OrderGrp.Delete(i);
1313      end;
1314    end;
1315    if ItemType = CH_ORD then UnlockOrder(AnID);
1316    if ItemType = CH_DOC then UnlockDocument(StrToIntDef(AnID, 0));
1317    if ItemType = CH_CON then UnlockDocument(StrToIntDef(AnID, 0));
1318    if ItemType = CH_SUM then UnlockDocument(StrToIntDef(AnID, 0));
1319    if ItemType = CH_SUR then UnlockDocument(StrToIntDef(AnID, 0));
1320  end;
1321  
1322  procedure TChanges.ReplaceID(ItemType: Integer; const OldID, NewID: string);
1323  var
1324    ChangeList: TList;
1325    i: Integer;
1326  begin
1327    ChangeList := nil;
1328    case ItemType of
1329    CH_DOC: ChangeList := FDocuments;
1330    CH_SUM: ChangeList := FDocuments;   {*REV*}
1331    CH_CON: ChangeList := FDocuments;
1332    CH_SUR: ChangeList := FDocuments;
1333    CH_ORD: ChangeList := fOrders;
1334    CH_PCE: ChangeList := FPCE;
1335    end;
1336    if ChangeList <> nil then with ChangeList do
1337      for i := 0 to Count - 1 do if TChangeItem(Items[i]).ID = OldID then
1338      begin
1339        TChangeItem(Items[i]).FID := NewID;
1340      end;
1341  end;
1342  
1343  procedure TChanges.ReplaceSignState(ItemType: Integer; const AnID: string; NewState: Integer);
1344  var
1345    ChangeList: TList;
1346    i: Integer;
1347  begin
1348    ChangeList := nil;
1349    case ItemType of
1350    CH_DOC: ChangeList := FDocuments;
1351    CH_SUM: ChangeList := FDocuments;   {*REV*}
1352    CH_CON: ChangeList := FDocuments;
1353    CH_SUR: ChangeList := FDocuments;
1354    CH_ORD: ChangeList := fOrders;
1355    CH_PCE: ChangeList := FPCE;
1356    end;
1357    if ChangeList <> nil then with ChangeList do
1358      for i := 0 to Count - 1 do if TChangeItem(Items[i]).ID = AnID then
1359      begin
1360        TChangeItem(Items[i]).FSignState := NewState;
1361      end;
1362  end;
1363  
1364  procedure TChanges.ReplaceText(ItemType: Integer; const AnID, NewText: string);
1365  var
1366    ChangeList: TList;
1367    i: Integer;
1368  begin
1369    ChangeList := nil;
1370    case ItemType of
1371    CH_DOC: ChangeList := FDocuments;
1372    CH_SUM: ChangeList := FDocuments;   {*REV*}
1373    CH_CON: ChangeList := FDocuments;
1374    CH_SUR: ChangeList := FDocuments;
1375    CH_ORD: ChangeList := fOrders;
1376    CH_PCE: ChangeList := FPCE;
1377    end;
1378    if ChangeList <> nil then with ChangeList do
1379      for i := 0 to Count - 1 do if TChangeItem(Items[i]).ID = AnID then
1380      begin
1381        TChangeItem(Items[i]).FText := NewText;
1382      end;
1383  end;
1384  
1385  function TChanges.RequireReview: Boolean;
1386  { returns true if documents can be signed or if any orders exist in Changes }
1387  var
1388    i: Integer;
1389  begin
1390    Result := False;
1391    AddUnsignedToChanges;
1392    if fOrders.Count > 0 then Result := True;
1393    if Result = False then with FDocuments do for i := 0 to Count - 1 do
1394      with TChangeItem(Items[i]) do if FSignState <> CH_SIGN_NA then
1395      begin
1396        Result := True;
1397        Break;
1398      end;
1399  end;
1400  
1401  procedure TChanges.AddUnsignedToChanges;
1402  { retrieves unsigned orders outside this session based on OR UNSIGNED ORDERS ON EXIT }
1403  var
1404    i, CanSign(*, OrderUser*): Integer;
1405    OrderUser: int64;
1406    AnID, Display: string;
1407    HaveOrders, OtherOrders: TStringList;
1408    AChangeItem: TChangeItem;
1409    IsDiscontinue, IsDelay: boolean;
1410  begin
1411    if Patient.DFN = '' then Exit;
1412    // exit if there is already an 'Other Unsigned' group?
1413    HaveOrders  := TStringList.Create;
1414    OtherOrders := TStringList.Create;
1415    try
1416      StatusText('Looking for unsigned orders...');
1417      for i := 0 to Pred(fOrders.Count) do
1418      begin
1419        AChangeItem := fOrders[i];
1420        HaveOrders.Add(AChangeItem.ID);
1421      end;
1422      LoadUnsignedOrders(OtherOrders, HaveOrders);
1423      if (Encounter.Provider = User.DUZ) and User.CanSignOrders
1424        then CanSign := CH_SIGN_YES
1425        else CanSign := CH_SIGN_NA;
1426      for i := 0 to Pred(OtherOrders.Count) do
1427      begin
1428        AnID := Piece(OtherOrders[i],U,1);
1429        if Piece(OtherOrders[i],U,2) = '' then OrderUser := 0
1430        else OrderUser := StrtoInt64(Piece(OtherOrders[i],U,2));
1431        //agp change the M code to pass back the value for the new order properties
1432        Display := Piece(OtherOrders[i],U,3);
1433        if Piece(OtherOrders[i],U,4) = '1' then  IsDiscontinue := True
1434        else IsDiscontinue := False;
1435        if Piece(OtherOrders[i],U,5) = '1' then  IsDelay := True
1436        else IsDelay := False;
1437        Add(CH_ORD, AnID, TextForOrder(AnID), 'Other Unsigned', CanSign,'', OrderUser, Display, IsDiscontinue, IsDelay);
1438      end;
1439    finally
1440      StatusText('');
1441      HaveOrders.Free;
1442      OtherOrders.Free;
1443    end;
1444  end;
1445  
1446  { TNotifications ---------------------------------------------------------------------------- }
1447  
1448  constructor TNotifications.Create;
1449  begin
1450    FList := TList.Create;
1451    FCurrentIndex := -1;
1452    FActive := False;
1453    FNotifIndOrders := False;
1454  end;
1455  
1456  destructor TNotifications.Destroy;
1457  begin
1458    Clear;
1459    FList.Free;
1460    inherited Destroy;
1461  end;
1462  
1463  procedure TNotifications.Add(const ADFN: string; AFollowUp: Integer; const ARecordID: string; AHighLightSection : string = '');  //*DFN*
1464  var
1465    NotifyItem: TNotifyItem;
1466  begin
1467    NotifyItem := TNotifyItem.Create;
1468    NotifyItem.DFN := ADFN;
1469    NotifyItem.FollowUp := AFollowUp;
1470    NotifyItem.RecordID := ARecordId;
1471    If AHighLightSection <> '' then NotifyItem.HighLightSection := AHighLightSection;
1472    FList.Add(NotifyItem);
1473    FActive := True;
1474  end;
1475  
1476  procedure TNotifications.Clear;
1477  var
1478    i: Integer;
1479  begin
1480    with FList do for i := 0 to Count - 1 do with TNotifyItem(Items[i]) do Free;
1481    FList.Clear;
1482    FActive := False;
1483    FCurrentIndex := -1;
1484    FNotifyItem := nil;
1485    FNotifIndOrders := False;
1486  end;
1487  
1488  function TNotifications.GetDFN: string;  //*DFN*
1489  begin
1490    if FNotifyItem <> nil then Result := FNotifyItem.DFN else Result := '';  //*DFN*
1491  end;
1492  
1493  function TNotifications.GetFollowUp: Integer;
1494  begin
1495    if FNotifyItem <> nil then Result := FNotifyItem.FollowUp else Result := 0;
1496  end;
1497  
1498  function TNotifications.GetAlertData: string;
1499  begin
1500    if FNotifyItem <> nil
1501      then Result := GetXQAData(Piece(FNotifyItem.RecordID, U, 2))
1502      else Result := '';
1503  end;
1504  
1505  function TNotifications.GetRecordID: string;
1506  begin
1507    if FNotifyItem <> nil then Result := FNotifyItem.RecordID else Result := '';
1508  end;
1509  
1510  function TNotifications.GetText: string;
1511  begin
1512    if FNotifyItem <> nil
1513      then Result := Piece(Piece(FNotifyItem.RecordID, U, 1 ), ':', 2)
1514      else Result := '';
1515  end;
1516  
1517  function TNotifications.GetHighLightSection: String; //CB
1518  begin
1519    if FNotifyItem <> nil then Result := FNotifyItem.HighLightSection else Result := '';
1520  end;
1521  
1522  function TNotifications.GetIndOrderDisplay: Boolean;
1523  begin
1524    Result := FNotifIndOrders;
1525  end;
1526  
1527  procedure TNotifications.SetIndOrderDisplay(Value: Boolean);
1528  begin
1529    FNotifIndOrders := Value;
1530  end;
1531  
1532  procedure TNotifications.Next;
1533  begin
1534    Inc(FCurrentIndex);
1535    if FCurrentIndex < FList.Count then FNotifyItem := TNotifyItem(FList[FCurrentIndex]) else
1536    begin
1537      FActive := False;
1538      FNotifyItem := nil;
1539    end;
1540  end;
1541  
1542  procedure TNotifications.Prior;
1543  begin
1544    Dec(FCurrentIndex);
1545    if FCurrentIndex < 0
1546      then FNotifyItem := nil
1547      else FNotifyItem := TNotifyItem(FList[FCurrentIndex]);
1548    if FList.Count > 0 then FActive := True;
1549  end;
1550  
1551  procedure TNotifications.Delete;
1552  begin
1553    if FNotifyItem <> nil then DeleteAlert(Piece(FNotifyItem.RecordID, U, 2));
1554  end;
1555  
1556  procedure TNotifications.DeleteForCurrentUser;
1557  begin
1558    if FNotifyItem <> nil then DeleteAlertForUser(Piece(FNotifyItem.RecordID, U, 2));
1559  end;
1560  
1561  { TRemoteSite methods ---------------------------------------------------------------------------- }
1562  
1563  constructor TRemoteSite.Create(ASite: string);
1564  begin
1565    FSiteID   := Piece(ASite, U, 1);
1566    FSiteName := MixedCase(Piece(ASite, U, 2));
1567    FLastDate := StrToFMDateTime(Piece(ASite, U, 3));
1568    FSelected := False;
1569    FQueryStatus := '';
1570    FData := TStringList.Create;
1571    FLabQueryStatus := '';
1572    FLabData := TStringList.Create;
1573    FCurrentLabQuery := '';
1574    FCurrentReportQuery := '';
1575  end;
1576  
1577  destructor TRemoteSite.Destroy;
1578  begin
1579    LabClear;
1580    ReportClear;
1581    FData.Free;
1582    FLabData.Free;
1583    inherited Destroy;
1584  end;
1585  
1586  procedure TRemoteSite.ReportClear;
1587  begin
1588    FData.Clear;
1589    FQueryStatus := '';
1590  end;
1591  
1592  procedure TRemoteSite.LabClear;
1593  begin
1594    FLabData.Clear;
1595    FLabQueryStatus := '';
1596  end;
1597  
1598  procedure TRemoteSite.SetSelected(Value: boolean);
1599  begin
1600    FSelected := Value;
1601  end;
1602  
1603  constructor TRemoteReport.Create(AReport: string);
1604  begin
1605    FReport   := AReport;
1606    FHandle := '';
1607  end;
1608  
1609  destructor TRemoteReport.Destroy;
1610  begin
1611    inherited Destroy;
1612  end;
1613  
1614  constructor TRemoteReportList.Create;
1615  begin
1616    FReportList := TList.Create;
1617    FCount := 0;
1618  end;
1619  
1620  destructor TRemoteReportList.Destroy;
1621  begin
1622    //Clear;
1623    FReportList.Free;
1624    inherited Destroy;
1625  end;
1626  
1627  procedure TRemoteReportList.Add(AReportList, AHandle: string);
1628  var
1629    ARemoteReport: TRemoteReport;
1630  begin
1631    ARemoteReport := TRemoteReport.Create(AReportList);
1632    ARemoteReport.Handle := AHandle;
1633    ARemoteReport.Report := AReportList;
1634    FReportList.Add(ARemoteReport);
1635    FCount := FReportList.Count;
1636  end;
1637  
1638  procedure TRemoteReportList.Clear;
1639  var
1640    i: Integer;
1641  begin
1642    with FReportList do
1643      for i := 0 to Count - 1 do
1644        with TRemoteReport(Items[i]) do Free;
1645    FReportList.Clear;
1646    FCount := 0;
1647  end;
1648  
1649  constructor TRemoteSiteList.Create;
1650  begin
1651    FSiteList := TList.Create;
1652    FCount := 0;
1653  end;
1654  
1655  destructor TRemoteSiteList.Destroy;
1656  begin
1657    Clear;
1658    FSiteList.Free;
1659    inherited Destroy;
1660  end;
1661  
1662  procedure TRemoteSiteList.Add(ASite: string);
1663  var
1664    ARemoteSite: TRemoteSite;
1665  begin
1666    ARemoteSite := TRemoteSite.Create(ASite);
1667    FSiteList.Add(ARemoteSite);
1668    FCount := FSiteList.Count;
1669  end;
1670  
1671  procedure TRemoteSiteList.Clear;
1672  var
1673    i: Integer;
1674  begin
1675    with FSiteList do for i := 0 to Count - 1 do with TRemoteSite(Items[i]) do Free;
1676    FSiteList.Clear;
1677    FCount := 0;
1678  end;
1679  
1680  procedure TRemoteSiteList.ChangePatient(const DFN: string);
1681  var
1682    ALocations: TStringList;
1683    i: integer;
1684  begin
1685    Clear;
1686    ALocations := TStringList.Create;
1687    try
1688      FRemoteDataExists := HasRemoteData(DFN, ALocations);
1689      if FRemoteDataExists then
1690        begin
1691          SortByPiece(ALocations, '^', 2);
1692          for i := 0 to ALocations.Count - 1 do
1693            if piece(ALocations[i],'^',5) = '1' then
1694              Add(ALocations.Strings[i]);
1695          FNoDataReason := '';
1696        end
1697      else
1698        FNoDataReason := Piece(ALocations[0], U, 2);
1699      FCount := FSiteList.Count;
1700    finally
1701      ALocations.Free;
1702    end;
1703  end;
1704  
1705  procedure TUser.SetCurrentPrinter(Value: string);
1706  begin
1707    FCurrentPrinter := Value;
1708  end;
1709  
1710  procedure GotoWebPage(const URL: WideString);
1711  begin
1712    if(URLMonHandle <> 0) then
1713      HlinkNav(nil, PWideChar(URL));
1714  end;
1715  
1716  function subtractMinutesFromDateTime(Time1 : TDateTime;Minutes : extended) : TDateTime;
1717  var
1718    TimeMinutes : TDateTime;
1719  const
1720    MinutesPerDay = 60 * 24;
1721  begin
1722    TimeMinutes := Minutes / MinutesPerDay;
1723    result := time1 - TimeMinutes;
1724  end;
1725  
1726  procedure LoadURLMon;
1727  const
1728    UrlMonLib = 'URLMON.DLL';
1729    HlinkName = 'HlinkNavigateString';
1730  
1731  begin
1732    URLMonHandle := LoadLibrary(PChar(UrlMonLib));
1733    if URLMonHandle <= HINSTANCE_ERROR then
1734      URLMonHandle := 0
1735    else
1736    begin
1737      HlinkNav := GetProcAddress(URLMonHandle, HlinkName);
1738      if(not assigned(HlinkNav)) then
1739      begin
1740        FreeLibrary(URLMonHandle);
1741        URLMonHandle := 0;
1742      end;
1743    end;
1744  end;
1745  
1746  procedure ReleaseURLMon;
1747  begin
1748    if(URLMonHandle <> 0) then
1749    begin
1750      FreeLibrary(URLMonHandle);
1751      URLMonHandle := 0;
1752    end;
1753  end;
1754  
1755  procedure TChanges.ReplaceODGrpName(const AnODID, NewGrp: string);
1756  var
1757    ChangeList: TList;
1758    i: Integer;
1759  begin
1760    ChangeList := fOrders;
1761    if ChangeList <> nil then with ChangeList do
1762      for i := 0 to Count - 1 do if TChangeItem(Items[i]).ID = AnODID then
1763        TChangeItem(Items[i]).FGroupName := NewGrp;
1764  end;
1765  
1766  procedure TChanges.ChangeOrderGrp(const oldGrpName,newGrpName: string);
1767  var
1768    i : integer;
1769  begin
1770    for i := 0 to FOrderGrp.Count - 1 do
1771    begin
1772      if AnsiCompareText(FOrderGrp[i],oldGrpName)= 0 then
1773        FOrderGrp[i] := newGrpName;
1774    end;
1775  end;
1776  
1777  initialization
1778    uVistaMsg := 0;
1779    LoadURLMon;
1780  
1781  finalization
1782    ReleaseURLMon;
1783    ReleaseAppNotification;
1784  
1785  end.

Module Calls (2 levels)


uCore
 ├rCore
 │ └uCore...
 ├uConst
 ├uCombatVet
 ├rTIU
 │ ├rCore...
 │ ├uCore...
 │ ├uConst
 │ ├uTIU
 │ └rMisc
 ├rOrders
 │ ├uCore...
 │ ├rCore...
 │ ├uConst
 │ ├UBAGlobals
 │ └UBACore
 ├rConsults
 │ ├rCore...
 │ ├uCore...
 │ ├uConsults
 │ └uTIU
 └uOrders
   ├uConst
   ├rConsults...
   ├rOrders...
   ├fODBase
   ├XuDsigS
   ├fODDiet
   ├fODMisc
   ├fODGen
   ├fODMedIn
   ├fODMedOut
   ├fODText
   ├fODConsult
   ├fODProc
   ├fODRad
   ├fODLab
   ├fODBBank
   ├fODMeds
   ├fODMedIV
   ├fODVitals
   ├fODAuto
   ├fOMNavA
   ├rCore...
   ├uCore...
   ├fFrame
   ├fEncnt
   ├fOMVerify
   ├fOrderSaveQuick
   ├fOMSet
   ├rMisc...
   ├uODBase
   ├rODMeds
   ├fLkUpLocation
   ├fOrdersPrint
   ├fOMAction
   ├fARTAllgy
   ├fOMHTML
   ├fOrders
   ├rODBase
   ├fODChild
   ├fMeds
   ├rMeds
   ├rPCE
   ├fRptBox
   ├fODMedNVA
   ├fODChangeUnreleasedRenew
   ├rODAllergy
   ├UBAGlobals...
   └uTemplateFields

Module Called-By (2 levels)


                          uCore
                      rOrders┤ 
                      fPage┤ │ 
                   uCore...┤ │ 
                    uOrders┤ │ 
                    fODBase┤ │ 
                    rODBase┤ │ 
                 UBAGlobals┤ │ 
                    UBACore┤ │ 
                     fFrame┤ │ 
                    fOrders┤ │ 
                  fOCAccept┤ │ 
               fOCMonograph┤ │ 
                    uODBase┤ │ 
          fBALocalDiagnoses┤ │ 
                     fCover┤ │ 
                fOrdersSign┤ │ 
                      fMeds┤ │ 
                   fProbEdt┤ │ 
                  fConsults┤ │ 
            fReminderDialog┤ │ 
                      fLabs┤ │ 
                    fReview┤ │ 
               fCSRemaining┤ │ 
                 uSignItems┤ │ 
                  fODDietLT┤ │ 
                    rODDiet┤ │ 
               fOrdersPrint┤ │ 
              fDefaultEvent┤ │ 
               fOrdersRenew┤ │ 
                    fODDiet┤ │ 
                   fOrderVw┤ │ 
                  fOrdersDC┤ │ 
                  fOrdersCV┤ │ 
                     fODGen┤ │ 
                   fODMedIn┤ │ 
                  fODMedOut┤ │ 
                fConsultAct┤ │ 
                     fODRad┤ │ 
                     fODLab┤ │ 
                   fODBBank┤ │ 
                    fODMeds┤ │ 
                    fODAuto┤ │ 
                    fOMNavA┤ │ 
            fOrderSaveQuick┤ │ 
                     fOMSet┤ │ 
                fOrdersHold┤ │ 
              fOrdersUnhold┤ │ 
               fOrdersAlert┤ │ 
                 fOrderFlag┤ │ 
               fOrderUnflag┤ │ 
             fOrdersRelease┤ │ 
                    fOMHTML┤ │ 
                  fODMedNVA┤ │ 
   fODChangeUnreleasedRenew┤ │ 
             fOrdersOnChart┤ │ 
         fOrdersEvntRelease┤ │ 
            fOrdersComplete┤ │ 
              fOrdersVerify┤ │ 
              fOrderComment┤ │ 
            fODReleaseEvent┤ │ 
                 fOCSession┤ │ 
                  fOrdersTS┤ │ 
                 mEvntDelay┤ │ 
                  fODActive┤ │ 
                fOrdersCopy┤ │ 
                   fMedCopy┤ │ 
        fActivateDeactivate┤ │ 
              fOrdersRefill┤ │ 
           fODChangeEvtDisp┤ │ 
               fRenewOutMed┘ │ 
                        rCore┤ 
                 rOrders...┤ │ 
                   uCore...┤ │ 
                       rTIU┤ │ 
                  rConsults┤ │ 
                 uOrders...┤ │ 
                 fODBase...┤ │ 
              UBAGlobals...┤ │ 
                 UBACore...┤ │ 
                  fFrame...┤ │ 
                 fOrders...┤ │ 
                 uTemplates┤ │ 
            uTemplateFields┤ │ 
                 uReminders┤ │ 
                       uPCE┤ │ 
       fBALocalDiagnoses...┤ │ 
                       rPCE┤ │ 
            fEncounterFrame┤ │ 
                 fVisitType┤ │ 
                 fProcedure┤ │ 
                    uVitals┤ │ 
                     uProbs┤ │ 
                    fVitals┤ │ 
                     fPtSel┤ │ 
             fOrdersSign...┤ │ 
             fPrintLocation┤ │ 
                  fARTAllgy┤ │ 
                 rODAllergy┤ │ 
                     fNotes┤ │ 
                   uDocTree┤ │ 
             fConsult513Prt┤ │ 
                   rReports┤ │ 
                   fReports┤ │ 
                       rECS┤ │ 
                     fVisit┤ │ 
                   rOptions┤ │ 
                     fEncnt┤ │ 
                     fProbs┤ │ 
                fProbEdt...┤ │ 
                   fProbflt┤ │ 
                   fProbLex┤ │ 
                   fProbCmt┤ │ 
              fReportsPrint┤ │ 
                    fGraphs┤ │ 
             fGraphProfiles┤ │ 
               fConsults...┤ │ 
               fPCEProvider┤ │ 
              fDeviceSelect┤ │ 
                    fDCSumm┤ │ 
                    rDCSumm┤ │ 
                     uSpell┤ │ 
         fReminderDialog...┤ │ 
                   fLabs...┤ │ 
                  fLabPrint┤ │ 
                 fReview...┤ │ 
            fClinicWardMeds┤ │ 
                 rReminders┤ │ 
        fBAOptionsDiagnoses┤ │ 
               fODDietLT...┤ │ 
                 rODDiet...┤ │ 
                   fSurgery┤ │ 
               fSurgeryView┤ │ 
                   rSurgery┤ │ 
                fPtSelOptns┤ │ 
                fPtSelDemog┤ │ 
              fAlertForward┤ │ 
            fOrdersRenew...┤ │ 
                 fODDiet...┤ │ 
              fLkUpLocation┤ │ 
                  fODGen...┤ │ 
                    fODText┤ │ 
                 fODConsult┤ │ 
                 fConsultBD┤ │ 
                  fSignItem┤ │ 
              fConsultsView┤ │ 
             fConsultAct...┤ │ 
                    fODProc┤ │ 
               fAddlSigners┤ │ 
                 fNoteProps┤ │ 
                    fNoteBA┤ │ 
                    fNoteBD┤ │ 
                   fNotePrt┤ │ 
                   fTIUView┤ │ 
               fDCSummProps┤ │ 
                  fEditProc┤ │ 
               fEditConsult┤ │ 
               fConsMedRslt┤ │ 
            fConsultAlertTo┤ │ 
              fNoteCPFields┤ │ 
                  fODRad...┤ │ 
                  fODLab...┤ │ 
                fODBBank...┤ │ 
                 fODMeds...┤ │ 
                   fODMedIV┤ │ 
            fOrdersAlert...┤ │ 
              fOrderFlag...┤ │ 
               fODMedNVA...┤ │ 
         fOrdersComplete...┤ │ 
           fOrdersVerify...┤ │ 
                fMedCopy...┤ │ 
                       fGAF┤ │ 
             fRemCoverSheet┤ │ 
                   fPCEEdit┤ │ 
          fOptionsSurrogate┤ │ 
                   uOptions┤ │ 
   fOptionsPatientSelection┤ │ 
              fOptionsLists┤ │ 
              fOptionsTeams┤ │ 
       fOptionsCombinations┤ │ 
              fOptionsOther┤ │ 
      fOptionsReportsCustom┤ │ 
     fOptionsReportsDefault┤ │ 
                       fvit┤ │ 
                   fODAllgy┘ │ 
                      rTIU...┤ 
                 rConsults...┤ 
                   uOrders...┤ 
                   fODBase...┤ 
                   rODBase...┤ 
                UBAGlobals...┤ 
                   UBACore...┤ 
                    fFrame...┤ 
                     fTimeout┤ 
                      uInit┘ │ 
                      rODMeds┤ 
                 uOrders...┤ │ 
                 fODMedOIFA┤ │ 
                 fOrders...┤ │ 
             fOrdersSign...┤ │ 
                 fReview...┤ │ 
            fOrdersRenew...┤ │ 
             fOtherSchedule┤ │ 
                  fIVRoutes┤ │ 
                 fODMeds...┤ │ 
                fODMedIV...┤ │ 
                 fODAuto...┤ │ 
                  fOMSet...┤ │ 
               fODMedNVA...┤ │ 
fODChangeUnreleasedRenew...┤ │ 
            fRenewOutMed...┘ │ 
                   fOrders...┤ 
                      dShared┤ 
                  CPRSChart┤ │ 
                 uODBase...┤ │ 
              uTemplates...┤ │ 
                   fDrawers┤ │ 
            fTemplateDialog┤ │ 
              uReminders...┤ │ 
                  fNotes...┤ │ 
                fReports...┤ │ 
               fConsults...┤ │ 
                 fDCSumm...┤ │ 
            fTemplateEditor┤ │ 
                fSurgery...┤ │ 
           fTemplateObjects┤ │ 
           fTemplateAutoGen┘ │ 
                uTemplates...┤ 
                   rTemplates┤ 
                  fFrame...┤ │ 
                 uODBase...┤ │ 
                 dShared...┤ │ 
              uTemplates...┤ │ 
                fDrawers...┤ │ 
         uTemplateFields...┤ │ 
              uReminders...┤ │ 
                  fNotes...┤ │ 
               fConsults...┤ │ 
                 fDCSumm...┤ │ 
         fTemplateEditor...┤ │ 
                fSurgery...┤ │ 
       fTemplateFieldEditor┤ │ 
            fTemplateFields┤ │ 
                 fODAuto...┤ │ 
        fTemplateAutoGen...┘ │ 
           uTemplateFields...┤ 
               uDlgComponents┤ 
         fTemplateDialog...┤ │ 
         uTemplateFields...┤ │ 
              uReminders...┤ │ 
                    fMHTest┤ │ 
    uVA508CPRSCompatibility┤ │ 
       mTemplateFieldButton┘ │ 
                uReminders...┤ 
                      uPCE...┤ 
         fBALocalDiagnoses...┤ 
                      fPCELex┤ 
       fBALocalDiagnoses...┤ │ 
                 fDiagnoses┤ │ 
               fPCEBaseMain┤ │ 
     fBAOptionsDiagnoses...┤ │ 
              fODConsult...┤ │ 
                 fODProc...┤ │ 
               fEditProc...┤ │ 
            fEditConsult...┘ │ 
                      rPCE...┤ 
           fEncounterFrame...┤ 
                fVisitType...┤ 
                fDiagnoses...┤ 
                   fEncVitals┤ 
         fEncounterFrame...┘ │ 
                   uVitals...┤ 
                    uProbs...┤ 
                       rProbs┤ 
                 fPCELex...┤ │ 
              fDiagnoses...┤ │ 
                  fProbs...┤ │ 
                fProbEdt...┤ │ 
                fProbflt...┤ │ 
                fProbLex...┤ │ 
          fRemCoverSheet...┘ │ 
                   fVitals...┤ 
                    fCover...┤ 
                       rCover┤ 
                  fCover...┤ │ 
                  fAllgyBox┤ │ 
               fARTAllgy...┤ │ 
                  fProbs...┤ │ 
                    fPtDemo┤ │ 
                    fPtCWAD┤ │ 
          fPatientFlagMulti┤ │ 
                   fODAllgy┘ │ 
                    fPtSelMsg┤ 
                  fFrame...┘ │ 
                    fPtSel...┤ 
               fOrdersSign...┤ 
            fPrintLocation...┤ 
                     fMeds...┤ 
                        rMeds┤ 
                 uOrders...┤ │ 
                 fOrders...┤ │ 
                  rCover...┤ │ 
                   fMeds...┤ │ 
     fActivateDeactivate...┤ │ 
           fOrdersRefill...┘ │ 
                 fARTAllgy...┤ 
                rODAllergy...┤ 
                    fNotes...┤ 
                  uDocTree...┤ 
            fConsult513Prt...┤ 
                  rReports...┤ 
                  fReports...┤ 
                      rECS...┤ 
                       fVisit┤ 
                    fEncnt...┤ 
                    fProbs...┤ 
                  fProbEdt...┤ 
                  fProbLex...┤ 
             fReportsPrint...┤ 
                   fGraphs...┤ 
                   fGraphData┤ 
                  fFrame...┤ │ 
                fReports...┤ │ 
                 fGraphs...┤ │ 
             fGraphSettings┤ │ 
          fGraphProfiles...┘ │ 
            fGraphProfiles...┤ 
                 fGraphOthers┤ 
                 fGraphs...┤ │ 
          fGraphProfiles...┘ │ 
                        rLabs┤ 
            fGraphOthers...┤ │ 
                   fLabs...┤ │ 
                   fLabTest┤ │ 
                  fLabTests┤ │ 
             fLabTestGroups┤ │ 
               fLabPrint...┤ │ 
                   fLabInfo┘ │ 
                 fConsults...┤ 
              fPCEProvider...┤ 
             fDeviceSelect...┤ 
                   fDCSumm...┤ 
                   rDCSumm...┤ 
           fTemplateEditor...┤ 
                  uEventHooks┤ 
                  CPRSChart┤ │ 
                 fODBase...┤ │ 
                  fFrame...┤ │ 
                 dShared...┤ │ 
              uTemplates...┘ │ 
           fReminderDialog...┤ 
                   fMHTest...┤ 
                     fLabs...┤ 
            fLabTestGroups...┤ 
                 fLabPrint...┤ 
                   fPtDemo...┤ 
                   fPtCWAD...┤ 
                   fReview...┤ 
           fClinicWardMeds...┤ 
              fCSRemaining...┤ 
                rReminders...┤ 
                     fOptions┤ 
                  fFrame...┘ │ 
       fBAOptionsDiagnoses...┤ 
                uSignItems...┤ 
                 fODDietLT...┤ 
                   rODDiet...┤ 
              fOrdersPrint...┤ 
                  fSurgery...┤ 
                  rSurgery...┤ 
   uVA508CPRSCompatibility...┤ 
                fDefaultEvent┤ 
         fPatientFlagMulti...┤ 
              fOrdersRenew...┤ 
                   fODDiet...┤ 
                 fOrdersDC...┤ 
                 fOrdersCV...┤ 
                 fODMedOut...┤ 
                fODConsult...┤ 
                   fConsultBS┤ 
               fConsults...┘ │ 
             fConsultsView...┤ 
               fConsultAct...┤ 
                   fODProc...┤ 
                    fCsltNote┤ 
               fConsults...┘ │ 
                fNoteProps...┤ 
                   fNoteBA...┤ 
                  fNotePrt...┤ 
                  fTIUView...┤ 
              fDCSummProps...┤ 
                 fEditProc...┤ 
              fEditConsult...┤ 
              fConsMedRslt...┤ 
             fNoteCPFields...┤ 
                   fCombatVet┤ 
                  fFrame...┘ │ 
                    fODRad...┤ 
                    fODLab...┤ 
                       rODLab┤ 
             fOrdersSign...┤ │ 
                 fReview...┤ │ 
                  fODLab...┤ │ 
              fODLabOthSpec┤ │ 
            fODLabImmedColl┤ │ 
              fLabCollTimes┤ │ 
                fODBBank...┤ │ 
          fOrdersRelease...┤ │ 
          fOrdersOnChart...┤ │ 
         fODReleaseEvent...┘ │ 
             fLabCollTimes...┤ 
                  fODBBank...┤ 
                   fODMeds...┤ 
                  fODMedIV...┤ 
                   fODAuto...┤ 
            fOrdersRelease...┤ 
                   fOMHTML...┤ 
                 fODMedNVA...┤ 
            fOrdersOnChart...┤ 
        fOrdersEvntRelease...┤ 
           fODReleaseEvent...┤ 
                fOCSession...┤ 
                 fOrdersTS...┤ 
                mEvntDelay...┤ 
                 fODActive...┤ 
               fOrdersCopy...┤ 
                  fMedCopy...┤ 
                      fGAF...┤ 
            fRemCoverSheet...┤ 
                  fPCEEdit...┤ 
     fOptionsReportsCustom...┤ 
    fOptionsReportsDefault...┤ 
                      fvit...┤ 
                     fODAllgy┘