Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var service = new ClinicService();
            var model   = service.GetClinics();

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task GetClinicById_WithInvalidId_ShouldReturnException()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);
            var clinic    = new Clinic
            {
                Id   = 20,
                Name = "Clinic 20"
            };
            var clinic2 = new Clinic
            {
                Id   = 21,
                Name = "Clinic 21"
            };

            dbContext.Clinics.Add(clinic);
            dbContext.Clinics.Add(clinic2);
            await dbContext.SaveChangesAsync();

            var repository = new DbRepository <Clinic>(dbContext);
            var service    = new ClinicService(repository);

            Assert.Throws <ArgumentException>(() => service.GetClinicById(22));
        }
Ejemplo n.º 3
0
        public void GetClinicById_WithValidId_ShouldReturnClinic()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);
            var clinic    = new Clinic
            {
                Id   = 10,
                Name = "Clinic 10"
            };
            var clinic2 = new Clinic
            {
                Id   = 11,
                Name = "clinic 11"
            };

            dbContext.Clinics.Add(clinic);
            dbContext.Clinics.Add(clinic2);
            dbContext.SaveChanges();

            var repository = new DbRepository <Clinic>(dbContext);
            var service    = new ClinicService(repository);
            var result     = service.GetClinicById(11);

            Assert.Same(clinic2, result);
        }
Ejemplo n.º 4
0
        public ActionResult Details(int id)
        {
            var service = new ClinicService();
            var model   = service.GetClinicById(id);

            return(View(model));
        }
Ejemplo n.º 5
0
        public async Task CanAddPatient()
        {
            //Arrange
            var createPatientVm = new CreatePatientVm {
                Name = "PatientX",
                Age  = 13
            };
            var dbContext = GetDbContext(nameof(CanAddPatient));
            var sut       = new ClinicService(dbContext);

            //Action
            await sut.AddPatientAsync(createPatientVm);

            //Assert
            var eavEntity = await dbContext.Entities
                            .AsNoTracking()
                            .WithAttributes()
                            .SingleAsync();

            eavEntity.Should().NotBeNull();
            eavEntity.EntityType.Should().Be(EntityType.Patient);

            eavEntity.AttributeValues.Should()
            .NotBeNullOrEmpty()
            .And.HaveCount(2);

            var name = eavEntity.AttributeValues.Single(x => x.AttributeType == AttributeType.PatientName).Value;

            name.Should().Be(createPatientVm.Name);

            var age = eavEntity.AttributeValues.Single(x => x.AttributeType == AttributeType.PatientAge).Value;

            age.Should().Be(createPatientVm.Age.ToString());
        }
Ejemplo n.º 6
0
        public ActionResult DeleteClinic(int id)
        {
            var service = new ClinicService();

            service.DeleteClinic(id);
            TempData["SaveResult"] = "Clinic successfully deleted.";
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public void GetClinicById_WithEmptyClinicSet_ShouldReturnException()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);

            var repository = new DbRepository <Clinic>(dbContext);
            var service    = new ClinicService(repository);

            Assert.Throws <ArgumentException>(() => service.GetClinicById(7));
        }
        public ClinicControllerShould()
        {
            var settings = new AppSettings()
            {
                InventoryApiUrl = "https://localhost:5001"
            };
            IOptions <AppSettings> appSettingsOptions = Options.Create(settings);
            var options = new Mock <IOptionsSnapshot <AppSettings> >();

            options.Setup(o => o.Value).Returns(settings);
            var logger        = new Mock <ILogger <ClinicController> >();
            var clinicService = new ClinicService(options.Object);

            sut = new ClinicController(clinicService, logger.Object);
        }
Ejemplo n.º 9
0
        public ActionResult Create(ClinicCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new ClinicService();

            if (service.CreateClinic(model))
            {
                TempData["SaveResult"] = "Clinic added to directory.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Failed to create Clinic.");
            return(View(model));
        }
