private bool SaveApplication() { try { ApplicationAllInOneMdl totalMdl = this.GetMdlFromGUI(); Consult_ApplicationMdl mdl = totalMdl.Consult_ApplicationMdl; Consult_ApplicationDAL dal = new Consult_ApplicationDAL(); // Save/Update the Patient info first #region MyRegion string patient_guid = EMR_PatientMdlDAL.GetPatientGUID(totalMdl.EMR_PatientMdl.name, totalMdl.EMR_PatientMdl.user_guid); if (string.IsNullOrEmpty(patient_guid)) { // New totalMdl.EMR_PatientMdl.patient_guid = Guid.NewGuid().ToString(); // Create new GUID totalMdl.Consult_ApplicationMdl.patient_guid = totalMdl.EMR_PatientMdl.patient_guid; // Copy GUID EMR_PatientMdlDAL.Add(totalMdl.EMR_PatientMdl); } else { // Update totalMdl.EMR_PatientMdl.patient_guid = patient_guid; // Create new GUID totalMdl.Consult_ApplicationMdl.patient_guid = totalMdl.EMR_PatientMdl.patient_guid; // Copy GUID EMR_PatientMdlDAL.Update(totalMdl.EMR_PatientMdl); } #endregion // Continue save the others info if (!dal.IsExist(mdl.guid)) { // Add Consult_ApplicationMdl dal.Add_consult_application(mdl); // Add consult_application_consultant dal.Add_consult_application_consultant(totalMdl.Consult_Application_ConsultantMdlCollection); // Add the Purpose Image dal.Add_consult_application_accessory(totalMdl.consult_application_accessoryMdl); return(true); } else { // Update Consult_ApplicationMdl dal.Update_consult_application(mdl); // Update consult_application_consultant dal.Update_consult_application_consultant(totalMdl.Consult_Application_ConsultantMdlCollection); // Update the Purpose Image dal.Update_consult_application_accessory(totalMdl.consult_application_accessoryMdl); return(true); } } catch (Exception ex) { Log4NetLogger.GetLogger().Error(ex.Message); this.lblErrorMsg.Text = ex.Message; } return(false); }
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 } }