Click here to Skip to main content
15,870,130 members
Articles / Mobile Apps / Windows Mobile

Pocket Personal Health Record

Rate me:
Please Sign up or sign in to vote.
4.75/5 (4 votes)
17 Feb 2009Ms-PL2 min read 28.5K   1.1K   24   6
Personal Pocket Health Record (PPHR) application helps to store and track a user's personal details and visits information on Windows powered pocket PC.

Introduction

Personal Pocket Health Record (PPHR) application helps to store a user's personal details and visits information on a Windows powered pocket PC. Source code and installer are available on CodePlex.

This is an open source application and my contribution to fellow humans.

Prerequisites

Development environment

  • Visual Studio 2008

Deployment Environment

  • Windows Mobile 5.0
  • .NET Framework CE 3.5 (.NET Framework CE can be downloaded from Microsoft or if you already installed Visual Studio 2008 on your PC, then you can find it in Installed Drive\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE)
  • SQL CE 3.5 (SQL CE can be downloaded from Microsoft or if you already installed Visual Studio 2008 on your PC, then you can find it in Installed Drive\Microsoft SQL Server Compact Edition\v3.5\Devices\wce500)

Solution Structure

Download the code from CodePlex. The solution is divided into five projects:

  1. PPHR (User interface forms) 
  2. PPHR.Common (Constant variables and Data classes to support User Interface and other components)
  3. PPHR.Dataccess (Data Access Layer to connect, store and retrieve data from SQL CE)
  4. PPHR.DataLogic (SQL queries to support user interface)
  5. PPHR.Setup (Web setup project to build CAB file)
pphr1/pphr_ProjStr.jpg

Open the solution to load the projects in Visual Studio.

Background

PPHR is an application to maintain personal health information. This application was written using C# and it uses .NET CE Framework 3.5 and SQL CE 3.5. SQLCE is a database, and it can run in a Windows powered pocket PC.

Using the Code

Each screen is associated with its own data logic and Data Class. 

In personal detail screen when the update button is clicked, it invokes the below method. First we will validate the form controls before submitting it to the DB. Then set the value in Data Object.

