source: cprs/branches/tmg-cprs/CPRS-Chart/rTIU.pas.kil.pas@ 1099

Last change on this file since 1099 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

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