Ignore:
Timestamp:
May 7, 2015, 12:34:29 PM (9 years ago)
Author:
healthsevak
Message:

Updating the working copy to CPRS version 28

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/fMHTest.pas

    r830 r1679  
    11unit fMHTest;
     2
     3{$DEFINE CCOWBROKER}
    24
    35interface
     
    68  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    79  StdCtrls, ExtCtrls, ORCtrls, ORFn, uConst, fBase508Form, uDlgComponents,
    8   VA508AccessibilityManager, uCore, orNet, TRPCB, StrUtils, rCore, VAUtils;
     10  VA508AccessibilityManager, uCore, orNet, TRPCB, StrUtils, rCore, VAUtils
     11  ;
    912
    1013type
    11 TShowProc = procedure(Broker: TRPCBroker;
     14TShowProc = procedure(
     15   RPCBrokerV: TRPCBroker;
    1216  InstrumentName,
    1317  PatientDFN,
     
    2125  var ProgressNote: string); stdcall;
    2226
    23 TSaveProc = procedure(Broker: TRPCBroker;
     27TSaveProc = procedure(
     28   RPCBrokerV: TRPCBroker;
    2429  InstrumentName,
    2530  PatientDFN,
     
    3035  var Status: string); stdcall;
    3136
    32 TRemoveTempFile = procedure(
     37TRemoveTempVistaFile = procedure(
     38   RPCBrokerV: TRPCBroker;
    3339  InstrumentName,
    3440  PatientDFN: string); stdcall;
     
    8591var
    8692  MHDLLHandle: THandle = 0;
    87  
     93
    8894implementation
    8995
     
    107113  ShowProc                    : TShowProc = nil;
    108114  SaveProc                    : TSaveProc = nil;
    109   RemoveTempFile              : TRemoveTempFile = nil;
    110   CloseProc                  : TCloseProc = nil;
     115  RemoveTempVistaFile         : TRemoveTempVistaFile = nil;
     116  CloseProc                   : TCloseProc = nil;
    111117  SHARE_DIR = '\VISTA\Common Files\';
    112118var
     
    115121  FYPos: TList;
    116122  UsedMHDll: TUsedMHDll;
    117   //DLLForceClose: boolean = false;
    118123
    119124type
     
    147152  end;
    148153
     154const
     155  MHDLLName = 'YS_MHA_A.DLL';
     156
     157procedure LoadMHDLL;
     158var
     159  MHPath: string;
     160
     161begin
     162  if MHDLLHandle = 0 then
     163  begin
     164    MHPath := GetProgramFilesPath + SHARE_DIR + MHDLLName;
     165    MHDLLHandle := LoadLibrary(PChar(MHPath));
     166  end;
     167end;
     168
     169procedure UnloadMHDLL;
     170begin
     171  if MHDLLHandle <> 0 then
     172  begin
     173    FreeLibrary(MHDLLHandle);
     174    MHDLLHandle := 0;
     175  end;
     176end;
     177
    149178procedure ProcessMsg;
    150179var
     
    224253function SaveMHTest(TestName, date, Loc: string): boolean;
    225254var
    226   MHPath, save: string;
    227  
    228 begin
    229   MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA';
    230   if MHDLLHandle = 0 then
    231     MHDLLHandle := LoadLibrary(PChar(MHPath));
     255  save: string;
     256begin
     257  LoadMHDLL;
    232258  Result := true;
    233259  if MHDLLHandle = 0 then
    234260    begin
    235       InfoBox('YS_MHA.DLL not available', 'Error', MB_OK);
     261      InfoBox(MHDLLName + ' not available', 'Error', MB_OK);
    236262      Exit;
    237263    end
     
    244270          begin
    245271          // function not found.. misspelled?
    246             infoBox('Save Instrument Function not found within YS_MHA.DLL.', 'Error', MB_OK);
     272            infoBox('Save Instrument Function not found within ' + MHDLLName + '.', 'Error', MB_OK);
    247273            Exit;
    248274          end;
     
    250276        if Assigned(SaveProc) then
    251277         begin
    252 //          fFrame.frmFrame.DLLActive := True;
    253278          try
    254279            SaveProc(RPCBrokerV,
     
    258283            InttoStr(User.duz), //AdministeredByDUZ
    259284            date,
    260             Loc, //LocationIEN
     285            Loc + 'V', //LocationIEN
    261286            save);
    262287          finally
    263 //            fFrame.frmFrame.DLLActive := false;
    264288            if RPCBrokerV.CurrentContext <> 'OR CPRS GUI CHART' then
    265289               begin
     
    270294         end;
    271295      finally
    272         if MHDLLHandle <> 0 then
    273         begin
    274           FreeLibrary(MHDLLHandle);
    275           MHDLLHandle := 0;
    276         end;
     296        UnloadMHDLL;
    277297      end; {try..finally}
    278298  end;
     
    280300
    281301procedure RemoveMHTest(TestName: string);
    282 var
    283   MHPath: string;
    284 begin
    285   MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA';
     302begin
     303  LoadMHDLL;
    286304  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);
     305    begin
     306      InfoBox(MHDLLName + ' not available', 'Error', MB_OK);
    291307      Exit;
    292308    end
     
    294310    begin
    295311      try
    296         @RemoveTempFile := GetProcAddress(MHDLLHandle, 'RemoveTempFile');
    297 
    298         if @RemoveTempFile = nil then
     312        @RemoveTempVistaFile := GetProcAddress(MHDLLHandle, 'RemoveTempVistaFile');
     313
     314        if @RemoveTempVistaFile = nil then
    299315          begin
    300316          // function not found.. misspelled?
    301             InfoBox('Remove Temp File function not found within YS_MHA.DLL.', 'Error', MB_OK);
     317            InfoBox('Remove Temp File function not found within ' + MHDLLName + '.', 'Error', MB_OK);
    302318            Exit;
    303319          end;
    304320
    305         if Assigned(RemoveTempFile) then
     321        if Assigned(RemoveTempVistaFile) then
    306322         begin
    307 //          fFrame.frmFrame.DLLActive := True;
    308323          try
    309             RemoveTempFile(UpperCase(TestName), //InstrumentName
     324            RemoveTempVistaFile(RPCBrokerV,
     325            UpperCase(TestName), //InstrumentName
    310326            Patient.DFN);
    311327          finally
    312 //            fFrame.frmFrame.DLLActive := False;
    313328            if RPCBrokerV.CurrentContext <> 'OR CPRS GUI CHART' then
    314329               begin
     
    319334         end;
    320335      finally
    321         if MHDLLHandle <> 0 then
    322         begin
    323           FreeLibrary(MHDLLHandle);
    324           MHDLLHandle := 0;
    325         end;
     336        UnloadMHDLL;
    326337      end; {try..finally}
    327338  end;
     
    329340
    330341function CheckforMHDll: boolean;
    331 var
    332   MHPath: string;
    333342begin
    334343  Result := True;
     
    346355  if MHDLLHandle = 0 then // if not 0 the DLL already loaded - result = true
    347356  begin
    348     MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA';
    349     MHDLLHandle := LoadLibrary(PChar(MHPath));
     357    LoadMHDLL;
    350358    if MHDLLHandle = 0 then
    351359      Result := false
    352360    else
    353     begin
    354       FreeLibrary(MHDLLHandle);
    355       MHDLLHandle := 0;
    356     end;
     361      UnloadMHDLL;
    357362  end;
    358363end;
     
    368373    end;
    369374  finally
    370     if MHDLLHandle <> 0 then
    371     begin
    372       FreeLibrary(MHDLLHandle);
    373       MHDLLHandle := 0;
    374     end;
     375    UnloadMHDLL;
    375376  end; {try..finally}
    376377end;
     
    693694function TfrmMHTest.CallMHDLL(TestName: string; Required: boolean): String;
    694695var                               
    695 //  dllHandle                   : THandle;
    696   ProgressNote, MHPath                : string;
     696  ProgressNote : string;
    697697begin
    698698  ProgressNote := '';
     
    704704      if UsedMHDll.Display = false then exit;
    705705    end;
    706   MHPath := GetProgramFilesPath + SHARE_DIR + 'YS_MHA';
    707   if MHDLLHandle = 0 then
    708     MHDLLHandle := LoadLibrary(PChar(MHPath));
     706  LoadMHDLL;
    709707  Result := '';
    710708  if MHDLLHandle = 0 then
    711709    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);
     710      InfoBox(MHDLLName + ' not available.' + CRLF +
     711                          'CPRS will continue processing the MH test using the previous format.' +
     712                  CRLF + CRLF + 'Contact IRM to install the ' + MHDLLName +
     713                                ' file on this machine.', 'Warning', MB_OK);
    714714      Exit;
    715715    end
     
    722722          begin
    723723          // function not found.. misspelled?
    724             InfoBox('Function ShowInstrument not found within YS_MHA.DLL not available', 'Error', MB_OK);
     724            InfoBox('Function ShowInstrument not found within ' + MHDLLName +
     725                    ' not available', 'Error', MB_OK);
    725726            Exit;
    726727          end;
     
    728729        if Assigned(ShowProc) then
    729730           begin
    730 //             MHDLLHandle := dllHandle;
    731731             Result := '';
    732 //             fFrame.frmFrame.DLLActive := True;
    733732             try
    734733               ShowProc(RPCBrokerV,
     
    740739               InttoStr(User.duz), //AdministeredByDUZ
    741740               Encounter.LocationName, //Location
    742                InttoStr(Encounter.Location), //LocationIEN
     741               InttoStr(Encounter.Location) + 'V', //LocationIEN
    743742               Required,
    744743               ProgressNote);
    745744               Result := ProgressNote;
    746745           finally
    747 //             MHDllHandle := 0;
    748 //             fFrame.frmFrame.DLLActive := false;
    749              if RPCBrokerV.CurrentContext <> 'OR CPRS GUI CHART' then
     746//           if RPCBrokerV.CurrentContext <> 'OR CPRS GUI CHART' then
    750747               begin
    751748                 if RPCBrokerV.CreateContext('OR CPRS GUI CHART') = false then
     
    755752            end;
    756753      finally
    757         if MHDLLHandle <> 0 then
    758         begin
    759           FreeLibrary(MHDLLHandle);
    760           MHDllHandle := 0;
    761         end;
     754        UnloadMHDLL;
    762755      end; {try..finally}
    763756      //Result := ProgressNote;
Note: See TracChangeset for help on using the changeset viewer.