public bool UpdateComments(HistoriaMedica objHmEnt) { bool flag = false; try { DbTransaction transaction = BaseConnection.GetTransaction(); try { MuestraLaboratorioDao muestraLaboratorioDao = new MuestraLaboratorioDao(); HistoriaMedicaDao historiaMedicaDao = new HistoriaMedicaDao(); if (!historiaMedicaDao.Update(objHmEnt, transaction)) { throw new Exception(historiaMedicaDao.Error); } if (!muestraLaboratorioDao.UpdateStatus(objHmEnt, transaction)) { throw new Exception(muestraLaboratorioDao.Error); } transaction.Commit(); flag = true; } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; transaction.Rollback(); } } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; } return(flag); }
public bool Save(HistoriaMedica objEnt, Paciente objEntPaciente) { bool flag = false; try { DbTransaction transaction = BaseConnection.GetTransaction(); try { HistoriaMedicaDao historiaMedicaDao = new HistoriaMedicaDao(); PacienteDao pacienteDao = new PacienteDao(); if (objEnt.Id != int.MinValue) { if (!historiaMedicaDao.Update(objEnt, transaction)) { throw new Exception(historiaMedicaDao.Error); } if (objEntPaciente != null && !pacienteDao.Update(objEntPaciente, transaction)) { throw new Exception(pacienteDao.Error); } } else if (!historiaMedicaDao.Create(objEnt, transaction)) { throw new Exception(historiaMedicaDao.Error); } transaction.Commit(); flag = true; } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; transaction.Rollback(); } finally { transaction.Dispose(); } } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; } return(flag); }
public bool IngresarPaciente( Paciente objEntPac, HistoriaMedica objEntHisMed, ArrayList examenes, Stream fotoCargada, string pathFilesPac) { bool flag1 = false; try { DbTransaction transaction = BaseConnection.GetTransaction(); string path = string.Empty; try { PacienteDao pacienteDao = new PacienteDao(); HistoriaMedicaDao historiaMedicaDao = new HistoriaMedicaDao(); if (!(objEntPac.Id == int.MinValue ? pacienteDao.Create(objEntPac, transaction) : pacienteDao.Update(objEntPac, transaction))) { throw new Exception(pacienteDao.Error); } objEntHisMed.IdPaciente = objEntPac.Id; bool flag2 = false; bool flag3; if (objEntHisMed.Id != int.MinValue) { flag3 = historiaMedicaDao.Update(objEntHisMed, transaction); flag2 = true; } else { flag3 = historiaMedicaDao.Create(objEntHisMed, transaction); } if (!flag3) { throw new Exception(historiaMedicaDao.Error); } if (examenes.Count > 0) { DataTable dtEstructure = MuestraLaboratorioDao.DtEstructure; foreach (int examene in examenes) { if (flag2) { if (new MuestraLaboratorioDao().GetList(objEntHisMed.Id, (Constants.ExamenLab)examene, false, string.Empty, DateTime.MinValue, short.MinValue, transaction).Rows.Count <= 0) { DataRow row = dtEstructure.NewRow(); row["ID_HISTORIA"] = (object)objEntHisMed.Id; row["ESTADO"] = (object)Convert.ToInt16((object)Constants.EstadosMuestraLaboratorio.SinAplicar); row["ID_TIPO_EXAMEN"] = (object)examene; row["RESULTADO"] = (object)"SIN REALIZAR"; row["NUMERO_MUESTRA"] = (object)1; row["ID_CREACION"] = (object)objEntPac.IdUltimaModificacion; row["FECHA_CREACION"] = (object)DateTime.Now; row["ID_ULTIMA_MODIFICACION"] = (object)objEntPac.IdUltimaModificacion; row["FECHA_ULTIMA_MODIFICACION"] = (object)DateTime.Now; dtEstructure.Rows.Add(row); } } else { DataRow row = dtEstructure.NewRow(); row["ID_HISTORIA"] = (object)objEntHisMed.Id; row["ESTADO"] = (object)Convert.ToInt16((object)Constants.EstadosMuestraLaboratorio.SinAplicar); row["ID_TIPO_EXAMEN"] = (object)examene; row["RESULTADO"] = (object)"SIN REALIZAR"; row["NUMERO_MUESTRA"] = (object)1; row["ID_CREACION"] = (object)objEntPac.IdUltimaModificacion; row["FECHA_CREACION"] = (object)DateTime.Now; row["ID_ULTIMA_MODIFICACION"] = (object)objEntPac.IdUltimaModificacion; row["FECHA_ULTIMA_MODIFICACION"] = (object)DateTime.Now; dtEstructure.Rows.Add(row); } } if (dtEstructure.Rows.Count > 0) { MuestraLaboratorioDao muestraLaboratorioDao = new MuestraLaboratorioDao(); if (!muestraLaboratorioDao.CreateFromDt(dtEstructure, transaction)) { throw new Exception(muestraLaboratorioDao.Error); } } } if (fotoCargada != null) { if (!Directory.Exists(pathFilesPac)) { throw new Exception("La ruta " + pathFilesPac + " no existe o no es accesible desde el servidor."); } path = pathFilesPac + (object)objEntHisMed.Id + "/"; string str = "ImgPaciente.png"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } byte[] buffer = new byte[fotoCargada.Length]; fotoCargada.Read(buffer, 0, buffer.Length); FileStream fileStream = new FileStream(path + str, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(buffer, 0, buffer.Length); fileStream.Flush(); fileStream.Close(); AnexoHistoriaBll anexoHistoriaBll = new AnexoHistoriaBll(); List <AnexoHistoria> anexoHistorias = anexoHistoriaBll.GetAnexoHistorias(objEntHisMed.Id, Constants.TipoRevision.MedicinaGeneral, false, int.MinValue, "Imagen Perfil Paciente"); AnexoHistoria objEnt; if (anexoHistorias.Count > 0) { objEnt = anexoHistorias[0]; } else { objEnt = new AnexoHistoria(); objEnt.IdCreacion = objEntHisMed.IdUltimaModificacion; objEnt.FechaCreacion = DateTime.Now; } objEnt.IdHistoria = objEntHisMed.Id; objEnt.NombreAdjunto = "Imagen Perfil Paciente"; objEnt.IdTipoRevision = Constants.TipoRevision.MedicinaGeneral; objEnt.NombreArchivo = str; objEnt.IdUltimaModificacion = objEntHisMed.IdUltimaModificacion; objEnt.FechaUltimaModificacion = DateTime.Now; if (!anexoHistoriaBll.Save(objEnt, transaction)) { throw new Exception(anexoHistoriaBll.Error); } } transaction.Commit(); flag1 = true; } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; transaction.Rollback(); if (path != null) { if (path != string.Empty) { if (Directory.Exists(path)) { Directory.Delete(path, true); } } } } finally { transaction.Dispose(); } } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; } return(flag1); }
public bool SolicitarMuestrasMedicina( int idHistoria, ArrayList arr, int idUsuario, string commentUser) { bool flag = false; try { DbTransaction transaction = BaseConnection.GetTransaction(); try { MuestraLaboratorioDao muestraLaboratorioDao = new MuestraLaboratorioDao(); HistoriaMedicaDao historiaMedicaDao = new HistoriaMedicaDao(); HistoriaMedica objToProcess1 = historiaMedicaDao.Load(idHistoria, transaction); DataTable dtEstructure = MuestraLaboratorioDao.DtEstructure; foreach (string str in arr) { MuestraLaboratorio objToProcess2 = new MuestraLaboratorio(); Constants.ExamenLab int32 = (Constants.ExamenLab)Convert.ToInt32(str); List <MuestraLaboratorio> muestraLaboratorios = muestraLaboratorioDao.GetMuestraLaboratorios(idHistoria, int32, false, string.Empty, DateTime.MinValue, short.MinValue, transaction); if (muestraLaboratorios.Count > 0) { objToProcess2.NumeroMuestra = muestraLaboratorios[0].NumeroMuestra; ++objToProcess2.NumeroMuestra; } else { objToProcess2.NumeroMuestra = (short)1; } MuestraLaboratorio muestraLaboratorio = muestraLaboratorios.Count > 0 ? muestraLaboratorios[0] : new MuestraLaboratorio(); objToProcess2.Estado = Constants.EstadosMuestraLaboratorio.SinAplicar; objToProcess2.IdHistoria = idHistoria; objToProcess2.IdTipoExamen = int32; objToProcess2.Resultado = "SIN APLICAR"; objToProcess2.FechaTomaMuestra = DateTime.Now; objToProcess2.IdCreacion = muestraLaboratorio.IdUltimaModificacion = idUsuario; objToProcess2.FechaCreacion = muestraLaboratorio.FechaUltimaModificacion = DateTime.Now; if (!muestraLaboratorioDao.Create(objToProcess2, transaction)) { throw new Exception(muestraLaboratorioDao.Error); } } objToProcess1.ComentarioLab += commentUser; objToProcess1.IdUltimaModificacion = idUsuario; objToProcess1.Finalizada = false; objToProcess1.EstadoRevisionLab = Constants.EstadoRevision.SinAplicar; objToProcess1.EstadoRevisionMed = Constants.EstadoRevision.SinAplicar; if (!historiaMedicaDao.Update(objToProcess1, transaction)) { throw new Exception(historiaMedicaDao.Error); } transaction.Commit(); flag = true; } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; transaction.Rollback(); } finally { transaction.Dispose(); } } catch (Exception ex) { this.error = ex.InnerException != null ? ex.InnerException.Message : ex.Message; } return(flag); }