Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // First control the type of parent page
     if (Request.QueryString["HcId"] != null)
     {
         hcId = Int32.Parse(Request.QueryString["HcId"]);
         hc = CntAriCli.GetHealthCompany(ctx);
         caller = "hccom"; // Called by a Healthcare Company
     }
     if (Request.QueryString["ClinicId"] != null)
     {
         clinicId = Int32.Parse(Request.QueryString["ClinicId"]);
         cl = CntAriCli.GetClinic(clinicId, ctx);
         caller = "clinic"; // Called by a Healthcare Company
     }
     if (Request.QueryString["PatientId"] != null)
     {
         patientId = Int32.Parse(Request.QueryString["PatientId"]);
         pat = CntAriCli.GetPatient(patientId, ctx);
         caller = "patient";
     }
     if (Request.QueryString["CustomerId"] != null)
     {
         customerId = Int32.Parse(Request.QueryString["CustomerId"]);
         cus = CntAriCli.GetCustomer(customerId, ctx);
         caller = "customer";
     }
     if (Request.QueryString["ProfessionalId"] != null)
     {
         professionalId = Int32.Parse(Request.QueryString["ProfessionalId"]);
         prof = CntAriCli.GetProfessional(professionalId, ctx);
         caller = "professional";
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Traspasa los datos de los pacientes desde OFT a AriClinic
        /// </summary>
        /// <param name="con"> Connector a OFT</param>
        /// <param name="ctx"> Contexto de AriClinic</param>
        public static void ImportPatientCustomer(OleDbConnection con, AriClinicContext ctx)
        {
            Console.WriteLine("---Importando Historiales---");
            // (1) Eliminar los datos que pudiera haber previamente y que serán
            // sustituidos por los nuevos.
            ctx.Delete(ctx.Addresses); // elimar direcciones.
            ctx.Delete(ctx.Emails); // eliminar correos electrónicos
            ctx.Delete(ctx.Telephones); // eliminar teléfonos.
            ctx.Delete(ctx.Customers); // eliminar los clientes.
            ctx.Delete(ctx.Patients); // por último, los pcaientes.
            ctx.SaveChanges();

            // (2) Lleer todos los pacientes en OFT
            string sql = "SELECT * FROM Historiales";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConHistoriales");
            int nreg = ds.Tables["ConHistoriales"].Rows.Count;
            int reg = 0;
            foreach (DataRow dr in ds.Tables["ConFacturas"].Rows)
            {
                Console.WriteLine("[{0} de {1}] {2}", ++reg, nreg, dr["Nombre"]);
                // (2.1) Crear cliente
                Customer customer = new Customer();
                customer.VATIN = (string)dr["NumDni"];
                customer.FullName = (string)dr["Nombre"];
                customer.ComercialName = (string)dr["Nombre"];
                ctx.Add(customer);

                // (2.2) Crear paciente y asignarle el cliente
                Patient patient = new Patient();
                patient.Name = (string)dr["Nom"];
                patient.Surname1 = (string)dr["Apell1"];
                patient.Surname2 = (string)dr["Apell2"];
                patient.FullName = (string)dr["Nombre"];
                patient.BornDate = (DateTime)dr["FechaNac"];
                patient.Customer = customer;
                ctx.Add(patient);

                // (2.3) Crear la dirección y asignársela a cliente y paciente.
                Address address = new Address();
                address.Street = (string)dr["Direccion"];
                address.City = (string)dr["Poblacion"];
                address.PostCode = (string)dr["CodPostal"];
                address.Province = (string)dr["Provincia"];
                address.Type = "Primary";
                ctx.Add(address);
                customer.Addresses.Add(address);
                patient.Addresses.Add(address);

                // (2.4) Lo mismo para los teléfono.
                Telephone telephone = new Telephone();
                if ((string)dr["Tel1"] != "")
                {
                    telephone.Number = (string)dr["Tel1"];
                    telephone.Type = "Primary";
                    ctx.Add(telephone);
                    patient.Telephones.Add(telephone);
                    customer.Telephones.Add(telephone);
                }
                if ((string)dr["Tel2"] != "")
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Tel2"];
                    telephone.Type = "Primary";
                    ctx.Add(telephone);
                    patient.Telephones.Add(telephone);
                    customer.Telephones.Add(telephone);
                }
                if ((string)dr["Movil"] != "")
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Movil"];
                    telephone.Type = "Secondary";
                    ctx.Add(telephone);
                    patient.Telephones.Add(telephone);
                    customer.Telephones.Add(telephone);
                }

                // (2.5) Igual pero para correos electrónicos
                Email email = new Email();
                email.Url = (string)dr["Email"];
                email.Type = "Primary";
                ctx.Add(email);
                patient.Emails.Add(email);
                customer.Emails.Add(email);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Traspasa los datos de los pacientes desde OFT a AriClinic
        /// </summary>
        /// <param name="con"> Connector a OFT</param>
        /// <param name="ctx"> Contexto de AriClinic</param>
        public static void ImportPatientCustomer(OleDbConnection con, AriClinicContext ctx)
        {
            // (1) Eliminar los datos que pudiera haber previamente y que serán
            // sustituidos por los nuevos.
            ctx.Delete(ctx.Addresses); // eliminar direcciones.
            ctx.Delete(ctx.Emails); // eliminar correos electrónicos
            ctx.Delete(ctx.Telephones); // eliminar teléfonos.
            ctx.Delete(ctx.Policies); // eliminar las pólizas.

            ctx.Delete(ctx.Customers); // eliminar los clientes.
            ctx.Delete(ctx.Patients); // por último, los pacientes.
            ctx.SaveChanges();

            // (2) Lleer todos los pacientes en OFT
            string sql = "SELECT * FROM Historiales";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConHistoriales");
            int nreg = ds.Tables["ConHistoriales"].Rows.Count;
            int reg = 0;

            // (2.0) Por cada fila lieda de la tabla, damos de alta el 
            // paciente correspondiente con sus direcciones, teléfonosç
            // y correo electrónico.
            foreach (DataRow dr in ds.Tables["ConHistoriales"].Rows)
            {
                ++reg; // un registro más (para saber por donde va)

                // (2.1) Crear cliente
                Customer customer = new Customer();
                if (dr["NumDni"] != DBNull.Value)
                    customer.VATIN = (string)dr["NumDni"];
                customer.FullName = (string)dr["Nombre"];
                customer.ComercialName = (string)dr["Nombre"];
                customer.OftId = (int)dr["NumHis"];
                ctx.Add(customer);

                // (2.2) Crear paciente y asignarle el cliente
                Patient patient = new Patient();
                patient.Name = (string)dr["Nom"];
                patient.Surname1 = (string)dr["Apell1"];
                if (dr["Apell2"] != DBNull.Value)
                    patient.Surname2 = (string)dr["Apell2"];
                patient.FullName = (string)dr["Nombre"];
                if (dr["FechaNac"] != DBNull.Value) 
                    patient.BornDate = (DateTime)dr["FechaNac"];
                patient.Sex = "M";
                if (dr["Sexo"] != DBNull.Value)
                    if ((byte)dr["Sexo"] == 2)
                        patient.Sex = "W";
                patient.Customer = customer;
                patient.OftId = (int)dr["NumHis"];
                ctx.Add(patient);

                // (2.3) Crear la dirección y asignársela a cliente y paciente.
                Address address = new Address();
                address.Street = (string)dr["Direccion"];
                address.City = (string)dr["Poblacion"];
                if (dr["CodPostal"] != DBNull.Value)
                    address.PostCode = (string)dr["CodPostal"];
                address.Province = (string)dr["Provincia"];
                address.Type = "Primary";
                ctx.Add(address);
                customer.Addresses.Add(address);
                patient.Addresses.Add(address);

                // (2.4) Lo mismo para los teléfono.
                Telephone telephone = new Telephone();
                if (dr["Tel1"] != DBNull.Value)
                {
                    telephone.Number = (string)dr["Tel1"];
                    telephone.Type = "Primary";
                    ctx.Add(telephone);
                    patient.Telephones.Add(telephone);
                    customer.Telephones.Add(telephone);
                }
                if (dr["Tel2"] != DBNull.Value)
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Tel2"];
                    telephone.Type = "Primary";
                    ctx.Add(telephone);
                    patient.Telephones.Add(telephone);
                    customer.Telephones.Add(telephone);
                }
                if (dr["Movil"] != DBNull.Value)
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Movil"];
                    telephone.Type = "Secondary";
                    ctx.Add(telephone);
                    patient.Telephones.Add(telephone);
                    customer.Telephones.Add(telephone);
                }

                // (2.5) Igual pero para correos electrónicos
                Email email = new Email();
                if (dr["Email"] != DBNull.Value)
                    email.Url = (string)dr["Email"];
                email.Type = "Primary";
                ctx.Add(email);
                patient.Emails.Add(email);
                customer.Emails.Add(email);
            }
            ctx.SaveChanges();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Traspasa los datos de los pacientes desde OFT a AriClinic
        /// </summary>
        /// <param name="con"> Connector a OFT</param>
        /// <param name="ctx"> Contexto de AriClinic</param>
        public static void ImportPatientCustomer(OleDbConnection con, AriClinicContext ctx)
        {
            // (1) Eliminar los datos que pudiera haber previamente y que serán
            // sustituidos por los nuevos.
            // DeletePatientRelated(ctx);

            /* ACL-176
             * Ahora solo pretendem,os importar direcciones, correos y telfonos
             * suponemos que personas, pacientes y clientes son correctos
             * y que los pacientes están corretamente ligados a clientes
             * 
             * */
            DeleteEmailsAddressAndTelephones(ctx);

            // (1.1) Montar las procedencias
            Console.WriteLine("Importing sources...");
            ImportSources(con, ctx);



            // (2) Lleer todos los pacientes en OFT
            string sql = "SELECT * FROM Historiales";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConHistoriales");
            int nreg = ds.Tables["ConHistoriales"].Rows.Count;
            int reg = 0;

            // (2.0) Por cada fila lieda de la tabla, damos de alta el 
            // paciente correspondiente con sus direcciones, teléfonosç
            // y correo electrónico.
            foreach (DataRow dr in ds.Tables["ConHistoriales"].Rows)
            {
                ++reg; // un registro más (para saber por donde va)
                Console.WriteLine("registro {1:#####0} de {2:#####0} / {0}", (string)dr["Nombre"], reg, nreg);
                // (2.1) Crear cliente
                // ACL-176 nos aseguramos que al menos el cliente existe
                Customer customer = CntAriCli.GetCustomerByOftId((int)dr["NumHis"], ctx);
                if (customer == null)
                {
                    customer = new Customer();
                    customer.OftId = (int)dr["NumHis"];
                    ctx.Add(customer);
                }
                if (dr["NumDni"] != DBNull.Value)
                    customer.VATIN = (string)dr["NumDni"];
                customer.FullName = (string)dr["Nombre"];
                customer.ComercialName = (string)dr["Nombre"];
                ctx.SaveChanges();

                // (2.2) Crear paciente y asignarle el cliente
                Patient patient = CntAriCli.GetPatientByOftId((int)dr["NumHis"], ctx);
                if (patient == null)
                {
                    patient = new Patient();
                    patient.OftId = (int)dr["NumHis"];
                    ctx.Add(patient);
                }
                patient.Name = (string)dr["Nom"];
                patient.Surname1 = (string)dr["Apell1"];
                if (dr["Apell2"] != DBNull.Value)
                    patient.Surname2 = (string)dr["Apell2"];
                patient.FullName = (string)dr["Nombre"];
                if (dr["FechaNac"] != DBNull.Value)
                    patient.BornDate = (DateTime)dr["FechaNac"];
                patient.Sex = "M";
                if (dr["Sexo"] != DBNull.Value)
                    if ((byte)dr["Sexo"] == 2)
                        patient.Sex = "W";
                // ACL-176 machacamos la asociación
                patient.Customer = customer;
                // asignar la procedencia
                // ACL-176 la procedencia preexiste
                Source src = (from s in ctx.Sources
                              where s.OftId == (int)dr["IdProcMed"]
                              select s).FirstOrDefault<Source>();
                if (src != null)
                    patient.Source = src;
                // asignar la fecha de apertura
                if (dr["FecAper"] != DBNull.Value)
                    patient.OpenDate = (DateTime)dr["FecAper"];
                ctx.SaveChanges();

                // ACL-176 innecesario por el borre inicial
                //// eliminar los datos asociados
                //ctx.Delete(customer.Addresses);
                //ctx.Delete(patient.Addresses);
                //ctx.SaveChanges();

                // (2.3) Crear la dirección y asignársela a paciente y cliente.
                Address address = new Address();
                address.Street = (string)dr["Direccion"];
                address.City = (string)dr["Poblacion"];
                if (dr["CodPostal"] != DBNull.Value)
                    address.PostCode = (string)dr["CodPostal"];
                address.Province = (string)dr["Provincia"];
                address.Type = "Primary";
                // ACL-176 ¿Qué persona es el paciente?
                address.Person = CntAriCli.GetPersonByPatient(patient, ctx);
                ctx.Add(address);
                ctx.SaveChanges();
                // ACL-176 pacientes y clientes tienen duplicados sus registros
                address = new Address();
                address.Street = (string)dr["Direccion"];
                address.City = (string)dr["Poblacion"];
                if (dr["CodPostal"] != DBNull.Value)
                    address.PostCode = (string)dr["CodPostal"];
                address.Province = (string)dr["Provincia"];
                address.Type = "Primary";
                // ACL-176 ¿Qué persona es el paciente?
                address.Person = CntAriCli.GetPersonByCustomer(customer, ctx);
                ctx.Add(address);
                ctx.SaveChanges();


                // ACL-176 el borre inicial lo vuelve innecesario
                //// eliminar los teléfonos asociados
                //ctx.Delete(customer.Telephones);
                //ctx.Delete(patient.Telephones);
                //ctx.SaveChanges();


                // (2.4) Lo mismo para los teléfono.
                Telephone telephone = new Telephone();
                if (dr["Tel1"] != DBNull.Value)
                {
                    telephone.Number = (string)dr["Tel1"];
                    if (telephone.Number != "")
                    {
                        telephone.Type = "Primary";
                        // ACL-176 turno del paciente
                        telephone.Person = CntAriCli.GetPersonByPatient(patient, ctx);
                        ctx.Add(telephone);
                        ctx.SaveChanges();
                    }
                }
                if (dr["Tel2"] != DBNull.Value)
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Tel2"];
                    if (telephone.Number != "")
                    {
                        telephone.Type = "Primary";
                        // ACL-176 turno del paciente
                        telephone.Person = CntAriCli.GetPersonByPatient(patient, ctx);
                        ctx.Add(telephone);
                        ctx.SaveChanges();
                    }
                }
                if (dr["Movil"] != DBNull.Value)
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Movil"];
                    if (telephone.Number != "")
                    {
                        telephone.Type = "Secondary";
                        // ACL-176 turno del paciente
                        telephone.Person = CntAriCli.GetPersonByPatient(patient, ctx);
                        ctx.Add(telephone);
                        ctx.SaveChanges();
                    }
                }

                //ACL-176 Es un rollo pero hay que repetir todo el proceso para el cliente
                telephone = new Telephone();
                if (dr["Tel1"] != DBNull.Value)
                {
                    telephone.Number = (string)dr["Tel1"];
                    if (telephone.Number != "")
                    {
                        telephone.Type = "Primary";
                        // ACL-176 turno del paciente
                        telephone.Person = CntAriCli.GetPersonByCustomer(customer, ctx);
                        ctx.Add(telephone);
                        ctx.SaveChanges();
                    }
                }
                if (dr["Tel2"] != DBNull.Value)
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Tel2"];
                    if (telephone.Number != "")
                    {
                        telephone.Type = "Primary";
                        // ACL-176 turno del paciente
                        telephone.Person = CntAriCli.GetPersonByCustomer(customer, ctx);
                        ctx.Add(telephone);
                        ctx.SaveChanges();
                    }
                }
                if (dr["Movil"] != DBNull.Value)
                {
                    telephone = new Telephone();
                    telephone.Number = (string)dr["Movil"];
                    if (telephone.Number != "")
                    {
                        telephone.Type = "Secondary";
                        // ACL-176 turno del paciente
                        telephone.Person = CntAriCli.GetPersonByCustomer(customer, ctx);
                        ctx.Add(telephone);
                        ctx.SaveChanges();
                    }

                }

                // ACL-176 innecasrio por borre total
                //// eliminar los correos anteriores
                //ctx.Delete(customer.Emails);
                //ctx.Delete(patient.Emails);
                //ctx.SaveChanges();

                // (2.5) Igual pero para correos electrónicos
                Email email = new Email();
                if (dr["Email"] != DBNull.Value)
                    email.Url = (string)dr["Email"];
                if (email.Url != "0" && email.Url != "")
                {
                    email.Type = "Primary";
                    //ACL-176 turno de paciente
                    email.Person = CntAriCli.GetPersonByPatient(patient, ctx);
                    ctx.Add(email);
                    ctx.SaveChanges();
                }
                // ACL-176 ahora el cliente.
                email = new Email();
                if (dr["Email"] != DBNull.Value)
                    email.Url = (string)dr["Email"];
                if (email.Url != "0" && email.Url != "")
                {
                    email.Type = "Primary";
                    //ACL-176 turno de paciente
                    email.Person = CntAriCli.GetPersonByCustomer(customer, ctx);
                    ctx.Add(email);
                    ctx.SaveChanges();
                }
            }
        }
