Example #1
0
        ///////////////////This are the methods used to update the display immideately after updating
        private async Task <bool> UpdateDiseaseData(BasicDiseases tempDisease)
        {
            docKitName.Text        = tempDisease.Name;
            docKitDescription.Text = "\n" + tempDisease.Description;
            docKitImage.Source     = await ImageMethods.Base64StringToBitmap(tempDisease.Image);

            docKitSymptomsPanel.Children.Clear();
            foreach (var i in tempDisease.Symptoms.Split(','))
            {
                if (i.Equals(""))
                {
                    continue;
                }

                StackPanel docKitSymptomsStackPanels = new StackPanel();
                docKitSymptomsStackPanels.Margin      = new Thickness(0, 15, 0, 0);
                docKitSymptomsStackPanels.Orientation = Orientation.Horizontal;

                TextBlock dot = new TextBlock();
                dot.Width    = 15;
                dot.FontSize = 20;
                dot.Text     = "•";
                docKitSymptomsStackPanels.Children.Add(dot);

                TextBlock Symptom = new TextBlock();
                Symptom.Width        = 650;
                Symptom.Text         = ExtraModules.RemoveStringSpace(i).Replace(",", "");
                Symptom.TextWrapping = TextWrapping.Wrap;
                Symptom.FontSize     = 20;
                docKitSymptomsStackPanels.Children.Add(Symptom);

                docKitSymptomsPanel.Children.Add(docKitSymptomsStackPanels);
            }
            return(true);
        }
Example #2
0
        private async Task <int> loadPatientDetails(string pid)
        {
            try
            {
                string    q = "SELECT * FROM Patient WHERE PID = @pid";
                Statement s = await this.database.PrepareStatementAsync(q);

                s.BindTextParameterWithName("@pid", pid);
                s.EnableColumnsProperty();
                if (await s.StepAsync())
                {
                    VisitPatientName.Text    = s.Columns["FirstName"] + " " + s.Columns["LastName"];
                    VisitPatientPhoto.Source = await ImageMethods.Base64StringToBitmap(s.Columns["Image"]);
                }

                return(DBConnect.RESULT_OK);
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("CREATE_NEW_VISIT---LOAD_PATIENT_DETAILS" + "\n" + ex.Message + "\n" + result.ToString());

                return(DBConnect.RESULT_ERROR);
            }
        }
Example #3
0
        private async Task <bool> UpdateFirstAidData(BasicFirstAid tempFirstAid)
        {
            docKitName.Text = tempFirstAid.Name;
            docKitFirstAidDescription.Text = "\n" + tempFirstAid.FirstAid;
            docKitFirstAidImage.Source     = await ImageMethods.Base64StringToBitmap(tempFirstAid.Image);

            docKitFirstAidSymptoms.Text = "\n" + tempFirstAid.DoNot;
            return(true);
        }
