Exemple #1
0
        private void checkInOutButton_Click(object sender, EventArgs e)
        {
            if (selectedVisit != null)
            {
                //the patient must be checking out, as they never exited their last visit.

                CheckOut C = new CheckOut(this, ref selectedPatient, ref selectedVisit);
                C.Closed += (s, args) => this.Close();
                C.Show();
                Hide();
                //selectedVisit.setExitDate(DateTime.Now);
                //RADGSHALibrary.DBConnectionObject conn = RADGSHALibrary.DBConnectionObject.getInstance();
                //conn.addVisit(selectedVisit, selectedPatient);
                //checkInOutButton.Text = "Check In";
                //selectedVisit = null;
            }
            else
            {
                DBConnectionObject conn = DBConnectionObject.getInstance();
                //The patient has already finished their last visit, must be checking into a new visit.
                //this.Hide();

                selectedPatient.checkIn();
                selectedVisit = selectedPatient.getCurrentVisit();
                selectedVisit.setEntryDate(DateTime.Now);
                selectedVisit.changeDiagnosis(VisitDiagnosisTextBox.Text);
                selectedVisit.setAttendingPhysician(textAttendingPhy.Text);
                selectedVisit.setNote(visitNotes.Text);
                ChangeRoom C = new ChangeRoom(this, ref selectedPatient, ref selectedVisit);

                // C.Closed += (s, args) => this.Close();
                C.ShowDialog();
                conn.addVisit(selectedVisit, selectedPatient);
                for (int i = 0; i < textSymptoms.Lines.Length; i++)
                {
                    selectedVisit.addSymptom(textSymptoms.Lines[i].Trim());
                    conn.addSymptom(selectedPatient, selectedVisit, textSymptoms.Lines[i].Trim());
                }
                // if (selectedVisit.getRoomList()[0]!=null) conn.addStaysIn(selectedVisit.getRoomList()[0], selectedPatient, selectedVisit);
                checkInOutButton.Text = "Check Out";
                displayPatient();
            }
        }
