Procedure

TfrmReports.GoRemote

Module

fReports

Last Modified

7/15/2014 3:26:38 PM

Visibility

Public/Published

Owner

TfrmReports

Declaration

procedure GoRemote(Dest: TStringList; AItem: string; AQualifier, ARpc: string; AHSTag: string; AHDR: string; aFHIE: string);

Calls Hierarchy


TfrmReports.GoRemote
 ├HDRActive
 ├StrToFMDateTime
 ├TRemoteSite.ReportClear
 ├TfrmReports.UpdateRemoteStatus
 ├TfrmReports.LoadListView
 │ ├TRowObject.Add
 │ │ ├TCellObject.Create
 │ │ └TCellObject.Add
 │ └TUser.HasKey
 │   └HasSecurityKey
 ├GetRemoteData
 ├DirectQuery
 └RemoteQuery

Called-By Hierarchy


                                   TfrmReports.GoRemote
                        TfrmReports.lstQualifierClick┤ 
                         TfrmReports.tvReportsClick┘ │ 
                  TfrmFrame.lstCIRNLocationsClick┤   │ 
                            TfrmFrame.SetUpCIRN┘ │   │ 
                       TfrmFrame.SetupPatient┘   │   │ 
                  UpdatePatientInfoForAlert┤     │   │ 
               TfrmFrame.mnuFileNextClick┘ │     │   │ 
             TfrmFrame.mnuFileOpenClick┤   │     │   │ 
                 TfrmFrame.UMInitiate┤ │   │     │   │ 
        TfrmFrame.mnuFileNextClick...┤ │   │     │   │ 
        TfrmFrame.mnuFileRefreshClick┤ │   │     │   │ 
        TfrmOrders.CheckOrderStatus┤ │ │   │     │   │ 
    TfrmOrders.mnuActChgEvntClick┤ │ │ │   │     │   │ 
       TfrmOrders.mnuActHoldClick┤ │ │ │   │     │   │ 
     TfrmOrders.mnuActUnholdClick┤ │ │ │   │     │   │ 
      TfrmOrders.mnuActRenewClick┤ │ │ │   │     │   │ 
     TfrmOrders.mnuActChangeClick┤ │ │ │   │     │   │ 
       TfrmOrders.mnuActCopyClick┘ │ │ │   │     │   │ 
             TfrmMeds.mnuActDCClick┤ │ │   │     │   │ 
            TfrmMeds.CheckMedStatus┘ │ │   │     │   │ 
         TfrmMeds.mnuActHoldClick┤   │ │   │     │   │ 
        TfrmMeds.mnuActRenewClick┤   │ │   │     │   │ 
       TfrmMeds.mnuActUnholdClick┤   │ │   │     │   │ 
       TfrmMeds.mnuActChangeClick┤   │ │   │     │   │ 
         TfrmMeds.mnuActCopyClick┤   │ │   │     │   │ 
       TfrmMeds.mnuActRefillClick┘   │ │   │     │   │ 
                   TfrmFrame.ViewInfo┘ │   │     │   │ 
                TfrmDCSumm.ViewInfo┤   │   │     │   │ 
              TfrmConsults.ViewInfo┤   │   │     │   │ 
      TfrmFrame.pnlRemindersMouseUp┤   │   │     │   │ 
       TfrmFrame.RemindersChanged┘ │   │   │     │   │ 
           TfrmFrame.FormCreate┘   │   │   │     │   │ 
             TfrmFrame.pnlCIRNClick┤   │   │     │   │ 
       TfrmFrame.pnlVistaWebClick┤ │   │   │     │   │ 
            TfrmFrame.FormKeyDown┘ │   │   │     │   │ 
          TfrmFrame.pnlPatientClick┤   │   │     │   │ 
            TfrmFrame.pnlVisitClick┤   │   │     │   │ 
      TfrmFrame.pnlPrimaryCareClick┤   │   │     │   │ 
        TfrmFrame.pnlRemindersClick┤   │   │     │   │ 
         TfrmFrame.pnlPostingsClick┤   │   │     │   │ 
             TfrmFrame.pnlFlagClick┤   │   │     │   │ 
               TfrmFrame.laMHVClick┤   │   │     │   │ 
              TfrmFrame.laVAA2Click┤   │   │     │   │ 
                TfrmOrders.ViewInfo┤   │   │     │   │ 
                  TfrmMeds.ViewInfo┤   │   │     │   │ 
               TfrmSurgery.ViewInfo┤   │   │     │   │ 
                 TfrmNotes.ViewInfo┤   │   │     │   │ 
              TfrmProblems.ViewInfo┘   │   │     │   │ 
      TfrmFrame.mnuFileNotifRemoveClick┤   │     │   │ 
              TfrmFrame.NextButtonClick┘   │     │   │ 
            TfrmFrame.SetUpNextButton┘     │     │   │ 
      TfrmFrame.mnuFileOpenClick...┤       │     │   │ 
               TfrmFrame.FormResize┘       │     │   │ 
             TfrmFrame.ChangeFont┘         │     │   │ 
     TfrmFrame.LoadSizesForUser┤           │     │   │ 
