コード例 #1
0
ファイル: FormTerminal.cs プロジェクト: royedwards/DRDNet
        ///<summary>Only in nonSimpleMode.  Occurs every 4 seconds. Checks the database to verify that this kiosk should still be running and that the
        ///correct patient's forms are loaded.  If there shouldn't be forms loaded, clears the forms.  If this kiosk (terminalactive row) has been deleted
        ///then this form is closed.  If FormSheetFillEdit is visible, signals that form to force it closed (user will lose any unsaved data).</summary>
        private void timer1_Tick(object sender, EventArgs e)
        {
            TerminalActive terminal = null;

            try{
                Process processCur = Process.GetCurrentProcess();
                terminal = TerminalActives.GetForCmptrSessionAndId(Environment.MachineName, processCur.SessionId, processCur.Id);
                labelConnection.Visible = false;
            }
            catch (Exception) {           //SocketException if db connection gets lost.
                labelConnection.Visible = true;
                return;
            }
            if (terminal == null)
            {
                //this terminal shouldn't be running, receptionist must've deleted this kiosk, close the form (causes application exit if NOT IsSimpleMode)
                if (_formSheetFillEdit != null && !_formSheetFillEdit.IsDisposed)
                {
                    _formSheetFillEdit.ForceClose();
                }
                Close();
                return;
            }
            if (_formSheetFillEdit == null || _formSheetFillEdit.IsDisposed)
            {
                return;
            }
            List <Sheet> listSheets = Sheets.GetForTerminal(terminal.PatNum);

            if (terminal.PatNum == 0 || terminal.PatNum != PatNum || listSheets.Count == 0 || listSheets.All(x => x.SheetNum != _formSheetFillEdit.SheetCur.SheetNum))
            {
                //patient has been changed or cleared, or there are no forms to fill for the selected patient, force FormSheetFillEdit closed if open
                _formSheetFillEdit.ForceClose();
            }
        }
コード例 #2
0
ファイル: FormTerminal.cs プロジェクト: royedwards/DRDNet
        private void butDone_Click(object sender, EventArgs e)
        {
            Sheets.ClearFromTerminal(PatNum);
            labelForms.Visible = false;
            listForms.Visible  = false;
            butDone.Visible    = false;
            if (IsSimpleMode)             //not subscribed to signals if IsSimpleMode
            {
                PatNum                = 0;
                _listSheets           = new List <Sheet>();
                labelThankYou.Visible = true;
                return;
            }
            //NOT IsSimpleMode from here down
            TerminalActive terminal;
            Process        processCur = Process.GetCurrentProcess();

            try{
                terminal = TerminalActives.GetForCmptrSessionAndId(Environment.MachineName, processCur.SessionId, processCur.Id);
                labelConnection.Visible = false;
            }
            catch (Exception) {           //SocketException if db connection gets lost.
                labelConnection.Visible = true;
                return;
            }
            //this terminal shouldn't be running, receptionist must've deleted this kiosk, close the form (causes application exit if NOT IsSimpleMode).
            if (terminal == null)
            {
                Close();                //signal sent in form closing
                return;
            }
            if (terminal.PatNum != 0)
            {
                labelWelcome.Visible = true;
                TerminalActives.SetPatNum(terminal.TerminalActiveNum, 0);
                PatNum      = 0;
                _listSheets = new List <Sheet>();
                Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id);              //signal the terminal manager to refresh its grid
            }
        }
コード例 #3
0
ファイル: FormTerminal.cs プロジェクト: royedwards/DRDNet
        ///<summary>Used in both modes.  Loads the list of sheets into the listbox.  Then launches the first sheet and goes through the sequence of sheets.
        ///If user clicks cancel, the seqeunce will exit.  If NOT IsSimpleMode, then the TerminalManager can also send a signal to immediately terminate
        ///the sequence.  If PatNum is 0, this will unload the patient by making the form list not visible and the welcome message visible.</summary>
        private void LoadPatient(bool isRefreshOnly)
        {
            TerminalActive terminal = null;

            _listSheets = new List <Sheet>();
            Process processCur = Process.GetCurrentProcess();

            if (IsSimpleMode)
            {
                if (PatNum > 0)
                {
                    _listSheets = Sheets.GetForTerminal(PatNum);
                }
            }
            else              //NOT IsSimpleMode
            {
                try{
                    terminal = TerminalActives.GetForCmptrSessionAndId(Environment.MachineName, processCur.SessionId, processCur.Id);
                    labelConnection.Visible = false;
                }
                catch (Exception) {               //SocketException if db connection gets lost.
                    labelConnection.Visible = true;
                    return;
                }
                if (terminal == null)
                {
                    //this terminal shouldn't be running, receptionist must've deleted this kiosk, close the form (causes application exit if NOT IsSimpleMode)
                    Close();                    //signal sent in form closing
                    return;
                }
                if (terminal.PatNum > 0)
                {
                    _listSheets = Sheets.GetForTerminal(terminal.PatNum);
                }
                if (_listSheets.Count == 0)               //either terminal.PatNum is 0 or no sheets for pat
                {
                    labelWelcome.Visible = true;
                    labelForms.Visible   = false;
                    listForms.Visible    = false;
                    butDone.Visible      = false;
                    if (terminal.PatNum > 0)                   //pat loaded but no sheets to show, unload pat, update db, send signal
                    {
                        TerminalActives.SetPatNum(terminal.TerminalActiveNum, 0);
                        Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id);
                    }
                    PatNum = 0;
                    if (_formSheetFillEdit != null && !_formSheetFillEdit.IsDisposed)
                    {
                        _formSheetFillEdit.ForceClose();
                    }
                    return;
                }
            }
            //we have a patient loaded who has some sheets to show in the terminal
            labelWelcome.Visible = false;
            labelForms.Visible   = true;
            listForms.Visible    = true;
            butDone.Visible      = true;
            listForms.Items.Clear();
            _listSheets.ForEach(x => listForms.Items.Add(x.Description));
            if (!IsSimpleMode)
            {
                if (PatNum == terminal.PatNum)
                {
                    return;                    //if the pat was not cleared or replaced just return, if sheets are currently being displayed (loop below), continue displaying them
                }
                //PatNum is changed, set it to the db terminalactive and signal others, then begin displaying sheets (loop below)
                PatNum = terminal.PatNum;
                if (_formSheetFillEdit != null && !_formSheetFillEdit.IsDisposed)
                {
                    _formSheetFillEdit.ForceClose();
                }
                Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id);
            }
            if (!isRefreshOnly)
            {
                AutoShowSheets();
            }
        }