} //------------------------------ #endregion #region Programmer-Defined Function Procedures //this procedure gets the searched patient information public DataTable GetSearchedPatientInformation(CommonExchange.SysAccess userInfo, String queryString, Boolean isNewSearch) { if (isNewSearch) { using (DatabaseLib.DbLibPatientManager dbLib = new DatabaseLib.DbLibPatientManager()) { _patientTable = dbLib.SelectPatientInformation(userInfo, queryString); } } DataTable dbTable = new DataTable("PatientInformationTable"); dbTable.Columns.Add("sysid_patient", System.Type.GetType("System.String")); dbTable.Columns.Add("patient_name", System.Type.GetType("System.String")); if (_patientTable != null) { foreach (DataRow patientRow in _patientTable.Rows) { DataRow newRow = dbTable.NewRow(); newRow["sysid_patient"] = patientRow["sysid_patient"]; newRow["patient_name"] = DentalLib.ProcStatic.GetCompleteNameMiddleInitial(patientRow, "last_name", "first_name", "middle_name"); dbTable.Rows.Add(newRow); } } return(dbTable); } //-------------------------
} //---------------------------------- //this function gets the employee image path private String GetEmployeeImagePath(CommonExchange.SysAccess userInfo, String patientId, String startUp) { String imagePath = startUp + _imagePath; if (!Directory.Exists(imagePath)) { //creates the directory DirectoryInfo dirInfo = new DirectoryInfo(imagePath); dirInfo.Create(); dirInfo.Attributes = FileAttributes.Hidden; } DataTable imageTable; using (DatabaseLib.DbLibPatientManager dbLib = new DatabaseLib.DbLibPatientManager()) { imageTable = dbLib.SelectImagePatientInformation(userInfo, patientId); } using (DataTableReader tableReader = new DataTableReader(imageTable)) { if (tableReader.HasRows) { Int32 picColumn = 2; while (tableReader.Read()) { if (!tableReader.IsDBNull(picColumn)) { imagePath += "\\" + tableReader["sysid_patient"].ToString() + tableReader["extension_name"].ToString(); if (!File.Exists(imagePath)) { Int64 len = tableReader.GetBytes(picColumn, 0, null, 0, 0); // Create a buffer to hold the bytes, and then // read the bytes from the DataTableReader. Byte[] buffer = new Byte[len]; tableReader.GetBytes(picColumn, 0, buffer, 0, (Int32)len); // Create a new Bitmap object, passing the array // of bytes to the constructor of a MemoryStream. using (Bitmap image = new Bitmap(new MemoryStream(buffer))) { image.Save(imagePath); } } } } } else { imagePath = null; } tableReader.Close(); } return(imagePath); } //------------------------------
} //------------------------------------ //this procedure updates a patient information public void UpdatePatientInformation(CommonExchange.SysAccess userInfo, CommonExchange.Patient patientInfo) { using (DatabaseLib.DbLibPatientManager dbLib = new DatabaseLib.DbLibPatientManager()) { dbLib.UpdatePatientInformation(userInfo, patientInfo); } _patientInfo = patientInfo; } //----------------------------
} //------------------------------ #endregion #region Programmer-Defined Function Procedures //this function returns a selected patient information by patient id public CommonExchange.Patient SelectByPatientSystemIdPatientInformation(CommonExchange.SysAccess userInfo, String patientId, String startUp) { CommonExchange.Patient patientInfo = new CommonExchange.Patient(); using (DatabaseLib.DbLibPatientManager dbLib = new DatabaseLib.DbLibPatientManager()) { patientInfo = dbLib.SelectByPatientSystemIdPatientInformation(userInfo, patientId); patientInfo.ImagePath = this.GetEmployeeImagePath(userInfo, patientId, startUp); patientInfo.ImageBytes = DentalLib.ProcStatic.GetImageByte(patientInfo.ImagePath); patientInfo.ImageExtension = this.GetImageExtensionName(patientInfo.ImagePath); patientInfo.Age = this.GetPatientAge(DateTime.Parse(patientInfo.BirthDate), DateTime.Parse(s_serverDateTime)); } return(patientInfo); } //-----------------------