Пример #1
0
 public PrintQueueEntryList(bool include)
 {
     includePrinted = include ? 1 : 0;
     constructor_args = null;
     this.pc = new ParameterCollection();
     pc.Add("includePrinted", includePrinted);
 }
Пример #2
0
 /**************************************************************************************************/
 public override void BackgroundLoadWork()
 {
     ParameterCollection pc = new ParameterCollection();
     pc.Add("clinicId", clinicId);
     DoLoadWithSpAndParams("sp_3_LoadAtRisk", pc);
     DoLoadWithSpAndParams("sp_3_LoadDashboardCounts", pc);
 }
Пример #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();
            pc.Add("MRN", txtMRN.Text);


            if ((retName != patientName) && (!String.IsNullOrEmpty(retName)))
            {
                errorProvider1.SetError(txtName, "Name and MRN discrepency found!");
                StringBuilder sb = new StringBuilder();
                sb.Append("There is an MRN associated with ");
                sb.Append("\"" + retName + "\" ");
                sb.Append("would you like to save appointment with patient identified name: ");
                sb.Append(patientName + "?");
                txtInstructions.Text = sb.ToString();
                retName = patientName;
            }
            else
            {
                //Test if mrn in text box changed from last iteration
                if (txtMRN.Text != patientEnteredMRN)
                {
                    txtInstructions.Text = "Is this correct?";
                    patientEnteredMRN    = txtMRN.Text;
                }
                else
                {
                    retMRN = txtMRN.Text;
                    this.Close();
                }
            }
        }
Пример #4
0
        public void SetLabels(int id, string mutProb, string name, string relationship)
        {
            relId = id;

            //old v2 way:
            //testingWillingnessComboBox.Text =
            //    Patient.getRelativeValueFromDB("tblRiskDataRelatives", "testingWillingness", relId);

            RelativeValueHolder relValHolder = new RelativeValueHolder("");

            ParameterCollection pc = new ParameterCollection("unitnum", SessionManager.Instance.GetActivePatient().unitnum);
            pc.Add("relativeid", relId);
            pc.Add("table", "tblRiskDataRelatives");
            pc.Add("column", "testingWillingness");
            relValHolder.DoLoadWithSpAndParams("sp_3_LoadRelativeValue", pc);
            testingWillingnessComboBox.Text = relValHolder.relativeValue;

            if (string.IsNullOrEmpty(mutProb) == false)
            {
                try
                {
                    brcapro = (int)Math.Round(double.Parse(mutProb));
                    if (brcapro > 0)
                    {
                        BrcaLabel.Text = brcapro.ToString() + "%";
                    }
                    else
                    {
                        BrcaLabel.Text = "";
                    }
                }
                catch { }
            }
            else
            {
                BrcaLabel.Text = "";
            }
            // You might well not know the mother's name (e.g.)
            if (!String.IsNullOrEmpty(name))
            {
                if (name.Contains(" "))
                {
                    string[] tokens = name.Split(' ');
                    if (name.Contains(','))
                        name = tokens[1].Replace(",","");
                    else
                        name = tokens[0];
                }
                //NameLabel.Text = name;
                RelationshipLabel.Text = name;
            }
            else
            {
                RelationshipLabel.Text = relationship;
            }
            RelationshipLabel.Text = RelationshipLabel.Text.Replace(" ", Environment.NewLine);
            int delta = this.Height - RelationshipLabel.Height;
            RelationshipLabel.Location = new Point(RelationshipLabel.Location.X, delta / 2);
        }
Пример #5
0
 /**************************************************************************************************/
 public override void BackgroundLoadWork()
 {
     ParameterCollection pc = new ParameterCollection();
     pc.Add("clinicId", clinicId);
     dt = new DataTable();
     SqlDataReader dr = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_LoadMyPatientsQueue", pc);
     dt.Load(dr);
 }
Пример #6
0
 public static void UpdateBigQueueByMrn(string mrn)
 {
     if (string.IsNullOrEmpty(mrn) == false)
     {
         ParameterCollection pc = new ParameterCollection("unitnum", mrn);
         BCDB2.Instance.RunSPWithParams("sp_3_populateBigQueue", pc);
     }
 }
Пример #7
0
        public PatientsByGroup(string userLogin, string groupName)
        {
            this.constructor_args = new object[] { };
            this.pc = new ParameterCollection();

            this.userLogin = userLogin;
            this.groupName = groupName;
        }
Пример #8
0
 /**************************************************************************************************/
 public override void BackgroundPersistWork(HraModelChangedEventArgs e)
 {
     var pc = new ParameterCollection();
     pc.Add("unitnum", unitnum);
     DoPersistWithSpAndParams(e,
                              "sp_3_Save_PedigreeAnnotations",
                              ref pc);
 }
Пример #9
0
 /**************************************************************************************************/
 public override void BackgroundLoadWork()
 {
     //dt = BCDB2.Instance.getDataTable(@"SELECT * from tblBigQueue where BreastHRQ = 1");
     ParameterCollection pc = new ParameterCollection();
     pc.Add("clinicId", clinicId);
     dt = new DataTable();
     SqlDataReader dr = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_LoadModerateBreastRiskQueue", pc);
     dt.Load(dr);
 }
Пример #10
0
        /**************************************************************************************************/
        public override void BackgroundLoadWork()
        {
            ParameterCollection pc = new ParameterCollection("unitnum", theProband.unitnum);
            pc.Add("apptid", theProband.apptid);
            DoLoadWithSpAndParams("sp_3_LoadProcHx", pc);

            breastBx.BackgroundLoadWork();
            base.BackgroundLoadWork();
        }
Пример #11
0
 /**************************************************************************************************/
 public override void BackgroundPersistWork(HraModelChangedEventArgs e)
 {
     ParameterCollection pc = new ParameterCollection();
     pc.Add("unitnum", theProband.unitnum);
     pc.Add("apptid", theProband.apptid);
     DoPersistWithSpAndParams(e,
                               "sp_3_Save_ProcHx",
                               ref pc);
 }
Пример #12
0
 /**************************************************************************************************/
 public override void BackgroundLoadWork()
 {
     //fill the local datatable object
     //dt = BCDB2.Instance.getDataTable(@"SELECT * from tblBigQueue where BeingFollowedInRiskClinic = 1");
     ParameterCollection pc = new ParameterCollection();
     pc.Add("clinicId", clinicId);
     dt = new DataTable();
     SqlDataReader dr = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_LoadBeingFollowedQueue", pc);
     dt.Load(dr);
 }
