[453] | 1 | //kt -- Modified with SourceScanner on 8/7/2007
|
---|
| 2 | unit rReminders;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 5 | uses
|
---|
| 6 | Windows,Classes, SysUtils, TRPCB, ORNet, ORFn;
|
---|
| 7 |
|
---|
| 8 | procedure GetCurrentReminders;
|
---|
| 9 | procedure GetOtherReminders(Dest: TStrings);
|
---|
| 10 | procedure EvaluateReminders(RemList: TStringList);
|
---|
| 11 | function EvaluateReminder(IEN: string): string;
|
---|
| 12 | procedure GetEducationTopicsForReminder(ReminderID: integer);
|
---|
| 13 | procedure GetEducationSubtopics(TopicID: integer);
|
---|
| 14 | procedure GetReminderWebPages(ReminderID: string);
|
---|
| 15 | function DetailReminder(IEN: Integer): TStrings;
|
---|
| 16 | function ReminderInquiry(IEN: Integer): TStrings;
|
---|
| 17 | function EducationTopicDetail(IEN: Integer): TStrings;
|
---|
| 18 | function GetDialogInfo(IEN: string; RemIEN: boolean): TStrings;
|
---|
| 19 | function GetDialogPrompts(IEN: string; Historical: boolean; FindingType: string): TStrings;
|
---|
| 20 | procedure GetDialogStatus(AList: TStringList);
|
---|
| 21 | function GetRemindersActive: boolean;
|
---|
| 22 | function GetProgressNoteHeader: string;
|
---|
| 23 | function LoadMentalHealthTest(TestName: string): TStrings;
|
---|
| 24 | procedure MentalHealthTestResults(var AText: string; const DlgIEN: integer; const TestName:
|
---|
| 25 | string; const AProvider: Int64; const Answers: string);
|
---|
| 26 | procedure SaveMentalHealthTest(const TestName: string; ADate: TFMDateTime;
|
---|
| 27 | const AProvider: Int64; const Answers: string);
|
---|
| 28 | procedure SaveWomenHealthData(var WHData: TStringlist);
|
---|
| 29 | function CheckGECValue(const RemIEN: string; NoteIEN: integer): String;
|
---|
| 30 | procedure SaveMSTDataFromReminder(VDate, Sts, Prov, FType, FIEN, Res: string);
|
---|
| 31 |
|
---|
| 32 | function GetReminderFolders: string;
|
---|
| 33 | procedure SetReminderFolders(const Value: string);
|
---|
| 34 | function GetDefLocations: TStrings;
|
---|
| 35 | function InsertRemTextAtCursor: boolean;
|
---|
| 36 |
|
---|
| 37 | function NewRemCoverSheetListActive: boolean;
|
---|
| 38 | function CanEditAllRemCoverSheetLists: boolean;
|
---|
| 39 | function GetCoverSheetLevelData(ALevel, AClass: string): TStrings;
|
---|
| 40 | procedure SetCoverSheetLevelData(ALevel, AClass: string; Data: TStrings);
|
---|
| 41 | function GetCategoryItems(CatIEN: integer): TStrings;
|
---|
| 42 | function GetAllRemindersAndCategories: TStrings;
|
---|
| 43 | function VerifyMentalHealthTestComplete(TestName, Answers: string): String;
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | implementation
|
---|
| 47 |
|
---|
| 48 | uses
|
---|
| 49 | uCore, uReminders, rCore;
|
---|
| 50 |
|
---|
| 51 | var
|
---|
| 52 | uLastDefLocUser: int64 = -1;
|
---|
| 53 | uDefLocs: TStringList = nil;
|
---|
| 54 | uRemInsertAtCursor: integer = -1;
|
---|
| 55 | uNewCoverSheetListActive: integer = -1;
|
---|
| 56 | uCanEditAllCoverSheetLists: integer = -1;
|
---|
| 57 |
|
---|
| 58 | procedure GetCurrentReminders;
|
---|
| 59 | begin
|
---|
| 60 | CallV('ORQQPXRM REMINDERS UNEVALUATED', [Patient.DFN, Encounter.Location]);
|
---|
| 61 | end;
|
---|
| 62 |
|
---|
| 63 | procedure GetOtherReminders(Dest: TStrings);
|
---|
| 64 | begin
|
---|
| 65 | CallV('ORQQPXRM REMINDER CATEGORIES', [Patient.DFN, Encounter.Location]);
|
---|
| 66 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 67 | end;
|
---|
| 68 |
|
---|
| 69 | procedure EvaluateReminders(RemList: TStringList);
|
---|
| 70 | var
|
---|
| 71 | i: integer;
|
---|
| 72 |
|
---|
| 73 | begin
|
---|
| 74 | with RPCBrokerV do
|
---|
| 75 | begin
|
---|
| 76 | ClearParameters := True;
|
---|
| 77 | RemoteProcedure := 'ORQQPXRM REMINDER EVALUATION';
|
---|
| 78 | Param[0].PType := literal;
|
---|
| 79 | Param[0].Value := Patient.DFN;
|
---|
| 80 | Param[1].PType := list;
|
---|
| 81 | for i := 0 to RemList.Count-1 do
|
---|
| 82 | Param[1].Mult[IntToStr(i+1)] := Piece(RemList[i],U,1);
|
---|
| 83 | CallBroker;
|
---|
| 84 | end;
|
---|
| 85 | end;
|
---|
| 86 |
|
---|
| 87 | function EvaluateReminder(IEN: string): string;
|
---|
| 88 | var
|
---|
| 89 | TmpSL: TStringList;
|
---|
| 90 |
|
---|
| 91 | begin
|
---|
| 92 | TmpSL := TStringList.Create;
|
---|
| 93 | try
|
---|
| 94 | TmpSL.Add(IEN);
|
---|
| 95 | EvaluateReminders(TmpSL);
|
---|
| 96 | if(RPCBrokerV.Results.Count > 0) then
|
---|
| 97 | Result := RPCBrokerV.Results[0]
|
---|
| 98 | else
|
---|
| 99 | Result := IEN;
|
---|
| 100 | finally
|
---|
| 101 | TmpSL.Free;
|
---|
| 102 | end;
|
---|
| 103 | end;
|
---|
| 104 |
|
---|
| 105 | procedure GetEducationTopicsForReminder(ReminderID: integer);
|
---|
| 106 | begin
|
---|
| 107 | CallV('ORQQPXRM EDUCATION SUMMARY', [ReminderID]);
|
---|
| 108 | end;
|
---|
| 109 |
|
---|
| 110 | procedure GetEducationSubtopics(TopicID: integer);
|
---|
| 111 | begin
|
---|
| 112 | CallV('ORQQPXRM EDUCATION SUBTOPICS', [TopicID]);
|
---|
| 113 | end;
|
---|
| 114 |
|
---|
| 115 | procedure GetReminderWebPages(ReminderID: string);
|
---|
| 116 | begin
|
---|
| 117 | if(User.WebAccess) then
|
---|
| 118 | CallV('ORQQPXRM REMINDER WEB', [ReminderID])
|
---|
| 119 | else
|
---|
| 120 | RPCBrokerV.ClearParameters := True;
|
---|
| 121 | end;
|
---|
| 122 |
|
---|
| 123 | function DetailReminder(IEN: Integer): TStrings; // Clinical Maintenance
|
---|
| 124 | begin
|
---|
| 125 | if InteractiveRemindersActive then
|
---|
| 126 | CallV('ORQQPXRM REMINDER DETAIL', [Patient.DFN, IEN])
|
---|
| 127 | else
|
---|
| 128 | CallV('ORQQPX REMINDER DETAIL', [Patient.DFN, IEN]);
|
---|
| 129 | Result := RPCBrokerV.Results;
|
---|
| 130 | end;
|
---|
| 131 |
|
---|
| 132 | function ReminderInquiry(IEN: Integer): TStrings;
|
---|
| 133 | begin
|
---|
| 134 | CallV('ORQQPXRM REMINDER INQUIRY', [IEN]);
|
---|
| 135 | Result := RPCBrokerV.Results;
|
---|
| 136 | end;
|
---|
| 137 |
|
---|
| 138 | function EducationTopicDetail(IEN: Integer): TStrings;
|
---|
| 139 | begin
|
---|
| 140 | CallV('ORQQPXRM EDUCATION TOPIC', [IEN]);
|
---|
| 141 | Result := RPCBrokerV.Results;
|
---|
| 142 | end;
|
---|
| 143 |
|
---|
| 144 | function GetDialogInfo(IEN: string; RemIEN: boolean): TStrings;
|
---|
| 145 | begin
|
---|
| 146 | if RemIEN then
|
---|
| 147 | CallV('ORQQPXRM REMINDER DIALOG', [IEN, Patient.DFN])
|
---|
| 148 | else
|
---|
| 149 | CallV('PXRM REMINDER DIALOG (TIU)', [IEN, Patient.DFN]);
|
---|
| 150 | Result := RPCBrokerV.Results;
|
---|
| 151 | end;
|
---|
| 152 |
|
---|
| 153 | function GetDialogPrompts(IEN: string; Historical: boolean; FindingType: string): TStrings;
|
---|
| 154 | begin
|
---|
| 155 | CallV('ORQQPXRM DIALOG PROMPTS', [IEN, Historical, FindingType]);
|
---|
| 156 | Result := RPCBrokerV.Results;
|
---|
| 157 | end;
|
---|
| 158 |
|
---|
| 159 | procedure GetDialogStatus(AList: TStringList);
|
---|
| 160 | var
|
---|
| 161 | i: integer;
|
---|
| 162 |
|
---|
| 163 | begin
|
---|
| 164 | if(Alist.Count = 0) then exit;
|
---|
| 165 | with RPCBrokerV do
|
---|
| 166 | begin
|
---|
| 167 | ClearParameters := True;
|
---|
| 168 | RemoteProcedure := 'ORQQPXRM DIALOG ACTIVE';
|
---|
| 169 | Param[0].PType := list;
|
---|
| 170 | for i := 0 to AList.Count-1 do
|
---|
| 171 | Param[0].Mult[AList[i]] := '';
|
---|
| 172 | CallBroker;
|
---|
| 173 | AList.Assign(Results);
|
---|
| 174 | end;
|
---|
| 175 | end;
|
---|
| 176 |
|
---|
| 177 | function GetRemindersActive: boolean;
|
---|
| 178 | begin
|
---|
| 179 | CallV('ORQQPX NEW REMINDERS ACTIVE', []);
|
---|
| 180 | Result := ((RPCBrokerV.Results.Count = 1) and (RPCBrokerV.Results[0] = '1'));
|
---|
| 181 | end;
|
---|
| 182 |
|
---|
| 183 | function GetProgressNoteHeader: string;
|
---|
| 184 | begin
|
---|
| 185 | Result := sCallV('ORQQPXRM PROGRESS NOTE HEADER', [Encounter.Location]);
|
---|
| 186 | end;
|
---|
| 187 |
|
---|
| 188 | function LoadMentalHealthTest(TestName: string): TStrings;
|
---|
| 189 | begin
|
---|
| 190 | CallV('ORQQPXRM MENTAL HEALTH', [TestName]);
|
---|
| 191 | Result := RPCBrokerV.Results;
|
---|
| 192 | end;
|
---|
| 193 |
|
---|
| 194 | procedure MentalHealthTestResults(var AText: string; const DlgIEN: integer; const TestName:
|
---|
| 195 | string; const AProvider: Int64; const Answers: string);
|
---|
| 196 | var
|
---|
| 197 | i, R: integer;
|
---|
| 198 | Ans, tmp: string;
|
---|
| 199 |
|
---|
| 200 | begin
|
---|
| 201 | with RPCBrokerV do
|
---|
| 202 | begin
|
---|
| 203 | ClearParameters := True;
|
---|
| 204 | RemoteProcedure := 'ORQQPXRM MENTAL HEALTH RESULTS';
|
---|
| 205 | Param[0].PType := literal;
|
---|
| 206 | Param[0].Value := IntToStr(DlgIEN);
|
---|
| 207 | Param[1].PType := list;
|
---|
| 208 | Param[1].Mult['"DFN"'] := Patient.DFN;
|
---|
| 209 | Param[1].Mult['"CODE"'] := TestName;
|
---|
| 210 | Param[1].Mult['"ADATE"'] := 'T';
|
---|
| 211 | Param[1].Mult['"STAFF"'] := IntToStr(AProvider);
|
---|
| 212 | R := 0;
|
---|
| 213 | tmp := '';
|
---|
| 214 | Ans := Answers;
|
---|
| 215 | repeat
|
---|
| 216 | tmp := copy(Ans,1,200);
|
---|
| 217 | delete(Ans,1,200);
|
---|
| 218 | inc(R);
|
---|
| 219 | Param[1].Mult['"R' + IntToStr(R) + '"'] := tmp;
|
---|
| 220 | until(Ans = '');
|
---|
| 221 | CallBroker;
|
---|
| 222 | AText := '';
|
---|
| 223 | for i := 0 to Results.Count-1 do
|
---|
| 224 | begin
|
---|
| 225 | tmp := Results[i];
|
---|
| 226 | if(Piece(tmp,U,1) = '7') then
|
---|
| 227 | begin
|
---|
| 228 | if(AText <> '') then
|
---|
| 229 | begin
|
---|
| 230 | if(copy(AText, length(AText), 1) = '.') then
|
---|
| 231 | AText := AText + ' ';
|
---|
| 232 | AText := AText + ' ';
|
---|
| 233 | end;
|
---|
| 234 | AText := AText + Trim(Piece(tmp, U, 2));
|
---|
| 235 | end;
|
---|
| 236 | end;
|
---|
| 237 | end;
|
---|
| 238 | end;
|
---|
| 239 |
|
---|
| 240 | procedure SaveMentalHealthTest(const TestName: string; ADate: TFMDateTime;
|
---|
| 241 | const AProvider: Int64; const Answers: string);
|
---|
| 242 | var
|
---|
| 243 | R: integer;
|
---|
| 244 | Ans, tmp: string;
|
---|
| 245 |
|
---|
| 246 | begin
|
---|
| 247 | with RPCBrokerV do
|
---|
| 248 | begin
|
---|
| 249 | ClearParameters := True;
|
---|
| 250 | RemoteProcedure := 'ORQQPXRM MENTAL HEALTH SAVE';
|
---|
| 251 | Param[0].PType := list;
|
---|
| 252 | Param[0].Mult['"DFN"'] := Patient.DFN;
|
---|
| 253 | Param[0].Mult['"CODE"'] := TestName;
|
---|
| 254 | Param[0].Mult['"ADATE"'] := FloatToStr(ADate);
|
---|
| 255 | Param[0].Mult['"STAFF"'] := IntToStr(AProvider);
|
---|
| 256 | R := 0;
|
---|
| 257 | tmp := '';
|
---|
| 258 | Ans := Answers;
|
---|
| 259 | repeat
|
---|
| 260 | tmp := copy(Ans,1,200);
|
---|
| 261 | delete(Ans,1,200);
|
---|
| 262 | inc(R);
|
---|
| 263 | Param[0].Mult['"R' + IntToStr(R) + '"'] := tmp;
|
---|
| 264 | until(Ans = '');
|
---|
| 265 | CallBroker;
|
---|
| 266 | end;
|
---|
| 267 | end;
|
---|
| 268 |
|
---|
| 269 | procedure SaveWomenHealthData(var WHData: TStringlist);
|
---|
| 270 | begin
|
---|
| 271 | if assigned(WHData) then
|
---|
| 272 | begin
|
---|
| 273 | CallV('ORQQPXRM WOMEN HEALTH SAVE', [WHData]);
|
---|
| 274 | // if RPCBrokerV.Results<>nil then
|
---|
| 275 | // infoBox(RPCBrokerV.Results.Text,'Error in Saving WH Data',MB_OK);
|
---|
| 276 | end;
|
---|
| 277 | end;
|
---|
| 278 |
|
---|
| 279 | function CheckGECValue(const RemIEN: string; NoteIEN: integer): String;
|
---|
| 280 | var
|
---|
| 281 | ans,str,str1,title: string;
|
---|
| 282 | fin: boolean;
|
---|
| 283 | i,cnt: integer;
|
---|
| 284 |
|
---|
| 285 | begin
|
---|
| 286 | Result := sCallV('ORQQPXRM GEC DIALOG', [RemIEN, Patient.DFN, Encounter.VisitStr, NoteIEN]);
|
---|
| 287 | if Piece(Result,U,1) <> '0' then
|
---|
| 288 | begin
|
---|
| 289 | if Piece(Result,U,5)='1' then
|
---|
| 290 | begin
|
---|
| 291 | if pos('~',Piece(Result,U,4))>0 then
|
---|
| 292 | begin
|
---|
| 293 | str:='';
|
---|
| 294 | str1 := Piece(Result,U,4);
|
---|
| 295 | cnt := DelimCount(str1, '~');
|
---|
| 296 | for i:=1 to cnt+1 do
|
---|
| 297 | begin
|
---|
| 298 | if i = 1 then str := Piece(str1,'~',i);
|
---|
| 299 | if i > 1 then str :=str+CRLF+Piece(str1,'~',i);
|
---|
| 300 | end;
|
---|
| 301 | end
|
---|
| 302 | else str := Piece(Result,U,1);
|
---|
| 303 | title := Piece(Result,U,3);
|
---|
| 304 | fin := (InfoBox(str,title, MB_YESNO)=IDYES);
|
---|
| 305 | if fin = true then ans := '1';
|
---|
| 306 | if fin = false then ans := '0';
|
---|
| 307 | CallV('ORQQPXRM GEC FINISHED?',[Patient.DFN,ans]);
|
---|
| 308 | end;
|
---|
| 309 | Result := Piece(Result, U,2);
|
---|
| 310 | end
|
---|
| 311 | else Result := '';
|
---|
| 312 | end;
|
---|
| 313 |
|
---|
| 314 | procedure SaveMSTDataFromReminder(VDate, Sts, Prov, FType, FIEN, Res: string);
|
---|
| 315 | begin
|
---|
| 316 | CallV('ORQQPXRM MST UPDATE', [Patient.DFN, VDate, Sts, Prov, FType, FIEN, Res]);
|
---|
| 317 | end;
|
---|
| 318 |
|
---|
| 319 | function GetReminderFolders: string;
|
---|
| 320 | begin
|
---|
| 321 | Result := sCallV('ORQQPX GET FOLDERS', []);
|
---|
| 322 | end;
|
---|
| 323 |
|
---|
| 324 | procedure SetReminderFolders(const Value: string);
|
---|
| 325 | begin
|
---|
| 326 | CallV('ORQQPX SET FOLDERS', [Value]);
|
---|
| 327 | end;
|
---|
| 328 |
|
---|
| 329 | function GetDefLocations: TStrings;
|
---|
| 330 | begin
|
---|
| 331 | if (User.DUZ <> uLastDefLocUser) then
|
---|
| 332 | begin
|
---|
| 333 | if(not assigned(uDefLocs)) then
|
---|
| 334 | uDefLocs := TStringList.Create;
|
---|
| 335 | tCallV(uDefLocs, 'ORQQPX GET DEF LOCATIONS', []);
|
---|
| 336 | uLastDefLocUser := User.DUZ;
|
---|
| 337 | end;
|
---|
| 338 | Result := uDefLocs;
|
---|
| 339 | end;
|
---|
| 340 |
|
---|
| 341 | function InsertRemTextAtCursor: boolean;
|
---|
| 342 | begin
|
---|
| 343 | if uRemInsertAtCursor < 0 then
|
---|
| 344 | begin
|
---|
| 345 | Result := (sCallV('ORQQPX REM INSERT AT CURSOR', []) = '1');
|
---|
| 346 | uRemInsertAtCursor := ord(Result);
|
---|
| 347 | end
|
---|
| 348 | else
|
---|
| 349 | Result := Boolean(uRemInsertAtCursor);
|
---|
| 350 | end;
|
---|
| 351 |
|
---|
| 352 | function NewRemCoverSheetListActive: boolean;
|
---|
| 353 | begin
|
---|
| 354 | if uNewCoverSheetListActive < 0 then
|
---|
| 355 | begin
|
---|
| 356 | Result := (sCallV('ORQQPX NEW COVER SHEET ACTIVE', []) = '1');
|
---|
| 357 | uNewCoverSheetListActive := ord(Result);
|
---|
| 358 | end
|
---|
| 359 | else
|
---|
| 360 | Result := Boolean(uNewCoverSheetListActive);
|
---|
| 361 | end;
|
---|
| 362 |
|
---|
| 363 | function CanEditAllRemCoverSheetLists: boolean;
|
---|
| 364 | begin
|
---|
| 365 | if uCanEditAllCoverSheetLists < 0 then
|
---|
| 366 | begin
|
---|
| 367 | Result := HasMenuOptionAccess('PXRM CPRS CONFIGURATION');
|
---|
| 368 | uCanEditAllCoverSheetLists := ord(Result);
|
---|
| 369 | end
|
---|
| 370 | else
|
---|
| 371 | Result := Boolean(uCanEditAllCoverSheetLists);
|
---|
| 372 | end;
|
---|
| 373 |
|
---|
| 374 | function GetCoverSheetLevelData(ALevel, AClass: string): TStrings;
|
---|
| 375 | begin
|
---|
| 376 | CallV('ORQQPX LVREMLST', [ALevel, AClass]);
|
---|
| 377 | Result := RPCBrokerV.Results;
|
---|
| 378 | end;
|
---|
| 379 |
|
---|
| 380 | procedure SetCoverSheetLevelData(ALevel, AClass: string; Data: TStrings);
|
---|
| 381 | var
|
---|
| 382 | i: integer;
|
---|
| 383 |
|
---|
| 384 | begin
|
---|
| 385 | with RPCBrokerV do
|
---|
| 386 | begin
|
---|
| 387 | ClearParameters := True;
|
---|
| 388 | RemoteProcedure := 'ORQQPX SAVELVL';
|
---|
| 389 | Param[0].PType := literal;
|
---|
| 390 | Param[0].Value := ALevel;
|
---|
| 391 | Param[1].PType := literal;
|
---|
| 392 | Param[1].Value := AClass;
|
---|
| 393 | Param[2].PType := list;
|
---|
| 394 | for i := 0 to Data.Count-1 do
|
---|
| 395 | Param[2].Mult[IntToStr(i+1)] := Data[i];
|
---|
| 396 | CallBroker;
|
---|
| 397 | end;
|
---|
| 398 | end;
|
---|
| 399 |
|
---|
| 400 | function GetCategoryItems(CatIEN: integer): TStrings;
|
---|
| 401 | begin
|
---|
| 402 | CallV('PXRM REMINDER CATEGORY', [CatIEN]);
|
---|
| 403 | Result := RPCBrokerV.Results;
|
---|
| 404 | end;
|
---|
| 405 |
|
---|
| 406 | function GetAllRemindersAndCategories: TStrings;
|
---|
| 407 | begin
|
---|
| 408 | CallV('PXRM REMINDERS AND CATEGORIES', []);
|
---|
| 409 | Result := RPCBrokerV.Results;
|
---|
| 410 | end;
|
---|
| 411 |
|
---|
| 412 | function VerifyMentalHealthTestComplete(TestName, Answers: string): String;
|
---|
| 413 |
|
---|
| 414 | begin
|
---|
| 415 | CallV('ORQQPXRM MHV', [Patient.DFN, TestName, Answers]);
|
---|
| 416 | if RPCBrokerV.Results[0]='2' then
|
---|
| 417 | begin
|
---|
| 418 | Result := '2'+ U;
|
---|
| 419 | EXIT;
|
---|
| 420 | end;
|
---|
| 421 | if RPCBrokerV.Results[0] = '1' then
|
---|
| 422 | begin
|
---|
| 423 | Result := '1' + U;
|
---|
| 424 | EXIT;
|
---|
| 425 | end;
|
---|
| 426 | if RPCBrokerV.Results[0] = '0' then
|
---|
| 427 | begin
|
---|
| 428 | Result := '0' + U + RPCBrokerV.Results[1];
|
---|
| 429 | EXIT;
|
---|
| 430 | end;
|
---|
| 431 | end;
|
---|
| 432 |
|
---|
| 433 | initialization
|
---|
| 434 |
|
---|
| 435 | finalization
|
---|
| 436 | FreeAndNil(uDefLocs);
|
---|
| 437 |
|
---|
| 438 | end.
|
---|