source: cprs/trunk/CPRS-Chart/rSurgery.pas@ 1571

Last change on this file since 1571 was 830, checked in by Kevin Toppenberg, 14 years ago

Upgrading to version 27

File size: 9.8 KB
Line 
1unit rSurgery;
2
3interface
4
5uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, TRPCB, dialogs, uSurgery;
6
7type
8 TSurgCaseContext = record
9 Changed: Boolean;
10 OpProc: string;
11 BeginDate: string;
12 FMBeginDate: TFMDateTime;
13 EndDate: string;
14 FMEndDate: TFMDateTime;
15 MaxDocs: integer;
16 Status: string;
17 GroupBy: string;
18 TreeAscending: Boolean;
19 end ;
20
21 TShowSurgeryTab = record
22 Evaluated: boolean;
23 ShowIt: boolean;
24 end;
25
26 TShowOpTop = record
27 Evaluated: boolean;
28 ShowIt: integer;
29 end;
30
31{Surgery Titles }
32function DfltSurgeryTitle(AClassName: string): integer;
33function DfltSurgeryTitleName(AClassName: string): string;
34procedure ListSurgeryTitlesShort(Dest: TStrings; AClassName: string);
35function SubSetOfSurgeryTitles(const StartFrom: string; Direction: Integer; AClassName: string): TStrings;
36function IsSurgeryTitle(TitleIEN: Integer): Boolean;
37procedure ResetSurgeryTitles;
38
39{ Data Retrieval }
40procedure GetSurgCaseList(Dest: TStrings; Early, Late: double; Context, Max: integer);
41procedure ListSurgeryCases(Dest: TStrings);
42procedure GetSingleCaseListItemWithDocs(Dest: TStrings; NoteIEN: integer);
43function GetSingleCaseListItemWithoutDocs(NoteIEN: integer): string;
44//procedure LoadOpTop(Dest: TStrings; ACaseIEN: integer; IsNonORProc, ShowReport: boolean) ;
45procedure LoadSurgReportText(Dest: TStrings; IEN: integer) ;
46procedure LoadSurgReportDetail(Dest: TStrings; IEN: integer) ;
47function GetCurrentSurgCaseContext: TSurgCaseContext;
48procedure SaveCurrentSurgCaseContext(AContext: TSurgCaseContext) ;
49function GetSurgCaseRefForNote(NoteIEN: integer): string;
50//function ShowOpTopOnSignature(ACaseIEN: integer): integer;
51function ShowSurgeryTab: boolean;
52function IsNonORProcedure(ACaseIEN: integer): boolean;
53
54implementation
55
56var
57 uSurgeryTitles: TSurgeryTitles;
58 uShowSurgeryTab: TShowSurgeryTab;
59 //uShowOpTop: TShowOpTop;
60
61function ShowSurgeryTab: boolean;
62begin
63 with uShowSurgeryTab do
64 begin
65 if not Evaluated then
66 begin
67 ShowIt := sCallV('ORWSR SHOW SURG TAB', [nil]) = '1';
68 Evaluated := True;
69 end;
70 Result := ShowIt;
71 end;
72end;
73{ -------------------------- Surgery Titles --------------------------------- }
74
75procedure LoadSurgeryTitles(AClassName: string);
76{ private - called to set up the uSurgeryTitles object }
77var
78 SurgeryClass: integer;
79 x: string;
80begin
81 if uSurgeryTitles <> nil then
82 begin
83 if uSurgeryTitles.Classname = AClassName then exit;
84 uSurgeryTitles.Free;
85 uSurgeryTitles := nil;
86 end;
87 // pass in class name to return OR/non-OR class, depending on selected case
88 SurgeryClass := StrToInt(sCallV('TIU IDENTIFY SURGERY CLASS',[AClassName])) ;
89 CallV('TIU PERSONAL TITLE LIST', [User.DUZ, SurgeryClass]);
90 RPCBrokerV.Results.Insert(0, '~SHORT LIST'); // insert so can call ExtractItems
91 uSurgeryTitles := TSurgeryTitles.Create;
92 ExtractItems(uSurgeryTitles.ShortList, RPCBrokerV.Results, 'SHORT LIST');
93 x := ExtractDefault(RPCBrokerV.Results, 'SHORT LIST');
94 uSurgeryTitles.ClassName := AClassName;
95 uSurgeryTitles.DfltTitle := StrToIntDef(Piece(x, U, 1), 0);
96 uSurgeryTitles.DfltTitleName := Piece(x, U, 2);
97end;
98
99procedure ResetSurgeryTitles;
100begin
101 if uSurgeryTitles <> nil then
102 begin
103 uSurgeryTitles.Free;
104 uSurgeryTitles := nil;
105 end;
106end;
107
108function DfltSurgeryTitle(AClassName: string): integer;
109{ returns the user defined default Surgery title (if any) }
110begin
111 if AClassName <> uSurgeryTitles.ClassName then LoadSurgeryTitles(AClassName);
112 Result := uSurgeryTitles.DfltTitle;
113end;
114
115function DfltSurgeryTitleName(AClassName: string): string;
116{ returns the name of the user defined default progress note title (if any) }
117begin
118 if AClassName <> uSurgeryTitles.ClassName then LoadSurgeryTitles(AClassName);
119 Result := uSurgeryTitles.DfltTitleName;
120end;
121
122procedure ListSurgeryTitlesShort(Dest: TStrings; AClassName: string);
123{ returns the user defined list (short list) of Surgery titles }
124begin
125 if (uSurgeryTitles = nil) or (AClassName <> uSurgeryTitles.ClassName) then LoadSurgeryTitles(AClassName);
126 FastAddStrings(uSurgeryTitles.ShortList, Dest);
127 if uSurgeryTitles.ShortList.Count > 0 then
128 begin
129 Dest.Add('0^________________________________________________________________________');
130 Dest.Add('0^ ');
131 end;
132end;
133
134function SubSetOfSurgeryTitles(const StartFrom: string; Direction: Integer; AClassName: string): TStrings;
135{ returns a pointer to a list of Surgery progress note titles (for use in a long list box) -
136 The return value is a pointer to RPCBrokerV.Results, so the data must be used BEFORE
137 the next broker call! }
138begin
139 // pass in class name based on OR/non-OR
140 CallV('TIU LONG LIST SURGERY TITLES', [StartFrom, Direction, AClassName]);
141 //MixedCaseList(RPCBrokerV.Results);
142 Result := RPCBrokerV.Results;
143end;
144
145function IsSurgeryTitle(TitleIEN: Integer): Boolean;
146begin
147 Result := False;
148 if not ShowSurgeryTab then exit;
149 if TitleIEN <= 0 then Exit;
150 Result := sCallV('TIU IS THIS A SURGERY?', [TitleIEN]) = '1';
151end;
152
153{--------------- data retrieval ------------------------------------------}
154
155procedure GetSurgCaseList(Dest: TStrings; Early, Late: double; Context, Max: integer);
156{ returns a list of surgery cases for a patient, based on selected dates, service, status, or ALL}
157(*
158CASE #^Operative Procedure^Date/Time of Operation^Surgeon;Surgeon name^^^^^^^^^+^Context*)
159var
160 date1, date2: string;
161begin
162 if Early <= 0 then date1 := '' else date1 := FloatToStr(Early) ;
163 if Late <= 0 then date2 := '' else date2 := FloatToStr(Late) ;
164 CallV('ORWSR LIST', [Patient.DFN, date1, date2, Context, Max]);
165 with RPCBrokerV do
166 begin
167 if Results.Count > 0 then
168 begin
169 SortByPiece(TStringList(Results), U, 2);
170 InvertStringList(TStringList(Results));
171 FastAssign(Results, Dest);
172 end
173 else
174 begin
175 Dest.Clear ;
176 Dest.Add('-1^No Matches') ;
177 end ;
178 end;
179end;
180
181procedure ListSurgeryCases(Dest: TStrings);
182{ returns a list of surgery cases for a patient, without documents, for fNoteProps case selection}
183//CASE #^Operative Procedure^Date/Time of Operation^Surgeon;Surgeon name)
184begin
185 CallV('ORWSR CASELIST', [Patient.DFN]);
186 with RPCBrokerV do
187 begin
188 if Results.Count > 0 then
189 begin
190 SortByPiece(TStringList(Results), U, 3);
191 InvertStringList(TStringList(Results));
192 SetListFMDateTime('mmm dd,yy hh:nn', TStringList(Results), U, 3);
193 FastAssign(Results, Dest);
194 end
195 else
196 begin
197 Dest.Clear ;
198 Dest.Add('-1^No Cases Found') ;
199 end ;
200 end;
201end;
202
203
204procedure LoadSurgReportText(Dest: TStrings; IEN: integer) ;
205{ returns the text of a surgery report }
206begin
207 CallV('TIU GET RECORD TEXT', [IEN]);
208 FastAssign(RPCBrokerV.Results, Dest);
209end;
210
211procedure LoadSurgReportDetail(Dest: TStrings; IEN: integer) ;
212{ returns the detail of a surgery report }
213begin
214 CallV('TIU DETAILED DISPLAY', [IEN]);
215 FastAssign(RPCBrokerV.Results, Dest);
216end;
217
218(*procedure LoadOpTop(Dest: TStrings; ACaseIEN: integer; IsNonORProc, ShowReport: boolean) ;
219{ returns the OpTop for a surgical case }
220begin
221 if IsNonORProc then
222 CallV('ORWSR OPTOP NON-OR', [ACaseIEN, ShowReport])
223 else
224 CallV('ORWSR OPTOP', [ACaseIEN, ShowReport]);
225 with RPCBrokerV do
226 begin
227 //if Results.Count > 0 then Results.Delete(0); //This is the value of the ShowOpTopOnSignature site parameter.
228 FastAssign(Results, Dest);
229 end;
230end;*)
231
232function GetCurrentSurgCaseContext: TSurgCaseContext;
233var
234 x: string;
235 AContext: TSurgCaseContext;
236begin
237 x := sCallV('ORWSR GET SURG CONTEXT', [User.DUZ]) ;
238 with AContext do
239 begin
240 Changed := True;
241 BeginDate := Piece(x, ';', 1);
242 FMBeginDate := StrToFMDateTime(BeginDate);
243 EndDate := Piece(x, ';', 2);
244 FMEndDate := StrToFMDateTime(EndDate);
245 Status := Piece(x, ';', 3);
246 GroupBy := Piece(x, ';', 4);
247 MaxDocs := StrToIntDef(Piece(x, ';', 5), 0);
248 TreeAscending := (Piece(x, ';', 6) = '1');
249 end;
250 Result := AContext;
251end ;
252
253procedure SaveCurrentSurgCaseContext(AContext: TSurgCaseContext) ;
254var
255 x: string;
256begin
257 with AContext do
258 begin
259 SetPiece(x, ';', 1, BeginDate);
260 SetPiece(x, ';', 2, EndDate);
261 SetPiece(x, ';', 3, Status);
262 SetPiece(x, ';', 4, GroupBy);
263 SetPiece(x, ';', 5, IntToStr(MaxDocs));
264 SetPiece(x, ';', 6, BOOLCHAR[TreeAscending]);
265 end;
266 CallV('ORWSR SAVE SURG CONTEXT', [x]);
267end;
268
269function GetSurgCaseRefForNote(NoteIEN: integer): string;
270var
271 x: string;
272begin
273 x := sCallV('TIU GET REQUEST', [NoteIEN]);
274 if Piece(x, ';', 2) <> 'SRF(' then
275 Result := '-1'
276 else
277 Result := x
278end;
279
280procedure GetSingleCaseListItemWithDocs(Dest: TStrings; NoteIEN: integer);
281begin
282 CallV('ORWSR ONECASE', [NoteIEN]);
283 FastAssign(RPCBrokerV.Results, Dest);
284end;
285
286function GetSingleCaseListItemWithoutDocs(NoteIEN: integer): string;
287begin
288 CallV('ORWSR ONECASE', [NoteIEN]);
289 if RPCBrokerV.Results.Count > 0 then Result := RPCBrokerV.Results[0];
290end;
291
292(*function ShowOpTopOnSignature(ACaseIEN: integer): integer;
293begin
294 with uShowOpTop do
295 begin
296 if not Evaluated then
297 begin
298 ShowIt := StrToIntDef(sCallV('ORWSR SHOW OPTOP WHEN SIGNING', [ACaseIEN]), 0);
299 Evaluated := True;
300 end;
301 Result := ShowIt;
302 end;
303end;*)
304
305function IsNonORProcedure(ACaseIEN: integer): boolean;
306begin
307 Result := sCallV('ORWSR IS NON-OR PROCEDURE', [ACaseIEN]) = '1';
308end;
309
310initialization
311
312finalization
313 if uSurgeryTitles <> nil then uSurgeryTitles.Free;
314
315end.
Note: See TracBrowser for help on using the repository browser.