Ejemplo n.º 10
0
        //GET: Edit
        public ActionResult Edit(int id)
        {
            var service = new ClinicService();
            var detail  = service.GetClinicById(id);
            var model   = new ClinicEdit
            {
                ClinicId = detail.ClinicId,
                Name     = detail.Name,
                Address  = detail.Address,
                City     = detail.City,
                State    = detail.State,
                Zip      = detail.Zip,
                Phone    = detail.Phone
            };

            return(View(model));
        }
Ejemplo n.º 11
0
        public void GetAllActive_WithInvalidClinics_ShouldReturnEmptyClinicsCollection()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);

            var clinic = new Clinic
            {
                Id       = 10,
                IsActive = true,
                Name     = "Clinic 1",
            };
            var dentist = new DentHubUser
            {
                Id       = "1",
                IsActive = false,
                ClinicId = 1
            };

            var clinic2 = new Clinic
            {
                Id       = 2,
                IsActive = false,
                Name     = "Clinic 2",
            };
            var dentist2 = new DentHubUser
            {
                Id       = "2",
                IsActive = true,
                ClinicId = 2
            };

            dbContext.Clinics.Add(clinic);
            dbContext.Clinics.Add(clinic2);
            dbContext.DentHubUsers.Add(dentist);
            dbContext.DentHubUsers.Add(dentist2);
            dbContext.SaveChanges();

            var repository = new DbRepository <Clinic>(dbContext);
            var service    = new ClinicService(repository);
            var result     = service.GetAllActive();

            Assert.Empty(result);
        }
