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
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:
PPHR
(User interface forms)
PPHR.Common
(Constant variables and Data classes to support User Interface and other components)
PPHR.Dataccess
(Data Access Layer to connect, store and retrieve data from SQL CE)
PPHR.DataLogic
(SQL queries to support user interface)
PPHR.Setup
(Web setup project to build CAB file)
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.
private void menuItemUpdate_Click(object sender, EventArgs e)
{
PersonalDetailLogic personalDataLogic = new PersonalDetailLogic();
Cursor.Current = Cursors.WaitCursor;
try {
if (ValidateForm())
{
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();
public void UpdateDetail(PersonalData PID)
{
try
{
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);
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);
foreach (Address adress in PID.Addresses)
{
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);
}
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
):
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:
- Maintain personal information
- Maintain visit information along with Prescription, Doctors dictation and additional information like report results
- Generate visit history on demand with certain filter criteria
Note: Refer to CodePlex for user manual. Some Screens Personal Detail:
Visit Detail
Visit History
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