C#
private void menuItemUpdate_Click(object sender, EventArgs e) 
{
    PersonalDetailLogic personalDataLogic = new PersonalDetailLogic();
    // Set Values PersonalData PID = new PersonalData();
    Cursor.Current = Cursors.WaitCursor;
    try {
        if (ValidateForm())
        {
            // PersonalData PID.PatientID = txtPatientID.Text;
            PID.Name = txtName.Text; PID.DOB = txtDOB.Value;
            ....
                personalDataLogic.UpdateDetail(PID)
                .....
        }
    }

    Finally call the data logic class to update the DB. 

        public class PersonalDetailLogic
    {
        CommonDataLogic commonLogic = new CommonDataLogic();
        DBConnection dbCon = new DBConnection();

        /// <summary>
        /// Update personal details in database
        /// </summary>
        /// <param name="PID">Personal details</param>
        public void UpdateDetail(PersonalData PID)
        {
            try
            {
                // Remove Personal Details
                string sql = string.Empty;
                int result = 0;
                sql = "Delete from Addresses";
                result = dbCon.ExecuteNonQuery(sql);
                sql = "Delete from OtherIDs";
                result = dbCon.ExecuteNonQuery(sql);
                sql = "Delete from PersonalDetail";
                result = dbCon.ExecuteNonQuery(sql);

                // Insert - Personal detail
                sql = "Insert into PersonalDetail Values(";
                sql += "'" + PID.PatientID + "', ";
                sql += "'" + commonLogic.replaceInjectionString(PID.Name) + "', ";
                sql += "'" + PID.DOB + "', ";
                sql += "'" + PID.Gender + "', ";
                sql += "'" + PID.MartialStatus + "', ";
                sql += "'" + commonLogic.replaceInjectionString(PID.SSNumber) + "', ";
                sql += "'" + commonLogic.replaceInjectionString(
                    PID.DrivingLicenseNumber) + "', ";
                sql += "'" + PID.Nationality + "', ";
                sql += "'" + commonLogic.replaceInjectionString(PID.AlergicTo) + "', ";
                sql += "'" + commonLogic.replaceInjectionString(PID.BloodGroup) + "', ";
                sql += "'" + commonLogic.replaceInjectionString(PID.MotherName) + "', ";
                sql += "'" + commonLogic.replaceInjectionString(PID.AliasName) + "', ";
                sql += "'" + commonLogic.replaceInjectionString(
                    PID.PrimaryLanguage) + "', ";
                sql += "'" + DateTime.Now.ToString() + "', ";
                sql += "'" + DateTime.Now.ToString() + "'";
                sql += ")";
                result = dbCon.ExecuteNonQuery(sql);

                // Insert - Address
                foreach (Address adress in PID.Addresses)
                {
                    //Address adress = PID.Addresses[i];
                    sql = "Insert into Addresses Values(";
                    sql += "'" + PID.PatientID + "', ";
                    sql += "'" + adress.AddressType + "', ";
                    sql += "'" + commonLogic.replaceInjectionString(adress.Street1) + "',
                        ";
                    sql += "'" + commonLogic.replaceInjectionString(adress.Street2) + "',
                        ";
                    sql += "'" + commonLogic.replaceInjectionString(adress.City) + "', ";
                    sql += "'" + 
			commonLogic.replaceInjectionString(adress.State) + "', ";
                    sql += "'" + commonLogic.replaceInjectionString(adress.Zip) + "', ";
                    sql += "'" + commonLogic.replaceInjectionString(adress.Country) + "',
                        ";
                    sql += "'" + commonLogic.replaceInjectionString(adress.Fax) + "', ";
                    sql += "'" + 
			commonLogic.replaceInjectionString(adress.Phone) + "', ";
                    sql += "'" + DateTime.Now.ToString() + "', ";
                    sql += "'" + DateTime.Now.ToString() + "'";
                    sql += ")";
                    result = dbCon.ExecuteNonQuery(sql);
                }

                // Other Ids
                foreach (IDs otherIDs in PID.OtherIDs)
                {
                    sql = "Insert into OtherIds Values(";
                    sql += "'" + PID.PatientID + "', ";
                    sql += "'" + commonLogic.replaceInjectionString(
                        otherIDs.Hospital) + "', ";
                    sql += "'" + commonLogic.replaceInjectionString(
                        otherIDs.HospitalID) + "',";
                    sql += "'" + DateTime.Now.ToString() + "', ";
                    sql += "'" + DateTime.Now.ToString() + "'";
                    sql += ")";
                    result = dbCon.ExecuteNonQuery(sql);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.ToString(), ex);
            }
        }

Data Access class exposed with two methods ExecuteQueryAndGetDataTable (execute select query) and ExecuteNonQuery (Insert, Update and Delete):

C#
public DataTable ExecuteQueryAndGetDataTable(string sSql)
{
    DataTable dt=null;
    DataSet ds = new DataSet();
    try
    {
        Connect();
        SqlCeDataAdapter da = new SqlCeDataAdapter(sSql, conn);
        da.Fill(ds);
        if (ds.Tables.Count >= 0)
        {
            dt = ds.Tables[0];
        }
        Disconnect();
    }
    catch(Exception ex)
    {
        throw new Exception("DBConnection", ex);
    }
    return dt;
}

public int ExecuteNonQuery(string sSql)
{
    int commitedRows = -1;
    try
    {
        Connect();
        SqlCeCommand cmd = new SqlCeCommand(sSql, conn);
        commitedRows = cmd.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        throw new Exception("DBConnection", ex);
    }
    return commitedRows;
}

Using the Application

The current version of PPHR covers the following functionalities:

  1. Maintain personal information
  2. Maintain visit information along with Prescription, Doctors dictation and additional information like report results
  3. Generate visit history on demand with certain filter criteria

Note: Refer to CodePlex for user manual. Some Screens Personal Detail:

pphr1/pphr_PID.jpg

Visit Detail 

pphr1/pphr_PV.jpg

Visit History

pphr1/pphr_VisitReport.jpg

Points of Interest

I haven't found any suitable or inexpensive tool to generate a report. Finally I thought of creating the report results as an HTML page and showing it in the browser control and it worked fine. You can find some of my articles here.

History

  • Version 1.0

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
India India
Called as Rasheed. Completed Master of Computer science. Working as Senior Consultant in Chennai, India.

Try to achive in different stream

Comments and Discussions

 
GeneralDatabase file cannot be located Pin
Member 78011139-Apr-11 6:35
Member 78011139-Apr-11 6:35 
GeneralRe: Database file cannot be located Pin
rasheed197910-Apr-11 5:39
rasheed197910-Apr-11 5:39 
GeneralGud Work! Pin
Muneer Abdullah24-Feb-09 20:42
Muneer Abdullah24-Feb-09 20:42 
GeneralRe: Gud Work! Pin
rasheed197925-Feb-09 19:58
rasheed197925-Feb-09 19:58 
GeneralGood Job! Thanks. Pin
thompsons17-Feb-09 15:45
thompsons17-Feb-09 15:45 
GeneralRe: Good Job! Thanks. Pin
rasheed197917-Feb-09 17:57
rasheed197917-Feb-09 17:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.