Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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);
        }