Ejemplo n.º 12
0
        public ActionResult Edit(int id, ClinicEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.ClinicId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var service = new ClinicService();

            if (service.UpdateClinic(model))
            {
                TempData["SaveResult"] = "Clinic information successfully updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Clinic could not be updated.");
            return(View(model));
        }
        public void SetUp()
        {
            // Boilerplate
            _mockRepository = new MockRepository(MockBehavior.Strict);
            _fixture        = new Fixture();

            //Prevent fixture from generating circular references
            _fixture.Behaviors.Add(new OmitOnRecursionBehavior(1));

            // Mock setup
            _context   = new PatientBookingContext(new DbContextOptionsBuilder <PatientBookingContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
            _validator = _mockRepository.Create <IAddClinicRequestValidator>();

            // Mock default
            SetupMockDefaults();

            // Sut instantiation
            _clinicService = new ClinicService(
                _context,
                _validator.Object
                );
        }
Ejemplo n.º 14
0
 public ServiceController(ClinicService clinicService, IMapper mapper) : base(mapper)
 {
     _clinicService = clinicService;
 }
Ejemplo n.º 15
0
        //-------------------------------- Hospital Services
        public string GetHospital(long id)
        {
            IClinicService clinicService = new ClinicService();

            return(clinicService.GetHospital(id));
        }
Ejemplo n.º 16
0
        public string GetAllHospitals()
        {
            IClinicService clinicService = new ClinicService();

            return(clinicService.GetAllHospitals());
        }
Ejemplo n.º 17
0
 public void Setup()
 {
     _assertHelper  = new AssertHelper <Clinic>();
     _unitOfWork    = new Mock <IUnitOfWork>();
     _clinicService = new ClinicService(_unitOfWork.Object);
 }
Ejemplo n.º 18
0
        public async Task CanGetAllPatients()
        {
            //Arrange
            var          dbContext       = GetDbContext(nameof(CanAddPatient));
            var          patientId       = Guid.NewGuid();
            const string patientName     = "Jon Snow";
            const string patientAge      = "24";
            var          patientEntities = new[] {
                new EavEntity {
                    Id              = patientId,
                    EntityType      = EntityType.Patient,
                    AttributeValues = new List <AttributeValueEntity> {
                        new AttributeValueEntity {
                            Id            = Guid.NewGuid(),
                            AttributeType = AttributeType.PatientName,
                            Value         = patientName
                        },
                        new AttributeValueEntity {
                            Id            = Guid.NewGuid(),
                            AttributeType = AttributeType.PatientAge,
                            Value         = patientAge
                        }
                    }
                },
                new EavEntity {
                    Id              = Guid.NewGuid(),
                    EntityType      = EntityType.Patient,
                    AttributeValues = new List <AttributeValueEntity> {
                        new AttributeValueEntity {
                            Id            = Guid.NewGuid(),
                            AttributeType = AttributeType.PatientName,
                            Value         = "123123"
                        },
                        new AttributeValueEntity {
                            Id            = Guid.NewGuid(),
                            AttributeType = AttributeType.PatientAge,
                            Value         = "12"
                        }
                    }
                }
            };

            var          operationId     = Guid.NewGuid();
            const string operationName   = "Lymphadenectomy";
            var          operationEntity = new EavEntity {
                Id              = operationId,
                EntityType      = EntityType.Operation,
                AttributeValues = new List <AttributeValueEntity> {
                    new AttributeValueEntity {
                        Id            = Guid.NewGuid(),
                        AttributeType = AttributeType.OperationName,
                        Value         = operationName
                    },
                    new AttributeValueEntity {
                        Id            = Guid.NewGuid(),
                        AttributeType = AttributeType.PatientId,
                        Value         = patientId.ToString()
                    }
                }
            };

            dbContext.Entities.AddRange(patientEntities);
            dbContext.Entities.Add(operationEntity);
            await dbContext.SaveChangesAsync();

            var sut = new ClinicService(dbContext);

            //Action
            var patients = await sut.GetAllPatientsAsync(default);
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            #region OTHER
            WorkDay work   = new WorkDay();
            WorkDay offDay = new WorkDay();
            offDay.ChangeDayToBusy();
            workDays.Add(work);
            workDays.Add(offDay);
            workDays.Add(work);
            workDays.Add(work);
            workDays.Add(work);
            #endregion

            #region DOCTORS
            Doctor d1 = new Doctor("Kuba", "Rzucidło", RandomPESEL(), SpecjalizationEnum.Cardiologist);
            Doctor d2 = new Doctor("Kasia", "Tobuk", RandomPESEL(), SpecjalizationEnum.Laryngologist);
            Doctor d3 = new Doctor("Retek", "Rydzyk", RandomPESEL(), SpecjalizationEnum.Family);

            d2.SetDoctorAvailibity(workDays);

            doctors.Add(d1);
            doctors.Add(d2);
            doctors.Add(d3);
            #endregion

            #region PATIENTS
            Adress a1 = new Adress("Kwiatowa", "Raciąż", CountryCode.PL, "09-140");

            Patient p1 = new Patient("Maciej", "Hawrzyniak", RandomPESEL(), a1);
            Patient p2 = new Patient("Marta", "Kkrawa", RandomPESEL(), a1);
            Patient p3 = new Patient("John", "Akoczny", RandomPESEL(), a1);

            patients.Add(p1);
            patients.Add(p2);
            patients.Add(p3);
            #endregion



            ClinicService clinicService = new ClinicService(patients, doctors);

            while (WorkStatus)
            {
                clinicService = RefreshClinicService();


                ShowClinicMenu();
                menuAnswer = Console.ReadLine();
                switch (menuAnswer)
                {
                case "1":
                    Console.Clear();
                    Patient patient = AddPatient();
                    patients.Add(patient);
                    break;

                case "2":
                    Console.Clear();
                    if (patients.Count > 0)
                    {
                        Console.WriteLine("Podaj PESEL pacjenta: ");
                        clinicService.RemovePatient(GetPeselFromUser());
                        patients = clinicService.GetPatients();
                    }
                    else
                    {
                        Console.WriteLine("LISTA PACJENTOW JEST PUSTA!!");
                    }

                    break;

                case "3":
                    Console.Clear();
                    Doctor doctor = AddDoctor();
                    doctors.Add(doctor);
                    break;

                case "4":
                    Console.Clear();
                    if (doctors.Count > 0)
                    {
                        Console.WriteLine("Podaj PESEL doktora: ");
                        clinicService.RemoveDoctor(GetPeselFromUser());
                        doctors = clinicService.GetDoctors();
                    }
                    else
                    {
                        Console.WriteLine("LISTA DOKTOROW JEST PUSTA!!");
                    }

                    break;

                case "5":
                    Console.Clear();
                    if (patients.Count > 0)
                    {
                        clinicService.SortPatients();
                        patients = clinicService.GetPatients();
                        Console.WriteLine("----------------");
                        Console.WriteLine("PACJENCI ZOSTALI POSORTOWANI!!!");
                        Console.WriteLine("----------------");
                    }
                    else
                    {
                        Console.WriteLine("LISTA PACJENTOW JEST PUSTA!!");
                    }
                    break;

                case "6":
                    Console.Clear();
                    clinicService.ShowPatient();
                    break;

                case "7":
                    Console.Clear();
                    Console.WriteLine("Podaj nazwisko pacjenta: ");
                    string surname = Console.ReadLine();
                    clinicService.SearchBySurname(surname);
                    break;

                case "8":
                    Console.Clear();
                    int day  = clinicService.CheackDay();
                    int hour = clinicService.CheackHour();
                    clinicService.ShowInfoAboutDoctors(day, hour);
                    break;

                case "9":
                    Console.Clear();
                    clinicService.ArrangeThePactient();
                    patients = clinicService.GetPatients();
                    doctors  = clinicService.GetDoctors();

                    break;

                case "10":
                    Console.Clear();
                    clinicService.ShowDoctors();
                    break;

                case "11":
                    Console.Clear();
                    clinicService.ShowPatientVisits();
                    break;

                case "12":

                    break;

                case "13":
                    Console.Clear();
                    WorkStatus = false;
                    break;

                default:

                    break;
                }
            }
            EndProgramInfo();
        }
Ejemplo n.º 20
0
        // Hospital Services
        public List <HospitalModel> getHospital(string id)
        {
            ClinicService clinicService = new ClinicService();

            return(clinicService.getHospital(id));
        }
Ejemplo n.º 21
0
 public ClinicController(PeoheDbContext context, ClinicService clinicService)
 {
     dbContext          = context;
     this.clinicService = clinicService;
 }
Ejemplo n.º 22
0
        public async Task CanGetPatient()
        {
            //Arrange
            var          dbContext     = GetDbContext(nameof(CanAddPatient));
            var          patientId     = Guid.NewGuid();
            const string patientName   = "Jon Snow";
            const string patientAge    = "24";
            var          patientEntity = new EavEntity {
                Id              = patientId,
                EntityType      = EntityType.Patient,
                AttributeValues = new List <AttributeValueEntity> {
                    new AttributeValueEntity {
                        Id            = Guid.NewGuid(),
                        AttributeType = AttributeType.PatientName,
                        Value         = patientName
                    },
                    new AttributeValueEntity {
                        Id            = Guid.NewGuid(),
                        AttributeType = AttributeType.PatientAge,
                        Value         = patientAge
                    }
                }
            };

            var          operationId     = Guid.NewGuid();
            const string operationName   = "Lymphadenectomy";
            var          operationEntity = new EavEntity {
                Id              = operationId,
                EntityType      = EntityType.Operation,
                AttributeValues = new List <AttributeValueEntity> {
                    new AttributeValueEntity {
                        Id            = Guid.NewGuid(),
                        AttributeType = AttributeType.OperationName,
                        Value         = operationName
                    },
                    new AttributeValueEntity {
                        Id            = Guid.NewGuid(),
                        AttributeType = AttributeType.PatientId,
                        Value         = patientId.ToString()
                    }
                }
            };

            dbContext.Entities.AddRange(patientEntity, operationEntity);
            await dbContext.SaveChangesAsync();

            var sut = new ClinicService(dbContext);

            //Action
            var patient = await sut.GetPatientAsync(patientId, default);

            //Assert
            patient.Should().NotBeNull();
            patient.Name.Should().Be(patientName);
            patient.Age.Should().Be(ushort.Parse(patientAge));

            patient.Operations.Should().NotBeNullOrEmpty();
            var operation = patient.Operations.Single();

            operation.Should().NotBeNull();
            operation.OperationId.Should().Be(operationId);
            operation.OperationName.Should().Be(operationName);
        }