Пример #13
0
 /**************************************************************************************************/
 public override void BackgroundPersistWork(HraModelChangedEventArgs e)
 {
     ParameterCollection pc = new ParameterCollection();
     pc.Add("unitnum", owner.person.owningFHx.proband.unitnum);
     pc.Add("relativeID", owner.person.relativeID);
     pc.Add("apptid", owner.person.owningFHx.proband.apptid);
     DoPersistWithSpAndParams(e,
                               "sp_3_Save_Nation",
                               ref pc);
 }
Пример #14
0
        /*******************************************************************************/
        public override void BackgroundPersistWork(HraModelChangedEventArgs e)
        {
            ParameterCollection pc = new ParameterCollection();
            pc.Add("paragraphID", paragraphID);
            pc.Add("providerID", providerID);

            DoPersistWithSpAndParams(e,
                                     "sp_3_Save_ProviderParagraph",
                                     ref pc);
        }
Пример #15
0
 /**************************************************************************************************/
 public override void BackgroundLoadWork()
 {
     //fill the local datatable object
     //dt = BCDB2.Instance.getDataTable(@"SELECT * from tblBigQueue where NumTestedFamilyMembers > 0");
     ParameterCollection pc = new ParameterCollection();
     pc.Add("clinicId", clinicId);
     dt = new DataTable();
     SqlDataReader dr = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_LoadBrcaPositiveQueue", pc);
     dt.Load(dr);
 }
Пример #16
0
 /**************************************************************************************************/
 public override void BackgroundLoadWork()
 {
     //fill the local datatable object
     //dt = BCDB2.Instance.getDataTable(@"SELECT * from tblBigQueue where MaxLifetimeScore > 20.0");
     ParameterCollection pc = new ParameterCollection();
     pc.Add("clinicId", clinicId);
     dt = new DataTable();
     SqlDataReader dr = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_LoadHighRiskLifetimeBreastQueue", pc);
     dt.Load(dr);
 }
Пример #17
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     System.Collections.ArrayList appts = (System.Collections.ArrayList)(e.Argument);
     foreach (object o in appts)
     {
         TestAppointment to = (TestAppointment)o;
         Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();
         pc.Add("apptID", to.apptID);
         BCDB2.Instance.RunSPWithParams("sp_AddTestPatientExclusion", pc);
     }
 }
Пример #18
0
        /**************************************************************************************************/
        public override void BackgroundLoadWork()
        {
            ParameterCollection pc = new ParameterCollection();
            pc.Add("clinicId", clinicId);
            pc.Add("when", date);

            //pc.Add("groupName", groupName);
            //pc.Add("userLogin", SessionManager.Instance.ActiveUser.userLogin);

            DoLoadWithSpAndParams("sp_3_GetMyPatientCounts", pc);
        }
Пример #19
0
        //a customized persistence method for TcRiskByAge items
        public void PersistFullObject(HraModelChangedEventArgs e, string unitnum, int apptid, string version, DateTime? BMRS_EffectiveTime, Int64? BMRS_RequestId)
        {
            ParameterCollection pc = new ParameterCollection();
            pc.Add("unitnum", unitnum);
            pc.Add("apptid", apptid);
            pc.Add("version", version);
            pc.Add("BMRS_EffectiveTime", BMRS_EffectiveTime);
            pc.Add("BMRS_RequestId", BMRS_RequestId);

            DoPersistWithSpAndParams(e,
                                        "sp_3_Save_TcRiskByAge",
                                        ref pc);
        }
Пример #20
0
 /**************************************************************************************************/
 public override void BackgroundLoadWork()
 {
     ParameterCollection pc = new ParameterCollection();
     pc.Add("clinicId", clinicId);
     pc.Add("startTime", startTime);
     pc.Add("endTime", endTime);
     pc.Add("type", type);
     pc.Add("output", output);
     DoLoadWithSpAndParams("sp_3_LoadBreastImagingDashboardElement", pc);
     pc.Clear();
     pc.Add("type", type);
     DoLoadWithSpAndParams("sp_3_LoadFilterDescription", pc);
 }
Пример #21
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            LegacyCoreAPI.StartWorkingWithAppointment(apptid, "");

            ParameterCollection pc = new ParameterCollection();
            pc.Add("application", "RiskApps3");
            pc.Add("userLogin", SessionManager.Instance.ActiveUser.userLogin);
            pc.Add("machineName", System.Environment.MachineName);
            pc.Add("message", "Accessed appointment");
            pc.Add("apptID", apptid);

            BCDB2.Instance.RunSPWithParams("sp_3_AuditUserActivity", pc);
        }
Пример #22
0
        /**************************************************************************************************/
        public override void BackgroundLoadWork()
        {
            //(optionally) update the big queue table in the database
            ParameterCollection pc = new ParameterCollection();
            if (forceUpdate != null)
            {
                pc.Add("forceUpdate", forceUpdate);
            }
            DoLoadWithSpAndParams("sp_3_UpdateQueueDataWhenOld", pc);
            forceUpdate = null;

            //fill the local datatable object
            dt = BCDB2.Instance.getDataTable(@"SELECT * from tblBigQueue");
        }
Пример #23
0
 private void deleteBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     System.Collections.ArrayList appts = (System.Collections.ArrayList)(e.Argument);
     foreach (object o in appts)
     {
         TestAppointment to = (TestAppointment)o;
         Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();
         pc.Add("apptID", to.apptID);
         pc.Add("purgeAuditData", 0);
         pc.Add("userLoginID", SessionManager.Instance.ActiveUser.userLogin);
         pc.Add("machineNameID", System.Environment.MachineName);
         pc.Add("applicationID", "RiskApps3 - DeleteTestAppointmentsPopup");
         BCDB2.Instance.RunSPWithParams("sp_deleteWebAppointment", pc);
     }
 }
Пример #24
0
        private string GetAreaProvidersByRelId(int r)
        {
            string retval = "";

            if (proband != null)
            {
                string sqlStr = "SELECT zipcode, city, state FROM tblRelativeDetails WHERE relativeID=@relativeID AND apptID=@apptID";
                ParameterCollection pc = new ParameterCollection();
                pc.Add("relativeID", r);
                pc.Add("apptID", proband.apptid);

                DbDataReader reader = BCDB2.Instance.ExecuteReaderWithParams(sqlStr, pc);

                bool hasZipCode = false;
                String zipcode = "";
                String city = "";
                String state = "";

                if (reader.Read())
                {
                    zipcode = reader.GetValue(0).ToString();
                    city = reader.GetValue(1).ToString();
                    state = reader.GetValue(2).ToString();
                }
                reader.Close();

                if (zipcode != "")
                {
                    hasZipCode = ZipCodes.isValidZip(zipcode);
                }
                else
                {
                    zipcode = ZipCodes.getZipCode(city, state);
                    if (zipcode != "")
                    {
                        hasZipCode = ZipCodes.isValidZip(zipcode);
                    }
                }

                if (hasZipCode)
                {
                    retval = GetAreaProvidersByZipCode(zipcode);
                }

            }

            return retval;
        }
