public ActionResult MedicalRecordEdit(int id, medicalRecord medicalRecord)
 {
     db.Entry(medicalRecord).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     TempData["Success"] = "Changes successfully applied to your Medical Record!";
     return(RedirectToAction("PatientIndex", "Patient"));
 }
        public ActionResult ConvertMedicalRecord(int idmedicalRecord, medicalRecord m)
        {
            Patient p  = db.Patients.Where(u => u.idmedicalRecords == idmedicalRecord).FirstOrDefault();
            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 + " medical record" + ".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 record");
                        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("Last control date");
                        t.AddCell(m.date.ToString().Split(' ')[0]);
                        t.AddCell("Disease and previous disease");
                        t.AddCell("" + m.diseases + " " + m.previousDiseases);
                        t.AddCell("Medication");
                        t.AddCell(m.meds);
                        t.AddCell("Allergies");
                        t.AddCell(m.allergies);
                        t.AddCell("Other information");
                        t.AddCell(m.info);
                        doc.Add(t);
                    }
                }
                // TODO: Add insert logic here

                return(RedirectToAction("AppointmentIndex", "Appointment"));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult MedicalRecordDelete(int id, medicalRecord medicalRecord)
 {
     try
     {
         db.medicalRecords.Remove(db.medicalRecords.Find(id));
         db.SaveChanges();
         TempData["Success"] = "Medical Record successfully deleted!";
         return(RedirectToAction("MedicalRecordIndex"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 4
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"));
        }
 public ActionResult MedicalRecordCreate(medicalRecord medicalRecord)
 {
     if (ModelState.IsValid)
     {
         int ok = 1;
         if (ok == 1)
         {
             medicalRecord.idmedicalRecords = 1;
             db.medicalRecords.Add(medicalRecord);
             db.SaveChanges();
             TempData["Success"] = "Medical Record successfully submitted!";
             return(RedirectToAction("PatientIndex", "Patient"));
         }
         else
         {
             TempData["Warning"] = "Medical Record already exists associated to this pacient!";
             return(RedirectToAction("PatientIndex", "Patient"));
         }
     }
     return(View());
 }
Esempio n. 6
0
 public ActionResult PatientCreate(Patient patient)
 {
     if (ModelState.IsValid)
     {
         PatientComparer cmp = new PatientComparer();
         int             ok  = 1;
         if (db.Patients.Count() > 0)
         {
             foreach (var a in db.Patients)
             {
                 if (cmp.Equals(a, patient))
                 {
                     ok = 0;
                 }
             }
         }
         if (ok == 1)
         {
             patient.idMedic = 1;
             medicalRecord m = new medicalRecord();
             db.medicalRecords.Add(m);
             db.SaveChanges();
             patient.idmedicalRecords = db.medicalRecords.ToList().Last().idmedicalRecords;
             db.Patients.Add(patient);
             db.SaveChanges();
             TempData["Success"] = "Patient successfully added to the database!";
             return(RedirectToAction("PatientIndex"));
         }
         else
         {
             TempData["Warning"] = "Patient already exists in the database!";
             return(RedirectToAction("PatientCreate"));
         }
     }
     return(View());
 }