1 | unit uEventHooks;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses SysUtils, Classes, Windows, Dialogs, Forms, ComObj, ActiveX,
|
---|
6 | CPRSChart_TLB, ORNet, ORFn, uCore;
|
---|
7 |
|
---|
8 | type
|
---|
9 | TCPRSExtensionData = record
|
---|
10 | Data1: string;
|
---|
11 | Data2: string;
|
---|
12 | end;
|
---|
13 |
|
---|
14 | procedure RegisterCPRSTypeLibrary;
|
---|
15 | procedure ProcessPatientChangeEventHook;
|
---|
16 | function ProcessOrderAcceptEventHook(OrderID: string; DisplayGroup: integer): boolean;
|
---|
17 | procedure GetCOMObjectText(COMObject: integer; const Param2, Param3: string;
|
---|
18 | var Data1, Data2: string);
|
---|
19 | function COMObjectOK(COMObject: integer): boolean;
|
---|
20 | function COMObjectActive: boolean;
|
---|
21 |
|
---|
22 | implementation
|
---|
23 |
|
---|
24 | uses
|
---|
25 | Trpcb, rEventHooks, VAUtils;
|
---|
26 |
|
---|
27 | type
|
---|
28 | ICPRSBrokerInitializer = interface(ICPRSBroker)
|
---|
29 | procedure Initialize;
|
---|
30 | end;
|
---|
31 |
|
---|
32 | TCPRSBroker = class(TAutoIntfObject, ICPRSBrokerInitializer)
|
---|
33 | private
|
---|
34 | FContext: string;
|
---|
35 | FRPCVersion: string;
|
---|
36 | FClearParameters: boolean;
|
---|
37 | FClearResults: boolean;
|
---|
38 | FResults: string;
|
---|
39 | FParam: TParams;
|
---|
40 | FEmptyParams: TParams;
|
---|
41 | public
|
---|
42 | constructor Create;
|
---|
43 | destructor Destroy; override;
|
---|
44 | procedure Initialize;
|
---|
45 | function SetContext(const Context: WideString): WordBool; safecall;
|
---|
46 | function Server: WideString; safecall;
|
---|
47 | function Port: Integer; safecall;
|
---|
48 | function DebugMode: WordBool; safecall;
|
---|
49 | function Get_RPCVersion: WideString; safecall;
|
---|
50 | procedure Set_RPCVersion(const Value: WideString); safecall;
|
---|
51 | function Get_ClearParameters: WordBool; safecall;
|
---|
52 | procedure Set_ClearParameters(Value: WordBool); safecall;
|
---|
53 | function Get_ClearResults: WordBool; safecall;
|
---|
54 | procedure Set_ClearResults(Value: WordBool); safecall;
|
---|
55 | procedure CallRPC(const RPCName: WideString); safecall;
|
---|
56 | function Get_Results: WideString; safecall;
|
---|
57 | procedure Set_Results(const Value: WideString); safecall;
|
---|
58 | function Get_Param(Index: Integer): WideString; safecall;
|
---|
59 | procedure Set_Param(Index: Integer; const Value: WideString); safecall;
|
---|
60 | function Get_ParamType(Index: Integer): BrokerParamType; safecall;
|
---|
61 | procedure Set_ParamType(Index: Integer; Value: BrokerParamType); safecall;
|
---|
62 | function Get_ParamList(Index: Integer; const Node: WideString): WideString; safecall;
|
---|
63 | procedure Set_ParamList(Index: Integer; const Node: WideString; const Value: WideString); safecall;
|
---|
64 | function ParamCount: Integer; safecall;
|
---|
65 | function ParamListCount(Index: Integer): Integer; safecall;
|
---|
66 | property RPCVersion: WideString read Get_RPCVersion write Set_RPCVersion;
|
---|
67 | property ClearParameters: WordBool read Get_ClearParameters write Set_ClearParameters;
|
---|
68 | property ClearResults: WordBool read Get_ClearResults write Set_ClearResults;
|
---|
69 | property Results: WideString read Get_Results write Set_Results;
|
---|
70 | property Param[Index: Integer]: WideString read Get_Param write Set_Param;
|
---|
71 | property ParamType[Index: Integer]: BrokerParamType read Get_ParamType write Set_ParamType;
|
---|
72 | property ParamList[Index: Integer; const Node: WideString]: WideString read Get_ParamList write Set_ParamList;
|
---|
73 | end;
|
---|
74 |
|
---|
75 | TCPRSState = class(TAutoIntfObject, ICPRSState)
|
---|
76 | private
|
---|
77 | FHandle: string;
|
---|
78 | public
|
---|
79 | constructor Create;
|
---|
80 | function Handle: WideString; safecall;
|
---|
81 | function UserDUZ: WideString; safecall;
|
---|
82 | function UserName: WideString; safecall;
|
---|
83 | function PatientDFN: WideString; safecall;
|
---|
84 | function PatientName: WideString; safecall;
|
---|
85 | function PatientDOB: WideString; safecall;
|
---|
86 | function PatientSSN: WideString; safecall;
|
---|
87 | function LocationIEN: Integer; safecall;
|
---|
88 | function LocationName: WideString; safecall;
|
---|
89 | end;
|
---|
90 |
|
---|
91 | TCPRSEventHookManager = class(TObject)
|
---|
92 | private
|
---|
93 | FCPRSBroker: ICPRSBrokerInitializer;
|
---|
94 | FCPRSState: ICPRSState;
|
---|
95 | FErrors: TStringList;
|
---|
96 | FLock: TRTLCriticalSection;
|
---|
97 | public
|
---|
98 | constructor Create;
|
---|
99 | destructor Destroy; override;
|
---|
100 | function ProcessComObject(const GUIDString: string;
|
---|
101 | const AParam2, AParam3: string;
|
---|
102 | var Data1, Data2: WideString): boolean;
|
---|
103 | procedure EnterCriticalSection;
|
---|
104 | procedure LeaveCriticalSection;
|
---|
105 | end;
|
---|
106 |
|
---|
107 |
|
---|
108 | var
|
---|
109 | uCPRSEventHookManager: TCPRSEventHookManager = nil;
|
---|
110 | uCOMObjectActive: boolean = False;
|
---|
111 |
|
---|
112 | procedure EnsureEventHookObjects;
|
---|
113 | begin
|
---|
114 | if not assigned(uCPRSEventHookManager) then
|
---|
115 | uCPRSEventHookManager := TCPRSEventHookManager.Create;
|
---|
116 | end;
|
---|
117 |
|
---|
118 | { TCPRSBroker }
|
---|
119 |
|
---|
120 | constructor TCPRSBroker.Create;
|
---|
121 | var
|
---|
122 | CPRSLib: ITypeLib;
|
---|
123 |
|
---|
124 | begin
|
---|
125 | FParam := TParams.Create(nil);
|
---|
126 | FEmptyParams := TParams.Create(nil);
|
---|
127 | OleCheck(LoadRegTypeLib(LIBID_CPRSChart, 1, 0, 0, CPRSLib));
|
---|
128 | inherited Create(CPRSLib, ICPRSBroker);
|
---|
129 | EnsureBroker;
|
---|
130 | end;
|
---|
131 |
|
---|
132 | procedure TCPRSBroker.CallRPC(const RPCName: WideString);
|
---|
133 | var
|
---|
134 | err: boolean;
|
---|
135 | tmpRPCVersion: string;
|
---|
136 | tmpClearParameters: boolean;
|
---|
137 | tmpClearResults: boolean;
|
---|
138 | tmpResults: string;
|
---|
139 | tmpParam: TParams;
|
---|
140 |
|
---|
141 | begin
|
---|
142 | EnsureEventHookObjects;
|
---|
143 | uCPRSEventHookManager.EnterCriticalSection;
|
---|
144 | try
|
---|
145 | err := (FContext = '');
|
---|
146 | if(not err) then
|
---|
147 | err := not UpdateContext(FContext);
|
---|
148 | if (not err) then
|
---|
149 | err := IsBaseContext;
|
---|
150 | if err then
|
---|
151 | raise EOleException.Create('Invalid Broker Context', OLE_E_FIRST, Application.ExeName ,'', 0)
|
---|
152 | else
|
---|
153 | begin
|
---|
154 | if RPCName <> '' then
|
---|
155 | begin
|
---|
156 | tmpRPCVersion := RPCBrokerV.RpcVersion;
|
---|
157 | tmpClearParameters := RPCBrokerV.ClearParameters;
|
---|
158 | tmpClearResults := RPCBrokerV.ClearResults;
|
---|
159 | tmpResults := RPCBrokerV.Results.Text;
|
---|
160 | tmpParam := TParams.Create(nil);
|
---|
161 | try
|
---|
162 | RPCBrokerV.RemoteProcedure := RPCName;
|
---|
163 | RPCBrokerV.RpcVersion := FRPCVersion;
|
---|
164 | RPCBrokerV.ClearParameters := FClearParameters;
|
---|
165 | RPCBrokerV.ClearResults := FClearResults;
|
---|
166 | RPCBrokerV.Param.Assign(FParam);
|
---|
167 | CallBrokerInContext;
|
---|
168 | FParam.Assign(RPCBrokerV.Param);
|
---|
169 | FResults := RPCBrokerV.Results.Text;
|
---|
170 | finally
|
---|
171 | RPCBrokerV.RpcVersion := tmpRPCVersion;
|
---|
172 | RPCBrokerV.ClearParameters := tmpClearParameters;
|
---|
173 | RPCBrokerV.ClearResults := tmpClearResults;
|
---|
174 | RPCBrokerV.Results.Text := tmpResults;
|
---|
175 | RPCBrokerV.Param.Assign(tmpParam);
|
---|
176 | tmpParam.Free;
|
---|
177 | end;
|
---|
178 | end
|
---|
179 | else
|
---|
180 | begin
|
---|
181 | RPCBrokerV.Results.Clear;
|
---|
182 | FResults := '';
|
---|
183 | end;
|
---|
184 | end;
|
---|
185 | finally
|
---|
186 | uCPRSEventHookManager.LeaveCriticalSection;
|
---|
187 | end;
|
---|
188 | end;
|
---|
189 |
|
---|
190 | function TCPRSBroker.DebugMode: WordBool;
|
---|
191 | begin
|
---|
192 | Result := RPCBrokerV.DebugMode;
|
---|
193 | end;
|
---|
194 |
|
---|
195 | function TCPRSBroker.Get_ClearParameters: WordBool;
|
---|
196 | begin
|
---|
197 | Result := FClearParameters;
|
---|
198 | end;
|
---|
199 |
|
---|
200 | function TCPRSBroker.Get_ClearResults: WordBool;
|
---|
201 | begin
|
---|
202 | Result := FClearResults;
|
---|
203 | end;
|
---|
204 |
|
---|
205 | function TCPRSBroker.Get_Param(Index: Integer): WideString;
|
---|
206 | begin
|
---|
207 | Result := FParam[Index].Value;
|
---|
208 | end;
|
---|
209 |
|
---|
210 | function TCPRSBroker.Get_ParamList(Index: Integer;
|
---|
211 | const Node: WideString): WideString;
|
---|
212 | begin
|
---|
213 | Result := FParam[Index].Mult[Node];
|
---|
214 | end;
|
---|
215 |
|
---|
216 | function TCPRSBroker.Get_ParamType(Index: Integer): BrokerParamType;
|
---|
217 | begin
|
---|
218 | case FParam[Index].PType of
|
---|
219 | literal: Result := bptLiteral;
|
---|
220 | reference: Result := bptReference;
|
---|
221 | list: Result := bptList;
|
---|
222 | else Result := bptUndefined;
|
---|
223 | end;
|
---|
224 | end;
|
---|
225 |
|
---|
226 | function TCPRSBroker.Get_Results: WideString;
|
---|
227 | begin
|
---|
228 | Result := FResults;
|
---|
229 | end;
|
---|
230 |
|
---|
231 | function TCPRSBroker.Get_RPCVersion: WideString;
|
---|
232 | begin
|
---|
233 | Result := FRPCVersion;
|
---|
234 | end;
|
---|
235 |
|
---|
236 | function TCPRSBroker.ParamCount: Integer;
|
---|
237 | begin
|
---|
238 | Result := FParam.Count;
|
---|
239 | end;
|
---|
240 |
|
---|
241 | function TCPRSBroker.ParamListCount(Index: Integer): Integer;
|
---|
242 | begin
|
---|
243 | Result := FParam[Index].Mult.Count;
|
---|
244 | end;
|
---|
245 |
|
---|
246 | function TCPRSBroker.Port: Integer;
|
---|
247 | begin
|
---|
248 | Result := RPCBrokerV.ListenerPort;
|
---|
249 | end;
|
---|
250 |
|
---|
251 | function TCPRSBroker.Server: WideString;
|
---|
252 | begin
|
---|
253 | Result := RPCBrokerV.Server;
|
---|
254 | end;
|
---|
255 |
|
---|
256 | procedure TCPRSBroker.Set_ClearParameters(Value: WordBool);
|
---|
257 | begin
|
---|
258 | FClearParameters := Value;
|
---|
259 | end;
|
---|
260 |
|
---|
261 | procedure TCPRSBroker.Set_ClearResults(Value: WordBool);
|
---|
262 | begin
|
---|
263 | FClearResults := Value;
|
---|
264 | end;
|
---|
265 |
|
---|
266 | procedure TCPRSBroker.Set_Param(Index: Integer; const Value: WideString);
|
---|
267 | begin
|
---|
268 | FParam[Index].Value := Value;
|
---|
269 | end;
|
---|
270 |
|
---|
271 | procedure TCPRSBroker.Set_ParamList(Index: Integer; const Node,
|
---|
272 | Value: WideString);
|
---|
273 | begin
|
---|
274 | FParam[Index].Mult[Node] := Value;
|
---|
275 | end;
|
---|
276 |
|
---|
277 | procedure TCPRSBroker.Set_ParamType(Index: Integer;
|
---|
278 | Value: BrokerParamType);
|
---|
279 | begin
|
---|
280 | case Value of
|
---|
281 | bptLiteral: FParam[Index].PType := literal;
|
---|
282 | bptReference: FParam[Index].PType := reference;
|
---|
283 | bptList: FParam[Index].PType := list;
|
---|
284 | else FParam[Index].PType := undefined;
|
---|
285 | end;
|
---|
286 | end;
|
---|
287 |
|
---|
288 | procedure TCPRSBroker.Set_Results(const Value: WideString);
|
---|
289 | begin
|
---|
290 | FResults := Value;
|
---|
291 | end;
|
---|
292 |
|
---|
293 | procedure TCPRSBroker.Set_RPCVersion(const Value: WideString);
|
---|
294 | begin
|
---|
295 | FRPCVersion := Value;
|
---|
296 | end;
|
---|
297 |
|
---|
298 | function TCPRSBroker.SetContext(const Context: WideString): WordBool;
|
---|
299 | begin
|
---|
300 | FContext := Context;
|
---|
301 | Result := UpdateContext(FContext);
|
---|
302 | end;
|
---|
303 |
|
---|
304 | procedure TCPRSBroker.Initialize;
|
---|
305 | begin
|
---|
306 | FContext := '';
|
---|
307 | FRPCVersion := RPCBrokerV.RpcVersion;
|
---|
308 | FClearParameters := RPCBrokerV.ClearParameters;
|
---|
309 | FClearResults := RPCBrokerV.ClearResults;
|
---|
310 | FResults := '';
|
---|
311 | FParam.Assign(FEmptyParams);
|
---|
312 | end;
|
---|
313 |
|
---|
314 | destructor TCPRSBroker.Destroy;
|
---|
315 | begin
|
---|
316 | FParam.Free;
|
---|
317 | FEmptyParams.Free;
|
---|
318 | inherited;
|
---|
319 | end;
|
---|
320 |
|
---|
321 | { TCPRSState }
|
---|
322 |
|
---|
323 | constructor TCPRSState.Create;
|
---|
324 | var
|
---|
325 | CPRSLib: ITypeLib;
|
---|
326 |
|
---|
327 | begin
|
---|
328 | OleCheck(LoadRegTypeLib(LIBID_CPRSChart, 1, 0, 0, CPRSLib));
|
---|
329 | inherited Create(CPRSLib, ICPRSState);
|
---|
330 | FHandle := DottedIPStr + 'x' + IntToHex(Application.Handle,8);
|
---|
331 | end;
|
---|
332 |
|
---|
333 | function TCPRSState.Handle: WideString;
|
---|
334 | begin
|
---|
335 | Result := FHandle;
|
---|
336 | end;
|
---|
337 |
|
---|
338 | function TCPRSState.LocationIEN: Integer;
|
---|
339 | begin
|
---|
340 | Result := Encounter.Location;
|
---|
341 | end;
|
---|
342 |
|
---|
343 | function TCPRSState.LocationName: WideString;
|
---|
344 | begin
|
---|
345 | Result := Encounter.LocationName;
|
---|
346 | end;
|
---|
347 |
|
---|
348 | function TCPRSState.PatientDFN: WideString;
|
---|
349 | begin
|
---|
350 | Result := Patient.DFN;
|
---|
351 | end;
|
---|
352 |
|
---|
353 | function TCPRSState.PatientDOB: WideString;
|
---|
354 | begin
|
---|
355 | Result := FormatFMDateTime('mm/dd/yyyy', Patient.DOB);
|
---|
356 | end;
|
---|
357 |
|
---|
358 | function TCPRSState.PatientName: WideString;
|
---|
359 | begin
|
---|
360 | Result := Patient.Name;
|
---|
361 | end;
|
---|
362 |
|
---|
363 | function TCPRSState.PatientSSN: WideString;
|
---|
364 | begin
|
---|
365 | Result := Patient.SSN;
|
---|
366 | end;
|
---|
367 |
|
---|
368 | function TCPRSState.UserDUZ: WideString;
|
---|
369 | begin
|
---|
370 | Result := IntToStr(User.DUZ);
|
---|
371 | end;
|
---|
372 |
|
---|
373 | function TCPRSState.UserName: WideString;
|
---|
374 | begin
|
---|
375 | Result := User.Name;
|
---|
376 | end;
|
---|
377 |
|
---|
378 | { TCPRSEventHookManager }
|
---|
379 |
|
---|
380 | constructor TCPRSEventHookManager.Create;
|
---|
381 | begin
|
---|
382 | inherited;
|
---|
383 | FCPRSBroker := TCPRSBroker.Create;
|
---|
384 | FCPRSState := TCPRSState.Create;
|
---|
385 | end;
|
---|
386 |
|
---|
387 | destructor TCPRSEventHookManager.Destroy;
|
---|
388 | begin
|
---|
389 | FCPRSState := nil;
|
---|
390 | FCPRSBroker := nil;
|
---|
391 | if assigned(FErrors) then
|
---|
392 | FErrors.Free;
|
---|
393 | inherited;
|
---|
394 | end;
|
---|
395 |
|
---|
396 | procedure TCPRSEventHookManager.EnterCriticalSection;
|
---|
397 | begin
|
---|
398 | Windows.EnterCriticalSection(FLock);
|
---|
399 | end;
|
---|
400 |
|
---|
401 | procedure TCPRSEventHookManager.LeaveCriticalSection;
|
---|
402 | begin
|
---|
403 | Windows.LeaveCriticalSection(FLock);
|
---|
404 | end;
|
---|
405 |
|
---|
406 | function TCPRSEventHookManager.ProcessComObject(const GUIDString: string;
|
---|
407 | const AParam2, AParam3: string;
|
---|
408 | var Data1, Data2: WideString): boolean;
|
---|
409 | var
|
---|
410 | ObjIEN, ObjName, ObjGUIDStr, err, AParam1: string;
|
---|
411 | ObjGUID: TGUID;
|
---|
412 | ObjIntf: IUnknown;
|
---|
413 | Obj: ICPRSExtension;
|
---|
414 |
|
---|
415 | begin
|
---|
416 | Result := FALSE;
|
---|
417 | ObjIEN := Piece(GUIDString,U,1);
|
---|
418 | if assigned(FErrors) and (FErrors.IndexOf(ObjIEN) >= 0) then exit;
|
---|
419 | ObjName := Piece(GUIDString,U,2);
|
---|
420 | ObjGUIDStr := Piece(GUIDString,U,3);
|
---|
421 | if (ObjGUIDStr <> '') then
|
---|
422 | begin
|
---|
423 | try
|
---|
424 | ObjGUID := StringToGUID(ObjGUIDStr);
|
---|
425 | try
|
---|
426 | ObjIntf := CreateComObject(ObjGUID);
|
---|
427 | if assigned(ObjIntf) then
|
---|
428 | begin
|
---|
429 | try
|
---|
430 | ObjIntf.QueryInterface(IID_ICPRSExtension, Obj);
|
---|
431 | if assigned(Obj) then
|
---|
432 | begin
|
---|
433 | AParam1 := Piece(GUIDString,U,5);
|
---|
434 | InitializeCriticalSection(FLock);
|
---|
435 | try
|
---|
436 | FCPRSBroker.Initialize;
|
---|
437 | uCOMObjectActive := True;
|
---|
438 | Result := Obj.Execute(FCPRSBroker, FCPRSState,
|
---|
439 | AParam1, AParam2, AParam3, Data1, Data2);
|
---|
440 | finally
|
---|
441 | DeleteCriticalSection(FLock);
|
---|
442 | uCOMObjectActive := False;
|
---|
443 | end;
|
---|
444 | end
|
---|
445 | else
|
---|
446 | err := 'COM Object ' + ObjName + ' does not support ICPRSExtension';
|
---|
447 | except
|
---|
448 | err := 'Error executing ' + ObjName;
|
---|
449 | end;
|
---|
450 | end;
|
---|
451 | except
|
---|
452 | err := 'COM Object ' + ObjName + ' not found on this workstation.';
|
---|
453 | end;
|
---|
454 | except
|
---|
455 | err := 'COM Object ' + ObjName + ' has an invalid GUID' + CRLF + ObjGUIDStr;
|
---|
456 | end;
|
---|
457 | if err <> '' then
|
---|
458 | begin
|
---|
459 | if not assigned(FErrors) then
|
---|
460 | FErrors := TStringList.Create;
|
---|
461 | if FErrors.IndexOf(ObjIEN) < 0 then
|
---|
462 | FErrors.Add(ObjIEN);
|
---|
463 | ShowMsg(err);
|
---|
464 | end;
|
---|
465 | end;
|
---|
466 | end;
|
---|
467 |
|
---|
468 | procedure FreeEventHookObjects;
|
---|
469 | begin
|
---|
470 | FreeAndNil(uCPRSEventHookManager);
|
---|
471 | end;
|
---|
472 |
|
---|
473 | // External Calls
|
---|
474 |
|
---|
475 | procedure RegisterCPRSTypeLibrary;
|
---|
476 | type
|
---|
477 | TUnregisterProc = function(const GUID: TGUID; VerMajor, VerMinor: Word;
|
---|
478 | LCID: TLCID; SysKind: TSysKind): HResult stdcall;
|
---|
479 |
|
---|
480 | var
|
---|
481 | Unregister: boolean;
|
---|
482 | CPRSLib: ITypeLib;
|
---|
483 | DoHalt: boolean;
|
---|
484 | ModuleName: string;
|
---|
485 | HelpPath: WideString;
|
---|
486 | Buffer: array[0..261] of Char;
|
---|
487 | Handle: THandle;
|
---|
488 | UnregisterProc: TUnregisterProc;
|
---|
489 | LibAttr: PTLibAttr;
|
---|
490 |
|
---|
491 | begin
|
---|
492 | DoHalt := TRUE;
|
---|
493 | if FindCmdLineSwitch('UNREGSERVER', ['-', '/'], True) then
|
---|
494 | Unregister := TRUE
|
---|
495 | else
|
---|
496 | begin
|
---|
497 | Unregister := FALSE;
|
---|
498 | if not FindCmdLineSwitch('REGSERVER', ['-', '/'], True) then
|
---|
499 | DoHalt := FALSE;
|
---|
500 | end;
|
---|
501 |
|
---|
502 | try
|
---|
503 | SetString(ModuleName, Buffer, Windows.GetModuleFileName(HInstance, Buffer, SizeOf(Buffer)));
|
---|
504 | if ModuleName <> '' then
|
---|
505 | begin
|
---|
506 | OleCheck(LoadTypeLib(PWideChar(WideString(ModuleName)), CPRSLib)); // will register if needed
|
---|
507 | if assigned(CPRSLib) then
|
---|
508 | begin
|
---|
509 | if Unregister then
|
---|
510 | begin
|
---|
511 | Handle := GetModuleHandle('OLEAUT32.DLL');
|
---|
512 | if Handle <> 0 then
|
---|
513 | begin
|
---|
514 | @UnregisterProc := GetProcAddress(Handle, 'UnRegisterTypeLib');
|
---|
515 | if @UnregisterProc <> nil then
|
---|
516 | begin
|
---|
517 | OleCheck(CPRSLib.GetLibAttr(LibAttr));
|
---|
518 | try
|
---|
519 | with LibAttr^ do
|
---|
520 | UnregisterProc(guid, wMajorVerNum, wMinorVerNum, lcid, syskind);
|
---|
521 | finally
|
---|
522 | CPRSLib.ReleaseTLibAttr(LibAttr);
|
---|
523 | end;
|
---|
524 | end;
|
---|
525 | end;
|
---|
526 | end
|
---|
527 | else
|
---|
528 | begin
|
---|
529 | HelpPath := ExtractFilePath(ModuleName);
|
---|
530 | OleCheck(RegisterTypeLib(CPRSLib, PWideChar(WideString(ModuleName)), PWideChar(HelpPath)));
|
---|
531 | end;
|
---|
532 | end;
|
---|
533 | end;
|
---|
534 | except
|
---|
535 | // ignore any errors
|
---|
536 | end;
|
---|
537 | if DoHalt then Halt;
|
---|
538 | end;
|
---|
539 |
|
---|
540 | procedure ProcessPatientChangeEventHook;
|
---|
541 | var
|
---|
542 | d1, d2: WideString;
|
---|
543 | COMObj: string;
|
---|
544 |
|
---|
545 | begin
|
---|
546 | COMObj := GetPatientChangeGUIDs;
|
---|
547 | if(COMObj <> '') and (COMObj <> '0') then
|
---|
548 | begin
|
---|
549 | EnsureEventHookObjects;
|
---|
550 | d1 := '';
|
---|
551 | d2 := '';
|
---|
552 | uCPRSEventHookManager.ProcessComObject(COMObj, 'P=' + Patient.DFN, '', d1, d2);
|
---|
553 | end;
|
---|
554 | end;
|
---|
555 |
|
---|
556 | function ProcessOrderAcceptEventHook(OrderID: string; DisplayGroup: integer): boolean;
|
---|
557 | var
|
---|
558 | d1, d2: WideString;
|
---|
559 | COMObj: string;
|
---|
560 |
|
---|
561 | begin
|
---|
562 | Result := False;
|
---|
563 | COMObj := GetOrderAcceptGUIDs(DisplayGroup);
|
---|
564 | if(COMObj <> '') and (COMObj <> '0') then
|
---|
565 | begin
|
---|
566 | EnsureEventHookObjects;
|
---|
567 | d1 := '';
|
---|
568 | d2 := '';
|
---|
569 | //Result will be set to True by Com object if the order is deleted by LES
|
---|
570 | Result := uCPRSEventHookManager.ProcessComObject(COMObj, 'O=' + OrderID, '', d1, d2);
|
---|
571 | end;
|
---|
572 | end;
|
---|
573 |
|
---|
574 | procedure GetCOMObjectText(COMObject: integer; const Param2, Param3: string;
|
---|
575 | var Data1, Data2: string);
|
---|
576 | var
|
---|
577 | d1, d2: WideString;
|
---|
578 | COMObj: string;
|
---|
579 |
|
---|
580 | begin
|
---|
581 | if COMObject > 0 then
|
---|
582 | begin
|
---|
583 | COMObj := GetCOMObjectDetails(COMObject);
|
---|
584 | if(COMObj <> '') and (COMObj <> '0') then
|
---|
585 | begin
|
---|
586 | EnsureEventHookObjects;
|
---|
587 | d1 := Data1;
|
---|
588 | d2 := Data2;
|
---|
589 | if uCPRSEventHookManager.ProcessComObject(COMObj, Param2, Param3, d1, d2) then
|
---|
590 | begin
|
---|
591 | Data1 := d1;
|
---|
592 | Data2 := d2;
|
---|
593 | end;
|
---|
594 | end;
|
---|
595 | end;
|
---|
596 | end;
|
---|
597 |
|
---|
598 | function COMObjectOK(COMObject: integer): boolean;
|
---|
599 | begin
|
---|
600 | if assigned(uCPRSEventHookManager) and assigned(uCPRSEventHookManager.FErrors) then
|
---|
601 | Result := (uCPRSEventHookManager.FErrors.IndexOf(IntToStr(COMObject)) < 0)
|
---|
602 | else
|
---|
603 | Result := TRUE;
|
---|
604 | end;
|
---|
605 |
|
---|
606 | function COMObjectActive: boolean;
|
---|
607 | begin
|
---|
608 | Result := uCOMObjectActive;
|
---|
609 | end;
|
---|
610 |
|
---|
611 | initialization
|
---|
612 |
|
---|
613 | finalization
|
---|
614 | FreeEventHookObjects;
|
---|
615 |
|
---|
616 | end.
|
---|