Пример #25
0
        /**************************************************************************************************/
        public override void BackgroundPersistWork(HraModelChangedEventArgs e)
        {
            ParameterCollection pc = new ParameterCollection();

            try
            {
                pc.Add("ID", ID);
                pc.Add("parameterValue", parameterValue);

                SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_SetQueueParameter", pc);
            }
            catch (Exception ee)
            {
                Logger.Instance.WriteToLog("Error saving QueueParameter: \r\n" + ee.InnerException.ToString());
            }
        }
Пример #26
0
        public static bool isValidZip(String zipcode)
        {
            bool validZip = false;

            String sqlStr = "SELECT city FROM lkpZipCodes WHERE zipcode=@zipcode";
            ParameterCollection pc = new ParameterCollection();
            pc.Add("zipcode", zipcode);

            DbDataReader reader = BCDB2.Instance.ExecuteReaderWithParams(sqlStr, pc);

            if (reader.Read())
            {
                validZip = true;
            }

            reader.Close();
            return validZip;
        }
Пример #27
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            //RiskAppCore.Globals.setApptID(apptid);
            //RiskAppCore.ApptUtils.MarkApptStartedAndPullForward();
            //SessionManager.Instance.GetActivePatient().hra_state = Model.HraObject.States.NULL;

            LegacyCoreAPI.StartWorkingWithAppointment(apptid,"");

            SessionManager.Instance.GetActivePatient().BackgroundLoadWork();

            ParameterCollection pc = new ParameterCollection();
            pc.Add("application", "RiskApps3");
            pc.Add("userLogin", SessionManager.Instance.ActiveUser.userLogin);
            pc.Add("machineName", System.Environment.MachineName);
            pc.Add("message", "Accessed appointment");
            pc.Add("apptID", apptid);

            BCDB2.Instance.RunSPWithParams("sp_3_AuditUserActivity", pc);
        }
Пример #28
0
        public static double getDistance(String zipcode1, String zipcode2)
        {
            String lat1 = "";
            String long1 = "";
            String lat2 = "";
            String long2 = "";

            // get lat and long for first zipcode
            String sqlStr = "SELECT latitude, longitude FROM lkpZipCodes WHERE zipcode=@zipcode";
            ParameterCollection pc = new ParameterCollection();
            pc.Add("zipcode", zipcode1);
            DbDataReader reader =BCDB2.Instance.ExecuteReaderWithParams(sqlStr, pc);
            while (reader.Read())
            {
                lat1 = reader.GetValue(0).ToString();
                long1 = reader.GetValue(1).ToString();
            }
            reader.Close();

            // get lat and long for second zipcode
            sqlStr = "SELECT latitude, longitude FROM lkpZipCodes WHERE zipcode=@zipcode";
            pc = new ParameterCollection();
            pc.Add("zipcode", zipcode2);
            reader = BCDB2.Instance.ExecuteReaderWithParams(sqlStr, pc);
            while (reader.Read())
            {
                lat2 = reader.GetValue(0).ToString();
                long2 = reader.GetValue(1).ToString();
            }
            reader.Close();

            if (lat1 == "" || long1 == "" || lat2 == "" || long2 == "")
            {
                return 0.0;
            }

            double latitude1 = Double.Parse(lat1);
            double longitude1 = Double.Parse(long1);
            double latitude2 = Double.Parse(lat2);
            double longitude2 = Double.Parse(long2);

            return Haversine(latitude1, longitude1, latitude2, longitude2);
        }
Пример #29
0
        public override void BackgroundLoadWork()
        {
            int output;
            if (mode == RiskApps3.View.Reporting.RiskElementControl.Mode.Incidence)
                output = 2;
            else
                output = 3;

            ParameterCollection pc = new ParameterCollection();
            pc.Add("clinicId", clinicId);
            pc.Add("startTime", startTime);
            pc.Add("endTime", endTime);
            pc.Add("type", type);
            pc.Add("output", output);

            SqlDataReader dr = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_LoadBreastImagingDashboardElement", pc);
            dt = new DataTable();
            dt.Load(dr);
        }
Пример #30
0
        public static String getZipCode(String city, string state)
        {
            String zipcode = "";

            String sqlStr = "SELECT zipcode FROM lkpZipCodes WHERE city=@city AND state=@state";
            ParameterCollection pc = new ParameterCollection();
            pc.Add("city",city);
            pc.Add("state",state);

            DbDataReader reader = BCDB2.Instance.ExecuteReaderWithParams(sqlStr, pc);

            if (reader.Read())
            {
                zipcode = reader.GetValue(0).ToString();
            }

            reader.Close();
            return zipcode;
        }
Пример #31
0
 public override void BackgroundLoadWork()
 {
     Claus_Table = "";
     RelOne = "";
     RelTwo = "";
     ParameterCollection pc = new ParameterCollection("unitnum", unitnum);
     pc.Add("apptid", apptid);
     DoLoadWithSpAndParams("sp_3_LoadClausRiskFactors", pc);
 }
