Ignore:
Timestamp:
Mar 23, 2011, 5:15:51 AM (13 years ago)
Author:
Sam Habiel
Message:

CGAppointment: Added Provider as a Member of Class. (auto property)
CGDocument: No changes
CGDocumentManager: Added UserPreferences as a member of a Class (private and property)
CGView: Changes to support printing of Routing Slip
DAppointPage: Changes to support UserPreferences member for auto printing the routing slips
DCheckIn: Extensive changes in load code (now uses LINQ instead of ADO.net). Changes to support UserPreferences member for auto printing the routing slips.
Patient: Documentation for UserFriendlyAge.
Provider: New class to represent Provider
UserPreferences: New class to represent User preferences. Does not interact with DB right now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs

    r1062 r1111  
    77using System.Diagnostics;
    88using IndianHealthService.BMXNet;
     9using System.Collections.Generic;
     10using System.Linq;
    911
    1012namespace IndianHealthService.ClinicalScheduling
     
    2325            //
    2426            InitializeComponent();
    25 
    26             //
    27             // TODO: Add any constructor code after InitializeComponent call
    28             //
    2927        }
    3028
     
    5957        private DataView m_dvClinic;
    6058        private DataView m_dvForm;
    61         private bool m_bInit;
    6259        public bool m_bPrintRouteSlip;
     60        private List<Provider> _providers;
    6361        private ToolTip toolTip1;
    6462       
     
    6866
    6967        /// <summary>
    70         /// Returns string representation of internal entry number of Provider in PROVIDER File
    71         /// </summary>
    72         public string ProviderIEN
     68        /// Returns Provider chosen for Check-In
     69        /// </summary>
     70        public Provider Provider
    7371        {
    7472            get
    7573            {
    76                 return this.m_sProviderIEN;
     74                if (cboProvider.SelectedIndex < 1) return null; // because first item is empty placeholder
     75                else return this._providers[cboProvider.SelectedIndex];
    7776            }
    7877        }
     
    113112        /// <param name="a">Appointment</param>
    114113        /// <param name="docManager">Document Manager</param>
    115         /// <param name="sDefaultProvider">Default provider</param>
    116         public void InitializePage(CGAppointment a, CGDocumentManager docManager,
    117             string sDefaultProvider, int nHospLoc)
    118         {
    119             m_bInit = true;
    120             m_DocManager = docManager;
     114        public void InitializePage(CGAppointment a)
     115        {
     116            m_DocManager = CGDocumentManager.Current;
    121117            m_dsGlobal = m_DocManager.GlobalDataSet;
    122             int nFind = 0;
     118
     119            Int32? nHospLoc = (from resource in m_dsGlobal.Tables["Resources"].AsEnumerable()
     120                           where resource.Field<string>("RESOURCE_NAME") == a.Resource
     121                           select resource.Field<Int32?>("HOSPITAL_LOCATION_ID"))
     122                           .SingleOrDefault();
     123
     124            //smh - following logic replaced with above...
     125            /*
     126            DataView rv = new DataView(this.m_DocManager.GlobalDataSet.Tables["Resources"]);
     127            rv.Sort = "RESOURCE_NAME ASC";
     128            int nFind = rv.Find((string)a.Resource);
     129            DataRowView drv = rv[nFind];
     130
     131            string sHospLoc = drv["HOSPITAL_LOCATION_ID"].ToString();
     132            sHospLoc = (sHospLoc == "") ? "0" : sHospLoc;
     133            int nHospLoc = 0;
     134            try
     135            {
     136                nHospLoc = Convert.ToInt32(sHospLoc);
     137            }
     138            catch (Exception ex)
     139            {
     140                Debug.Write("CGView.AppointmentCheckIn Error: " + ex.Message);
     141            }
     142            */
    123143
    124144            //smh new code
    125145            //if the resource is linked to a valid hospital location, grab this locations providers
    126146            //from the provider multiple and put them in the combo box.
    127             if (nHospLoc != 0)
     147            if (nHospLoc != null)
    128148            {
    129149                //RPC BSDX HOSP LOC PROVIDERS returns Table w/ Columns:
    130150                //HOSPITAL_LOCATION_ID^BMXIEN (ie Prov IEN)^NAME^DEFALUT
    131151                string sCommandText = "BSDX HOSP LOC PROVIDERS^" + nHospLoc;
    132                 m_dtProvider = docManager.RPMSDataTable(sCommandText, "ClinicProviders");
    133                 m_dtProvider.DefaultView.Sort = "NAME ASC";
    134 
    135                 cboProvider.DataSource = m_dtProvider;
    136                 cboProvider.DisplayMember = "NAME";
    137                 cboProvider.ValueMember = "BMXIEN";
    138 
    139                 //Add None to the top of the list
    140                 DataRow drProv = m_dtProvider.NewRow();
    141                 drProv.BeginEdit();
    142                 drProv["HOSPITAL_LOCATION_ID"] = 0;
    143                 drProv["NAME"] = "<None>";
    144                 drProv["BMXIEN"] = 0;
    145                 drProv.EndEdit();
    146                 m_dtProvider.Rows.InsertAt(drProv, 0);
    147                 cboProvider.SelectedIndex = 0;
     152                m_dtProvider = m_DocManager.RPMSDataTable(sCommandText, "ClinicProviders");
     153               
     154                _providers = (from providerRow in m_dtProvider.AsEnumerable()
     155                              orderby providerRow.Field<string>("NAME")
     156                             select new Provider
     157                             {
     158                                 IEN = providerRow.Field<int>("BMXIEN"),
     159                                 Name = providerRow.Field<string>("NAME"),
     160                                 Default = providerRow.Field<string>("DEFAULT") == "YES" ? true : false
     161                             }).ToList();
     162
     163
     164
     165                //cboProvider.DisplayMember = "NAME";
     166                //cboProvider.ValueMember = "BMXIEN";
     167                _providers.Insert(0, new Provider { Name = "<None>", IEN = -1 });
     168                cboProvider.DataSource = _providers;
     169                cboProvider.SelectedIndex = _providers.FindIndex(prov => prov.Default);
     170                // if no provider is default, set default to be <none> item.
     171                if (cboProvider.SelectedIndex == -1) cboProvider.SelectedIndex = 0;
     172                ////Add None to the top of the list
     173                //DataRow drProv = m_dtProvider.NewRow();
     174                //drProv.BeginEdit();
     175                //drProv["HOSPITAL_LOCATION_ID"] = 0;
     176                //drProv["NAME"] = "<None>";
     177                //drProv["BMXIEN"] = 0;
     178                //drProv.EndEdit();
     179                //m_dtProvider.Rows.InsertAt(drProv, 0);
     180                ////cboProvider.SelectedIndex = 0;
    148181
    149182                //Find default provider--search for Yes in Field DEFAULT           
    150                 DataRow[] nRow = m_dtProvider.Select("DEFAULT='YES'", "NAME ASC");
    151                 if (nRow.Length > 0) nFind = m_dtProvider.Rows.IndexOf(nRow[0]);
    152                 cboProvider.SelectedIndex = nFind;
     183                //DataRow[] nRow = m_dtProvider.Select("DEFAULT='YES'", "NAME ASC");
     184                //if (nRow.Length > 0) nFind = m_dtProvider.Rows.IndexOf(nRow[0]);
     185               
    153186
    154187            }
     
    156189            else
    157190            {
    158                 m_dtProvider = m_dsGlobal.Tables["Provider"];
    159                 m_dtProvider.DefaultView.Sort = "NAME ASC";
    160 
    161                 cboProvider.DataSource = m_dtProvider;
    162                 cboProvider.DisplayMember = "NAME";
    163                 cboProvider.ValueMember = "BMXIEN";
     191
     192                _providers = (from providerRow in m_dsGlobal.Tables["Provider"].AsEnumerable()
     193                              orderby providerRow.Field<string>("NAME")
     194                              select new Provider
     195                              {
     196                                  IEN = providerRow.Field<int>("BMXIEN"),
     197                                  Name = providerRow.Field<string>("NAME"),
     198                                  Default = false
     199                              }).ToList();
     200
     201               
     202                /*m_dtProvider = m_dsGlobal.Tables["Provider"];
     203                m_dtProvider.DefaultView.Sort = "NAME ASC";*/
     204                _providers.Insert(0, new Provider { Name = "<None>", IEN = -1 });
     205                cboProvider.DataSource = _providers;
     206                cboProvider.SelectedIndex = 0;
     207                //cboProvider.DisplayMember = "NAME";
     208                //cboProvider.ValueMember = "BMXIEN";
    164209
    165210                //Add None to the top of the list
    166                 DataRow drProv = m_dtProvider.NewRow();
    167                 drProv.BeginEdit();
    168                 drProv["NAME"] = "<None>";
    169                 drProv["BMXIEN"] = 0;
    170                 drProv.EndEdit();
    171                 m_dtProvider.Rows.InsertAt(drProv, 0);
    172                 cboProvider.SelectedIndex = 0;
    173             }
    174 
     211                //DataRow drProv = m_dtProvider.NewRow();
     212                //drProv.BeginEdit();
     213                //drProv["NAME"] = "<None>";
     214                //drProv["BMXIEN"] = 0;
     215                //drProv.EndEdit();
     216                //m_dtProvider.Rows.InsertAt(drProv, 0);
     217                //cboProvider.SelectedIndex = 0;
     218            }
     219
     220                           
    175221
    176222            m_sPatientName = a.PatientName;
     
    187233            }
    188234
     235            //Print Routing Slip based on user preferences.
     236            chkRoutingSlip.Checked = CGDocumentManager.Current.UserPreferences.PrintRoutingSlipAutomatically;
     237
    189238            UpdateDialogData(true);
    190             m_bInit = false;
    191239        }
    192240
     
    363411            // cboProvider
    364412            //
     413            this.cboProvider.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    365414            this.cboProvider.Location = new System.Drawing.Point(96, 88);
    366415            this.cboProvider.Name = "cboProvider";
     
    384433            this.chkRoutingSlip.Text = "Print Routing Slip";
    385434            this.toolTip1.SetToolTip(this.chkRoutingSlip, "Prints routing slip to the Windows Default Printer");
     435            this.chkRoutingSlip.CheckedChanged += new System.EventHandler(this.chkRoutingSlip_CheckedChanged);
    386436            //
    387437            // DCheckIn
     
    418468        }
    419469
     470        /// <summary>
     471        /// Save this in User Preferences Object.
     472        /// </summary>
     473        /// <param name="sender"></param>
     474        /// <param name="e"></param>
     475        private void chkRoutingSlip_CheckedChanged(object sender, EventArgs e)
     476        {
     477            CGDocumentManager.Current.UserPreferences.PrintRoutingSlipAutomatically = chkRoutingSlip.Checked;
     478        }
     479
    420480        #endregion Events
     481
    421482    }
    422483}
Note: See TracChangeset for help on using the changeset viewer.