Пример #1
0
        public static List<Dosage> getPrescribedDoses(int prescriptionId)
        {
            //select M.medicine,D.mid,D.reco,D.m,D.n,D.e from PRESCRIPTION_DOSAGE PD,DOSAGE D,MEDICINES M where PD.did = D.id AND D.mid = M.id AND  PD.pid = 23
            List<Dosage> doses = new List<Dosage>();
            using (SQLiteConnection conn = getConnection())
            {
                conn.Open();
                using (SQLiteCommand command = conn.CreateCommand())
                {
                    command.CommandText = "select M.medicine,D.mid,D.reco,D.m,D.n,D.e from PRESCRIPTION_DOSAGE PD,DOSAGE D,MEDICINES M where PD.did = D.id AND D.mid = M.id AND  PD.pid = @prescriptionId";
                    command.Parameters.Add(new SQLiteParameter("@prescriptionId", prescriptionId));
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {

                            Dosage d = new Dosage((string)reader["reco"], new Medicine( (int)((Int64)reader["mid"]) , (string)reader["medicine"]));
                            d.setDose(  (int)(Int64)reader["m"],
                                        (int)(Int64)reader["n"],
                                        (int)(Int64)reader["e"]
                                     );
                            doses.Add(d);
                        }
                    }
                }
            }
            return doses;
        }
Пример #2
0
        public static Dosage getDosage(int id)
        {
            long m = -1, n = -1, e = -1;
            string reco = null,medname = null;
            long mid = -1;
            using (SQLiteConnection conn = getConnection())
            {
                conn.Open();
                using (SQLiteCommand command = conn.CreateCommand())
                {
                    command.CommandText = "SELECT id,reco,m,n,e,mid from DOSAGE where id = @id";
                    command.Parameters.Add(new SQLiteParameter("@id", id));
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            m = (Int64) reader["m"];
                            n = (Int64) reader["n"];
                            e = (Int64) reader["e"];
                            mid = (Int64)reader["mid"];
                            reco = (string) reader["reco"];
                        }
                    }
                    if (mid > 0)
                    {
                        command.CommandText = "SELECT id,medicine from MEDICINES where id = @id";
                        command.Parameters.Add(new SQLiteParameter("@id", mid));
                        using (SQLiteDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                medname = (string)reader["medicine"];
                            }
                        }
                    }

                    if (mid != -1)
                    {
                        Dosage d = new Dosage(reco, new Medicine((int)mid, medname));
                        d.setDose((int)m, (int)n, (int)e);
                        return d;
                    }
                }
            }
            return null;
        }
Пример #3
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] + "";
                    }
                }
            }
        }
Пример #4
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;
            }
        }
Пример #5
0
        public void addCurrentDosageToGrid()
        {
            TextBox t = null;
            string mi, ni, ei, di;
            textViews.TryGetValue("morningRoot_txt", out t);
            mi = t.Text;
            textViews.TryGetValue("afternoonRoot_txt", out t);
            ni = t.Text;
            textViews.TryGetValue("eveningRoot_txt", out t);
            ei = t.Text;

            textViews.TryGetValue("dosageRoot_txt", out t);
            di = t.Text;

            if (currentDosage.getMedicine() == null) // we have'nt seen this med before so lets save it.
            {
                textViews.TryGetValue("medicationRoot_txt", out t);
                int medId = DB.addMedicine(t.Text);
                Medicine newMed = new Medicine(medId, t.Text);
                currentDosage = new Dosage(di, newMed);
                currentDosage.setDose(Int32.Parse(mi), Int32.Parse(ni), Int32.Parse(ei));
            }
            else
            {
                currentDosage.replaceIfUpdated(di, Int32.Parse(mi), Int32.Parse(ni), Int32.Parse(ei));
            }

            int[] mne = currentDosage.getDose();
            medGrid.Rows.Add(currentDosage.getMedicine().getName(), currentDosage.getRecommended(),
                mne[0], mne[1], mne[2]);

            patientInView.getCurrentPrescription().add(currentDosage);
            currentDosage = new Dosage("", null);
        }
Пример #6
0
 public void add(Dosage row)
 {
     if (row != null)
     {
         prescriptions.Add(row);
     }
 }