/// <summary>
 /// Initts the specified patient.
 /// </summary>
 /// <param name="patient">The patient.</param>
 /// <param name="lastDiagnosis">The last diagnosis.</param>
 /// <param name="lastTherapy">The last therapy.</param>
 public void init(PatientData patient, string lastDiagnosis, string lastTherapy)
 {
     this.patient = patient;
     this.lastDiagnosis = lastDiagnosis;
     this.lastTherapy = lastTherapy;
     fillTextBoxes();
 }
        internal void init(PatientData currentPatient)
        {
            this.currentPatient = currentPatient;

            this.labelPatient.Text = this.currentPatient.FirstName + " " + this.currentPatient.SurName;
            this.textBoxToDo.Clear();
            refresh();
        }
        private static String onePatient(PatientData patient, ISPDBL patComp)
        {
            StringBuilder sb = new StringBuilder();
            OperationData operation = patComp.GetLastOperationByPatientID(patient.Id);
            VisitData visit = patComp.GetLastVisitByPatientID(patient.Id);
            StringBuilder toDoSB = new StringBuilder();

            sb.Append(firstLine(patient));
            sb.Append(name(patient));
            sb.Append(opDiagnoses(operation));
            if (operation == null || String.IsNullOrEmpty(operation.Diagnoses)) {
                sb.Append(visitDiagnoses(visit));
            }
            sb.Append(opPerformed(operation));
            sb.Append(opTeam(operation));
            sb.Append(seperator());
            return sb.ToString();
        }
        private static String onePatient(PatientData patient, ISPDBL patComp, long year, long halfyear, ActionKind actionKind)
        {
            StringBuilder sb = new StringBuilder();
            OperationData operation = patComp.GetLastOperationByPatientID(patient.Id);
            VisitData visit = patComp.GetLastVisitByPatientID(patient.Id);
            StringBuilder toDoSB = new StringBuilder();
            foreach (NextActionData nextAction in patComp.GetNextActionsByPatientID(patient.Id)) {
                if (nextAction.ActionYear == year &&
                    nextAction.ActionhalfYear == halfyear &&
                    nextAction.ActionKind == actionKind &&
                    !String.IsNullOrEmpty(nextAction.Todo)) {
                    toDoSB.Append(nextAction.Todo);
                }
            }

            sb.Append(firstLine(patient));
            sb.Append(name(patient));
            sb.Append(opDiagnoses(operation));
            sb.Append(visitDiagnoses(visit));
            sb.Append(visitTherapy(visit));
            sb.Append(toDo(toDoSB.ToString()));
            sb.Append(seperator());
            return sb.ToString();
        }
 /// <summary>
 /// Updates the patient.
 /// </summary>
 /// <param name="patientData">The patient data.</param>
 /// <returns></returns>
 public override bool UpdatePatient(PatientData patientData)
 {
     bool ok = base.UpdatePatient(patientData);
     if (ok && patientBuffer != null) { // update in buffer as well
         patientBuffer.Remove(patientData);
         patientBuffer.Add(patientData);
     }
     return ok;
 }
 /// <summary>
 /// Inserts the patient.
 /// </summary>
 /// <param name="patientData">The patient data.</param>
 /// <returns></returns>
 public virtual PatientData InsertPatient(PatientData patientData)
 {
     IPatient patientDB = Database.CreatePatient();
     long id = patientDB.Insert(patientData);
     if (id != 0) {
         PatientData newPatient = new PatientData(id, patientData.FirstName, patientData.SurName,
             patientData.DateOfBirth, patientData.Sex,
             patientData.Phone, patientData.Weight,
              patientData.Address, patientData.ResidentOfAsmara, patientData.Ambulant,
              patientData.Finished, patientData.Linz, patientData.WaitListStartDate);
         return newPatient;
     } else {
         return null;
     }
 }
 /// <summary>
 /// Updates the patient.
 /// </summary>
 /// <param name="patientData">The patient data.</param>
 /// <returns></returns>
 public virtual bool UpdatePatient(PatientData patientData)
 {
     IPatient patientDB = Database.CreatePatient();
     bool ok = patientDB.Update(patientData);
     return ok;
 }
        /// <summary>
        /// Parses the patients.
        /// </summary>
        /// <param name="jsonPatients">The json patients.</param>
        /// <returns></returns>
        private static IList<PatientData> parsePatients(ArrayList jsonPatients)
        {
            IList<PatientData> patientList = new List<PatientData>();

            foreach (Hashtable htpat in jsonPatients) {
                PatientData patient = new PatientData();

                if (htpat.ContainsKey(patient_patientID)) {
                    patient.Id = Convert.ToInt64(htpat[patient_patientID]);
                }

                if (htpat.ContainsKey(patient_firstname)) {
                    patient.FirstName = Convert.ToString(htpat[patient_firstname]);
                }

                if (htpat.ContainsKey(patient_surname)) {
                    patient.SurName = Convert.ToString(htpat[patient_surname]);
                }

                if (htpat.ContainsKey(patient_birthdate)) {
                    patient.DateOfBirth = DateTime.Parse(Convert.ToString(htpat[patient_birthdate]), DateTimeFormatInfo.InvariantInfo);
                }

                if (htpat.ContainsKey(patient_sex)) {
                    patient.Sex = (Sex)Convert.ToInt64(htpat[patient_sex]);
                } else {
                    throw new SPDJsonParseException(null, "Json Patient Sex not set.", null);
                }

                if (htpat.ContainsKey(patient_phone)) {
                    patient.Phone = Convert.ToString(htpat[patient_phone]);
                }

                if (htpat.ContainsKey(patient_weight)) {
                    patient.Weight = Convert.ToInt32(htpat[patient_weight]);
                }

                if (htpat.ContainsKey(patient_residentOfAsmara)) {
                    patient.ResidentOfAsmara = (ResidentOfAsmara)Convert.ToInt64(htpat[patient_residentOfAsmara]);
                } else {
                    patient.ResidentOfAsmara = ResidentOfAsmara.undefined;
                }

                if (htpat.ContainsKey(patient_finished)) {
                    patient.Finished = (Finished)Convert.ToInt64(htpat[patient_finished]);
                } else {
                    patient.Finished = Finished.undefined;
                }

                if (htpat.ContainsKey(patient_ambulant)) {
                    patient.Ambulant = (Ambulant)Convert.ToInt64(htpat[patient_ambulant]);
                } else {
                    patient.Ambulant = Ambulant.notAmbulant;
                }

                if (htpat.ContainsKey(patient_linz)) {
                    patient.Linz = (Linz)Convert.ToInt64(htpat[patient_linz]);
                } else {
                    patient.Linz = Linz.undefined;
                }

                if (htpat.ContainsKey(patient_waitListStartDate)) {
                    patient.WaitListStartDate = DateTime.Parse(Convert.ToString(htpat[patient_waitListStartDate]), DateTimeFormatInfo.InvariantInfo);
                }

                patientList.Add(patient);
            }

            return patientList;
        }
        //private delegate void fillComboBoxesDelegate();
        /// <summary>
        /// Inits the specified currend patient.
        /// </summary>
        /// <param name="currendPatient">The currend patient.</param>
        /// <param name="patComp">The pat comp.</param>
        public void Init(PatientData currendPatient, ISPDBL patComp)
        {
            //DateTime dt = DateTime.Now;
            //string zeit = "";
            this.patComp = patComp;
            //zeit = zeit + "\r\n" + (DateTime.Now - dt).ToString();
            if (currendPatient != null) {
                this.Clear(false);
                listViewPatients.Items.Add(createPatientListViewItem(currendPatient));
                if (listViewPatients.Items.Count > 0) {
                    listViewPatients.SelectedIndices.Add(0);
                }
                listViewPatients.Focus();
            } else {
                //zeit = zeit + "\r\n" + (DateTime.Now - dt).ToString();
                this.Clear(true);
            }
            //zeit = zeit + "\r\n" + (DateTime.Now - dt).ToString();
            //MessageBox.Show(zeit);

            comboBoxDiagnoseGroups.Items.Clear();
            foreach(DiagnoseGroupData dgd in patComp.FindAllDiagnoseGroups()) {
                comboBoxDiagnoseGroups.Items.Add(dgd);
            }
        }
 /// <summary>
 /// Adds the patient.
 /// </summary>
 /// <param name="p">The p.</param>
 public void addPatient(PatientData p)
 {
     if (patients == null) {
         patients = new List<PatientData>();
     }
     patients.Add(p);
 }
 private static String firstLine(PatientData patient)
 {
     return "<tr><td class='what'>ID: </td><td>" + patient.Id + "</td><td class='what'>Sex: </td><td>" + patient.Sex + "</td><td class='what'>Phone: </td><td>" + patient.Phone + "</td><td class='what'>Birthdate: </td><td>" + patient.DateOfBirth.ToShortDateString() + "</td></tr>" + Environment.NewLine;
 }
        private void buttonSaveData_Click(object sender, EventArgs e)
        {
            DateTime birthDate = new DateTime();
            if (!(textBoxBirthYear.Text.Trim().Equals("") &&
                textBoxBirthMonth.Text.Trim().Equals("") &&
                textBoxBirthDay.Text.Trim().Equals(""))) {
                try {
                    birthDate = new DateTime(Int32.Parse(textBoxBirthYear.Text.Trim()),
                                             Int32.Parse(textBoxBirthMonth.Text.Trim()),
                                             Int32.Parse(textBoxBirthDay.Text.Trim()));
                } catch (Exception exxx) {
                    MessageBox.Show("Sorry - but the date is not correct" + exxx.ToString());
                    return;
                }
            }

            DateTime? waitListDate = null;
            if (!string.IsNullOrWhiteSpace(labelWaitListDateValue.Text))
            {
                waitListDate = DateTime.Parse(labelWaitListDateValue.Text, DateTimeFormatInfo.InvariantInfo);
            }

            if (listBoxSex.SelectedItems.Count == 0) {
                MessageBox.Show("No gender is selected");
                return;
            }

            if (listBoxAmbulant.SelectedItems.Count == 0) {
                MessageBox.Show("Ambulant is not selected");
                return;
            }

            if (listBoxResidentOfAsmara.SelectedItems.Count == 0) {
                MessageBox.Show("Resident of Asmara is not selected");
                return;
            }

            if (listBoxFinished.SelectedItems.Count == 0) {
                MessageBox.Show("Finished is not selected");
                return;
            }

            if (listBoxLinz.SelectedItems.Count == 0) {
                MessageBox.Show("Linz is not selected");
                return;
            }

            Sex sex = (Sex)Enum.Parse(new Sex().GetType(), this.listBoxSex.Text);
            Ambulant ambulant = (Ambulant)Enum.Parse(new Ambulant().GetType(), this.listBoxAmbulant.Text);
            ResidentOfAsmara residentOfAsmara = (ResidentOfAsmara)Enum.Parse(new ResidentOfAsmara().GetType(), this.listBoxResidentOfAsmara.Text);
            Finished finished = (Finished)Enum.Parse(new Finished().GetType(), this.listBoxFinished.Text);
            Linz linz = (Linz)Enum.Parse(new Linz().GetType(), this.listBoxLinz.Text);

            long pId;
            if (currentPatient == null)
                pId = 0;
            else
                pId = currentPatient.Id;

            int weight;

            try {
                weight = Int32.Parse(textBoxWeight.Text.Trim());
            } catch (Exception) {
                weight = 0;
                if (textBoxWeight.Text.Trim().Equals("")){
                    weight = 0;
                }else{
                    MessageBox.Show("In the weight field has to be a integer number");
                    return;
                }
            }

            if (this.patComp.DoesPhoneExist(this.textBoxPhone.Text.Trim())) {
                IList<PatientData> patients = this.patComp.FindPatientByPhone(this.textBoxPhone.Text.Trim());
                if (!(patients.Count == 1 && currentPatient != null && patients[0].Id == currentPatient.Id)) {
                    StringBuilder sb = new StringBuilder();
                    foreach (PatientData pd in patients) {
                        sb.Append(Environment.NewLine + "-----------------------------------" + Environment.NewLine).Append(pd.ToLineBreakedString()).Append(Environment.NewLine);
                    }
                    DialogResult res = MessageBox.Show("This phone Number is already stored." + Environment.NewLine + "Do you want to add the Patient anyway?" + "Patient(s):" + sb.ToString(), "Warning!", MessageBoxButtons.YesNo);
                    if (res == DialogResult.No) {
                        return;
                    }
                }
            }

            PatientData patient = new PatientData(pId, textBoxFirstName.Text.Trim(), textBoxSurname.Text.Trim(),
                    birthDate, sex, textBoxPhone.Text.Trim(),
                    weight, textBoxAddress.Text.Trim(), residentOfAsmara, ambulant, finished, linz, waitListDate);

            IList<DiagnoseGroupData> diagnoseGroups = new List<DiagnoseGroupData>();
            foreach (DiagnoseGroupData dg in listBoxAssignedDiagnoseGroups.Items) {
                diagnoseGroups.Add(dg);
            }

            NewPatientStoreEventArgs e2 = new NewPatientStoreEventArgs(patient, diagnoseGroups);

            Store(this, e2);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NewPatientStoreEventArgs" /> class.
 /// </summary>
 /// <param name="patient">The patient.</param>
 /// <param name="diagnoseGroups">The diagnose groups.</param>
 public NewPatientStoreEventArgs(PatientData patient, IList<DiagnoseGroupData> diagnoseGroups)
 {
     this.patient = patient;
     this.diagnoseGroups = diagnoseGroups;
 }
 private ListViewItem createPatientListViewItem(PatientData pd)
 {
     ListViewItem item = new ListViewItem(pd.Id.ToString());
     item.SubItems.Add(pd.SurName);
     item.SubItems.Add(pd.FirstName);
     item.SubItems.Add(CommonUtilities.StaticUtilities.getAgeFromBirthDate(pd.DateOfBirth));
     item.SubItems.Add(pd.Sex.ToString());
     item.SubItems.Add(pd.Address);
     item.SubItems.Add(pd.Weight.ToString());
     item.SubItems.Add(pd.Phone);
     return item;
 }
 /// <summary>
 /// Initts this instance.
 /// </summary>
 public void Init(PatientData currentPatient)
 {
     this.currentPatient = currentPatient;
     enabler(true);
     monthCalendarBirth.Visible = false;
     buttonSubmitCalendar.Visible = false;
     buttonNoCalender.Visible = false;
     textBoxSurname.Select();
     fillTextBoxes();
     this.textBoxSurname.Focus();
     this.textBoxSurname.Select(0, 0);
     labelLastHighestPiD.Text = Convert.ToString(this.patComp.getHighesPatientId());
 }
 private static String name(PatientData patient)
 {
     return "<tr><td class='what'>Name: </td><td colspan='4'>" + patient.FirstName + " " + patient.SurName + "</td><td class='what'>Waitlist Date: </td><td colspan='3'>" + ((patient.WaitListStartDate == null) ? "" : ((DateTime)patient.WaitListStartDate).ToShortDateString()) + "</td></tr>" + Environment.NewLine;
 }
        /// <summary>
        /// Comperer Patients by Wait List Date
        /// </summary>
        /// <param name="x">Patient a</param>
        /// <param name="y">Patient b</param>
        /// <returns></returns>
        public static int comparePatientsByWaitList(PatientData x, PatientData y)
        {
            if (x == null) {
                if (y == null) {
                    return 0;
                } else {
                    return -1;
                }
            } else {
                if (y == null) {
                    return 1;
                } else {
                    int retval = ((DateTime)x.WaitListStartDate).CompareTo(((DateTime)y.WaitListStartDate));

                    if (retval != 0) {
                        return retval;
                    } else {
                        return ((DateTime)x.WaitListStartDate).CompareTo(((DateTime)y.WaitListStartDate));
                    }
                }
            }
        }
 /// <summary>
 /// Inits the specified patient.
 /// </summary>
 /// <param name="patient">The patient.</param>
 /// <param name="visits">The visits.</param>
 public void Init(PatientData patient, IList<VisitData> visits)
 {
     this.patient = patient;
     this.visits = CommonUtilities.StaticUtilities.SortVisitsListByDate(visits);
     fillVisitList();
     labelHeadlineAndPatientData.Text = "Visits: " + patient.ToString();
     if (patient != null && patient.Id == 313) {
         this.pictureBoxEasterEgg.Visible = true;
     } else {
         this.pictureBoxEasterEgg.Visible = false;
     }
 }
Example #19
0
 /// <summary>
 /// Inserts the patient.
 /// </summary>
 /// <param name="patientData">The patient data.</param>
 /// <returns></returns>
 public override PatientData InsertPatient(PatientData patientData)
 {
     PatientData patient = base.InsertPatient(patientData);
     if (patient != null) {
         if (patientBuffer != null) {
             patientBuffer.Add(patient); // Add new Patient also to buffer
         }
         return patient;
     } else {
         return null;
     }
 }
        public void PatientFinalReportTest()
        {
            IPatient patientDB = Database.CreatePatient();
            DateTime date = new DateTime(2006, 12, 24);
            PatientData patient = new PatientData(0, "first", "sure", date, Sex.male, "0123456789", 29, "address", ResidentOfAsmara.no, Ambulant.ambulant, Finished.finished, Linz.finished);
            long pID = patientDB.Insert(patient);
            PatientData pdataWithID = new PatientData(pID,
                patient.FirstName, patient.SurName, patient.DateOfBirth,
                patient.Sex, patient.Phone, patient.Weight, patient.Address, patient.ResidentOfAsmara, patient.Ambulant, patient.Finished, patient.Linz);

            patientDB.InsertFinalReport("Trallala Final Report", pID);
            Assert.AreEqual("Trallala Final Report", patientDB.GetFinalReportByPatentID(pID));

            patientDB.InsertFinalReport("Döner", pID);
            Assert.AreEqual("Döner", patientDB.GetFinalReportByPatentID(pID));

            Assert.IsTrue(patientDB.Delete(pID));

            Assert.IsNull(patientDB.FindByID(pID));
        }
 /// <summary>
 /// Updates the patient.
 /// </summary>
 /// <param name="patientData">The patient data.</param>
 /// <returns></returns>
 public bool UpdatePatient(PatientData patientData)
 {
     using (ChannelFactory<ISPDBL> cf = new ChannelFactory<ISPDBL>(binding,endpointAddress)) {
         ISPDBL spdBL = cf.CreateChannel();
         return spdBL.UpdatePatient(patientData);
     }
 }
        public void PatientUpdateTest()
        {
            IPatient patientDB = Database.CreatePatient();
            DateTime date = new DateTime(2006, 12, 24);
            PatientData patient = new PatientData(0, "first", "sure", date, Sex.male, "0123456789", 29, "address", ResidentOfAsmara.no, Ambulant.ambulant, Finished.finished, Linz.finished);
            long pID = patientDB.Insert(patient);
            PatientData pdataWithID = new PatientData(pID,
                patient.FirstName, patient.SurName, patient.DateOfBirth,
                patient.Sex, patient.Phone, patient.Weight, patient.Address, patient.ResidentOfAsmara, patient.Ambulant, patient.Finished, patient.Linz);

            pdataWithID.Address = "Trallala";
            pdataWithID.DateOfBirth = new DateTime(2007, 05, 06);
            pdataWithID.FirstName = "asdf";
            pdataWithID.Phone = "0815";
            pdataWithID.Sex = Sex.female;
            pdataWithID.SurName = "asdasfd";
            pdataWithID.Weight = 35;

            patientDB.Update(pdataWithID);

            patient = patientDB.FindByID(pID);

            Assert.AreEqual(patient.Id, pdataWithID.Id);
            Assert.AreEqual(patient.FirstName, pdataWithID.FirstName);
            Assert.AreEqual(patient.Phone, pdataWithID.Phone);
            Assert.AreEqual(patient.SurName, pdataWithID.SurName);
            Assert.AreEqual(patient.DateOfBirth, pdataWithID.DateOfBirth);
            Assert.AreEqual(patient.Sex, pdataWithID.Sex);
            Assert.AreEqual(patient.Weight, pdataWithID.Weight);
            Assert.AreEqual(patient.Address, pdataWithID.Address);

            Assert.IsTrue(patientDB.Delete(pID));
            Assert.IsNull(patientDB.FindByID(pID));
        }
 public void MyTestInitialize()
 {
     IPatient patientDB = Database.CreatePatient();
     DateTime date = new DateTime(2006, 12, 24);
     PatientData patient = new PatientData(0, "first", "sure", date, Sex.male, "0123456789", 29, "address", ResidentOfAsmara.no, Ambulant.ambulant, Finished.finished, Linz.finished);
     pID = patientDB.Insert(patient);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NextActionEventArgs"/> class.
 /// </summary>
 /// <param name="patient">The patient.</param>
 public NextActionEventArgs(PatientData patient)
 {
     this.patient = patient;
 }
 private static String name(PatientData patient)
 {
     return "<tr><td class='what'>Name: </td><td colspan='7'>" + patient.FirstName + " " + patient.SurName + "</td></tr>" + Environment.NewLine;
 }
        void oPControl_Store(object sender, NewOperationStoreEventArgs e)
        {
            if (!Directory.Exists(textBoxExportPath.Text)) {
                MessageBox.Show("The Export directory does not exist!");
                e.StoredOk = false;
                return;
            }

            long pId;
            try {
                pId = Int64.Parse(textBoxPatientId.Text);
            } catch (FormatException) {
                MessageBox.Show("PatientId is not valid!");
                e.StoredOk = false;
                return;
            }

            OperationData op = e.Operation;
            op.PatientId = Int64.Parse(textBoxPatientId.Text);

            JsonContainer jsonContainer = new JsonContainer();
            jsonContainer.addOperation(op);
            string jsonString = SpdJsonTools.GenerateJson(jsonContainer);

            try {
                TextFileHelper.WriteFile(
                    textBoxExportPath.Text + Path.DirectorySeparatorChar + "SPD.Operation." + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + ".json",
                    jsonString);
            } catch (Exception ex) {
                MessageBox.Show("Storing not possible:\n" + ex.Message);
                e.StoredOk = false;
                return;
            }

            PatientData pd  = null;
            try {
                pd = this.patComp.FindPatientById(op.PatientId);
            } catch (Exception) {}

            if (pd == null) {
                pd = new PatientData();
                pd.Id = op.PatientId;
                pd.Address = string.Empty;
                pd.FirstName = string.Empty;
                pd.Phone = string.Empty;
                pd.SurName = string.Empty;
            }

            this.oPControl.CurrentPatient = pd;

            e.TakeFromDB = false;

            this.oPControl.Clear();
            this.textBoxPatientId.Clear();
            SPD.GUI.OPWriter.Properties.Settings.Default.exportPath = textBoxExportPath.Text;
            SPD.GUI.OPWriter.Properties.Settings.Default.Save();
        }
        public void PatientFindAllTest()
        {
            IPatient patientDB = Database.CreatePatient();
            IList<PatientData> patients;
            patients = patientDB.FindAll();
            int originalCountOfPatients = patients.Count;
            DateTime date = new DateTime(2006, 12, 24);
            PatientData patient = new PatientData(0, "first", "sure", date, Sex.male, "0123456789", 29, "address", ResidentOfAsmara.no, Ambulant.ambulant, Finished.finished, Linz.finished);
            long pID = patientDB.Insert(patient);
            PatientData pdataWithID = new PatientData(pID,
                patient.FirstName, patient.SurName, patient.DateOfBirth,
                patient.Sex, patient.Phone, patient.Weight, patient.Address, patient.ResidentOfAsmara, patient.Ambulant, patient.Finished, patient.Linz);

            patients = patientDB.FindAll();

            Assert.AreEqual(originalCountOfPatients + 1, patients.Count);

            bool exists = false;
            long maxPID = 0;
            int newCountOfPatients = patients.Count;

            foreach (PatientData patientlocal1 in patients) {
                if (patientlocal1.Id == pID) {
                    exists = true;
                }
                if (patientlocal1.Id > maxPID) {
                    maxPID = patientlocal1.Id;
                }
            }
            Assert.IsTrue(exists);

            IList<PatientData> patients2 = new List<PatientData>();
            for (int i = 0; i < (maxPID + 1); i++) {
                PatientData patientlocal2 = patientDB.FindByID(i);
                if (patientlocal2 != null) {
                    patients2.Add(patientlocal2);
                }
            }

            Assert.AreEqual(patients2.Count, patients.Count);

            Assert.IsTrue(patientDB.Delete(pID));
            Assert.IsNull(patientDB.FindByID(pID));

            patients = patientDB.FindAll();

            Assert.AreEqual(originalCountOfPatients, patients.Count);
            Assert.AreEqual(patients.Count + 1, newCountOfPatients);
        }
        private PatientData createRandomPatient()
        {
            PatientData patient = new PatientData();
            patient.FirstName = getRandomString(5, 20, false);
            patient.SurName = getRandomString(5, 20, false);
            patient.Address = getRandomString(5, 20, true);
            patient.Phone = getRandomString(5, 20, true);
            patient.Weight = (int)(rand.NextDouble() * 15);

            switch (rand.Next(0,2))
            {
                case 0:
                    patient.Ambulant = Ambulant.ambulant;
                    break;
                case 1:
                    patient.Ambulant = Ambulant.notAmbulant;
                    break;
            }

            switch (rand.Next(0, 3))
            {
                case 0:
                    patient.Finished = Finished.finished;
                    break;
                case 1:
                    patient.Finished = Finished.notFinished;
                    break;
                case 2:
                    patient.Finished = Finished.undefined;
                    break;
            }

            switch (rand.Next(0, 2))
            {
                case 0:
                    patient.Sex = Sex.female;
                    break;
                case 1:
                    patient.Sex = Sex.male;
                    break;
            }

            switch (rand.Next(0, 5))
            {
                case 0:
                    patient.Linz = Linz.undefined;
                    break;
                case 1:
                    patient.Linz = Linz.finished;
                    break;
                case 2:
                    patient.Linz = Linz.notPlanned;
                    break;
                case 3:
                    patient.Linz = Linz.planned;
                    break;
                case 4:
                    patient.Linz = Linz.running;
                    break;
            }

            switch (rand.Next(0, 3)) {
                case 0:
                    patient.ResidentOfAsmara = ResidentOfAsmara.no;
                    break;
                case 1:
                    patient.ResidentOfAsmara = ResidentOfAsmara.undefined;
                    break;
                case 2:
                    patient.ResidentOfAsmara = ResidentOfAsmara.yes;
                    break;
            }

            patient.DateOfBirth = new DateTime(
                DateTime.Now.Year - rand.Next(1,20),
                rand.Next(1,13), rand.Next(1,29));

            return patient;
        }
        /// <summary>
        /// Prints the next appointment.
        /// </summary>
        /// <param name="patient">The patient.</param>
        /// <param name="diagnoses">The diagnoses.</param>
        /// <param name="todo">The todo.</param>
        /// <param name="date">The date.</param>
        /// <param name="time">The time.</param>
        /// <param name="numberOfSheets">The number of sheets.</param>
        public void PrintNextAppointment(PatientData patient, string diagnoses, string todo, string date, string time, int numberOfSheets)
        {
            if (patient == null) {
                return;
            }

            float leftMargin = 100;
            float topMargin = 100;

            Font headlineFont = new Font("Arial", 18.0f, FontStyle.Bold);
            Font dateFont = new Font("Arial", 12f, FontStyle.Bold);
            Font pointFont = new Font("Arial", 15f, FontStyle.Bold);
            Font printFont = new Font("Arial", 11, FontStyle.Regular);
            Font barCodeFont = null;
            if (StaticUtilities.IsFontInstalled("Free 3 of 9 Extended") && SPD.GUI.Properties.Settings.Default.Barcode) {
                barCodeFont = new Font("Free 3 of 9 Extended", 35, FontStyle.Regular, GraphicsUnit.Point);
            }

            //HeadlineFont: 27,59766
            //dateFont: 18,39844
            //printFont: 16,86523

            PrintableDocument pd = new PrintableDocument();
            pd.DocumentName = "SPD Next Appointment";

            PrintablePage pp = new PrintablePage();
            OperationData od = patComp.GetLastOperationByPatientID(patient.Id);

            putLetterhead(pp);

            float yPos = (float)topMargin + (float)(4 * 16.86523);

            pp.AddPrintableObject(new PrintableTextObject("NEXT OUTPATIENT APPOINTMENT", headlineFont, Brushes.Red, leftMargin + 100, yPos));
            yPos += 16.86523F;
            yPos += 16.86523F;
            yPos += 16.86523F;
            if (barCodeFont != null) {
                pp.AddPrintableObject(new PrintableTextObject(String.Format("*000000{0}*", patient.Id.ToString()), barCodeFont, Brushes.Black, 500, yPos));
            }
            pp.AddPrintableObject(new PrintableTextObject("Printed: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), printFont, Brushes.Black, leftMargin, yPos));
            yPos += 16.86523F;
            yPos += 16.86523F;
            pp.AddPrintableObject(new PrintableTextObject("Patient ID: " + patient.Id.ToString(), pointFont, Brushes.Black, leftMargin, yPos));
            yPos += 25F;
            pp.AddPrintableObject(new PrintableTextObject("Name: " + patient.FirstName + " " + patient.SurName, pointFont, Brushes.Black, leftMargin, yPos));
            yPos += 25F;
            pp.AddPrintableObject(new PrintableTextObject("Date: " + date, pointFont, Brushes.Black, leftMargin, yPos));
            yPos += 25F;
            pp.AddPrintableObject(new PrintableTextObject("Time: " + time, pointFont, Brushes.Black, leftMargin, yPos));
            yPos += 25F;
            pp.AddPrintableObject(new PrintableTextObject("Place: " + SPD.GUI.Properties.Settings.Default.Location, pointFont, Brushes.Black, leftMargin, yPos));
            yPos += 25F;
            yPos += 16.86523F;
            pp.AddPrintableObject(new PrintableTextObject("Birthdate: " + patient.DateOfBirth.ToShortDateString() + " - Age: " + StaticUtilities.getAgeFromBirthDate(patient.DateOfBirth), printFont, Brushes.Black, leftMargin, yPos));
            yPos += 16.86523F;
            yPos += 16.86523F;
            yPos += 16.86523F;
            pp.AddPrintableObject(new PrintableTextObject("Diagnoses:", dateFont, Brushes.Black, leftMargin, yPos));
            yPos += 16.86523F;

            List<string> diagnosesList = new List<string>();
            diagnosesList.Add(diagnoses);
            diagnosesList = SplitStringsForPrinting(80, diagnosesList);
            foreach (string diagnosesLine in diagnosesList) {
                pp.AddPrintableObject(new PrintableTextObject(diagnosesLine, printFont, Brushes.Black, leftMargin, yPos));
                yPos += 16.86523F;
                if (yPos > 1050) {
                    yPos = topMargin;
                    pd.AddPrintPage(pp);
                    pp = new PrintablePage();
                }
            }

            yPos += 16.86523F;
            pp.AddPrintableObject(new PrintableTextObject("TODO:", dateFont, Brushes.Black, leftMargin, yPos));
            yPos += 16.86523F;
            List<string> todoList = new List<string>();
            todoList.Add(todo);
            todoList = SplitStringsForPrinting(80, todoList);
            foreach (string todoLine in todoList) {
                pp.AddPrintableObject(new PrintableTextObject(todoLine, printFont, Brushes.Black, leftMargin, yPos));
                yPos += 16.86523F;
                if (yPos > 1050) {
                    yPos = topMargin;
                    pd.AddPrintPage(pp);
                    pp = new PrintablePage();
                }
            }

            pd.AddPrintPage(pp);

            pd.duplicate(numberOfSheets);

            pd.DoPrint();
        }
 /// <summary>
 /// Inits the specified opdata.
 /// </summary>
 /// <param name="opdata">The opdata.</param>
 /// <param name="currentPatient">The current patient</param>
 public void Init(OperationData opdata, PatientData currentPatient)
 {
     this.operation = opdata;
     this.currentPatient = currentPatient;
     Clear();
     textBoxOPDate.Text = DateTime.Now.ToShortDateString();
     if (currentPatient != null){
         this.labelPatientData.Text = currentPatient.Id.ToString() + " " + currentPatient.FirstName + " " + currentPatient.SurName;
     }
     if (opdata != null) {
         textBoxOPDate.Text = operation.Date.ToShortDateString();
         textBoxOPDiagnoses.Text = operation.Diagnoses;
         textBoxOPProcess.Text = operation.Process;
         textBoxOPTeam.Text = operation.Team;
         textBoxPerformedOP.Text = operation.Performed;
         textBoxAdditionalInformation.Text = operation.Additionalinformation;
         textBoxMedication.Text = operation.Medication;
         textBoxIntdiagnoses.Text = operation.IntDiagnoses.ToString();
         comboBoxPPPS.Text = operation.Ppps.ToString();
         comboBoxResult.Text = operation.Result.ToString();
         comboBoxKathDays.Text = operation.KathDays.ToString();
         comboBoxOrgan.Text = operation.Organ.ToString();
         textBoxOpResult.Text = operation.OpResult;
     }
 }