TfrmFrame.LoadUserPreferences┘ │           │     │   │ 
       TfrmFrame.UMInitiate┘   │           │     │   │ 
     TfrmFrame.mnuFontSizeClick┘           │     │   │ 
              TfrmFrame.mnuFileOpenClick...┤     │   │ 
           TfrmFrame.AllowCCOWContextChange┤     │   │ 
            TfrmFrame.mnuFileNextClick...┤ │     │   │ 
            TfrmFrame.mnuFileOpenClick...┤ │     │   │ 
   TfrmFrame.mnuFileResumeContextSetClick┘ │     │   │ 
                TfrmFrame.UpdateCCOWContext┤     │   │ 
            TfrmFrame.mnuFileOpenClick...┤ │     │   │ 
          TfrmFrame.ctxContextorCommitted┤ │     │   │ 
           TfrmFrame.StartCCOWContextor┘ │ │     │   │ 
                 TfrmFrame.FormCreate┘   │ │     │   │ 
   TfrmFrame.mnuFileResumeContextGetClick┘ │     │   │ 
     TfrmFrame.mnuFileResumeContextSetClick┘     │   │ 
                          TfrmReports.DisplayPage┤   │ 
                         TfrmReports.LoadTreeView┤   │ 
                        TfrmReports.DisplayPage┤ │   │ 
           TfrmOptionsReportsDefault.btnOKClick┤ │   │ 
        TfrmOptionsReportsDefault.btnResetClick┤ │   │ 
         TfrmOptionsReportsCustom.btnApplyClick┘ │   │ 
          TfrmOptionsReportsCustom.btnOKClick┘   │   │ 
                 TfrmReports.ProcessNotifications┤   │ 
                        TfrmReports.DisplayPage┘ │   │ 
                     TfrmReports.tvReportsKeyDown┤   │ 
                  TfrmReports.tvProceduresKeyDown┤   │ 
                      TfrmReports.chkMaxFreqClick┤   │ 
             TfrmOptionsReportsDefault.btnOKClick┤   │ 
          TfrmOptionsReportsDefault.btnResetClick┤   │ 
        TfrmOptionsReportsCustom.btnApplyClick...┘   │ 
                        TfrmReports.tvReportsClick...┘ 

Calls

Name Declaration Comments
DirectQuery procedure DirectQuery(Dest: TStrings; AReportType: string; AHSType, ADaysback, AExamID: string; Alpha, AOmega: Double; ASite, ARemoteRPC, AHSTag: String); -
GetRemoteData procedure GetRemoteData(Dest: TStrings; aHandle: string; aItem: PChar); -
HDRActive function HDRActive: String; -
TfrmReports.LoadListView procedure LoadListView(aReportData: TStringList); -
RemoteQuery procedure RemoteQuery(Dest: TStrings; AReportType: string; AHSType, ADaysback, AExamID: string; Alpha, AOmega: Double; ASite, ARemoteRPC, AHSTag: String); -
TRemoteSite.ReportClear procedure ReportClear; -
StrToFMDateTime function StrToFMDateTime(const AString: string): TFMDateTime; -
TfrmReports.UpdateRemoteStatus procedure UpdateRemoteStatus(aSiteID, aStatus: string); -

Called-By

Name Declaration Comments
TfrmReports.lstQualifierClick procedure lstQualifierClick(Sender: TObject); -
TfrmReports.tvReportsClick procedure tvReportsClick(Sender: TObject); -


Source