Пример #32
0
        public bool AuthenticateUser(string username, string password, out string msg, out string fullName)
        {
            RA.User u      = null;
            bool    result = false;

            SessionManager.Instance.MetaData.Users.BackgroundListLoad();
            fullName = string.Empty;

            var users = SessionManager.Instance.MetaData.Users;

            bool validUser = users.Any(x => ((RA.User)x).userLogin.ToLower() == username.ToLower());

            if (validUser)
            {
                u = (RA.User)(users.First(x => ((RA.User)x).userLogin.ToLower() == username.ToLower()));
            }

            String encryptedPassword = RiskAppCore.User.encryptPassword(password);

            bool   authenticated     = false;
            int    numFailedAttempts = 0;
            int    numMaxFailures    = 5;
            int    lockoutPeriod     = 0;
            string lockoutMsg        = "";

            RiskApps3.Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();
            pc.Add("ntLoginName", "");
            pc.Add("userLogin", (u != null) ? u.userLogin : username);

            pc.Add("userPassword", encryptedPassword);



            SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_Authenticate_User", pc);

            if (reader != null)
            {
                if (reader.Read())
                {
                    authenticated     = (bool)reader.GetSqlBoolean(0);
                    numFailedAttempts = (int)reader.GetInt32(1);
                    numMaxFailures    = (int)reader.GetInt32(2);
                    lockoutPeriod     = (int)reader.GetInt32(3);
                }
                reader.Close();
            }
            if ((!validUser) || (!authenticated))  //note that if they're not a valid user they won't be authenticated, but we've updated the failed count and timeout values
            {
                if (lockoutPeriod > 0)
                {
                    lockoutMsg = "\r\nLogin attempts will be blocked for " + lockoutPeriod.ToString() + " minute" + ((lockoutPeriod > 1) ? "s." : ".");
                }
                else
                {
                    lockoutMsg = "\r\nYou have made " + numFailedAttempts.ToString() + " failed Login attempt" + ((numFailedAttempts > 1) ? "s" : "") + " of a maximum " + numMaxFailures.ToString() + " allowed.";
                }
            }

            msg = lockoutMsg;

            if (numFailedAttempts == 1)
            {
                msg = "You have provided an incorrect username or password.\r\nPlease correct your password or try a different user." + lockoutMsg;
            }



            result = (validUser && authenticated);

            if (result)
            {
                SessionManager.Instance.ActiveUser = u;
                HraObject.AuditUserLogin(u.userLogin);
                fullName = u.User_userFullName;
                _hraSessionManager.SetRaActiveUser(username);
            }

            return(result);
        }
Пример #33
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            List <Appointment> appts = (List <Appointment>)e.Argument;

            try
            {
                foreach (object o in appts)
                {
                    Appointment appt = (Appointment)o;
                    if (appt.CloudWebQueueState == CREATE_NEW_APPT || appt.CloudWebQueueState == SYNCH_APPT)
                    {
                        backgroundWorker2.ReportProgress(2, "Retrieving Patient Record: " + appt.PatientName + " - " + appt.Dob);
                        XmlNode xml = cloud.FetchPatientRecord(appt.apptID);

                        MemoryStream stm = new MemoryStream();
                        StreamWriter stw = new StreamWriter(stm);
                        stw.Write(xml.OuterXml);
                        stw.Flush();
                        stm.Position = 0;

                        backgroundWorker2.ReportProgress(2, "Saving Data: " + appt.PatientName + " - " + appt.Dob);
                        DataContractSerializer ds = new DataContractSerializer(typeof(Patient));
                        Patient p2 = (Patient)ds.ReadObject(stm);

                        if (appt.CloudWebQueueState == CREATE_NEW_APPT)
                        {
                            SurveyResponse newMRN = (SurveyResponse)p2.SurveyReponses.Find(g => ((SurveyResponse)g).responseTag == "PatientReportedMRN");

                            if (!String.IsNullOrEmpty(newMRN.SurveyResponse_responseValue))
                            {
                                using (CloudMRNReconcile reconcileForm = new CloudMRNReconcile(newMRN.SurveyResponse_responseValue, p2.name, p2.apptid, appt.clinicID))
                                {
                                    reconcileForm.ShowDialog();

                                    if ((reconcileForm.retMRN != "Cancel") && (!String.IsNullOrEmpty(reconcileForm.retMRN)))
                                    {
                                        p2.unitnum = reconcileForm.retMRN;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }

                            Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();
                            pc.Add("unitnum", p2.unitnum);
                            pc.Add("patientname", p2.name);
                            pc.Add("dob", p2.dob);
                            pc.Add("clinicId", appt.ClinicId);
                            object newApptId = BCDB2.Instance.ExecuteSpWithRetValAndParams("sp_createMasteryAppointment", SqlDbType.Int, pc);
                            p2.apptid = (int)newApptId;
                        }
                        else
                        {
                            if (appt.CloudWebQueueState == SYNCH_APPT)
                            {
                                p2.apptid = appt.CloudWebQueueSynchId;
                            }
                        }

                        p2.FHx.proband = p2;
                        p2.PersistFullObject(new RiskApps3.Model.HraModelChangedEventArgs(null));

                        if (checkBox4.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Marking Complete and updating meta data: " + appt.PatientName + " - " + appt.Dob);
                            ParameterCollection pc = new ParameterCollection("apptID", p2.apptid);
                            BCDB2.Instance.RunSPWithParams("sp_markRiskDataCompleted", pc);
                        }


                        if (checkBox1.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Running Risk Models: " + appt.PatientName + " - " + appt.Dob);
                            p2.RecalculateRisk();

                            ParameterCollection pc = new ParameterCollection("unitnum", p2.unitnum);
                            BCDB2.Instance.RunSPWithParams("sp_3_populateBigQueue", pc);
                        }

                        if (checkBox2.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Printing Automation Documents: " + appt.PatientName + " - " + appt.Dob);

                            p2.RunAutomation();

                            //ParameterCollection printDocArgs = new ParameterCollection();
                            //printDocArgs.Add("apptid", p2.apptid);
                            //SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_AutomationHtmlDocsToPrint", printDocArgs);
                            //while (reader.Read())
                            //{
                            //    int templateID = -1;
                            //    if (reader.IsDBNull(0) == false)
                            //    {
                            //        templateID = reader.GetInt32(0);
                            //    }
                            //    SessionManager.Instance.SetActivePatientNoCallback(p2.unitnum, p2.apptid);
                            //    DocumentTemplate template = new DocumentTemplate();
                            //    template.documentTemplateID = templateID;
                            //    template.BackgroundLoadWork();
                            //    template.OpenHTML();
                            //    template.ProcessDocument();
                            //    htmlInProgress = true;
                            //    backgroundWorker2.ReportProgress(1, template.htmlText);
                            //    while (htmlInProgress)
                            //    {
                            //        Application.DoEvents();
                            //        Thread.Sleep(500);
                            //    }

                            //}
                        }
                        if (checkBox5.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Removing Web Survey: " + appt.PatientName + " - " + appt.Dob);
                            backgroundWorker2.ReportProgress(4, appt);
                            cloud.DeleteSurvey(appt.apptID);
                        }
                        backgroundWorker2.ReportProgress(2, "Precessing Queue Documents: " + appt.PatientName + " - " + appt.Dob);
                        if (checkBox3.Checked)
                        {
                            ParameterCollection pc = new ParameterCollection("apptID", p2.apptid);
                            BCDB2.Instance.RunSPWithParams("sp_processQueueDocuments", pc);
                        }
                    }
                    else if (appt.CloudWebQueueState == DELETE_APPT)
                    {
                        backgroundWorker2.ReportProgress(2, "Removing Web Survey: " + appt.PatientName + " - " + appt.Dob);
                        backgroundWorker2.ReportProgress(4, appt);
                        cloud.DeleteSurvey(appt.apptID);
                    }
                    backgroundWorker2.ReportProgress(3, o);
                }
            }
            catch (Exception exc)
            {
                Logger.Instance.WriteToLog(exc.ToString());
            }
        }
Пример #34
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            int surveyID = 0;
            //KeyValuePair<int, string> kvpSurvey;
            KeyValuePair <int, string> kvpClinic;

            foreach (KeyValuePair <int, string> pair in surveyDic)
            {
                if (pair.Value == cbSurvey.Text)
                {
                    surveyID = pair.Key;
                }
            }


            int x = 0;

            if (cbNumPatients.SelectedItem != null)
            {
                int    i     = int.Parse(cbNumPatients.SelectedItem.ToString());
                int    index = 0;
                string time;
                Random random    = new Random();
                string firstName = "";

                string nextUnitNum = createTestUnitnum();
                long   unitNum     = Int64.Parse(nextUnitNum);

                while (i > x)
                {
                    RiskApps3.Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();

                    if (x <= 9)
                    {
                        time = "0" + x.ToString();
                    }
                    else
                    {
                        time = (x % 60).ToString();
                    }

                    pc.Add("apptdate", dtAppointmentDate.Value.ToString("MM/dd/yyyy"));
                    pc.Add("appttime", "08:" + time + " AM");
                    index     = random.Next(10000) % names.Count;
                    firstName = names[index];
                    pc.Add("firstname", firstName);
                    pc.Add("lastname", "Test" + cbSurvey.Text.Replace(" ", ""));
                    pc.Add("gender", "F");
                    pc.Add("dob", "09/23/1970");
                    pc.Add("email", "*****@*****.**");
                    pc.Add("address1", (i * 10).ToString() + " Broadway");
                    pc.Add("city", "Cambridge");
                    pc.Add("state", "MA");
                    pc.Add("zip", "02473");
                    pc.Add("phone", "6175551212");
                    pc.Add("emailaddress", "*****@*****.**");
                    pc.Add("sendByEmail", 1);
                    pc.Add("machinename", "test");
                    pc.Add("preferredInstitutionName", "test");
                    if (cbClinic.SelectedItem != null)
                    {
                        kvpClinic = (KeyValuePair <int, string>)cbClinic.SelectedItem;
                        pc.Add("clinicID", kvpClinic.Key);
                    }
                    else
                    {
                        pc.Add("clinicID", 1);      // default
                    }

                    pc.Add("unitnum", unitNum.ToString());
                    pc.Add("createdby", cbSurvey.Text);
                    pc.Add("insertApptWebRecord", 1);
                    pc.Add("surveyID", surveyID);

                    BCDB2.Instance.ExecuteReaderSPWithParams("sp_createApptFromSchedService", pc);
                    unitNum++;
                    x++;
                }
            }

            this.Close();
        }
