public ActionResult ConvertMedicalPrescription(int idmedicalPrescription, medicalPrescription m)
        {
            Appointment a = db.Appointments.Where(u => u.idmedicalPrescription == idmedicalPrescription).FirstOrDefault();

            m = db.medicalPrescriptions.Find(idmedicalPrescription);
            Patient p  = db.Patients.Find(a.cardNumber);
            Medic   mm = db.Medics.Find(p.idMedic);

            try
            {
                var exportFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                var exportFile   = System.IO.Path.Combine(exportFolder, p.firstName + " " + p.lastName + "." + a.cardNumber + "." + ".pdf");

                using (var writer = new PdfWriter(exportFile))
                {
                    using (var pdf = new PdfDocument(writer))
                    {
                        var       doc  = new Document(pdf);
                        Table     t    = new Table(2);
                        Paragraph para = new Paragraph("Medical prescription");
                        para.SetBold();
                        para.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        doc.Add(para);

                        doc.Add(new Paragraph(""));
                        doc.Add(new Paragraph("Patient first name: " + p.firstName));
                        doc.Add(new Paragraph("Patient last name: " + p.lastName));
                        doc.Add(new Paragraph("Card number: " + p.cardNumber));
                        doc.Add(new Paragraph("Birth date: " + p.birthDate.ToString().Split(' ')[0]));

                        t.AddCell("Medic name");
                        t.AddCell(mm.lastName + " " + mm.firstName);
                        t.AddCell("Appointment date");
                        t.AddCell("" + a.Date.ToString().Split(' ')[0]);
                        t.AddCell("DIAGNOSTIC");
                        t.AddCell(m.Diagnostic);
                        t.AddCell("MEDICATION");
                        t.AddCell(m.Medication);
                        t.AddCell("FREE");
                        if (m.Free == true)
                        {
                            t.AddCell("YES");
                        }
                        else
                        {
                            t.AddCell("NO");
                        }
                        doc.Add(t);
                    }
                }
                // TODO: Add insert logic here

                return(RedirectToAction("AppointmentIndex", "Appointment"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult MedicalPrescriptionEdit(int id, medicalPrescription medicalPrescription)
        {
            db.Entry(medicalPrescription).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            Appointment   a = db.Appointments.Where(u => u.idmedicalPrescription == id).FirstOrDefault();
            Patient       p = db.Patients.Find(a.cardNumber);
            medicalRecord m = db.medicalRecords.Find(p.idmedicalRecords);

            m.previousDiseases = m.previousDiseases + ", " + medicalPrescription.Diagnostic;
            m.date             = a.Date;
            db.Entry(m).State  = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            TempData["Success"] = "Changes successfully applied to your Medical Prescription!";
            return(RedirectToAction("AppointmentIndex", "Appointment"));
        }
Beispiel #3
0
        public ActionResult MedicalPrescriptionDelete(int id, medicalPrescription medicalPrescription)
        {
            try
            {
                db.medicalPrescriptions.Remove(db.medicalPrescriptions.Find(id));
                db.SaveChanges();
                TempData["Success"] = "Medical Prescription successfully deleted!";
                // TODO: Add delete logic here

                return(RedirectToAction("MedicalPrescriptionIndex"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #4
0
 public ActionResult MedicalPrescriptionCreate(medicalPrescription medicalPrescription)
 {
     if (ModelState.IsValid)
     {
         int ok = 1;
         if (ok == 1)
         {
             medicalPrescription.idmedicalPrescription = 1;
             db.medicalPrescriptions.Add(medicalPrescription);
             db.SaveChanges();
             TempData["Success"] = "Medical Prescription successfully submitted!";
             return(RedirectToAction("AppointmentIndex", "Appointment"));
         }
         else
         {
             TempData["Warning"] = "Medical Prescription already exists associated to this pacient!";
             return(RedirectToAction("AppointmentIndex", "Appointment"));
         }
     }
     return(View());
 }
        public ActionResult AppointmentCreate(Appointment appointment)
        {
            if (ModelState.IsValid)
            {
                AppointmentComparer cmp = new AppointmentComparer();
                int ok = 1;
                if (db.Appointments.Count() > 0)
                {
                    foreach (var a in db.Appointments)
                    {
                        if (cmp.Equals(a, appointment))
                        {
                            ok = 0;
                        }
                    }
                }
                if (ok == 1)
                {
                    appointment.idMedic = 1;
                    medicalPrescription m = new medicalPrescription();
                    m.Diagnostic = "To be completed";
                    m.Medication = "To be completed";
                    m.Free       = true;
                    db.medicalPrescriptions.Add(m);
                    db.SaveChanges();
                    appointment.idmedicalPrescription = db.medicalPrescriptions.ToList().Last().idmedicalPrescription;
                    db.Appointments.Add(appointment);
                    db.SaveChanges();
                    TempData["Success"] = "Appointment successfully submitted!";
                    return(RedirectToAction("AppointmentIndex"));
                }
                else
                {
                    String[] availableHours = new String[] { "9:00", "9:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30" };

                    TimeSpan time = (TimeSpan)appointment.Time;
                    String[] notAvailableHours = new String[20];
                    int      k = 0;
                    if (db.Appointments.Count() > 0)
                    {
                        foreach (var a in db.Appointments)
                        {
                            if (a.Date.Equals(appointment.Date))
                            {
                                TimeSpan time1 = (TimeSpan)a.Time;
                                notAvailableHours[k++] = time1.ToString().Split(':')[0] + ":" + time1.ToString().Split(':')[1];
                            }
                        }
                    }
                    String content = "";
                    int    ok1;
                    for (int i = 0; i < availableHours.Length; i++)
                    {
                        ok1 = 1;
                        for (int j = 0; j < k; j++)
                        {
                            if (notAvailableHours[j].Equals(availableHours[i]))
                            {
                                ok1 = 0;
                            }
                        }
                        if (ok1 == 1)
                        {
                            content = content + availableHours[i] + " | ";
                        }
                    }
                    TempData["Warning"] = "Appointment already booked! Times available this day are: " + content;
                }
            }
            return(View());
        }