public ActionResult Details(int id)
        {
            var db      = new PatientsDbContext();
            var patient = db.Patients.Where(c => c.Id == id)
                          .Select(c => new PatientsDetailsModel
            {
                Name      = c.Name,
                Age       = c.Age,
                Gender    = c.Gender,
                Condition = c.Condition,
                Status    = c.Status,
                Room      = c.Room,
                DoctorId  = c.DoctorId,
                ImagePath = c.ImagePath,
                Doctor    = c.Doctor.FullName,
                Id        = c.Id
            })
                          .FirstOrDefault();

            if (patient == null)
            {
                return(HttpNotFound());
            }
            return(View(patient));
        }
        public ActionResult Edit(int id)
        {
            using (var db = new PatientsDbContext())
            {
                var patient = db.Patients.Find(id);

                if (patient == null || !IsAuthorizedToEdit(patient))
                {
                    return(HttpNotFound());
                }

                var patientEditModel = new PatientsEditModel
                {
                    Id        = patient.Id,
                    Age       = patient.Age,
                    Name      = patient.Name,
                    Gender    = patient.Gender,
                    Condition = patient.Condition,
                    Status    = patient.Status,
                    Room      = patient.Room,
                    ImagePath = patient.ImagePath
                };
                return(View(patientEditModel));
            }
        }
 public PatientsService(IStorageHandler storageHandler, IMapper mapper, IOptions <Settings> settings, PatientsDbContext dbContext)
 {
     _mapper         = mapper;
     _dbContext      = dbContext;
     _storageHandler = storageHandler;
     _settings       = settings.Value.AppSettings;
 }
Exemplo n.º 4
0
        public static void Seed()
        {
            var patients = PatientsDbContext.Open();
            var exists   = patients.AsQueryable().Where(p => p.Name == "Scott").Any();

            if (!exists)
            {
                var newPatients = new List <Patient>()
                {
                    new Patient
                    {
                        Name     = "Allan",
                        Ailments = new List <Ailment>()
                        {
                            new Ailment {
                                Name = "Crazy Ailment 1 "
                            }
                        },
                        Medications = new List <Medication> {
                            new Medication {
                                Name = "Crazy Medicament 1", Doses = 1
                            }
                        }
                    },
                    new Patient
                    {
                        Name     = "Scott",
                        Ailments = new List <Ailment>()
                        {
                            new Ailment {
                                Name = "Crazy Ailment 2"
                            }
                        },
                        Medications = new List <Medication> {
                            new Medication {
                                Name = "Crazy Medicament 2", Doses = 1
                            }
                        }
                    },
                    new Patient
                    {
                        Name     = "Allen",
                        Ailments = new List <Ailment>()
                        {
                            new Ailment {
                                Name = "Crazy Ailment 3"
                            }
                        },
                        Medications = new List <Medication> {
                            new Medication {
                                Name = "Crazy Medicament 3", Doses = 1
                            }
                        }
                    }
                };

                patients.InsertMany(newPatients);
            }
        }
        public ActionResult Delete(int id)
        {
            using (var db = new PatientsDbContext())
            {
                var patient = db.Patients.Find(id);



                if (patient == null || !IsAuthorizedToEdit(patient))
                {
                    return(HttpNotFound());
                }
                return(View(patient));
            }
        }
