65.9K
CodeProject 正在变化。 阅读更多。
Home

口袋个人健康记录

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.75/5 (4投票s)

2009年2月17日

Ms-PL

2分钟阅读

viewsIcon

30099

downloadIcon

1089

个人口袋健康记录 (PPHR) 应用程序帮助在 Windows 掌上电脑上存储和跟踪用户的个人详细信息和就诊信息。

引言

个人口袋健康记录 (PPHR) 应用程序帮助在 Windows 掌上电脑上存储用户的个人详细信息和就诊信息。 源代码和安装程序可在 CodePlex 上找到。

这是一个开源应用程序,是我对同胞们的贡献。

必备组件

开发环境

  • Visual Studio 2008

部署环境

  • Windows Mobile 5.0
  • .NET Framework CE 3.5 (.NET Framework CE 可以从 Microsoft 下载,或者如果您已经在您的 PC 上安装了 Visual Studio 2008,那么您可以在 已安装驱动器\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE 中找到它)
  • SQL CE 3.5 (SQL CE 可以从 Microsoft 下载,或者如果您已经在您的 PC 上安装了 Visual Studio 2008,那么您可以在 已安装驱动器\Microsoft SQL Server Compact Edition\v3.5\Devices\wce500 中找到它)

解决方案结构

CodePlex 下载代码。 该解决方案分为五个项目

  1. PPHR (用户界面表单) 
  2. PPHR.Common (常量变量和数据类以支持用户界面和其他组件)
  3. PPHR.Dataccess (数据访问层,用于连接、存储和从 SQL CE 检索数据)
  4. PPHR.DataLogic (SQL 查询以支持用户界面)
  5. PPHR.Setup (Web 安装项目,用于构建 CAB 文件)
pphr1/pphr_ProjStr.jpg

打开解决方案以在 Visual Studio 中加载项目。

背景

PPHR 是一个维护个人健康信息的应用程序。 该应用程序使用 C# 编写,并使用 .NET CE Framework 3.5 和 SQL CE 3.5。 SQLCE 是一个数据库,它可以在 Windows 掌上电脑上运行。

Using the Code

每个屏幕都与其自己的数据逻辑和数据类相关联。 

在个人详细信息屏幕中,当单击“更新”按钮时,它将调用以下方法。 首先,我们将验证表单控件,然后再将其提交到数据库。 然后在数据对象中设置值。

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);
            }
        }

数据访问类公开了两种方法,ExecuteQueryAndGetDataTable (执行选择查询)和 ExecuteNonQuery InsertUpdate 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;
}

使用应用程序

PPHR 的当前版本涵盖以下功能

  1. 维护个人信息
  2. 维护就诊信息,包括处方、医生口述和其他信息,如报告结果
  3. 根据某些过滤条件生成按需就诊历史记录

注意:请参阅 CodePlex 了解用户手册。 某些屏幕 个人详细信息

pphr1/pphr_PID.jpg

就诊详细信息 

pphr1/pphr_PV.jpg

就诊历史记录

pphr1/pphr_VisitReport.jpg

关注点

我还没有找到任何合适的或便宜的工具来生成报告。 最后,我考虑将报告结果创建为 HTML 页面并在浏览器控件中显示它,并且效果很好。 您可以在 此处 找到我的一些文章。

历史

  • 版本 1.0
© . All rights reserved.