Exemplo n.º 5
0
 public static IList<Payment> GetPayments(Customer cus, AriClinicContext ctx)
 {
     var rs = from p in ctx.Payments
              orderby p.PaymentDate descending
              where p.Ticket.Policy.Customer.PersonId == cus.PersonId
              select p;
     return rs.ToList<Payment>();
 }
Exemplo n.º 6
0
 public static Policy PrimaryPolicy(Customer cus)
 {
     return (from p in cus.Policies
             where p.Type == "Primary"
             select p).FirstOrDefault<Policy>();
 }
Exemplo n.º 7
0
 public static IList<Ticket> GetTicketsNotInvoiced(Customer cus, AriClinicContext ctx)
 {
     return (from t in ctx.Tickets
             where t.Policy.Customer.PersonId == cus.PersonId &&
                   t.InvoiceLines.Count == 0
             select t).ToList<Ticket>();
 }
Exemplo n.º 8
0
 public static IList<GeneralPayment> GetGeneralPayments(Customer cus, AriClinicContext ctx)
 {
     return (from gp in ctx.GeneralPayments
             select gp).ToList<GeneralPayment>();
 }
Exemplo n.º 9
0
 public static IList<Ticket> GeTickets(bool notPaid, Customer cus, AriClinicContext ctx)
 {
     var rs2 = from t in ctx.Tickets
               orderby t.TicketDate descending
               where t.Policy.Customer.PersonId == cus.PersonId &&
                     t.Amount > t.Paid
               select t;
     return rs2.ToList<Ticket>();
 }
