Example #1
0
 public static void ProcessPaquimetry(int id, Paquimetry pq, OleDbConnection con, AriClinicContext ctx)
 {
     // WithoutGlasses
     string sql = String.Format("SELECT * FROM Paquimetria WHERE IdRef={0}", id);
     cmd = new OleDbCommand(sql, con);
     da = new OleDbDataAdapter(cmd);
     DataSet ds = new DataSet();
     da.Fill(ds, "ConSNGRefracto");
     DataRow dr = ds.Tables["ConSNGRefracto"].Rows[0];
     pq.RightEyeCentralC0 = (decimal)dr["CentralC0D"];
     pq.RightEyeC1 = (decimal)dr["C1D"];
     pq.RightEyeC3 = (decimal)dr["C3D"];
     pq.RightEyeC5 = (decimal)dr["C5D"];
     pq.RightEyeC7 = (decimal)dr["C7D"];
     pq.LeftEyeCentralC0 = (decimal)dr["CentralC0I"];
     pq.LeftEyeC1 = (decimal)dr["C1I"];
     pq.LeftEyeC3 = (decimal)dr["C3I"];
     pq.LeftEyeC5 = (decimal)dr["C5I"];
     pq.LeftEyeC7 = (decimal)dr["C7I"];
 }
Example #2
0
        public static void ImportExaminationsAssigned(OleDbConnection con, AriClinicContext ctx)
        {
            // (0) Borra tipos previos
            //ctx.Delete(ctx.WithoutGlassesTests);
            //ctx.Delete(ctx.GlassesTests);
            //ctx.Delete(ctx.ContactLensesTests);
            //ctx.Delete(ctx.OpticalObjectiveExaminations);
            //ctx.Delete(ctx.SubjectiveOpticalExaminations);
            //ctx.Delete(ctx.Cycloplegias);
            //ctx.Delete(ctx.PrescriptionGlasses);

            //ctx.Delete(ctx.Refractometries);
            //ctx.Delete(ctx.Biometries);
            //ctx.Delete(ctx.Paquimetries);
            //ctx.Delete(ctx.Topographies);

            //ctx.Delete(ctx.ExaminationAssigneds);
            //ctx.SaveChanges();

            // (1) Dar de alta los diferentes diagnósticos
            string sql = "SELECT * FROM HistExplor";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConExploraciones");
            int nreg = ds.Tables["ConExploraciones"].Rows.Count;
            int reg = 0;
            foreach (DataRow dr in ds.Tables["ConExploraciones"].Rows)
            {
                reg++;
                Boolean newEx = false;
                Console.WriteLine("Exploraciones asignadas {0:#####0} de {1:#####0} {2}", reg, nreg, "EXPASG");
                int id = (int)dr["NumHis"];
                Patient patient = (from p in ctx.Patients
                                   where p.OftId == id
                                   select p).FirstOrDefault<Patient>();
                id = (int)dr["IdExEs"];
                Examination examination = (from ex in ctx.Examinations
                                           where ex.OftId == id
                                           select ex).FirstOrDefault<Examination>();
                DateTime examinationDate = (DateTime)dr["Fecha"];
                ExaminationAssigned examas = (from e in ctx.ExaminationAssigneds
                                              where e.Patient.PersonId == patient.PersonId
                                              && e.Examination.ExaminationId == examination.ExaminationId
                                              && e.ExaminationDate == examinationDate
                                              select e).FirstOrDefault<ExaminationAssigned>();
                if (examas == null)
                {
                    examas = new ExaminationAssigned();
                    newEx = true;
                }

                examas.Patient = patient;
                examas.Examination = examination;
                examas.ExaminationDate = examinationDate;
                examas.Comments = (string)dr["Hallazgos"];
                if ((int)dr["TipoProc"] == 1)
                {
                    id = (int)dr["ExtProc"];
                    examas.BaseVisit = (from bs in ctx.BaseVisits
                                        where bs.OftRefVisita == id
                                        select bs).FirstOrDefault<BaseVisit>();
                }
                switch (examas.Examination.ExaminationType.Code)
                {
                    case "general":
                        if (newEx) ctx.Add(examas);
                        ctx.SaveChanges();
                        break;
                    case "refractometry":
                        Refractometry refra;    
                        if (newEx)
                            refra = new Refractometry();
                        else
                            refra = (Refractometry)examas;
                        refra.Patient = examas.Patient;
                        refra.Examination = examas.Examination;
                        refra.ExaminationDate = examas.ExaminationDate;
                        refra.BaseVisit = examas.BaseVisit;
                        refra.Comments = examas.Comments;
                        id = (int)dr["ExtExEs"];
                        ProcessRefractometry(id, refra, con, ctx);
                        if (newEx) ctx.Add(refra);
                        ctx.SaveChanges();
                        break;
                    case "paquimetry":
                        Paquimetry paq;
                        if (newEx)
                            paq = new Paquimetry();
                        else
                            paq = (Paquimetry)examas;
                        paq.Patient = examas.Patient;
                        paq.Examination = examas.Examination;
                        paq.ExaminationDate = examas.ExaminationDate;
                        paq.BaseVisit = examas.BaseVisit;
                        paq.Comments = examas.Comments;
                        id = (int)dr["ExtExEs"];
                        ProcessPaquimetry(id, paq, con, ctx);
                        if (newEx) ctx.Add(paq);
                        ctx.SaveChanges();
                        break;
                    case "biometry":
                        Biometry bio;
                        if (newEx)
                            bio = new Biometry();
                        else
                            bio = (Biometry)examas;
                        bio.Patient = examas.Patient;
                        bio.Examination = examas.Examination;
                        bio.ExaminationDate = examas.ExaminationDate;
                        bio.BaseVisit = examas.BaseVisit;
                        bio.Comments = examas.Comments;
                        if (newEx) ctx.Add(bio);
                        ctx.SaveChanges();
                        break;
                    case "topography":
                        Topography top;
                        if (newEx)
                            top = new Topography();
                        else
                            top = (Topography)examas;
                        top.Patient = examas.Patient;
                        top.Examination = examas.Examination;
                        top.ExaminationDate = examas.ExaminationDate;
                        top.BaseVisit = examas.BaseVisit;
                        top.Comments = examas.Comments;
                        if (newEx) ctx.Add(top);
                        ctx.SaveChanges();
                        break;
                }
            }
        }