Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static EMR_PatientMdl GetModel(string patient_guid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 patient_guid,user_guid,name,gender,birthday,diagnosis,diagnosis_t,created_dt,modified_dt from EMR_Patient ");
            strSql.Append(" where patient_guid=@patient_guid   ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@patient_guid", SqlDbType.VarChar, 36)
            };
            parameters[0].Value = patient_guid;


            EMR_PatientMdl model = new EMR_PatientMdl();
            DataSet        ds    = SqlHelper.ExecuteQuery(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool Add(EMR_PatientMdl model)
        {
            if (model.name.Trim().Length == 0)
            {
                return(false);
            }
            if (IsExist(model.name, model.user_guid))
            {
                return(false);
            }

            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into emr_patient(");
            strSql.Append("patient_guid,user_guid,name,gender,birthday,diagnosis,diagnosis_t,created_dt,modified_dt)");
            strSql.Append(" values (");
            strSql.Append("@patient_guid,@user_guid,@name,@gender,@birthday,@diagnosis,@diagnosis_t,getdate(),getdate())");
            SqlParameter[] parameters =
            {
                new SqlParameter("@patient_guid", SqlDbType.VarChar,    36),
                new SqlParameter("@user_guid",    SqlDbType.VarChar,    36),
                new SqlParameter("@name",         SqlDbType.NVarChar,   64),
                new SqlParameter("@gender",       SqlDbType.Int,         4),
                new SqlParameter("@birthday",     SqlDbType.DateTime),
                new SqlParameter("@diagnosis",    SqlDbType.NVarChar,  256),
                new SqlParameter("@diagnosis_t",  SqlDbType.NVarChar, 256)
            };
            parameters[0].Value = model.patient_guid;
            parameters[1].Value = model.user_guid;
            parameters[2].Value = model.name;
            parameters[3].Value = model.gender;
            parameters[4].Value = model.birthday;
            parameters[5].Value = model.diagnosis;
            parameters[6].Value = model.diagnosis_t;

            int rows = SqlHelper.ExecuteNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static EMR_PatientMdl DataRowToModel(DataRow row)
        {
            EMR_PatientMdl model = new EMR_PatientMdl();

            if (row != null)
            {
                if (row["patient_guid"] != null)
                {
                    model.patient_guid = row["patient_guid"].ToString();
                }
                if (row["user_guid"] != null)
                {
                    model.user_guid = row["user_guid"].ToString();
                }
                if (row["name"] != null)
                {
                    model.name = row["name"].ToString();
                }
                if (row["gender"] != null && row["gender"].ToString() != "")
                {
                    model.gender = int.Parse(row["gender"].ToString());
                }
                if (row["birthday"] != null && row["birthday"].ToString() != "")
                {
                    model.birthday = DateTime.Parse(row["birthday"].ToString());
                }
                if (row["diagnosis"] != null)
                {
                    model.diagnosis = row["diagnosis"].ToString();
                }
                if (row["diagnosis_t"] != null)
                {
                    model.diagnosis_t = row["diagnosis_t"].ToString();
                }
                if (row["created_dt"] != null && row["created_dt"].ToString() != "")
                {
                    model.created_dt = DateTime.Parse(row["created_dt"].ToString());
                }
                if (row["modified_dt"] != null && row["modified_dt"].ToString() != "")
                {
                    model.modified_dt = DateTime.Parse(row["modified_dt"].ToString());
                }
            }
            return(model);
        }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(EMR_PatientMdl model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update emr_patient set ");
            strSql.Append("name=@name,");
            strSql.Append("gender=@gender,");
            strSql.Append("birthday=@birthday,");
            strSql.Append("diagnosis=@diagnosis,");
            strSql.Append("diagnosis_t=@diagnosis_t,");
            strSql.Append("modified_dt=getdate()");
            strSql.Append(" where patient_guid=@patient_guid and user_guid=@user_guid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@patient_guid", SqlDbType.VarChar,    36),
                new SqlParameter("@user_guid",    SqlDbType.VarChar,    36),
                new SqlParameter("@name",         SqlDbType.NVarChar,   64),
                new SqlParameter("@gender",       SqlDbType.Int,         4),
                new SqlParameter("@birthday",     SqlDbType.DateTime),
                new SqlParameter("@diagnosis",    SqlDbType.NVarChar,  256),
                new SqlParameter("@diagnosis_t",  SqlDbType.NVarChar, 256)
            };
            parameters[0].Value = model.patient_guid;
            parameters[1].Value = model.user_guid;
            parameters[2].Value = model.name;
            parameters[3].Value = model.gender;
            parameters[4].Value = model.birthday;
            parameters[5].Value = model.diagnosis;
            parameters[6].Value = model.diagnosis_t;

            int rows = SqlHelper.ExecuteNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        private void InitUI()
        {
            DataSet dsEMRType = EMR_PatientMdlDAL.GetEMRType();

            this.rptEMRType.DataSource = dsEMRType.Tables[0];
            this.rptEMRType.DataBind();
            this.ddlEMRType.DataTextField  = "name";
            this.ddlEMRType.DataValueField = "guid";
            this.ddlEMRType.DataSource     = dsEMRType.Tables[0];
            this.ddlEMRType.DataBind();


            if (Page.Request.QueryString["patient_guid"] != null)
            {
                #region Come from the Worklist
                this.hidPatientGUID.Value = Page.Request.QueryString["patient_guid"];
                RefreshEMRListByPatientUidAndEMRType();
                EMR_PatientMdl mdl = EMR_PatientMdlDAL.GetModel(this.hidPatientGUID.Value);
                this.txtName.Text = mdl.name;
                if (mdl.gender == 0)
                {
                    this.txtGender.Text = "未知";
                }
                if (mdl.gender == 1)
                {
                    this.txtGender.Text = "女";
                }
                if (mdl.gender == 2)
                {
                    this.txtGender.Text = "男";
                }
                DateTime dtDOB = Convert.ToDateTime(mdl.birthday);
                this.txtAge.Text = dtDOB.ToString("yyyy-MM-dd");
                #endregion
            }
            else
            {
                #region Come from the Application Request Page
                if (Page.Request.QueryString["patname"] != null && Page.Request.QueryString["patname"].Trim().Length > 0)
                {
                    this.txtName.Text = Page.Request.QueryString["patname"];
                }
                else
                {
                    return;
                }
                if (Page.Request.QueryString["gender"] != null)
                {
                    this.txtGender.Text = Page.Request.QueryString["gender"];
                }
                else
                {
                    return;
                }
                if (Page.Request.QueryString["dob"] != null)
                {
                    this.txtAge.Text = Page.Request.QueryString["dob"];
                }
                else
                {
                    return;
                }

                string userGUID    = "";
                string patientName = "";
                if (Page.Request.QueryString["userid"] != null)
                {
                    userGUID = Page.Request.QueryString["userid"];
                }
                else
                {
                    return;
                }
                if (Page.Request.QueryString["patname"] != null)
                {
                    patientName = Page.Request.QueryString["patname"];
                }
                else
                {
                    return;
                }


                // First, check if the patient is exist or not
                #region Check Patient and Create New Patient
                if (EMR_PatientMdlDAL.IsExist(patientName, userGUID))
                {
                    this.hidPatientGUID.Value = EMR_PatientMdlDAL.GetPatientGUID(patientName, userGUID);
                }
                else
                {
                    // This patient is not exist, create new one
                    EMR_PatientMdl newPatient = new EMR_PatientMdl();
                    newPatient.patient_guid = Guid.NewGuid().ToString();
                    newPatient.user_guid    = userGUID;
                    newPatient.name         = patientName;
                    int nGender = 0;
                    int.TryParse(Page.Request.QueryString["genderType"], out nGender);
                    newPatient.gender = nGender;
                    DateTime dtDOB = DateTime.Now;
                    DateTime.TryParse(Page.Request.QueryString["dob"], out dtDOB);
                    newPatient.birthday = dtDOB;
                    EMR_PatientMdlDAL.Add(newPatient);
                    this.hidPatientGUID.Value = newPatient.patient_guid;
                }
                #endregion


                // Bind EMR Detail List
                RefreshEMRListByPatientUidAndEMRType();


                #endregion
            }
        }
Пример #6
0
        private ApplicationAllInOneMdl GetMdlFromGUI()
        {
            ApplicationAllInOneMdl totalMdl = new ApplicationAllInOneMdl();

            // Basic info
            Consult_ApplicationMdl consultAppMdl = new Consult_ApplicationMdl();

            #region MyRegion
            // Try to get guid
            consultAppMdl.guid = this.hidGUID.Value.Trim();
            if (string.IsNullOrEmpty(consultAppMdl.guid))
            {
                // New Application Request
                consultAppMdl.guid       = Guid.NewGuid().ToString();
                consultAppMdl.created_dt = DateTime.Now;
                consultAppMdl.status     = 1; // After save, the status will be changed to 1;
                this.hidGUID.Value       = consultAppMdl.guid;
            }
            else
            {
                // Get exists data first, then using new GUI to update
                Consult_ApplicationDAL dal = new Consult_ApplicationDAL();
                consultAppMdl = dal.GetModel(consultAppMdl.guid);
                // Update status from 0 to 1
                if (consultAppMdl.status == 0)
                {
                    consultAppMdl.status = 1;
                }
            }

            consultAppMdl.location_type = int.Parse(this.ddlLocalType.SelectedValue);
            consultAppMdl.user_guid     = Session["USER_GUID"].ToString();
            consultAppMdl.user_name     = this.txtName.Text.Trim();
            consultAppMdl.purpose       = this.txtApplicationPurpose.Text;
            #endregion


            // Patient Info
            EMR_PatientMdl patientMdl = new EMR_PatientMdl();
            #region MyRegion
            patientMdl.user_guid = this.hidUserGUID.Value; // Pateint belongs to User
            patientMdl.name      = this.txtPatientName.Text.Trim();
            patientMdl.gender    = int.Parse(this.ddlGender.SelectedValue);
            string   strDOB = this.txtDOB.Text;
            DateTime dtDOB  = DateTime.Now;
            DateTime.TryParse(strDOB, out dtDOB);
            patientMdl.birthday = dtDOB;
            #endregion


            // Hospital Info
            List <Consult_Application_ConsultantMdl> consultantMdlCollection = new List <Consult_Application_ConsultantMdl>();
            #region MyRegion
            int HospitalCount = int.Parse(this.ddlHospitalCount.SelectedValue);
            for (int i = 1; i <= HospitalCount; i++)
            {
                Consult_Application_ConsultantMdl consultantMdl = new Consult_Application_ConsultantMdl();
                DropDownList ddlHospital = this.panDoctorGroup.FindControl("ddlHospital" + i.ToString()) as DropDownList;
                if (ddlHospital.SelectedItem != null)
                {
                    consultantMdl.hospital_guid = ddlHospital.SelectedValue;
                    consultantMdl.hospital_name = ddlHospital.SelectedItem.Text;
                    string location_guid = "";
                    string location_name = "";
                    Consult_ApplicationDAL.GetLocationInfoByHospitalUID(consultantMdl.hospital_guid, ref location_guid, ref location_name);
                    consultantMdl.location_guid = location_guid;
                    consultantMdl.location_name = location_name;
                }

                DropDownList ddlDoctor = this.panDoctorGroup.FindControl("ddlDoctor" + i.ToString()) as DropDownList;
                if (ddlDoctor.SelectedItem != null)
                {
                    consultantMdl.doctor_guid = ddlDoctor.SelectedValue;
                    consultantMdl.doctor_name = ddlDoctor.SelectedItem.Text;
                }
                consultantMdl.consult_application_guid = consultAppMdl.guid;
                consultantMdlCollection.Add(consultantMdl);
            }
            #endregion


            // consult_application_accessory info
            #region MyRegion
            consult_application_accessoryMdl thumbnailMdl = null;
            if (!string.IsNullOrEmpty(this.hidPurposeImg.Value) && File.Exists(this.hidPurposeImg.Value))
            {
                thumbnailMdl = new consult_application_accessoryMdl();
                if (string.IsNullOrEmpty(this.hidPurposeImgGUID.Value))
                {
                    thumbnailMdl.guid = Guid.NewGuid().ToString();
                }
                else
                {
                    thumbnailMdl.guid = this.hidPurposeImgGUID.Value;
                }

                thumbnailMdl.consult_application_guid = consultAppMdl.guid;
                thumbnailMdl.type      = 0;
                thumbnailMdl.content   = File.ReadAllBytes(this.hidPurposeImg.Value);
                thumbnailMdl.thumbnail = ImageUtils.getThumbnail(thumbnailMdl.content);
            }
            #endregion



            totalMdl.Consult_ApplicationMdl = consultAppMdl;
            totalMdl.EMR_PatientMdl         = patientMdl;
            totalMdl.Consult_Application_ConsultantMdlCollection = consultantMdlCollection;
            totalMdl.consult_application_accessoryMdl            = thumbnailMdl;
            return(totalMdl);
        }