Exemplo n.º 6
0
        public ActionResult Index()
        {
            var db = new PatientsDbContext();

            var patients = db.Patients
                           .OrderByDescending(c => c.Id)
                           .Take(3)
                           .Select(c => new PatientsListingModel
            {
                Id        = c.Id,
                ImagePath = c.ImagePath
            })
                           .ToList();

            return(View(patients));
        }
        public ActionResult Edit(PatientsEditModel model, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                using (var db = new PatientsDbContext())
                {
                    var patient = db.Patients.Find(model.Id);

                    if (patient == null || !IsAuthorizedToEdit(patient))
                    {
                        return(HttpNotFound());
                    }

                    patient.Id        = model.Id;
                    patient.Name      = model.Name;
                    patient.ImagePath = model.ImagePath;
                    patient.Room      = model.Room;
                    patient.Age       = model.Age;
                    patient.Status    = model.Status;
                    patient.Gender    = model.Gender;
                    patient.Condition = model.Condition;

                    if (image != null)
                    {
                        var allowedContentTypes = new[] { "image/jpeg", "image/jpg", "image/png" };

                        if (allowedContentTypes.Contains(image.ContentType))
                        {
                            var imagesPath = "/Content/Images/";

                            var fileName     = image.FileName;
                            var uploadPath   = imagesPath + fileName;
                            var physicalPath = Server.MapPath(uploadPath);

                            image.SaveAs(physicalPath);
                            patient.ImagePath = uploadPath;
                        }
                    }

                    db.SaveChanges();
                }

                return(RedirectToAction("Details", new { id = model.Id }));
            }
            return(View(model));
        }
        public ActionResult AllPatients()
        {
            var db            = new PatientsDbContext();
            var patientsQuery = db.Patients.AsQueryable();


            var patients = db.Patients
                           .Select(c => new PatientsListingModel
            {
                Id        = c.Id,
                Name      = c.Name,
                ImagePath = c.ImagePath
            })
                           .ToList();

            return(View(patients));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            using (var db = new PatientsDbContext())
            {
                var patient = db.Patients.Find(id);



                if (patient == null || !IsAuthorizedToEdit(patient))
                {
                    return(HttpNotFound());
                }
                db.Patients.Remove(patient);
                db.SaveChanges();
                return(RedirectToAction("AllPatients"));
            }
        }
Exemplo n.º 10
0
        public ActionResult MyPatients()
        {
            var db       = new PatientsDbContext();
            var userId   = this.User.Identity.GetUserId();
            var patients = db.Patients
                           .OrderByDescending(c => c.Id)
                           .Where(c => c.DoctorId == userId)
                           .Select(c => new MyPatientsModel
            {
                Name      = c.Name,
                Condition = c.Condition,
                Room      = c.Room,
                Id        = c.Id
            }
                                   )
                           .ToList();

            return(View(patients));
        }
        public ActionResult Create(CreateNewPatient model, HttpPostedFileBase image)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var doctorId = this.User.Identity.GetUserId();
                var patient  = new Patient
                {
                    Name      = model.Name,
                    Age       = model.Age,
                    Gender    = model.Gender,
                    Condition = model.Condition,
                    Status    = model.Status,
                    Room      = model.Room,
                    DoctorId  = doctorId,
                    Id        = model.Id
                };

                if (image != null)
                {
                    var allowedContentTypes = new[] { "image/jpeg", "image/jpg", "image/png" };

                    if (allowedContentTypes.Contains(image.ContentType))
                    {
                        var imagesPath = "/Content/Images/";

                        var fileName     = image.FileName;
                        var uploadPath   = imagesPath + fileName;
                        var physicalPath = Server.MapPath(uploadPath);

                        image.SaveAs(physicalPath);
                        patient.ImagePath = uploadPath;
                    }
                }
                var db = new PatientsDbContext();
                db.Patients.Add(patient);
                db.SaveChanges();

                return(RedirectToAction("Details", new { id = patient.Id }));
            }
            return(View(model));
        }
Exemplo n.º 12
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <PatientsDbContext>()
                          .UseInMemoryDatabase(databaseName: "PatientsDatabase")
                          .Options;

            _memoryDbContext = new PatientsDbContext(options);
            _memoryDbContext.Patients.Add(new PatientRecord()
            {
                Id = Guid.NewGuid()
            });
            _memoryDbContext.SaveChanges();
            _storageHandlerMock = new Mock <IStorageHandler>();
            _mockSettings       = new Mock <IOptions <Settings> >();
            _mapperMock         = new Mock <IMapper>();
            _mockSettings.Setup(x => x.Value).Returns(new Settings()
            {
                AppSettings = new AppSettings()
            });
            _storageHandlerMock.Setup(x => x.StoreFile(It.IsAny <Stream>())).Returns("path");
            _patientService = new PatientsService(_storageHandlerMock.Object, _mapperMock.Object, _mockSettings.Object, _memoryDbContext);
        }
Exemplo n.º 13
0
 public PacientesService(PatientsDbContext context)
 {
     _context = context;
 }
 public ReferenciasService(PatientsDbContext patientsDbContext)
 {
     _patientsDbContext = patientsDbContext;
 }
 public FacturasServices(PatientsDbContext pacientesDbContext)
 {
     _pacientesDbContext = pacientesDbContext;
 }
Exemplo n.º 16
0
 public CalendarioServices(PatientsDbContext context)
 {
     _context = context;
 }
Exemplo n.º 17
0
 public PatientsController()
 {
     _patients = PatientsDbContext.Open();
 }