예제 #1
0
        protected PatientAssessmentRepositoryADO()
        {
            // set the db location
            dbLocation = DatabaseFilePath;

            // instantiate the database
            db = new PatientDatabase(dbLocation);
        }
예제 #2
0
        public void AddPatientTest_ValidPatient()
        {
            // arrange
            Patient           p  = new Patient("Aaa", "Bbb", "1-2-2003", 111222333);
            PatientSerializer ps = new PatientSerializer("AddPatientTest.json");
            PatientDatabase   db = new PatientDatabase(ps);

            // act
            bool success = db.AddPatient(p);

            // assert
            Assert.IsTrue(success);
        }
예제 #3
0
        public void AddPatientTest_DuplicatePatient()
        {
            // arrange
            Patient           p  = new Patient("A", "B", "3-2-2001", 111222333);
            PatientSerializer ps = new PatientSerializer("AddPatientTest.json");
            PatientDatabase   db = new PatientDatabase(ps);

            // act
            db.AddPatient(p);
            bool success = db.AddPatient(p); // Duplicate patient added, should return false

            // assert
            Assert.IsFalse(success);
        }
예제 #4
0
        public void WritePatientsTest()
        {
            // arrange
            Patient           p1 = new Patient("A", "B", "3-2-2001", 111222333);
            Patient           p2 = new Patient("C", "D", "4-5-2006", 123456782);
            PatientSerializer ps = new PatientSerializer("WritePatientsTest.json");
            PatientDatabase   db = new PatientDatabase(ps);

            db.AddPatient(p1);
            db.AddPatient(p2);

            // act
            bool success = db.WritePatients();

            // assert
            Assert.IsTrue(success);
        }
예제 #5
0
        public void WritePatientsTest_MockedSerializer()
        {
            // arrange
            Patient p1 = new Patient("A", "B", "3-2-2001", 111222333);
            Patient p2 = new Patient("C", "D", "4-5-2006", 123456782);
            Mock <IPatientSerializer> psMock = new Mock <IPatientSerializer>();

            psMock.Setup(ps => ps.StartSerialize()).Returns(true);
            psMock.Setup(ps => ps.Serialize(It.IsAny <Patient>())).Returns(false);
            psMock.Setup(ps => ps.EndSerialize()).Returns(true);
            PatientDatabase db = new PatientDatabase(psMock.Object);

            db.AddPatient(p1);
            db.AddPatient(p2);

            // act
            bool success = db.WritePatients();

            // assert
            Assert.IsFalse(success);
        }
예제 #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            PersonSettings Person = new PersonSettings();

            #region "List"
            //Find our controls
            patientListView  = FindViewById <ListView> (Resource.Id.listViewPatients);
            addPatientButton = FindViewById <Button> (Resource.Id.btnOpenPatient);

            // wire up add task button handler
            if (addPatientButton != null)
            {
                addPatientButton.Click += (sender, e) => {
                    StartActivity(typeof(PatientDetailsScreen));
                };
            }

            // wire up task click handler
            if (patientListView != null)
            {
                patientListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                    var patientDetails = new Intent(this, typeof(PatientDetailsScreen));
                    patientDetails.PutExtra("PatientID", patients[e.Position].PatientID);
                    StartActivity(patientDetails);
                };
            }


            #endregion "List"



            // Get our button from the layout resource,
            // and attach an event to it

            var btnAddDatabase = FindViewById <Button> (Resource.Id.btnCreateDatabase);
            var btnAddTable    = FindViewById <Button> (Resource.Id.btnCreateTable);
            var btnAddItem     = FindViewById <Button> (Resource.Id.btnAddItems);
            var btnReadItem    = FindViewById <Button> (Resource.Id.btnRead);
            var btnCountItem   = FindViewById <Button> (Resource.Id.btnCount);
            var btnDelTable    = FindViewById <Button> (Resource.Id.btnDeleteTable);
            var btnDelDatabase = FindViewById <Button> (Resource.Id.btnDeleteDatabase);
            var results        = FindViewById <TextView> (Resource.Id.txtResults);

            var btnAddMedicTable          = FindViewById <Button> (Resource.Id.btnAddMedicTable);
            var btnAddPatientDetailsTable = FindViewById <Button> (Resource.Id.btnAddPatientTable);
            var btnAddVitalsTable         = FindViewById <Button> (Resource.Id.btnVitalsTable);
            var btnAddMedicalTable        = FindViewById <Button> (Resource.Id.btnAddMedical);
            var btnAddTraumaTable         = FindViewById <Button> (Resource.Id.btnAddTrauma);

            var btnGoToPatient = FindViewById <Button> (Resource.Id.btnOpenPatient);

            var PeopleIDText = FindViewById <EditText> (Resource.Id.txtPeopleID);
            int PeopleID     = Convert.ToInt32(PeopleIDText.Text);
            Person.PersonID = PeopleID;
            var btnDelFromPeople = FindViewById <Button> (Resource.Id.btnDeletePeopleID);

            // create and test the database connection
            var docsFolder     = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            var pathToDatabase = Path.Combine(docsFolder, "Simpledb_adonet1.db");



            var context = btnAddTable.Context;
            // create the event for the button
            //Create database

            #region "Buttons"
            btnAddDatabase.Click += (sender, e) =>
            {
                try
                {
                    bool exists = File.Exists(pathToDatabase);
                    if (!exists)
                    {
                        SqliteConnection.CreateFile(pathToDatabase);
                        results.Text = string.Format("Database created successfully - filename = {0}\n", pathToDatabase);
                    }
                    else
                    {
                        results.Text = string.Format("Database aleady exists");
                    }
                }
                catch (IOException ex)
                {
                    var reason = string.Format("Unable to create the database - reason = {0}", ex.Message);
                    Toast.MakeText(context, reason, ToastLength.Long).Show();
                }

                // create the schema, perform using an async task
                //txtResult.Text += await createTable(pathToDatabase);
            };



            btnAddTable.Click += (sender, e) =>
            {
                results.Text = createTable(pathToDatabase);
            };
//

            btnAddItem.Click += (sender, e) =>
            {
                results.Text = addItems(pathToDatabase);
            };


            btnReadItem.Click += (sender, e) =>
            {
                results.Text = readItems(pathToDatabase);
            };

            btnCountItem.Click += (sender, e) =>
            {
                results.Text = countItems(pathToDatabase);
            };

            btnDelTable.Click += (sender, e) =>
            {
                results.Text = deleteTable(pathToDatabase);
            };
            btnDelDatabase.Click += (sender, e) =>
            {
                results.Text = deleteDatabase(pathToDatabase);
            };
            btnDelFromPeople.Click += (sender, e) =>
            {
                results.Text = DeletePeopleDetails(pathToDatabase, Person.PersonID);
            };

            //Create Patient Assessment Database Tables

            btnAddMedicTable.Click += (sender, e) =>
            {
                results.Text = PatientDatabase.createMedicSettingsTable(pathToDatabase);
            };


            btnAddPatientDetailsTable.Click += (sender, e) =>
            {
                results.Text = PatientDatabase.createPatientDetailsTable(pathToDatabase);
            };

            btnAddVitalsTable.Click += (sender, e) =>
            {
                results.Text = PatientDatabase.createVitalsTable(pathToDatabase);
            };

            btnAddMedicalTable.Click += (sender, e) =>
            {
                results.Text = PatientDatabase.createMedicalTable(pathToDatabase);
            };


            btnAddTraumaTable.Click += (sender, e) =>
            {
                results.Text = PatientDatabase.createTraumaTable(pathToDatabase);
            };
        }