Пример #35
0
        public void automate()
        {
            if (status != null)
            {
                try
                {
                    //status.LogHeartbeat(this.Text);
                }
                catch (Exception ex)
                {
                    //  Logger.Instance.WriteToLog(ex.ToString());
                }
            }

            List <int> apptIDs = new List <int>();

            /***********************   get appointments to automate   ********************/
            SqlDataReader reader;
            string        CustomAutomationString = Configurator.getNodeValue("DatabaseInfo", "AUTOMATION_SQL");

            if (string.IsNullOrEmpty(CustomAutomationString) == false)
            {
                reader = BCDB2.Instance.ExecuteReader(CustomAutomationString);
            }
            else
            {
                reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_Automation", null);
            }
            try
            {
                while (reader.Read())
                {
                    if (reader.IsDBNull(0) == false)
                    {
                        apptIDs.Add(reader.GetInt32(0));
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Instance.WriteToLog("Error getting appointment IDs: " + e.ToString());
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            if (apptIDs.Count == 0)
            {
                ProcessingThread.ReportProgress(0,
                                                "No appointments are marked for automation - " + DateTime.Now.ToString());
                return;
            }


            /***********************    automation cycle   ********************/
            foreach (int apptid in apptIDs)
            {
                if (ProcessingThread.CancellationPending)
                {
                    return;
                }

                ProcessingThread.ReportProgress(0, "Running automation for appt: " + apptid.ToString() + ".");

                /***********************  Get Unitnum & set active patient  ********************/
                string unitnum         = "";
                ParameterCollection pc = new ParameterCollection("apptID", apptid);
                using (reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_GetUnitnum", pc))
                //ExecuteReader("SELECT unitnum FROM tblAppointments WHERE apptID = " + apptid))
                {
                    if (reader != null && reader.Read())
                    {
                        unitnum = reader.GetValue(0).ToString();
                    }
                }

                //StatusReport sr = new StatusReport();
                //sr.apptid = apptid;
                //sr.description = "Started Automation cycle";
                //ProcessingThread.ReportProgress(300, sr);

                //StatusReport sr = (StatusReport)e.UserState;
                //if (status != null)
                //{
                try
                {
                    //temp debug
                    //status.LogStatus(this.Text,
                    //         "Automation",
                    //         "Ok",
                    //         "tarted Automation cycle " + apptid.ToString());
                }
                catch (Exception ex)
                {
                    Logger.Instance.WriteToLog(ex.ToString());
                }
                //}
                SessionManager.Instance.SetActivePatientNoCallback(unitnum, (int)apptid);

                /***********************  Risk Calculations   ********************/
                try
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Running risk calculations for appointment: " + apptid.ToString() +
                                                    ".");
                    SessionManager.Instance.GetActivePatient().RecalculateRisk();
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Risk calculations FAILED for appointment: " + apptid.ToString() +
                                                    ". " + e.ToString());
                }

                /***********************  Update BigQueue   ********************/
                try
                {
                    ProcessingThread.ReportProgress(1, "Updating BigQueue for appointment: " + apptid.ToString() + ".");
                    pc = new ParameterCollection("unitnum", unitnum);
                    BCDB2.Instance.RunSPWithParams("sp_3_populateBigQueue", pc);
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Updating BigQueue FAILED for appointment: " + apptid.ToString() +
                                                    ". " + e.ToString());
                }

                /***********************  Process Queue Documents    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Processing Queue Documents for appointment: " + apptid.ToString() + ".");
                pc = new ParameterCollection("apptID", apptid);
                BCDB2.Instance.RunSPWithParams("sp_processQueueDocuments", pc);



                /***********************  Process Automation Save Documents    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Processing Auto Save Documents: " + apptid.ToString() + ".");
                ApptUtils.saveAutomationDocumentsToPrintQueue(apptid);


                /***********************  Run Automation Stored Procedures    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Run Automation Stored Procedures  : " + apptid.ToString() + ".");

                ApptUtils.runAutomationStoredProcedures(apptid);

                /***********************  export HL7 files    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Export HL7 File: " + apptid.ToString() + ".");
                RiskService.exportHL7File(apptid);

                /***********************  Print Documents   ********************/
                try
                {
                    ProcessingThread.ReportProgress(1, "Printing documents for appointment: " + apptid.ToString() + ".");
                    ParameterCollection printDocArgs = new ParameterCollection();
                    printDocArgs.Add("apptid", apptid);
                    reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_AutomationHtmlDocsToPrint", printDocArgs);

                    int    templateID = -1;
                    string printer    = "";

                    while (reader.Read())
                    {
                        if (reader.IsDBNull(0) == false)
                        {
                            templateID = reader.GetInt32(0);
                        }
                        if (reader.IsDBNull(1) == false)
                        {
                            printer = reader.GetString(1);
                        }

                        if (templateID > 0)
                        {
                            if (string.IsNullOrEmpty(printer) == false)
                            {
                                if (printer.ToUpper() != "NO_PRINT")
                                {
                                    ProcessingThread.ReportProgress(1,
                                                                    "Printing templateID " + templateID.ToString() +
                                                                    " for apptID " + apptid.ToString() + ".");
                                    HtmlDocument hdoc = new HtmlDocument(templateID, unitnum, apptid);
                                    hdoc.targetPrinter = printer;
                                    hdoc.apptid        = apptid;
                                    htmlInProgress     = true;


                                    //try
                                    //{
                                    //    ////temp debug
                                    //    //status.LogStatus(this.Text,
                                    //    //                 "Automation",
                                    //    //                 "Ok",
                                    //    //                 "Appt " + hdoc.apptid.ToString() + " Sent doc " + hdoc.template.documentTemplateID.ToString() + " to " + hdoc.targetPrinter);
                                    //}
                                    //catch (Exception ex) { Logger.Instance.WriteToLog(ex.ToString()); }

                                    if (status != null)
                                    {
                                        try
                                        {
                                            status.LogStatus(this.Text,
                                                             "Automation",
                                                             "Ok",
                                                             "Appt " + hdoc.apptid.ToString() + " Sent doc " +
                                                             hdoc.template.documentTemplateID.ToString() + " to " +
                                                             hdoc.targetPrinter);
                                        }
                                        catch (System.Web.Services.Protocols.SoapException e)
                                        {
                                            //do nothing
                                        }
                                        catch (Exception ex)
                                        {
                                            Logger.Instance.WriteToLog(ex.ToString());
                                        }
                                    }


                                    ProcessingThread.ReportProgress(100, hdoc);
                                    while (htmlInProgress)
                                    {
                                        Thread.Sleep(100);
                                    }

                                    string sqlStr =
                                        "INSERT INTO tblDocuments([apptID],[documentTemplateID],[created],[createdBy]) VALUES(" +
                                        hdoc.apptid.ToString() + "," + hdoc.template.documentTemplateID + "," + "'" +
                                        DateTime.Now +
                                        "','AUTOMATION');";

                                    BCDB2.Instance.ExecuteNonQuery(sqlStr);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Printing FAILED for appointment: " + apptid.ToString() + ". " +
                                                    e.ToString());
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
                /***********************  Mark as printed to complete automation   ********************/
                try
                {
                    String sqlStr = "UPDATE tblRiskData SET printed = 1 WHERE apptid = " + apptid.ToString() + ";";
                    BCDB2.Instance.ExecuteNonQuery(sqlStr);
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    ("Automation - unable to update appt id=" + apptid.ToString() +
                                                     " printed=1.\n" + e.ToString()));
                }

                ProcessingThread.ReportProgress(200, "");
            }
        }
Пример #36
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            string lockoutMsg = "";
            User   u          = null;
            bool   validUser  = users.Any(x => ((User)x).userLogin.ToLower() == usernameTextBox.Text.ToLower());

            if (validUser)
            {
                u = (User)(users.First(x => ((User)x).userLogin.ToLower() == usernameTextBox.Text.ToLower()));
            }

            // begin jdg 10/30/15
            NameValueCollection values = Configurator.GetConfig("AppSettings");

            if (values != null)
            {
                LDAPSecurityContext = values["SecurityContext"];
            }
            if (String.IsNullOrEmpty(LDAPSecurityContext))
            {
                LDAPSecurityContext = "Off";
            }
            bool bLDAPSuccess = false;
            bool bLDAP        = (((LDAPSecurityContext.ToUpper() == "MACHINE") || (LDAPSecurityContext.ToUpper() == "DOMAIN")) ? true : false);

            try
            {
                if (bLDAP)
                {
                    switch (LDAPSecurityContext.ToUpper())
                    {
                    case "MACHINE":
                        using (var context = new PrincipalContext(ContextType.Machine))
                        {
                            if (context.ValidateCredentials(usernameTextBox.Text, passwordTextBox.Text))
                            {
                                bLDAPSuccess = true;
                            }
                        }
                        break;

                    case "DOMAIN":
                        using (var context = new PrincipalContext(ContextType.Domain))
                        {
                            if (context.ValidateCredentials(usernameTextBox.Text, passwordTextBox.Text))
                            {
                                bLDAPSuccess = true;
                            }
                        }
                        break;

                    default:

                        break;
                    }
                }
            }
            catch (Exception excLDAP)
            {
                RiskApps3.Utilities.Logger.Instance.WriteToLog("LDAP Authentication failed for user " + usernameTextBox.Text + " for this reason: " + excLDAP.ToString());
            }
            // end jdg 10/30/15

            String encryptedPassword = RiskAppCore.User.encryptPassword(passwordTextBox.Text);

            bool authenticated     = false;
            int  numFailedAttempts = 0;
            int  numMaxFailures    = 5;
            int  lockoutPeriod     = 0;

            lockoutMsg = "";

            Utilities.ParameterCollection pc = new Utilities.ParameterCollection();
            pc.Add("ntLoginName", DBUtils.makeSQLSafe(ntUser));
            pc.Add("userLogin", DBUtils.makeSQLSafe((u != null) ? u.userLogin : usernameTextBox.Text));

            //if (SessionManager.Instance.MetaData.Globals.encryptPasswords)
            if ((SessionManager.Instance.MetaData.Globals.encryptPasswords) && (!bLDAP))
            {
                pc.Add("userPassword", DBUtils.makeSQLSafe(encryptedPassword));
            }
            else
            {
                pc.Add("userPassword", DBUtils.makeSQLSafe(passwordTextBox.Text));
            }
            // begin jdg 10/30/15
            pc.Add("bLDAP", (bLDAP ? 1 : 0));
            pc.Add("bLDAPSuccess", (bLDAPSuccess ? 1 : 0));
            // end jdg 10/30/15

            SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_Authenticate_User", pc);

            if (reader != null)
            {
                if (reader.Read())
                {
                    authenticated     = (bool)reader.GetSqlBoolean(0);
                    numFailedAttempts = (int)reader.GetInt32(1);
                    numMaxFailures    = (int)reader.GetInt32(2);
                    lockoutPeriod     = (int)reader.GetInt32(3);
                }
                reader.Close();
            }
            if ((!validUser) || (!authenticated))  //note that if they're not a valid user they won't be authenticated, but we've updated the failed count and timeout values
            {
                if (lockoutPeriod > 0)
                {
                    lockoutMsg = "\r\nLogin attempts will be blocked for " + lockoutPeriod.ToString() + " minute" + ((lockoutPeriod > 1) ? "s." : ".");
                }
                else
                {
                    lockoutMsg = "\r\nYou have made " + numFailedAttempts.ToString() + " failed Login attempt" + ((numFailedAttempts > 1) ? "s" : "") + " of a maximum " + numMaxFailures.ToString() + " allowed.";
                }
            }

            if (validUser && authenticated)
            {
                //see if user is forced to change password
                if (!bLDAP) // jdg 10/30/15
                {
                    if (ApplicationUtils.checkPasswordForceChange(u.userLogin))
                    {
                        String username = usernameTextBox.Text;
                        SessionManager.Instance.MetaData.Users.BackgroundListLoad();
                        passwordTextBox.Text = "";
                        usernameTextBox.Text = username;
                        this.DialogResult    = System.Windows.Forms.DialogResult.None;
                        return;
                    }

                    if (ApplicationUtils.checkPasswordDateOK(u.userLogin) == false)
                    {
                        String username = usernameTextBox.Text;
                        SessionManager.Instance.MetaData.Users.BackgroundListLoad();
                        passwordTextBox.Text = "";
                        usernameTextBox.Text = username;
                        this.DialogResult    = System.Windows.Forms.DialogResult.None;
                        return;
                    }
                }
                roleID   = RiskAppCore.User.fetchUserRoleID(u.userLogin);
                roleName = RiskAppCore.User.fetchUserRoleName(u.userLogin);

                switch (roleName)
                {
                case "Tablet":
                    RiskAppCore.ErrorMessages.Show(RiskAppCore.ErrorMessages.ROLE_ACCESS_DENIED);
                    return;

                default:
                    break;
                }
                SessionManager.Instance.ActiveUser = u;
                InitUserGUIPrefs(u);
                u.UserClinicList.user_login = u.userLogin;
                u.UserClinicList.AddHandlersWithLoad(null, UserClinicListLoaded, null);
                //DialogResult = DialogResult.OK;

                HraObject.AuditUserLogin(u.userLogin);

                stopWatch.Stop();
                // Get the elapsed time as a TimeSpan value.
                TimeSpan ts = stopWatch.Elapsed;
                if (ts.TotalSeconds < requiredSplashTime)
                {
                    progressBar1.Style = ProgressBarStyle.Blocks;
                    progressBar1.Value = progressBar1.Maximum;
                    progressBar1.Refresh();
                    Application.DoEvents();
                    Thread.Sleep((int)(1000 * (requiredSplashTime - ts.TotalSeconds)));
                }

                return;
            }

            if (numFailedAttempts == 1)
            {
                MessageBox.Show(
                    "You have provided an incorrect username or password.\r\nPlease correct your password or try a different user." + lockoutMsg,
                    "Incorrect Username/Password",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            else if (numFailedAttempts > 1)
            {
                MessageBox.Show(
                    lockoutMsg,
                    "Incorrect Username/Password",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            return;
        }
Пример #37
0
        public void PersistFullObject(HraModelChangedEventArgs e, string unitnum, int apptid)
        {
            ParameterCollection pc = new ParameterCollection();
            pc.Add("unitnum", unitnum);
            pc.Add("apptid", apptid);

            DoPersistWithSpAndParams(e,
                                        "sp_3_Save_ClausParameters",
                                        ref pc);
        }
Пример #38
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            int surveyID = 0;
            //KeyValuePair<int, string> kvpSurvey;
            KeyValuePair<int, string> kvpClinic;

            foreach (KeyValuePair<int, string> pair in surveyDic)
            {
                if (pair.Value == cbSurvey.Text)
                {
                    surveyID = pair.Key;
                }
            }

            int x = 0;
            if (cbNumPatients.SelectedItem != null)
            {
                int i = int.Parse(cbNumPatients.SelectedItem.ToString());
                int index = 0;
                string time;
                Random random = new Random();
                string firstName = "";

                string nextUnitNum = createTestUnitnum();
                long unitNum = Int64.Parse(nextUnitNum);

                while (i > x)
                {
                    RiskApps3.Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();

                    if (x <= 9)
                    {
                        time = "0" + x.ToString();
                    }
                    else
                    {
                        time = (x % 60).ToString();
                    }

                    pc.Add("apptdate", dtAppointmentDate.Value.ToString("MM/dd/yyyy"));
                    pc.Add("appttime", "08:" + time + " AM");
                    index = random.Next(10000) % names.Count;
                    firstName = names[index];
                    pc.Add("firstname", firstName);
                    pc.Add("lastname", "Test" + cbSurvey.Text.Replace(" ",""));
                    pc.Add("gender", "F");
                    pc.Add("dob", "09/23/1970");
                    pc.Add("email", "*****@*****.**");
                    pc.Add("address1", (i * 10).ToString() + " Broadway");
                    pc.Add("city", "Cambridge");
                    pc.Add("state", "MA");
                    pc.Add("zip", "02473");
                    pc.Add("phone", "6175551212");
                    pc.Add("emailaddress", "*****@*****.**");
                    pc.Add("sendByEmail", 1);
                    pc.Add("machinename", "test");
                    pc.Add("preferredInstitutionName", "test");
                    if(cbClinic.SelectedItem != null)
                    {
                        kvpClinic = (KeyValuePair<int, string>)cbClinic.SelectedItem;
                        pc.Add("clinicID", kvpClinic.Key);
                    }
                    else
                    {
                        pc.Add("clinicID", 1);      // default
                    }

                    pc.Add("unitnum", unitNum.ToString());
                    pc.Add("createdby", cbSurvey.Text);
                    pc.Add("insertApptWebRecord", 1);
                    pc.Add("surveyID", surveyID);

                    BCDB2.Instance.ExecuteReaderSPWithParams("sp_createApptFromSchedService", pc);
                    unitNum++;
                    x++;
                }
            }

            this.Close();
        }
Пример #39
0
        public void CreateTestPatients(int NoOfPatients, string dtAppointmentDate, int surveyID, string SurveyName, int clinicID)
        {
            List <string> names = new List <string> {
                "Mary", "Jane", "Sylvia", "Ruth", "Penelope", "Fernanda", "Gertrude", "Tiffany", "Cher", "Elizabeth", "Rene", "Chloe", "Rapunzel", "Ashley", "Jessica", "Emily", "Sarah", "Samantha", "Brittany", "Amanda", "Elizabeth", "Taylor", "Margarete", "Stephanie", "Kayley", "Laura", "Jennifer", "Rachel", "Anna", "Nicole", "Amber", "Alexis", "Courtney", "Victoria", "Daniela", "Adelheid", "Rebecca", "Jasmine", "Katherine", "Melissa", "Alexandra", "Brianna", "Chelsea", "Michaela", "Morgan", "Kelsey", "Tiffany", "Kimberley", "Christine", "Madison", "Heather", "Selby", "Anna", "Mary", "Mary", "Alison", "Sarah", "Laura", "Andrea", "Olivia", "Erin", "Hayley", "Abigail", "Katherine", "Jordan", "Natalie", "Vanessa", "Kelly", "Brooke", "Erica", "Christine", "Julia", "Crystal", "Amata", "Katherine", "Mary", "Lindsay", "Paige", "Cassandra", "Sidney", "Katherine", "Katherine", "Katherine", "Emma", "Shannon", "Angela", "Gabriele", "Jacqueline", "Johanna", "Jacqueline", "Mary", "Adelheid", "Brianna", "Alexandra", "Destiny", "Miranda", "Monica", "Brittany", "Katherine", "Savannah", "Sierra", "Sabrina", "Brianna", "Whitney", "Carla", "Mary", "Magdalena", "Erica", "Grace", "Diana", "Leah", "Angelica", "Lindsay", "Christine", "Katherine", "Cynthia", "Margarete", "Cheyenne", "Mackenzie", "Margarete", "Veronica", "Melanie", "Bailey", "Christine", "Blanche", "Elizabeth", "Holly", "Christine", "Alexandra", "Ariela", "Bethany", "Hayley", "Leslie", "April", "Casey", "Brenda", "Katherine", "Julia", "Patrizia", "Autumn", "Karin", "Gabriele", "Brandy", "Anna", "Rachel", "Kendra", "Karin", "Dominika", "Valerie", "Desiree", "Cara", "Carla", "Clare", "Tara", "Adriana", "Kayley", "Natalie", "Michaela", "Chloe", "Jocelyn", "Kylie", "Crystal", "Hayley", "Katherine", "Alison", "Anna", "Sophia", "Daisy", "Rebecca", "Daniela", "Juliana", "Cassidy", "Alexandra", "Raven", "Jade", "Angela", "Summer", "Edeltraud", "Gabriele", "Chelsea", "Alexandra", "Adriana", "Katherine", "Claudia", "Monica", "Margarete", "Johanna", "Christine", "Faith", "Michaela", "Brandy", "Ciara", "Michaela", "Mallory", "Christine", "Diana", "Jessenia", "Ashley", "Cynthia", "Mercedes", "Adelheid", "Regina", "Lydia", "Felizia", "Mackenzie", "Zoe", "Brigitte", "Mary", "Priska", "Carla", "Cassandra", "Denise", "Jasmine", "Victoria", "Isabella", "Selina", "Diamond", "Evelyn", "Anna", "Amelia", "Christine", "Alison", "Tabitha", "Abigail", "Ashley", "Lacey", "Jasmine", "Isabella", "Asia", "Candace", "Ciara", "Sierra", "Colleen", "Jacqueline", "Carla", "Hope", "Linda", "Noemi", "Helen", "Mary", "Theresa", "Meredith", "Guadalupe", "Johanna", "Renate", "Nicole", "Kendall", "Jasmine", "Tamara", "Brittany", "Justine", "Theresa", "Susanne", "Tatjana", "Tiara", "Daniela", "Maja", "Adriana", "Genesis", "Rose", "Myra", "Kelly", "Casey", "Candace", "Clare", "Aubrey", "Adriana", "Nina", "Theresa"
            };

            int x = 0;

            if (NoOfPatients != 0)
            {
                int    i     = NoOfPatients;
                int    index = 0;
                string time;
                Random random    = new Random();
                string firstName = "";

                string nextUnitNum = createTestUnitnum();
                long   unitNum     = Int64.Parse(nextUnitNum);

                while (i > x)
                {
                    RiskApps3.Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();

                    if (x <= 9)
                    {
                        time = "0" + x.ToString();
                    }
                    else
                    {
                        time = (x % 60).ToString();
                    }

                    pc.Add("apptdate", Convert.ToDateTime(dtAppointmentDate).ToString("MM/dd/yyyy"));
                    pc.Add("appttime", "08:" + time + " AM");
                    index     = random.Next(10000) % names.Count;
                    firstName = names[index];
                    pc.Add("firstname", firstName);
                    pc.Add("lastname", "Test" + SurveyName.Replace(" ", ""));
                    pc.Add("gender", "F");
                    pc.Add("dob", "09/23/1970");
                    pc.Add("email", "*****@*****.**");
                    pc.Add("address1", (i * 10).ToString() + " Broadway");
                    pc.Add("city", "Cambridge");
                    pc.Add("state", "MA");
                    pc.Add("zip", "02473");
                    pc.Add("phone", "6175551212");
                    pc.Add("emailaddress", "*****@*****.**");
                    pc.Add("sendByEmail", 1);
                    pc.Add("machinename", "test");
                    pc.Add("preferredInstitutionName", "test");
                    if (clinicID != null && clinicID != 0)
                    {
                        pc.Add("clinicID", clinicID);
                    }
                    else
                    {
                        pc.Add("clinicID", 1);      // default
                    }

                    pc.Add("unitnum", unitNum.ToString());
                    pc.Add("createdby", SurveyName);
                    pc.Add("insertApptWebRecord", 0);
                    pc.Add("surveyID", surveyID);

                    BCDB2.Instance.ExecuteReaderSPWithParams("sp_createApptFromSchedService", pc);
                    unitNum++;
                    x++;
                }
            }
        }