Пример #1
0
        public void updateViewState(string source, string id, string value)
        {
            if (onSelectCallBack != null)
            {
                onSelectCallBack.Invoke(source, id, value);
            }

            /**
             * figure out how to push the various text boxes to the model objects
             * i.e. if source is medicineName then a new medicine object needs to be inited.
             * if source is name, then the view's name fields need to reflect the selection.
             * **/
            //MessageBox.Show( + " - " + id + " = " + text);
            TextBox t = null;
            textViews.TryGetValue(source, out t);
            if (t != null)
            {
                t.Text = value;
                t.Focus();

                if (source.Equals("medicationRoot_txt"))
                {
                    currentDosage = new Dosage("",new Medicine(Int32.Parse(id), value));

                    /** if the dosage is null, then create new.
                     * else use the same dosage and update the dosage count.
                     * **/
                    // patientInView.getCurrentPrescription().getCurrent().setDose(d);
                }
                else if (source.Equals("patientName_txt"))
                {
                    Patient p = new Patient(value, Int32.Parse(id), -2); // will update age from the age field.
                    bindViewFor(p);
                    RichTextBox rt;
                    richTextViews.TryGetValue("prevDiagnosis_rtxt", out rt);
                    if (rt != null)
                    {
                        Prescription pr = DB.getMostRecentPrescription(Int32.Parse(id));
                        if (pr != null)
                        {
                            rt.Text = pr.getDiagnosis();
                            textViews.TryGetValue("patientAge_txt", out t);
                            t.Text = ""+pr.getPatientAge();

                            textViews.TryGetValue("prevAppontmentDate_txt", out t);
                            t.Text = pr.getDate().ToString("dd-MMM-yyyy");

                            //String note = DB.getNote(pr.getId());

                            List<Note> allNotes = DB.getNotes(pr.getId());
                            StringBuilder notesBuilder = new StringBuilder();
                            foreach (Note n in allNotes)
                            {
                                notesBuilder.Append(n.getNote());
                                notesBuilder.Append("\n");
                            }

                            richTextViews.TryGetValue("prevPresNote_rtxt", out rt);
                            rt.Text = notesBuilder.ToString();

                        }
                        string gender = DB.getGender(Int32.Parse(id));
                        int genderIndex = 0;
                        switch (gender)
                        {
                            case "F":
                                genderIndex = 0;
                            break;

                            case "M":
                                genderIndex = 1;
                            break;

                            case "T":
                                genderIndex = 2;
                            break;
                        }
                        ComboBox cb;
                        dropDownViews.TryGetValue("gender_cbx", out cb);
                        cb.SelectedIndex = genderIndex;

                        /*if (
                               (gender != null && (gender.Trim().Equals("M", StringComparison.InvariantCultureIgnoreCase))
                            || (gender.Trim().Equals("F", StringComparison.InvariantCultureIgnoreCase)))
                           )
                        {
                            ComboBox cb;
                            dropDownViews.TryGetValue("gender_cbx", out cb);
                            cb.SelectedIndex = "F".Equals(gender.Trim(), StringComparison.InvariantCultureIgnoreCase) ? 0 : 1;
                        }*/
                    }
                    richTextViews.TryGetValue("allergy_rtxt", out rt);
                    rt.Text = DB.getAllergies(p.getId());
                    p.updateAllergies(rt.Text);
                }
                else if (source.Equals("dosageRoot_txt"))
                {
                    //MessageBox.Show(source + " " + id + " " + value);
                    Dosage d = DB.getDosage(Int32.Parse(id));
                    //MessageBox.Show(d.getMedicine().getName());
                    if (d != null)
                    {
                        currentDosage = d;
                        textViews.TryGetValue("morningRoot_txt", out t);
                        t.Text = d.getDose()[0] +"";
                        textViews.TryGetValue("afternoonRoot_txt", out t);
                        t.Text = d.getDose()[1] + "";
                        textViews.TryGetValue("eveningRoot_txt", out t);
                        t.Text = d.getDose()[2] + "";
                    }
                }
            }
        }
Пример #2
0
        public void cleanView()
        {
            /**
             * 1- clean internal variables.
             * 2- clean out the grid.
             * */
            patientInView = new Patient("", -1, -2);// blank patient
            currentDosage = new Dosage("", null); // blank dosage

            while (medGrid.Rows.Count > 0)
            {
                medGrid.Rows.RemoveAt(0);
            }
            foreach (TextBox t in textViews.Values)
            {
                string value = String.Empty;
                if (defaultTextValues.ContainsKey(t.Name))
                {
                    defaultTextValues.TryGetValue(t.Name, out value);
                    t.Text = value;
                }
                else
                {
                    t.Text = String.Empty;
                }
            }
            foreach (RichTextBox rt in richTextViews.Values)
            {
                rt.Text = String.Empty;
            }
            foreach(ComboBox cb in dropDownViews.Values)
            {
                cb.Text = String.Empty;
                cb.SelectedIndex = -1;
            }
        }
Пример #3
0
        private void buildPrescriptionFromPatient(Patient patient)
        {
            // e,g.
            //new string[] { "", "Medication", "Morning", "Noon", "Evening" },
            //new string[] { "1", "iso ace 20mg", "100", "100", "100" },
            //new string[] { "", "you should now have a keystore that opens to the password bzFE5gja if you change this password, you need to modify the jvm.options file to reflect the same.", "", "", "" },
            //new string[] { "", "", "", "", "" }

            List<string> medlines = new List<string>();

            int i = 1;
            string[] HEAD = { "", "Medication", "Morning", "Noon", "Evening" };
            string[] BLANK = { "", "", "", "", "" };
            string[] lines;
            foreach (string[] D in new string[][] { HEAD })
            {
                lines = formatMedicationOrDosageForPrint(D);
                foreach (string line in lines)
                {
                    medlines.Add(line);
                }
            }
            foreach (Dosage d in patient.getCurrentPrescription().getPrescriptionItems())
            {
                int[] dose = d.getDose();
                string[] dosage = {"", d.getRecommended(), "", "", "" };
                string[] med = {  i + "", d.getMedicine().getName(), dose[0] + "", dose[1] + "", dose[2] + "" };
                i++;
                foreach (string[] D in new string[][] { med, dosage, BLANK })
                {
                    lines = formatMedicationOrDosageForPrint(D);
                    foreach (string line in lines)
                    {
                        medlines.Add(line);
                    }
                }
            }
            PRESCRIPTION = medlines.ToArray();
        }
Пример #4
0
 public void bindViewFor(Patient p)
 {
     this.patientInView = p;
 }
Пример #5
0
        public void print(Patient patient)
        {
            printDocument = new PrintDocument();
            printDocument.PrintPage += new PrintPageEventHandler(PrintPage);
            string name = patient.getName();
            string age_gen = patient.getAge() + "/" + patient.getGender();
            string date = DateTime.Now.ToString("dd-MMM-yyyy");

            name_age_date = new string[] {name,age_gen,date};
            diagnosis = patient.getCurrentPrescription().getDiagnosis();

            buildPrescriptionFromPatient(patient);

            printDocument.Print();
        }