Exemplo n.º 10
0
 public static Person GetPersonByCustomer(Customer customer, AriClinicContext ctx)
 {
     return (from p in ctx.People
             where p.PersonId == customer.PersonId
             select p).FirstOrDefault<Person>();
 }
Exemplo n.º 11
0
 public static List<ServiceNote> GetServiceNotesByPerson(Person p, AriClinicContext ctx)
 {
     Customer cust;
     if (p is Patient)
         cust = (p as Patient).Customer;
     else if (p is Customer)
         cust = (p as Customer);
     else
         cust = new Customer();
             
     return (from anes in ctx.ServiceNotes
             orderby anes.ServiceNoteDate descending
             where anes.Customer == cust
             select anes).ToList<ServiceNote>();
 }
Exemplo n.º 12
0
 public static List<AnestheticServiceNote> GetAnestheticServiceNotesByPerson(Person p, AriClinicContext ctx)
 {
     Customer cust;
     if (p is Patient)
         cust = (p as Patient).Customer;
     else if (p is Customer)
         cust = (p as Customer);
     else
         cust = new Customer();
 
     return (from anes in ctx.AnestheticServiceNotes
             where anes.Customer == cust
             select anes).ToList<AnestheticServiceNote>();
 }
Exemplo n.º 13
0
 public static bool DeleteCustomer(Customer cus, AriClinicContext ctx)
 {
     foreach (Policy item in cus.Policies)
     {
         ctx.Delete(item.Tickets);
     }
     ctx.Delete(cus.Policies);
     ctx.Delete(cus);
     ctx.SaveChanges();
     return true;
 }