Changeset 830 for cprs/trunk/CPRS-Chart/fMHTest.pas
- Timestamp:
- Jul 7, 2010, 4:51:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Chart/fMHTest.pas
r456 r830 5 5 uses 6 6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 7 StdCtrls, ExtCtrls, ORCtrls, ORFn, uConst; 7 StdCtrls, ExtCtrls, ORCtrls, ORFn, uConst, fBase508Form, uDlgComponents, 8 VA508AccessibilityManager, uCore, orNet, TRPCB, StrUtils, rCore, VAUtils; 8 9 9 10 type 10 TfrmMHTest = class(TForm) 11 TShowProc = procedure(Broker: TRPCBroker; 12 InstrumentName, 13 PatientDFN, 14 OrderedBy, 15 OrderedByDUZ, 16 AdministeredBy, 17 AdministeredByDUZ, 18 Location, 19 LocationIEN: string; 20 Required: boolean; 21 var ProgressNote: string); stdcall; 22 23 TSaveProc = procedure(Broker: TRPCBroker; 24 InstrumentName, 25 PatientDFN, 26 OrderedByDUZ, 27 AdministeredByDUZ, 28 AdminDate, 29 LocationIEN: string; 30 var Status: string); stdcall; 31 32 TRemoveTempFile = procedure( 33 InstrumentName, 34 PatientDFN: string); stdcall; 35 36 TCloseProc = procedure; 37 38 TUsedMHDll = record 39 Checked: boolean; 40 Display: boolean; 41 end; 42 43 type 44 TfrmMHTest = class(TfrmBase508Form) 11 45 sbMain: TScrollBox; 12 46 pnlBottom: TPanel; … … 27 61 FObjs: TList; 28 62 FInfoText: string; 29 FInfoLabel: TMe mo;63 FInfoLabel: TMentalHealthMemo; 30 64 FBuilt: boolean; 31 65 FMaxLines: integer; … … 40 74 MHTestComp: string; 41 75 MHA3: boolean; 42 end; 43 44 function PerformMHTest(InitialAnswers, TestName: string; QText: TStringList): string; 45 76 function CallMHDLL(TestName: string; Required: boolean): String; 77 end; 78 79 function PerformMHTest(InitialAnswers, TestName: string; QText: TStringList; Required: boolean): string; 80 function SaveMHTest(TestName, Date, Loc: string): boolean; 81 procedure RemoveMHTest(TestName: string); 82 function CheckforMHDll: boolean; 83 procedure CloseMHDLL; 84 85 var 86 MHDLLHandle: THandle = 0; 87 46 88 implementation 47 89 48 uses rReminders;90 uses fFrame,rReminders, VA508AccessibilityRouter; 49 91 50 92 {$R *.DFM} … … 63 105 Gap = 2; 64 106 107 ShowProc : TShowProc = nil; 108 SaveProc : TSaveProc = nil; 109 RemoveTempFile : TRemoveTempFile = nil; 110 CloseProc : TCloseProc = nil; 111 SHARE_DIR = '\VISTA\Common Files\'; 65 112 var 66 113 frmMHTest: TfrmMHTest; 67 114 FFirstCtrl: TList; 68 115 FYPos: TList; 116 UsedMHDll: TUsedMHDll; 117 //DLLForceClose: boolean = false; 69 118 70 119 type … … 117 166 end; 118 167 119 function PerformMHTest(InitialAnswers, TestName: string; QText: TStringList): string; 168 function PerformMHTest(InitialAnswers, TestName: string; QText: TStringList; Required: boolean): string; 169 var 170 str,scores, tempStr: string; 120 171 begin 121 172 Result := InitialAnswers; 173 str := frmMHTest.CallMHDLL(testName, Required); 174 if str <> '' then 175 begin 176 if Piece(str,U,1) = 'COMPLETE' then 177 begin 178 Scores := Piece(str, U, 4); 179 if QText <> nil then 180 begin 181 tempStr := Piece(Str, U, 5); 182 if Pos('GAF Score', tempStr) = 0 then tempStr := Copy(tempStr, 2, Length(tempStr)); 183 tempStr := AnsiReplaceStr(tempStr,'1156','Response not required due to responses to other questions.'); 184 tempStr := AnsiReplaceStr(tempStr,'*','~~'); 185 PiecesToList(tempStr,'~',QText); 186 end; 187 Result := 'New MH dll^COMPLETE^'+ Scores; 188 end 189 else if Piece(str,U,1) = 'INCOMPLETE' then 190 begin 191 Result := 'New MH dll^INCOMPLETE^'; 192 end 193 else if (Piece(str,U,1) = 'CANCELLED') or (Piece(str, U, 1) = 'NOT STARTED') then 194 begin 195 Result := 'New MH dll^CANCELLED^'; 196 end; 197 frmMHTest.Free; 198 exit; 199 end; 122 200 frmMHTest := TfrmMHTest.Create(Application); 123 201 try … … 142 220 frmMHTest.Free; 143 221 end; 222 end; 223 224 function SaveMHTest(TestName, date, Loc: string): boolean; 225 var 226 MHPath, save: string; 227 228 begin 229 MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA'; 230 if MHDLLHandle = 0 then 231 MHDLLHandle := LoadLibrary(PChar(MHPath)); 232 Result := true; 233 if MHDLLHandle = 0 then 234 begin 235 InfoBox('YS_MHA.DLL not available', 'Error', MB_OK); 236 Exit; 237 end 238 else 239 begin 240 try 241 @SaveProc := GetProcAddress(MHDLLHandle, 'SaveInstrument'); 242 243 if @SaveProc = nil then 244 begin 245 // function not found.. misspelled? 246 infoBox('Save Instrument Function not found within YS_MHA.DLL.', 'Error', MB_OK); 247 Exit; 248 end; 249 250 if Assigned(SaveProc) then 251 begin 252 // fFrame.frmFrame.DLLActive := True; 253 try 254 SaveProc(RPCBrokerV, 255 UpperCase(TestName), //InstrumentName 256 Patient.DFN, //PatientDFN 257 InttoStr(User.duz), //OrderedByDUZ 258 InttoStr(User.duz), //AdministeredByDUZ 259 date, 260 Loc, //LocationIEN 261 save); 262 finally 263 // fFrame.frmFrame.DLLActive := false; 264 if RPCBrokerV.CurrentContext <> 'OR CPRS GUI CHART' then 265 begin 266 if RPCBrokerV.CreateContext('OR CPRS GUI CHART') = false then 267 infoBox('Error switching broker context','Error', MB_OK); 268 end; 269 end; {inner try..finally} 270 end; 271 finally 272 if MHDLLHandle <> 0 then 273 begin 274 FreeLibrary(MHDLLHandle); 275 MHDLLHandle := 0; 276 end; 277 end; {try..finally} 278 end; 279 end; 280 281 procedure RemoveMHTest(TestName: string); 282 var 283 MHPath: string; 284 begin 285 MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA'; 286 if MHDLLHandle = 0 then 287 MHDLLHandle := LoadLibrary(PChar(MHPath)); 288 if MHDLLHandle = 0 then 289 begin 290 InfoBox('YS_MHA.DLL not available', 'Error', MB_OK); 291 Exit; 292 end 293 else 294 begin 295 try 296 @RemoveTempFile := GetProcAddress(MHDLLHandle, 'RemoveTempFile'); 297 298 if @RemoveTempFile = nil then 299 begin 300 // function not found.. misspelled? 301 InfoBox('Remove Temp File function not found within YS_MHA.DLL.', 'Error', MB_OK); 302 Exit; 303 end; 304 305 if Assigned(RemoveTempFile) then 306 begin 307 // fFrame.frmFrame.DLLActive := True; 308 try 309 RemoveTempFile(UpperCase(TestName), //InstrumentName 310 Patient.DFN); 311 finally 312 // fFrame.frmFrame.DLLActive := False; 313 if RPCBrokerV.CurrentContext <> 'OR CPRS GUI CHART' then 314 begin 315 if RPCBrokerV.CreateContext('OR CPRS GUI CHART') = false then 316 infoBox('Error switching broker context','Error', MB_OK); 317 end; 318 end; {inner try..finally} 319 end; 320 finally 321 if MHDLLHandle <> 0 then 322 begin 323 FreeLibrary(MHDLLHandle); 324 MHDLLHandle := 0; 325 end; 326 end; {try..finally} 327 end; 328 end; 329 330 function CheckforMHDll: boolean; 331 var 332 MHPath: string; 333 begin 334 Result := True; 335 if (UsedMHDll.Checked = True) and (UsedMHDll.Display = False) then Exit 336 else if UsedMHDll.Checked = false then 337 begin 338 UsedMHDll.Display := UsedMHDllRPC; 339 UsedMHDll.Checked := True; 340 if UsedMHDll.Display = false then 341 begin 342 Result := False; 343 exit; 344 end; 345 end; 346 if MHDLLHandle = 0 then // if not 0 the DLL already loaded - result = true 347 begin 348 MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA'; 349 MHDLLHandle := LoadLibrary(PChar(MHPath)); 350 if MHDLLHandle = 0 then 351 Result := false 352 else 353 begin 354 FreeLibrary(MHDLLHandle); 355 MHDLLHandle := 0; 356 end; 357 end; 358 end; 359 360 procedure CloseMHDLL; 361 begin 362 if MHDLLHandle = 0 then Exit; 363 try 364 @CloseProc := GetProcAddress(MHDLLHandle, 'CloseDLL'); 365 if Assigned(CloseProc) then 366 begin 367 CloseProc; 368 end; 369 finally 370 if MHDLLHandle <> 0 then 371 begin 372 FreeLibrary(MHDLLHandle); 373 MHDLLHandle := 0; 374 end; 375 end; {try..finally} 144 376 end; 145 377 … … 250 482 TstData := TStringList.Create; 251 483 try 252 TstData.Assign(LoadMentalHealthTest(TestName));484 FastAssign(LoadMentalHealthTest(TestName), TstData); 253 485 if TstData.Strings[0] = '1' then MHA3 := True 254 486 else MHA3 := False; … … 360 592 end; 361 593 if(not Result) then 362 ShowMessage('Error encountered loading ' + TestName)594 InfoBox('Error encountered loading ' + TestName, 'Error', MB_OK) 363 595 else 364 596 begin … … 407 639 if(not assigned(FInfoLabel)) then 408 640 begin 409 FInfoLabel := TMe mo.Create(Self);641 FInfoLabel := TMentalHealthMemo.Create(Self); 410 642 FInfoLabel.Color := clBtnFace; 411 643 FInfoLabel.BorderStyle := bsNone; 412 644 FInfoLabel.ReadOnly := TRUE; 413 FInfoLabel.TabStop := FALSE;645 FInfoLabel.TabStop := ScreenReaderSystemActive; 414 646 FInfoLabel.Parent := sbMain; 415 647 FInfoLabel.WordWrap := TRUE; 416 648 FInfoLabel.Text := FInfoText; 417 649 FInfoLabel.Left := Gap; 650 UpdateColorsFor508Compliance(FInfoLabel); 418 651 end; 419 652 BoundsRect := FInfoLabel.BoundsRect; … … 439 672 end; 440 673 end; 674 amgrMain.RefreshComponents; 441 675 end; 442 676 … … 455 689 for i := 0 to FObjs.Count-1 do 456 690 QText.Add(copy(IntToStr(i+1) + '. ', 1, lx) + TMHQuestion(FObjs[i]).Question); 691 end; 692 693 function TfrmMHTest.CallMHDLL(TestName: string; Required: boolean): String; 694 var 695 // dllHandle : THandle; 696 ProgressNote, MHPath : string; 697 begin 698 ProgressNote := ''; 699 if (UsedMHDll.Checked = True) and (UsedMHDll.Display = False) then Exit 700 else if UsedMHDll.Checked = false then 701 begin 702 UsedMHDll.Display := UsedMHDllRPC; 703 UsedMHDll.Checked := True; 704 if UsedMHDll.Display = false then exit; 705 end; 706 MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA'; 707 if MHDLLHandle = 0 then 708 MHDLLHandle := LoadLibrary(PChar(MHPath)); 709 Result := ''; 710 if MHDLLHandle = 0 then 711 begin 712 InfoBox('YS_MHA.dll not available.' + CRLF + 'CPRS will continue processing the MH test using the previous format.' + 713 CRLF + CRLF + 'Contact IRM to install the YS_MHA.dll file on this machine.', 'Warning', MB_OK); 714 Exit; 715 end 716 else 717 begin 718 try 719 @ShowProc := GetProcAddress(MHDLLHandle, 'ShowInstrument'); 720 721 if @ShowProc = nil then 722 begin 723 // function not found.. misspelled? 724 InfoBox('Function ShowInstrument not found within YS_MHA.DLL not available', 'Error', MB_OK); 725 Exit; 726 end; 727 728 if Assigned(ShowProc) then 729 begin 730 // MHDLLHandle := dllHandle; 731 Result := ''; 732 // fFrame.frmFrame.DLLActive := True; 733 try 734 ShowProc(RPCBrokerV, 735 UpperCase(TestName), //InstrumentName 736 Patient.DFN, //PatientDFN 737 '', //OrderedByName 738 InttoStr(User.duz), //OrderedByDUZ 739 User.Name, //AdministeredByName 740 InttoStr(User.duz), //AdministeredByDUZ 741 Encounter.LocationName, //Location 742 InttoStr(Encounter.Location), //LocationIEN 743 Required, 744 ProgressNote); 745 Result := ProgressNote; 746 finally 747 // MHDllHandle := 0; 748 // fFrame.frmFrame.DLLActive := false; 749 if RPCBrokerV.CurrentContext <> 'OR CPRS GUI CHART' then 750 begin 751 if RPCBrokerV.CreateContext('OR CPRS GUI CHART') = false then 752 infoBox('Error switching broker context','Error', MB_OK); 753 end; 754 end; {inner try ..finally} 755 end; 756 finally 757 if MHDLLHandle <> 0 then 758 begin 759 FreeLibrary(MHDLLHandle); 760 MHDllHandle := 0; 761 end; 762 end; {try..finally} 763 //Result := ProgressNote; 764 end; 457 765 end; 458 766 … … 502 810 Shift: TShiftState); 503 811 begin 812 inherited; 504 813 if Key = VK_PRIOR then 505 814 begin … … 520 829 var 521 830 RCombo: TComboBox; 522 LNLbl, RLbl: TMe mo;831 LNLbl, RLbl: TMentalHealthMemo; 523 832 Bvl: TBevel; 524 833 cb: TORCheckBox; … … 556 865 if(FText <> '') then 557 866 begin 558 RLbl := TMe mo(GetCtrl(QuestionLabelTag));867 RLbl := TMentalHealthMemo(GetCtrl(QuestionLabelTag)); 559 868 if(not assigned(RLbl)) then 560 869 begin 561 RLbl := TMe mo.Create(frmMHTest);870 RLbl := TMentalHealthMemo.Create(frmMHTest); 562 871 RLbl.Color := clBtnFace; 563 872 RLbl.BorderStyle := bsNone; 564 873 RLbl.ReadOnly := TRUE; 565 RLbl.TabStop := FALSE;874 RLbl.TabStop := ScreenReaderSystemActive; 566 875 RLbl.Parent := frmMHTest.sbMain; 567 876 RLbl.Tag := FID + QuestionLabelTag; … … 569 878 RLbl.Text := FText; 570 879 FObjects.Add(RLbl); 880 UpdateColorsFor508Compliance(RLbl); 571 881 end; 572 882 BoundsRect.Top := Y; … … 596 906 if(frmMHTest.FObjs.Count >= NumberThreshhold) then 597 907 begin 598 LNLbl := TMe mo(GetCtrl(LineNumberTag));908 LNLbl := TMentalHealthMemo(GetCtrl(LineNumberTag)); 599 909 if(not assigned(LNLbl)) then 600 910 begin 601 LNLbl := TMe mo.Create(frmMHTest);911 LNLbl := TMentalHealthMemo.Create(frmMHTest); 602 912 LNLbl.Color := clBtnFace; 603 913 LNLbl.BorderStyle := bsNone; 604 914 LNLbl.ReadOnly := TRUE; 605 LNLbl.TabStop := FALSE;915 LNLbl.TabStop := ScreenReaderSystemActive; 606 916 LNLbl.Parent := frmMHTest.sbMain; 607 917 LNLbl.Tag := FID + LineNumberTag; 608 918 LNLbl.Text := IntToStr(QNum+1) + '.'; 919 if ScreenReaderSystemActive then 920 frmMHTest.amgrMain.AccessText[LNLbl] := 'Question'; 609 921 LNLbl.Width := TextWidthByFont(LNLbl.Font.Handle, LNLbl.Text); 610 922 LNLbl.Height := TextHeightByFont(LNLbl.Font.Handle, LNLbl.Text); 611 923 FObjects.Add(LNLbl); 924 UpdateColorsFor508Compliance(LNLbl); 612 925 end; 613 926 LNLbl.Top := Y; … … 625 938 Bvl.Shape := bsFrame; 626 939 FObjects.Add(Bvl); 940 UpdateColorsFor508Compliance(Bvl); 627 941 end; 628 942 Bvl.Top := Y; … … 660 974 cb.Caption := Piece(frmMHTest.FAnswers[FAnswerIndex + idx], U, 2); 661 975 FObjects.Add(cb); 976 UpdateColorsFor508Compliance(cb); 662 977 end; 663 978 cb.Top := Y; … … 692 1007 RCombo.Width := MaxDX + 24; 693 1008 RCombo.OnChange := OnChange; 1009 UpdateColorsFor508Compliance(RCombo); 694 1010 end; 695 1011 RCombo.Top := Y;
Note:
See TracChangeset
for help on using the changeset viewer.