Ejemplo n.º 1
0
        public void getPatientMatchesCountTest()
        {
            int pID1 = this.insertPatient();
            int pID2 = this.insertPatient();
            int pID3 = this.insertPatient();
            ACV acv1 = new ACV(new List<Visit>());
            ACV acv2 = new ACV(new List<Visit>());
            ACV acv3 = new ACV(new List<Visit>());
            DateTime now = DateTime.Now;

            this.insertVisit(pID1, 1, 1, now);
            this.insertVisit(pID1, 1, 1, now);
            this.insertVisit(pID1, 1, 2, now);

            this.insertVisit(pID2, 1, 1, now);
            this.insertVisit(pID2, 1, 2, now);
            this.insertVisit(pID2, 1, 3, now);

            this.insertVisit(pID3, 1, 1, now.AddDays(1));
            this.insertVisit(pID3, 1, 2, now.AddDays(2));
            this.insertVisit(pID3, 1, 3, now.AddDays(3));

            acv1.Add(new Visit(1, 1, 1, now));
            acv1.Add(new Visit(1, 1, 1, now));

            int count = DbMethods.getInstance().getPatientMatchesCount(acv1, pID1);
            Assert.True(count == 0);

            acv2.Add(new Visit(1, 1, 1, now));
            acv2.Add(new Visit(1, 1, 2, now));

            count = DbMethods.getInstance().getPatientMatchesCount(acv2, pID1);
            Assert.True(count == 1);

            acv3.Add(new Visit(1, 1, 1, now.AddDays(1)));

            count = DbMethods.getInstance().getPatientMatchesCount(acv3, pID1);
            Assert.True(count == 1);
        }
Ejemplo n.º 2
0
        private void RenderCMMatches(int patientID)
        {
            int cmSize = 0;
            ACV CM = new ACV(new List<Visit>());
            Patient p = new Patient(patientID);

            do
            {
                Console.WriteLine("Choose the size of the CM : ");
                cmSize = int.Parse(Console.ReadLine());
            } while (cmSize <= 0);

            for (int i = 0; i < cmSize; i++)
            {
                int year;
                int month;
                int day;
                int rational;

                do
                {
                    Console.WriteLine("CM no : " + (i + 1));
                    Console.WriteLine("Month : ");
                    month = int.Parse(Console.ReadLine());
                } while (month <= 0);

                do
                {
                    Console.WriteLine("Day : ");
                    day = int.Parse(Console.ReadLine());
                } while (day <= 0);

                do
                {
                    Console.WriteLine("Year : ");
                    year = int.Parse(Console.ReadLine());
                } while (year <= 0);

                do
                {
                    Console.WriteLine("Rational : ");
                    Console.WriteLine("1. New");
                    Console.WriteLine("2. Checkup");
                    Console.WriteLine("3. Follow-up");
                    Console.WriteLine("4. Referral");
                    Console.WriteLine("5. Emergency");
                    rational = int.Parse(Console.ReadLine());
                } while (rational < 1 && rational > 5);

                CM.Add(new Visit(-1, -1, rational, new DateTime(year, month, day)));
            }

            //this._controller.matchCM(patientID, CM, false);
            List<ACV> matches = p.GetCMMatches(CM);
            int matchCounter = 1;

            foreach (ACV acv in matches)
            {
                Console.WriteLine();
                Console.WriteLine("Match : " + matchCounter++);
                Console.WriteLine(acv.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Combination to match : ");
            Console.WriteLine(CM.ToString());
            Console.WriteLine("Number of matches : " + matches.Count);
            Console.WriteLine();
        }
Ejemplo n.º 3
0
        //returns list of ACV for a patient
        public List<ACV> getPatientACV(int patientID, int acvSize)
        {
            SqlCeCommand selectCommand = new SqlCeCommand("SELECT DISTINCT * FROM Visit v0", this._conn);
            SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(selectCommand);
            DataTable dt = new DataTable();
            List<ACV> acvs = new List<ACV>();

            for (int i = 1; i < acvSize; i++)
            {
                selectCommand.CommandText += " JOIN Visit v" + i + " ON v" + (i - 1) + ".FK_patient = v" + i + ".FK_patient";
            }

            selectCommand.CommandText += " WHERE v0.FK_patient = @patientID";
            selectCommand.Parameters.AddWithValue("@patientID", patientID);

            for (int i = 0; i < acvSize - 1; i++)
            {
                selectCommand.CommandText += " AND v" + i + ".id < v" + (i + 1) + ".id";
            }

            dataAdapter.Fill(dt);

            foreach (DataRow row in dt.Rows)
            {
                ACV acv = new ACV(new List<Visit>());

                for (int i = 0; i < acvSize; i++)
                {
                    if (i == 0)
                    {
                        acv.Add(new Visit((int)row["ID"], (int)row["FK_Professional"], (int)row["FK_Rational"], (DateTime)row["date"]));
                    }
                    else
                    {
                        acv.Add(new Visit((int)row["ID" + i], (int)row["FK_Professional" + i], (int)row["FK_Rational" + i], (DateTime)row["date" + i]));
                    }
                }

                acvs.Add(acv);
            }

            return acvs;
        }