Пример #1
0
        static void Main(string[] args)
        {
            var     connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectToPostgreSql"].ConnectionString;
            Patient patient          = new Patient
            {
                FirstName   = "Венедикт",
                MiddleName  = "Альбертович",
                LastName    = "Слабоумов",
                CreatedDate = DateTime.Now,
                Age         = 32,
                Gender      = Gender.Male,
                Id          = 2,
                //SoftDeletedDate = DateTime.Now
            };

            patient.MiddleName = "АВДОСИЙ";
            patient.Age        = 53;
            PatientsService patientsService = new PatientsService(connectionString);

            //patientsService.Add(patient);
            //patientsService.Update(patient);
            patientsService.Delete(1);

            Console.ReadKey();
        }
 async Task OnDeletePatient()
 {
     await ExecuteAsync(async() =>
     {
         await PatientsService.DeleteAsync(Patient.Id);
         await Navigation.PopAsync();
     });
 }
 async Task OnUpdatePatient()
 {
     await ExecuteAsync(async() =>
     {
         Patient.DoctorId = DoctorSelected.Id;
         await PatientsService.UpdateAsync(Patient);
         await Navigation.PopAsync();
     });
 }
 public override async Task InitAsync()
 {
     await ExecuteAsync(async() =>
     {
         Patient        = await PatientsService.GetByIdAsync(id);
         Doctors        = new ObservableCollection <Doctor>(await DoctorsService.GetAllAsync());
         DoctorSelected = Patient.Doctor;
     });
 }
 async Task OnAddNewPatient()
 {
     await ExecuteAsync(async() =>
     {
         Patient.PatientId = InitialDataProviderService.GetPatientId(10);
         Patient.DoctorId  = DoctorSelected.Id;
         await PatientsService.AddAsync(Patient);
         await Navigation.PopAsync();
     });
 }
        public PatientsServiceTests()
        {
            this.list        = new List <Patient>();
            this.listOfUsers = new List <ApplicationUser>();

            var mockRepo       = new Mock <IDeletableEntityRepository <Patient> >();
            var mockRepoOfUser = new Mock <IDeletableEntityRepository <ApplicationUser> >();

            mockRepo.Setup(x => x.All()).Returns(this.list.AsQueryable());
            mockRepo.Setup(x => x.AllAsNoTracking()).Returns(this.list.AsQueryable());
            mockRepo.Setup(x => x.AddAsync(It.IsAny <Patient>())).Callback((Patient patient) => this.list.Add(patient));

            mockRepoOfUser.Setup(x => x.All()).Returns(this.listOfUsers.AsQueryable());
            mockRepoOfUser.Setup(x => x.AddAsync(It.IsAny <ApplicationUser>())).Callback((ApplicationUser user) => this.listOfUsers.Add(user));

            AutoMapperConfig.RegisterMappings(
                typeof(PatientViewModel).GetTypeInfo().Assembly);

            var service = new PatientsService(mockRepo.Object);

            this.patientsService = service;
        }
Пример #7
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);
        }
Пример #8
0
        public static Task Seed(PatientsService patientsService, AppointmentsService appointmentService,
                                ILoggerFactory loggerFactory)
        {
            var logger = loggerFactory.CreateLogger <DataContextSeed>();

            try
            {
                // seed patients
                for (int i = 1; i <= 5; i++)
                {
                    var patient = new Patient()
                    {
                        FirstName   = "Patient First" + i,
                        LastName    = "Patient Last" + i,
                        DateOfBirth = DateTime.Now.AddYears(i * -10)
                    };
                    patientsService.Create(patient);
                }

                for (int i = 1; i <= 5; i++)
                {
                    var appointment = new Appointment()
                    {
                        PatientId       = i,
                        AppointmentTime = DateTime.Now.AddDays(i * 5).AddHours(i * 2),
                        Notes           = "Give patient instructions on how to use prescribed medications."
                    };
                    appointmentService.Create(appointment);
                }
            }
            catch (Exception ex)
            {
                //var logger = loggerFactory.CreateLogger<DataContextSeed>();
                logger.LogError(ex, "An error occured during data seeding");
            }

            return(Task.FromResult(0));
        }
        async Task LoadPatients()
        {
            var patients = await PatientsService.GetAllAsync();

            Patients = new ObservableCollection <PatientItemViewModel>(patients?.Select(p => new PatientItemViewModel(p)));
        }
Пример #10
0
 public PatientsController(PatientsService patientsService, IMapper mapper)
 {
     _patientsService = patientsService;
     _mapper          = mapper;
 }