protected void Page_Load(object sender, EventArgs e) { // First control the type of parent page if (Request.QueryString["InsuranceID"] != null) { insuranceId = Int32.Parse(Request.QueryString["InsuranceId"]); ins = CntAriCli.GetInsurance(insuranceId, ctx); caller = "ins"; // Called by Insurance } }
public static void ImportAssurancePolicies(OleDbConnection con, AriClinicContext ctx) { //(0) Borrar las aseguradoras y pólizas previas. ctx.Delete(ctx.Policies); ctx.Delete(ctx.Insurances); ctx.Delete(ctx.InsuranceServices); ctx.SaveChanges(); //(1) Por defecto creamos una aseguradora que es la clínica de Valencia. Insurance insurance = (from i in ctx.Insurances where i.Name == "MIESTETIC (Valencia)" select i).FirstOrDefault<Insurance>(); if (insurance == null) { insurance = new Insurance(); insurance.Name = "MIESTETIC (Valencia)"; insurance.Internal = true; ctx.Add(insurance); } //(2) Ahora leemos, de nuevo, todos los tipos de servicio porque en OFT // ellos llevan los importes y en nuestro caso son los Insurance services string sql = "SELECT * FROM ServMed"; cmd = new OleDbCommand(sql, con); da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "ConServicios"); int nreg = ds.Tables["ConServicios"].Rows.Count; int reg = 0; InsuranceService ins = null; foreach (DataRow dr in ds.Tables["ConServicios"].Rows) { reg++; Console.WriteLine("Servicions {0:#####0} de {1:#####0} {2}", reg, nreg, "SERVICIO"); int id = (int)dr["IdServMed"]; ins = (from i in ctx.InsuranceServices where i.OftId == id select i).FirstOrDefault<InsuranceService>(); if (ins == null) { ins = new InsuranceService(); ctx.Add(ins); } ins.Insurance = insurance; ins.Service = (from s in ctx.Services where s.OftId == id select s).FirstOrDefault<Service>(); ins.Price = (decimal)dr["Importe"]; } //(3) por último asignamos una póliza a todos los clientes que tenemos dados de alta. foreach (Customer cus in ctx.Customers) { Customer localCus = cus; Policy pol = (from p in ctx.Policies where p.Customer.PersonId == localCus.PersonId && p.Insurance.InsuranceId == insurance.InsuranceId select p).FirstOrDefault<Policy>(); if (pol == null) { pol = new Policy(); pol.Customer = localCus; pol.Insurance = insurance; ctx.Add(pol); } } ctx.SaveChanges(); }
public static IList<Patient> GetPatients(Insurance insurance, AriClinicContext ctx) { var rs = from p in ctx.Policies where p.Insurance.InsuranceId == insurance.InsuranceId select p; IList<Patient> lp = new List<Patient>(); foreach (Policy p in rs) { Patient pat = (from pt in ctx.Patients where pt.Customer.PersonId == p.Customer.PersonId select pt).FirstOrDefault<Patient>(); if (pat != null) lp.Add(pat); } return lp; }
public static InsuranceService GetInsuranceService(int id, Insurance insurance, AriClinicContext ctx) { return (from i in ctx.InsuranceServices where i.InsuranceServiceId == id && i.Insurance.InsuranceId == insurance.InsuranceId select i).FirstOrDefault<InsuranceService>(); }