Example #4
0
        private async void LoadDetails()
        {
            try
            {
                string    query     = "SELECT * FROM Patient WHERE PID = @pid";
                Statement statement = await this.database.PrepareStatementAsync(query);

                statement.BindTextParameterWithName("@pid", this.PID);
                statement.EnableColumnsProperty();

                if (await statement.StepAsync())
                {
                    ProfileName.Text    = statement.Columns["LastName"] + " " + statement.Columns["FirstName"];
                    ProfileImage.Source = await ImageMethods.Base64StringToBitmap(statement.Columns["Image"]);

                    ProfileDateOfBirth.Text = statement.Columns["Birthday"];
                    ProfileAge.Text         = (DateTime.Now.Year - Convert.ToInt32(statement.Columns["Birthday"].Substring(0, statement.Columns["Birthday"].IndexOf("-")))).ToString();
                    ProfileBloodGroup.Text  = statement.Columns["BloodGroup"];
                    ProfileSex.Text         = statement.Columns["Sex"];
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---PATIENT" + "\n" + ex.Message + "\n" + result.ToString());
            }

            string street = "", city = "", state = "", country = "", zip = "";

            try
            {
                string    query     = "SELECT * FROM Address WHERE PID = @pid";
                Statement statement = await this.database.PrepareStatementAsync(query);

                statement.BindTextParameterWithName("@pid", this.PID);
                statement.EnableColumnsProperty();
                if (await statement.StepAsync())
                {
                    street = statement.Columns["Street"];
                    zip    = statement.Columns["ZIP"];
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---ADDRESS" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                string    query     = "SELECT * FROM AddressZIP WHERE ZIP = @zip";
                Statement statement = await this.database.PrepareStatementAsync(query);

                statement.BindIntParameterWithName("@zip", Int32.Parse(zip));
                statement.EnableColumnsProperty();
                if (await statement.StepAsync())
                {
                    city = statement.Columns["City"];
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---ADDRESS_ZIP" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                string    query     = "SELECT * FROM AddressCity WHERE City = @city";
                Statement statement = await this.database.PrepareStatementAsync(query);

                statement.BindTextParameterWithName("@city", city);
                statement.EnableColumnsProperty();
                if (await statement.StepAsync())
                {
                    state = statement.Columns["State"];
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---ADDRESS_CITY" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                string    query     = "SELECT * FROM AddressState WHERE State = @state";
                Statement statement = await this.database.PrepareStatementAsync(query);

                statement.BindTextParameterWithName("@state", state);
                statement.EnableColumnsProperty();
                if (await statement.StepAsync())
                {
                    country = statement.Columns["Country"];
                }
                ProfileAddress.Text = street + "\n" + city + ", " + state + ", " + zip + "\n" + country;
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---ADDRESS_STATE" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                string    queryDetails = "SELECT * FROM MutableDetails WHERE PID = @pid";
                Statement statement    = await this.database.PrepareStatementAsync(queryDetails);

                statement.BindTextParameterWithName("@pid", this.PID);
                statement.EnableColumnsProperty();

                if (await statement.StepAsync())
                {
                    ProfileContact.Text = statement.Columns["Mobile"];

                    if (statement.Columns["EmMobile"].ToString() != "0")
                    {
                        ProfileEmContact.Text = statement.Columns["EmMobile"];
                    }
                    else
                    {
                        ProfileEmContact.Text = "NA";
                    }

                    ProfileEmail.Text         = statement.Columns["Email"];
                    ProfileOccupation.Text    = statement.Columns["Occupation"];
                    ProfileFamilyHistory.Text = statement.Columns["FamilyBackground"];

                    if (statement.Columns["Married"].Equals("T"))
                    {
                        ProfileMaritalStatus.Text = "Married";
                    }
                    else
                    {
                        ProfileMaritalStatus.Text = "Unmarried";
                    }
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---MUTABLE_DETAILS" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                ProfileAllergies.Text = "";
                string    allergyDetails = "SELECT * FROM MutableDetailsAllergy WHERE PID = @pid";
                Statement statement      = await this.database.PrepareStatementAsync(allergyDetails);

                statement.BindTextParameterWithName("@pid", this.PID);
                statement.EnableColumnsProperty();
                while (await statement.StepAsync())
                {
                    ProfileAllergies.Text += statement.Columns["Allergy"] + ",";
                }
                if (!ProfileAllergies.Text.Equals(""))
                {
                    ProfileAllergies.Text = ProfileAllergies.Text.Substring(0, ProfileAllergies.Text.Length - 1).TrimStart().TrimEnd();
                }
                else
                {
                    ProfileAllergies.Text = "NA";
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---MUTABLE_DETAILS_ALLERGY" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                ProfileOperations.Text = "";
                string    operationDetails = "SELECT * FROM MutableDetailsOperation WHERE PID = @pid";
                Statement statement        = await this.database.PrepareStatementAsync(operationDetails);

                statement.BindTextParameterWithName("@pid", this.PID);
                statement.EnableColumnsProperty();

                while (await statement.StepAsync())
                {
                    ProfileOperations.Text += statement.Columns["Operation"] + ",";
                }
                if (!ProfileOperations.Text.Equals(""))
                {
                    ProfileOperations.Text = ProfileOperations.Text.Substring(0, ProfileOperations.Text.Length - 1).TrimStart().TrimEnd();
                }
                else
                {
                    ProfileOperations.Text = "NA";
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---MUTABLE_DETAILS_OPERATION" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                ProfileAddictions.Text = "";
                string    addictionDetails = "SELECT * FROM MutableDetailsAddiction WHERE PID = @pid";
                Statement statement        = await this.database.PrepareStatementAsync(addictionDetails);

                statement.BindTextParameterWithName("@pid", this.PID);
                statement.EnableColumnsProperty();

                while (await statement.StepAsync())
                {
                    ProfileAddictions.Text += statement.Columns["Addiction"] + ",";
                }
                if (!ProfileAddictions.Text.Equals(""))
                {
                    ProfileAddictions.Text = ProfileAddictions.Text.Substring(0, ProfileAddictions.Text.Length - 1).TrimEnd().TrimStart();
                }
                else
                {
                    ProfileAddictions.Text = "NA";
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("PROFILE_DETAILS_PAGE---LOAD_DETAILS---MUTABLE_DETAILS_ADDICTION" + "\n" + ex.Message + "\n" + result.ToString());
            }

            try
            {
                string    query     = "SELECT * FROM MedicalDetails WHERE PID = @pid";
                Statement statement = await database.PrepareStatementAsync(query);

                statement.BindTextParameterWithName("@pid", this.PID);
                statement.EnableColumnsProperty();
                double height = -1;
                double bmi    = -1;
                Int32  weight = -1;
                Int32  bg     = -1;
                Int32  sbp    = -1;
                Int32  dbp    = -1;
                while (await statement.StepAsync())
                {
                    height = Double.Parse(statement.Columns["Height"]);
                    weight = Int32.Parse(statement.Columns["Weight"]);
                    bmi    = Convert.ToDouble(statement.Columns["BMI"]);
                    bmi    = Math.Round(bmi, 3);
                    bg     = Int32.Parse(statement.Columns["BloodGlucose"]);
                    sbp    = Int32.Parse(statement.Columns["SystolicBP"]);
                    dbp    = Int32.Parse(statement.Columns["DiastolicBP"]);
                }

                if (height > 0)
                {
                    VisitTextHeight.Text = height.ToString();
                }
                if (weight > 0)
                {
                    VisitTextWeight.Text = weight.ToString();
                }
                if (bmi > 0)
                {
                    VisitTextBMI.Text = bmi.ToString();
                }
                if (bg > 0)
                {
                    VisitTextBG.Text = bg.ToString();
                }
                if (dbp > 0 && sbp > 0)
                {
                    VisitTextBP.Text = sbp.ToString() + "/" + dbp.ToString();
                }
            }
            catch (Exception ex)
            {
                var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                Debug.WriteLine("CREATE_NEW_VISIT---Add_Visit_Clicked" + "\n" + ex.Message + "\n" + result.ToString());
            }
        }
Example #5
0
        private async Task GetSampleDataAsync()
        {
            if (this.Groups.Count() == 0)
            {
                try
                {
                    this.db = App.database;

                    if (this.db != null)
                    {
                        //string query = "SELECT * FROM (Patient NATURAL JOIN (Address NATURAL JOIN AddressZIP));";
                        string    query     = "SELECT Patient.PID, Patient.FirstName, Patient.LastName, Patient.BloodGroup, Patient.Sex, Patient.Birthday, Patient.Image, Address.ZIP, Address.Street, AddressZIP.City FROM ((Patient INNER JOIN Address ON Patient.PID = Address.PID) INNER JOIN AddressZIP ON AddressZIP.ZIP = Address.ZIP)";
                        Statement statement = await db.PrepareStatementAsync(query);

                        statement.EnableColumnsProperty();
                        List <SampleDataGroup> sampleList = new List <SampleDataGroup>();
                        int edgeCaseCount = 0;
                        //string prevGroup = "xxx";
                        //SampleDataGroup groups = null;

                        //Check previous entered city and current city are same. if same -> add new item to same grp; if not -> create new grp and
                        //add the new item to this new grp.
                        while (await statement.StepAsync())
                        {
                            //Debug.WriteLine(statement.Columns["PID"] + " " + statement.Columns["FirstName"] + " " + statement.Columns["LastName"] + " " + statement.Columns["ZIP"] + " " + statement.Columns["City"]);
                            edgeCaseCount++;
                            BitmapImage bmp = await ImageMethods.Base64StringToBitmap(statement.Columns["Image"]);

                            SampleDataGroup sampleGroup = Groups.ToList().Find(item => item.Title.Equals(statement.Columns["City"]));
                            if (sampleGroup == null)
                            {
                                sampleGroup = new SampleDataGroup(statement.Columns["City"], statement.Columns["City"]);
                                sampleGroup.Items.Add(new SampleDataItem(statement.Columns["PID"], statement.Columns["FirstName"] + " " + statement.Columns["LastName"], statement.Columns["Street"], bmp));
                                Groups.Add(sampleGroup);
                            }
                            else
                            {
                                sampleGroup.Items.Add(new SampleDataItem(statement.Columns["PID"], statement.Columns["FirstName"] + " " + statement.Columns["LastName"], statement.Columns["Street"], bmp));
                            }
                            //string currentGroup = statement.Columns["City"];
                            //if (currentGroup.Equals(prevGroup))
                            //{
                            //    BitmapImage bmp = await ImageMethods.Base64StringToBitmap(statement.Columns["Image"]);
                            //    groups.Items.Add(new SampleDataItem(statement.Columns["PID"], statement.Columns["FirstName"] + " " + statement.Columns["LastName"], statement.Columns["Street"], bmp));
                            //}
                            //else
                            //{
                            //    if (groups != null)
                            //    {
                            //        this.Groups.Add(groups);
                            //    }

                            //    BitmapImage bmp = await ImageMethods.Base64StringToBitmap(statement.Columns["Image"]);
                            //    groups = new SampleDataGroup(statement.Columns["City"], statement.Columns["City"]);
                            //    groups.Items.Add(new SampleDataItem(statement.Columns["PID"], statement.Columns["FirstName"] + " " + statement.Columns["LastName"], statement.Columns["Street"], bmp));
                            //}
                            //prevGroup = currentGroup;
                        }
                        //foreach (SampleDataGroup group in sampleList)
                        //{
                        //    this.Groups.Add(group);
                        //}
                        //if (groups != null)
                        //{
                        //    this.Groups.Add(groups);
                        //}
                    }
                }
                catch (Exception ex)
                {
                    var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                    Debug.WriteLine("HOME_PAGE_DATA_SOURCE---LOAD_GROUP_ASYNC" + "\n" + ex.Message + "\n" + result.ToString());
                }
            }
            return;
        }
Example #6
0
        private async Task GetSampleDataAsync()
        {
            if (this._groups.Count != 0)
            {
                return;
            }


            this.db = App.database;

            if (this.db != null)
            {
                //Create a hashmap of (pid, item) and one by one query DB and add all the details to it.
                try
                {
                    //string query = "SELECT * FROM (Patient NATURAL JOIN MutableDetails) NATURAL JOIN (Address NATURAL JOIN (AddressZIP NATURAL JOIN (AddressCity NATURAL JOIN AddressState)))";
                    string query = "SELECT Patient.PID, Patient.FirstName, Patient.LastName, Patient.BloodGroup, Patient.Sex, Patient.Birthday, Patient.Image, MutableDetails.Married, MutableDetails.Occupation, MutableDetails.FamilyBackground, MutableDetails.Email, MutableDetails.Mobile, MutableDetails.EmMobile, Address.ZIP, Address.Street, AddressCity.City, AddressCity.State, AddressState.Country FROM (((((Patient INNER JOIN MutableDetails ON Patient.PID = MutableDetails.PID) INNER JOIN Address ON MutableDetails.PID = Address.PID) INNER JOIN AddressZIP ON Address.ZIP = AddressZIP.ZIP) INNER JOIN AddressCity ON AddressZIP.CITY = AddressCity.CITY)  INNER JOIN AddressState ON AddressCity.STATE = AddressState.STATE)";

                    Statement statement = await db.PrepareStatementAsync(query);

                    statement.EnableColumnsProperty();
                    Dictionary <string, AnalysisSampleDataItem> group = new Dictionary <string, AnalysisSampleDataItem>();

                    while (await statement.StepAsync())
                    {
                        //Debug.WriteLine(statement.Columns["PID"] + " " + statement.Columns["FirstName"] + " " + statement.Columns["LastName"] + " " + statement.Columns["ZIP"] + " " + statement.Columns["City"] + " " + statement.Columns["State"] + " " + statement.Columns["Country"] + " " + statement.Columns["Occupation"] + " " + statement.Columns["Married"]);
                        AnalysisSampleDataItem newItem = new AnalysisSampleDataItem();
                        newItem.UniqueId = statement.Columns["PID"];
                        BitmapImage bmp = await ImageMethods.Base64StringToBitmap(statement.Columns["Image"]);

                        newItem.Name       = statement.Columns["FirstName"] + " " + statement.Columns["LastName"];
                        newItem.BloodGroup = statement.Columns["BloodGroup"];
                        newItem.Sex        = statement.Columns["Sex"][0];
                        newItem.Image      = bmp;

                        if (statement.Columns["Married"].Equals("T"))
                        {
                            newItem.Married = true;
                        }
                        else
                        {
                            newItem.Married = false;
                        }

                        newItem.Occupation = statement.Columns["Occupation"];
                        newItem.FamilyBG   = statement.Columns["FamilyBackground"];
                        newItem.City       = statement.Columns["City"];
                        newItem.State      = statement.Columns["State"];
                        newItem.Country    = statement.Columns["Country"];
                        group.Add((statement.Columns["PID"]), newItem);
                    }

                    //Now after adding the basic details and creating their HASHMAP get other details from DB & add it to the HASHMAP which later
                    //would be added to Groups of the GRID VIEW.
                    statement.Reset();
                    string queryAllergy = "SELECT * FROM MutableDetailsAllergy";
                    statement = await this.db.PrepareStatementAsync(queryAllergy);

                    statement.EnableColumnsProperty();

                    while (await statement.StepAsync())
                    {
                        List <string> sample = group[(statement.Columns["PID"])].Allergy;
                        if (sample != null)
                        {
                            sample.Add(statement.Columns["Allergy"]);
                        }
                    }

                    statement.Reset();
                    string queryAddiction = "SELECT * FROM MutableDetailsAddiction";
                    statement = await this.db.PrepareStatementAsync(queryAddiction);

                    statement.EnableColumnsProperty();

                    while (await statement.StepAsync())
                    {
                        List <string> sample = group[(statement.Columns["PID"])].Addiction;
                        if (sample != null)
                        {
                            sample.Add(statement.Columns["Addiction"]);
                        }
                    }

                    statement.Reset();
                    string queryOperation = "SELECT * FROM MutableDetailsOperation";
                    statement = await this.db.PrepareStatementAsync(queryOperation);

                    statement.EnableColumnsProperty();

                    while (await statement.StepAsync())
                    {
                        List <string> sample = group[(statement.Columns["PID"])].Operation;
                        if (sample != null)
                        {
                            sample.Add(statement.Columns["Operation"]);
                        }
                    }

                    statement.Reset();
                    string queryDateVisited = "SELECT * FROM MedicalDetails";
                    statement = await this.db.PrepareStatementAsync(queryDateVisited);

                    statement.EnableColumnsProperty();

                    while (await statement.StepAsync())
                    {
                        List <string> sampleDatesVisited           = group[(statement.Columns["PID"])].DatesVisited;
                        Dictionary <string, string> sampleVaccines = group[(statement.Columns["PID"])].Vaccines;
                        Dictionary <string, string> sampleDiseases = group[(statement.Columns["PID"])].Diseases;
                        if (sampleDatesVisited != null && sampleDiseases != null && sampleVaccines != null)
                        {
                            sampleDatesVisited.Add(statement.Columns["DateVisited"]);
                            sampleVaccines.Add(statement.Columns["DateVisited"], "0");
                            sampleDiseases.Add(statement.Columns["DateVisited"], statement.Columns["DiseaseFound"]);
                        }
                    }

                    statement.Reset();
                    string queryVaccines = "SELECT * FROM MedicalDetailsVaccine";
                    statement = await this.db.PrepareStatementAsync(queryVaccines);

                    statement.EnableColumnsProperty();

                    while (await statement.StepAsync())
                    {
                        Dictionary <string, string> sampleVaccines = group[(statement.Columns["PID"])].Vaccines;
                        if (sampleVaccines != null)
                        {
                            sampleVaccines[statement.Columns["DateVisited"]] = statement.Columns["Vaccine"];
                        }
                    }

                    //After adding all the details add the items to GRID VIEW
                    foreach (KeyValuePair <string, AnalysisSampleDataItem> sample in group)
                    {
                        Groups.Add(sample.Value);
                    }

                    //Collect garbage after all this loading happens
                    GC.Collect();
                }
                catch (Exception ex)
                {
                    var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult);
                    Debug.WriteLine("ANALYSIS_PAGE_DATA_SOURCE---LOAD_ITEMS_ASYNC" + "\n" + ex.Message + "\n" + result.ToString());
                }
            }
        }