1707  procedure TfrmReports.GoRemote(Dest: TStringList; AItem: string; AQualifier, ARpc: string; AHSTag: string; AHDR: string; aFHIE: string);
1708  var
1709    i, j: integer;
1710    LocalHandle, Query, Report, Seq: string;
1711    HSType, DaysBack, ExamID, MaxOcc: string;
1712    Alpha, Omega, Trans: double;
1713  begin
1714    HSType := '';
1715    DaysBack := '';
1716    ExamID := '';
1717    Alpha := 0;
1718    Omega := 0;
1719    Seq := '';
1720    if AHDR = '1' then
1721      begin
1722        if HDRActive = '0' then
1723          begin
1724            InfoBox('The HDR is currently inactive in CPRS.' + CRLF + 'You must use VistaWeb to view this report.', 'Use VistaWeb for HDR data', MB_OK);
1725            Exit;
1726          end;
1727        //InfoBox('You must use VistaWeb to view this report.', 'Use VistaWeb for HDR data', MB_OK);
1728        if (Piece(AItem, ':', 1) = 'OR_VWAL') or (Piece(AItem, ':', 1) = 'OR_VWRX') then
1729          AQualifier := 'T-50000;T+50000;99999';
1730        if (Piece(AItem, ':', 1) = 'OR_VWVS') and (CharAt(AQualifier, 1) = ';') then
1731          AQualifier := 'T-50000;T+50000;99999';
1732      end;
1733    if CharAt(AQualifier, 1) = 'd' then
1734      begin
1735        DaysBack := Copy(AQualifier, 2, Length(AQualifier));
1736        AQualifier := ('T-' + Piece(DaysBack,';',1) + ';T;' + Pieces(AQualifier,';',2,3));
1737        DaysBack := '';
1738      end;
1739    if CharAt(AQualifier, 1) = 'T' then
1740      begin
1741        if Piece(AQualifier,';',1) = 'T-0' then SetPiece(AQualifier,';',1,'T');
1742        if (Piece(Aqualifier,';',1) = 'T') and (Piece(Aqualifier,';',2) = 'T')
1743          then SetPiece(AQualifier,';',2,'T+1');
1744        Alpha := StrToFMDateTime(Piece(AQualifier,';',1));
1745        Omega := StrToFMDateTime(Piece(AQualifier,';',2));
1746        if Alpha > Omega then
1747          begin
1748            Trans := Omega;
1749            Omega := Alpha;
1750            Alpha := Trans;
1751          end;
1752        MaxOcc := Piece(AQualifier,';',3);
1753        SetPiece(AHSTag,';',4,MaxOcc);
1754      end;
1755    if CharAt(AQualifier, 1) = 'h' then HSType   := Copy(AQualifier, 2, Length(AQualifier));
1756    if CharAt(AQualifier, 1) = 'i' then ExamID   := Copy(AQualifier, 2, Length(AQualifier));
1757    with RemoteSites.SiteList do for i := 0 to Count - 1 do
1758      begin
1759      if (AHDR='1') and (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') then
1760        begin
1761          //TRemoteSite(Items[i]).Selected := true;
1762          //frmFrame.lstCIRNLocations.Checked[i+1] := true;
1763        end;
1764      if TRemoteSite(Items[i]).Selected then
1765        begin
1766          TRemoteSite(Items[i]).ReportClear;
1767          if (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') and not(AHDR = '1') then
1768            begin
1769              TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
1770              UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
1771              TRemoteSite(Items[i]).RemoteHandle := '';
1772              TRemoteSite(Items[i]).QueryStatus := '1^Done';
1773              if uQualifierType = 6 then seq := '1^';
1774              TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
1775              if uQualifierType = 6 then seq := '2^';
1776              TRemoteSite(Items[i]).Data.Add(seq + '<No HDR Data Included> - Use "HDR Reports" menu for HDR Data.');
1777              TabControl1.OnChange(nil);
1778              if (length(piece(uHState,';',2)) > 0) then
1779                LoadListView(TRemoteSite(Items[i]).Data);
1780              continue;
1781            end;
1782          if (AHDR = '1') and not(LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') then
1783            begin
1784              TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
1785              UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
1786              TRemoteSite(Items[i]).RemoteHandle := '';
1787              TRemoteSite(Items[i]).QueryStatus := '1^Done';
1788              if uQualifierType = 6 then seq := '1^';
1789              TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
1790              if uQualifierType = 6 then seq := '2^';
1791              TRemoteSite(Items[i]).Data.Add(seq + '<No HDR Data> This site is not a source for HDR Data.');
1792              TabControl1.OnChange(nil);
1793              if (length(piece(uHState,';',2)) > 0) then
1794                LoadListView(TRemoteSite(Items[i]).Data);
1795              continue;
1796            end;
1797          if (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200') and not(aFHIE = '1') then
1798            begin
1799              TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
1800              UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
1801              TRemoteSite(Items[i]).RemoteHandle := '';
1802              TRemoteSite(Items[i]).QueryStatus := '1^Done';
1803              if uQualifierType = 6 then seq := '1^';
1804              TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
1805              if uQualifierType = 6 then seq := '2^';
1806              TRemoteSite(Items[i]).Data.Add(seq + '<No DOD Data> - Use "Dept. of Defense Reports" Menu to retrieve data from DOD.');
1807              TabControl1.OnChange(nil);
1808              if (length(piece(uHState,';',2)) > 0) then
1809                LoadListView(TRemoteSite(Items[i]).Data);
1810              continue;
1811            end;
1812          TRemoteSite(Items[i]).CurrentReportQuery := 'Report' + Patient.DFN + ';'
1813            + Patient.ICN + '^' + AItem + '^^^' + ARpc + '^' + HSType +
1814            '^' + DaysBack + '^' + ExamID + '^' + FloatToStr(Alpha) + '^' +
1815            FloatToStr(Omega) + '^' + TRemoteSite(Items[i]).SiteID + '^' + AHSTag + '^' + AHDR;
1816          LocalHandle := '';
1817          Query := TRemoteSite(Items[i]).CurrentReportQuery;
1818          for j := 0 to RemoteReports.Count - 1 do
1819            begin
1820              Report := TRemoteReport(RemoteReports.ReportList.Items[j]).Report;
1821              if Report = Query then
1822                begin
1823                  LocalHandle := TRemoteReport(RemoteReports.ReportList.Items[j]).Handle;
1824                  break;
1825                end;
1826            end;
1827          if Length(LocalHandle) > 1 then
1828            with RemoteSites.SiteList do
1829              begin
1830                GetRemoteData(TRemoteSite(Items[i]).Data,LocalHandle,Items[i]);
1831                TRemoteSite(Items[i]).RemoteHandle := '';
1832                TRemoteSite(Items[i]).QueryStatus := '1^Done';
1833                UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Done');
1834                TabControl1.OnChange(nil);
1835                if (length(piece(uHState,';',2)) > 0) then //and (chkText.Checked = false) then
1836                  LoadListView(TRemoteSite(Items[i]).Data);
1837              end
1838          else
1839            begin
1840              if uDirect = '1' then
1841                begin
1842                  StatusText('Retrieving reports from ' + TRemoteSite(Items[i]).SiteName + '...');
1843                  TRemoteSite(Items[i]).QueryStatus := '1^Direct Call';
1844                  UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Direct Call');
1845                  DirectQuery(Dest, AItem, HSType, Daysback, ExamID, Alpha, Omega, TRemoteSite(Items[i]).SiteID, ARpc, AHSTag);
1846                  if Copy(Dest[0],1,2) = '-1' then
1847                    begin
1848                      TRemoteSite(Items[i]).QueryStatus := '-1^Communication error';
1849                      UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication error');
1850                      if uQualifierType = 6 then seq := '1^';
1851                      TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
1852                      if uQualifierType = 6 then seq := '2^';
1853                      TRemoteSite(Items[i]).Data.Add(seq + '<ERROR>- Unable to communicate with Remote site');
1854                      TabControl1.OnChange(nil);
1855                      if (length(piece(uHState,';',2)) > 0) then
1856                        LoadListView(TRemoteSite(Items[i]).Data);
1857                    end
1858                  else
1859                    begin
1860                      QuickCopy(Dest,TRemoteSite(Items[i]).Data);
1861                      TRemoteSite(Items[i]).RemoteHandle := '';
1862                      TRemoteSite(Items[i]).QueryStatus := '1^Done';
1863                      UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Done');
1864                      TabControl1.OnChange(nil);
1865                      if (length(piece(uHState,';',2)) > 0) then
1866                        LoadListView(TRemoteSite(Items[i]).Data);
1867                    end;
1868                  StatusText('');
1869                end
1870              else
1871                begin
1872                  RemoteQuery(Dest, AItem, HSType, Daysback, ExamID, Alpha, Omega, TRemoteSite(Items[i]).SiteID, ARpc, AHSTag);
1873                  if Dest[0] = '' then
1874                    begin
1875                      TRemoteSite(Items[i]).QueryStatus := '-1^Communication error';
1876                      UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication error');
1877                      if uQualifierType = 6 then seq := '1^';
1878                      TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
1879                      if uQualifierType = 6 then seq := '2^';
1880                      TRemoteSite(Items[i]).Data.Add(seq + '<ERROR>- Unable to communicate with Remote site');
1881                      TabControl1.OnChange(nil);
1882                      if (length(piece(uHState,';',2)) > 0) then
1883                        LoadListView(TRemoteSite(Items[i]).Data);
1884                    end
1885                  else
1886                    begin
1887                      TRemoteSite(Items[i]).RemoteHandle := Dest[0];
1888                      TRemoteSite(Items[i]).QueryStatus := '0^initialization...';
1889                      UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'initialization');
1890                      Timer1.Enabled := True;
1891                      StatusText('Retrieving reports from ' + TRemoteSite(Items[i]).SiteName + '...');
1892                    end;
1893                end;
1894            end;
1895        end;
1896      end;
1897  end;