1 | unit rSurgery;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, TRPCB, dialogs, uSurgery;
|
---|
6 |
|
---|
7 | type
|
---|
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 }
|
---|
32 | function DfltSurgeryTitle(AClassName: string): integer;
|
---|
33 | function DfltSurgeryTitleName(AClassName: string): string;
|
---|
34 | procedure ListSurgeryTitlesShort(Dest: TStrings; AClassName: string);
|
---|
35 | function SubSetOfSurgeryTitles(const StartFrom: string; Direction: Integer; AClassName: string): TStrings;
|
---|
36 | function IsSurgeryTitle(TitleIEN: Integer): Boolean;
|
---|
37 | procedure ResetSurgeryTitles;
|
---|
38 |
|
---|
39 | { Data Retrieval }
|
---|
40 | procedure GetSurgCaseList(Dest: TStrings; Early, Late: double; Context, Max: integer);
|
---|
41 | procedure ListSurgeryCases(Dest: TStrings);
|
---|
42 | procedure GetSingleCaseListItemWithDocs(Dest: TStrings; NoteIEN: integer);
|
---|
43 | function GetSingleCaseListItemWithoutDocs(NoteIEN: integer): string;
|
---|
44 | //procedure LoadOpTop(Dest: TStrings; ACaseIEN: integer; IsNonORProc, ShowReport: boolean) ;
|
---|
45 | procedure LoadSurgReportText(Dest: TStrings; IEN: integer) ;
|
---|
46 | procedure LoadSurgReportDetail(Dest: TStrings; IEN: integer) ;
|
---|
47 | function GetCurrentSurgCaseContext: TSurgCaseContext;
|
---|
48 | procedure SaveCurrentSurgCaseContext(AContext: TSurgCaseContext) ;
|
---|
49 | function GetSurgCaseRefForNote(NoteIEN: integer): string;
|
---|
50 | //function ShowOpTopOnSignature(ACaseIEN: integer): integer;
|
---|
51 | function ShowSurgeryTab: boolean;
|
---|
52 | function IsNonORProcedure(ACaseIEN: integer): boolean;
|
---|
53 |
|
---|
54 | implementation
|
---|
55 |
|
---|
56 | var
|
---|
57 | uSurgeryTitles: TSurgeryTitles;
|
---|
58 | uShowSurgeryTab: TShowSurgeryTab;
|
---|
59 | //uShowOpTop: TShowOpTop;
|
---|
60 |
|
---|
61 | function ShowSurgeryTab: boolean;
|
---|
62 | begin
|
---|
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;
|
---|
72 | end;
|
---|
73 | { -------------------------- Surgery Titles --------------------------------- }
|
---|
74 |
|
---|
75 | procedure LoadSurgeryTitles(AClassName: string);
|
---|
76 | { private - called to set up the uSurgeryTitles object }
|
---|
77 | var
|
---|
78 | SurgeryClass: integer;
|
---|
79 | x: string;
|
---|
80 | begin
|
---|
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);
|
---|
97 | end;
|
---|
98 |
|
---|
99 | procedure ResetSurgeryTitles;
|
---|
100 | begin
|
---|
101 | if uSurgeryTitles <> nil then
|
---|
102 | begin
|
---|
103 | uSurgeryTitles.Free;
|
---|
104 | uSurgeryTitles := nil;
|
---|
105 | end;
|
---|
106 | end;
|
---|
107 |
|
---|
108 | function DfltSurgeryTitle(AClassName: string): integer;
|
---|
109 | { returns the user defined default Surgery title (if any) }
|
---|
110 | begin
|
---|
111 | if AClassName <> uSurgeryTitles.ClassName then LoadSurgeryTitles(AClassName);
|
---|
112 | Result := uSurgeryTitles.DfltTitle;
|
---|
113 | end;
|
---|
114 |
|
---|
115 | function DfltSurgeryTitleName(AClassName: string): string;
|
---|
116 | { returns the name of the user defined default progress note title (if any) }
|
---|
117 | begin
|
---|
118 | if AClassName <> uSurgeryTitles.ClassName then LoadSurgeryTitles(AClassName);
|
---|
119 | Result := uSurgeryTitles.DfltTitleName;
|
---|
120 | end;
|
---|
121 |
|
---|
122 | procedure ListSurgeryTitlesShort(Dest: TStrings; AClassName: string);
|
---|
123 | { returns the user defined list (short list) of Surgery titles }
|
---|
124 | begin
|
---|
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;
|
---|
132 | end;
|
---|
133 |
|
---|
134 | function 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! }
|
---|
138 | begin
|
---|
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;
|
---|
143 | end;
|
---|
144 |
|
---|
145 | function IsSurgeryTitle(TitleIEN: Integer): Boolean;
|
---|
146 | begin
|
---|
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';
|
---|
151 | end;
|
---|
152 |
|
---|
153 | {--------------- data retrieval ------------------------------------------}
|
---|
154 |
|
---|
155 | procedure 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 | (*
|
---|
158 | CASE #^Operative Procedure^Date/Time of Operation^Surgeon;Surgeon name^^^^^^^^^+^Context*)
|
---|
159 | var
|
---|
160 | date1, date2: string;
|
---|
161 | begin
|
---|
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;
|
---|
179 | end;
|
---|
180 |
|
---|
181 | procedure 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)
|
---|
184 | begin
|
---|
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;
|
---|
201 | end;
|
---|
202 |
|
---|
203 |
|
---|
204 | procedure LoadSurgReportText(Dest: TStrings; IEN: integer) ;
|
---|
205 | { returns the text of a surgery report }
|
---|
206 | begin
|
---|
207 | CallV('TIU GET RECORD TEXT', [IEN]);
|
---|
208 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
209 | end;
|
---|
210 |
|
---|
211 | procedure LoadSurgReportDetail(Dest: TStrings; IEN: integer) ;
|
---|
212 | { returns the detail of a surgery report }
|
---|
213 | begin
|
---|
214 | CallV('TIU DETAILED DISPLAY', [IEN]);
|
---|
215 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
216 | end;
|
---|
217 |
|
---|
218 | (*procedure LoadOpTop(Dest: TStrings; ACaseIEN: integer; IsNonORProc, ShowReport: boolean) ;
|
---|
219 | { returns the OpTop for a surgical case }
|
---|
220 | begin
|
---|
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;
|
---|
230 | end;*)
|
---|
231 |
|
---|
232 | function GetCurrentSurgCaseContext: TSurgCaseContext;
|
---|
233 | var
|
---|
234 | x: string;
|
---|
235 | AContext: TSurgCaseContext;
|
---|
236 | begin
|
---|
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;
|
---|
251 | end ;
|
---|
252 |
|
---|
253 | procedure SaveCurrentSurgCaseContext(AContext: TSurgCaseContext) ;
|
---|
254 | var
|
---|
255 | x: string;
|
---|
256 | begin
|
---|
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]);
|
---|
267 | end;
|
---|
268 |
|
---|
269 | function GetSurgCaseRefForNote(NoteIEN: integer): string;
|
---|
270 | var
|
---|
271 | x: string;
|
---|
272 | begin
|
---|
273 | x := sCallV('TIU GET REQUEST', [NoteIEN]);
|
---|
274 | if Piece(x, ';', 2) <> 'SRF(' then
|
---|
275 | Result := '-1'
|
---|
276 | else
|
---|
277 | Result := x
|
---|
278 | end;
|
---|
279 |
|
---|
280 | procedure GetSingleCaseListItemWithDocs(Dest: TStrings; NoteIEN: integer);
|
---|
281 | begin
|
---|
282 | CallV('ORWSR ONECASE', [NoteIEN]);
|
---|
283 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
284 | end;
|
---|
285 |
|
---|
286 | function GetSingleCaseListItemWithoutDocs(NoteIEN: integer): string;
|
---|
287 | begin
|
---|
288 | CallV('ORWSR ONECASE', [NoteIEN]);
|
---|
289 | if RPCBrokerV.Results.Count > 0 then Result := RPCBrokerV.Results[0];
|
---|
290 | end;
|
---|
291 |
|
---|
292 | (*function ShowOpTopOnSignature(ACaseIEN: integer): integer;
|
---|
293 | begin
|
---|
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;
|
---|
303 | end;*)
|
---|
304 |
|
---|
305 | function IsNonORProcedure(ACaseIEN: integer): boolean;
|
---|
306 | begin
|
---|
307 | Result := sCallV('ORWSR IS NON-OR PROCEDURE', [ACaseIEN]) = '1';
|
---|
308 | end;
|
---|
309 |
|
---|
310 | initialization
|
---|
311 |
|
---|
312 | finalization
|
---|
313 | if uSurgeryTitles <> nil then uSurgeryTitles.Free;
|
---|
314 |
|
---|
315 | end.
|
---|