Exemple #2
0
        private void saveCurrentPatient()
        {
            DBConnectionObject conn = DBConnectionObject.getInstance();

            selectedPatient.setFirstName(patientFirstNameTextBox.Text);
            selectedPatient.setMiddleInitial(PatientMiddleInitialTextBox.Text[0]);
            selectedPatient.setFirstName(patientFirstNameTextBox.Text);
            selectedPatient.setLastName(patientLastNameTextBox.Text);
            selectedPatient.setAddressLine1(patientAddressLine1TextBox.Text);
            selectedPatient.setAddressLine2(patientAddressLine2TextBox.Text);
            selectedPatient.setCity(patientCityTextBox.Text);
            selectedPatient.setState(patientStateTextBox.Text);
            selectedPatient.setZipcode(patientZipTextBox.Text);
            selectedPatient.setGender(patientGenderTextBox.Text[0]);
            selectedPatient.setInsurer(patientInsurerID.Text);

            if (patientDNR.Text == "True")
            {
                selectedPatient.setDoNotResuscitateStatus(true);
            }
            else if (patientDNR.Text == "False")
            {
                selectedPatient.setDoNotResuscitateStatus(false);
            }

            if (patientOrganDonor.Text == "True")
            {
                selectedPatient.setOrganDonorStatus(true);
            }
            else if (patientOrganDonor.Text == "False")
            {
                selectedPatient.setOrganDonorStatus(false);
            }



            selectedPatient.setBirthDate(dateBirthdate.Value);

            conn.updatePatient(selectedPatient);

            if (selectedVisit != null)
            {
                selectedVisit.setEntryDate(EntryDatePicker.Value);
                selectedVisit.setAttendingPhysician(textAttendingPhy.Text);
                selectedVisit.changeDiagnosis(VisitDiagnosisTextBox.Text);
                selectedVisit.setNote(visitNotes.Text);

                for (int i = 0; i < textSymptoms.Lines.Length; i++)
                {
                    bool hasSymptom = false;;
                    foreach (string s in selectedVisit.getSymptomList())
                    {
                        if (textSymptoms.Lines[i].Trim() == s)
                        {
                            hasSymptom = true;
                        }
                    }
                    if (hasSymptom == false)
                    {
                        conn.addSymptom(selectedPatient, selectedVisit, textSymptoms.Lines[i].Trim());
                    }
                }

                conn.updateVisit(selectedVisit, selectedPatient);
            }
        }
        public async void importPatientData(string url)
        {
            int numErrors = 0;

            int numberOfLines     = getFileLineLength(url);
            int currentLineNumber = 0;

            int outputPercentTimer = 0;

            status.Imported = 0;
            status.Total    = numberOfLines;

            string line;

            Char[] prohibitedChars      = { ' ', '*', '.' };
            System.IO.StreamReader file =
                new System.IO.StreamReader(url);
            while ((line = file.ReadLine()) != null)
            {
                // This "await Task.Delay(0);" line may look useless, but it allows the form to act asynchronous.
                await Task.Delay(1);

                string patientLastName  = line.Substring(0, 50).Trim(prohibitedChars).Replace("'", "’");
                string patientFirstName = line.Substring(50, 25).Trim(prohibitedChars).Replace("'", "’");

                Char   patientMiddleInitial = line.Substring(75, 1).Trim(prohibitedChars).Replace("'", "’").ToCharArray().First();
                Char   patientGender        = line.Substring(76, 1).Trim(prohibitedChars).Replace("'", "’").ToCharArray().First();
                string patientSSN           = line.Substring(77, 9).Trim(prohibitedChars).Replace("'", "’");

                int      birthDate_month = Int32.Parse(line.Substring(86, 2).Trim(prohibitedChars).Replace("'", "’"));
                int      birthDate_day   = Int32.Parse(line.Substring(88, 2).Trim(prohibitedChars).Replace("'", "’"));
                int      birthDate_year  = Int32.Parse(line.Substring(90, 4).Trim(prohibitedChars).Replace("'", "’"));
                DateTime birthDate       = new DateTime(birthDate_year, birthDate_month, birthDate_day);

                string patientZipcode      = line.Substring(559, 5).Trim(prohibitedChars).Replace("'", "’");
                string patientState        = line.Substring(557, 2).Trim(prohibitedChars).Replace("'", "’");
                string patientCity         = line.Substring(532, 25).Trim(prohibitedChars).Replace("'", "’");
                string patientAddressLine1 = line.Substring(462, 35).Trim(prohibitedChars).Replace("'", "’");
                string patientAddressLine2 = line.Substring(497, 35).Trim(prohibitedChars).Replace("'", "’");
                string patientInsurer      = line.Substring(457, 5).Trim(prohibitedChars).Replace("'", "’");

                string  DnrStatusString   = line.Substring(564, 1).Trim(prohibitedChars).Replace("'", "’");
                Boolean patientDnrStatus  = (DnrStatusString == "Y");
                string  OrganDonorString  = line.Substring(565, 1).Trim(prohibitedChars).Replace("'", "’");
                Boolean patientOrganDonor = (OrganDonorString == "Y");

                Patient p = new Patient(patientSSN);
                p.setFirstName(patientFirstName);
                p.setMiddleInitial(patientMiddleInitial);
                p.setLastName(patientLastName);
                p.setGender(patientGender);
                p.setZipcode(patientZipcode);
                p.setState(patientState);
                p.setCity(patientCity);
                p.setAddressLine1(patientAddressLine1);
                p.setAddressLine2(patientAddressLine2);
                p.setBirthDate(birthDate);
                p.setInsurer(patientInsurer);
                p.setDoNotResuscitateStatus(patientDnrStatus);
                p.setOrganDonorStatus(patientOrganDonor);

                if (conn.queryPatient(patientSSN, "", "", "").Count >= 1)
                {
                    conn.updatePatient(p);
                }
                else
                {
                    conn.addPatient(p);
                }

                string[] symptom = new string[6];
                symptom[0] = line.Substring(132, 25).Trim();
                symptom[1] = line.Substring(157, 25).Trim();
                symptom[2] = line.Substring(182, 25).Trim();
                symptom[3] = line.Substring(207, 25).Trim();
                symptom[4] = line.Substring(232, 25).Trim();
                symptom[5] = line.Substring(257, 25).Trim();
                string   diagnosis     = line.Substring(282, 75).Trim();
                string   attendingPhys = line.Substring(118, 5).Trim(prohibitedChars);
                string   note          = line.Substring(357, 100).Trim();
                DateTime entryDate;

                string entryMonth  = line.Substring(94, 2);
                string entryDay    = line.Substring(96, 2);
                string entryYear   = line.Substring(98, 4);
                string entryHour   = line.Substring(102, 2);
                string entryMinute = line.Substring(104, 2);
                entryDate = DateTime.Parse(entryMonth + "/" + entryDay + "/" + entryYear + " " + entryHour + ":" + entryMinute);

                DateTime exitDate;
                string   exitMonth  = line.Substring(106, 2);
                string   exitDay    = line.Substring(108, 2);
                string   exitYear   = line.Substring(110, 4);
                string   exitHour   = line.Substring(114, 2);
                string   exitMinute = line.Substring(116, 2);
                exitDate = DateTime.Parse(exitMonth + "/" + exitDay + "/" + exitYear + " " + exitHour + ":" + exitMinute);

                string roomNumber = line.Substring(123, 9);

                Visit v = new Visit();
                v.setEntryDate(entryDate);
                v.setExitDate(exitDate);
                v.setAttendingPhysician(attendingPhys);
                v.setNote(note);

                v.changeDiagnosis(diagnosis);

                try
                {
                    conn.addVisit(v, p);



                    for (int i = 0; i < 6; i++)
                    {
                        List <string> l = conn.querySymptoms(p, v, symptom[i]);
                        //Console.WriteLine("Matching symptoms for " + symptom[i] +" : " + l.Count());
                        if (l.Count == 0)
                        {
                            conn.addSymptom(p, v, symptom[i]);               // if this patient doesn't have the symptom, add it
                        }
                    }
                    conn.closeVisit(p, v);

                    List <Room> rooms = conn.queryRoom(roomNumber);

                    int bestIndex = -1;
                    for (int i = 0; i < rooms.Count; i++)
                    {
                        if (v.getEntryDate() < rooms[i].getEffectiveDate())
                        {
                            bestIndex = i;
                        }
                    }
                    if (bestIndex != -1)
                    {
                        conn.addStaysIn(rooms[bestIndex], p, v);
                    }

                    conn.closeStaysIn(p, v, rooms[bestIndex], v.getExitDate());
                }
                catch (Exception e)
                {
                    numErrors++;
                }
                currentLineNumber++;
                outputPercentTimer++;

                status.Imported = currentLineNumber;


                if (outputPercentTimer > 1000)
                {
                    outputPercentTimer = 0;
                    Console.WriteLine(((currentLineNumber * 100) / (numberOfLines)).ToString() + "% complete");
                    // status.PercentDone = (currentLineNumber * 100) / (numberOfLines);
                }
            }
            //status.PercentDone = 100;
            status.Imported = status.Total;
            Console.WriteLine("Import Completed.");
            file.Close();
            Console.WriteLine("Import Completed with " + numErrors + " errors. If errors occurred, it's possible user is already imported.");
        }