public async Task <ActionResult <IEnumerable <object> > > PatientHistory(decimal patientId, int?limit, int?skip) { if (!await _authorizationService.CanUserAccessPatientData(patientId, this)) { return(Unauthorized(UnauthorizedEmptyJsonResult)); } List <object> patientsHistory = new List <object>(); patientsHistory.AddRange(await _repository.GetAll(patientId)); patientsHistory.AddRange(await _oldMedicinesHistoryRepository.GetAll(patientId)); return(Ok(PaginationService <object> .SplitAndLimitIEnumerable(skip, limit, patientsHistory))); }
public async Task <ActionResult <IEnumerable <object> > > AllByPatientId(decimal patientId, int?limit, int?skip) { var illnesshistoryList = _repository.GetAllWithAdditionalInfo(patientId); if (illnesshistoryList == null) { return(NotFound(NotFoundEmptyJsonResult)); } if (!await _authorizationService.CanUserAccessPatientData(patientId, this)) { return(Unauthorized(UnauthorizedEmptyJsonResult)); } var enumerableHistory = PaginationService <object> .SplitAndLimitIEnumerable(skip, limit, illnesshistoryList); return(enumerableHistory.ToList()); }
public async Task <ActionResult <IEnumerable <object> > > PossibleAppointments(decimal?cityId, decimal?specId, decimal?doctorId, DateTime?startHour, DateTime?endHour, DateTime?startDate, DateTime?endDate, int?limit, int?skip) { //TODO: może przenieść do walidacji w jakiś sposób? if ((cityId.HasValue && !specId.HasValue && doctorId.HasValue) || (cityId.HasValue && !specId.HasValue && !doctorId.HasValue) || (!cityId.HasValue && specId.HasValue && doctorId.HasValue) || (!cityId.HasValue && !specId.HasValue && !doctorId.HasValue)) { return(BadRequest(BadRequestJsonResult("Niepoprawne kryteria wyszukiwania"))); } IEnumerable <Reservation> allReservations = _repository.AllReservationsForPossibleAppointments(cityId, specId, doctorId, startDate, endDate); IEnumerable <Workinghours> workinghours = _workHoursRepository.GetAllFutureWorkHours(cityId, specId, doctorId, startDate, endDate); Speciality doctorSpeciality; if (specId.HasValue) { doctorSpeciality = _specialitiesRepository.GetByID(specId.Value); } else { doctorSpeciality = (await _doctorsRepository.GetByIdWithSpecialization(doctorId.Value)).Speciality; } var slotList = CalcPossibleAppointments(allReservations, workinghours, doctorSpeciality); if (startDate.HasValue && endDate.HasValue) { slotList = slotList.Where(x => x.Start.Date >= startDate.Value.Date && x.End.Date <= endDate.Value.Date).ToList(); } if (startHour.HasValue && endHour.HasValue) { slotList = slotList.Where(x => x.Start.TimeOfDay >= startHour.Value.TimeOfDay && x.End.TimeOfDay <= endHour.Value.TimeOfDay).ToList(); } slotList = PaginationService <SlotDTO> .SplitAndLimitIEnumerable(skip, limit, slotList); return(Ok(slotList)); }
public async Task <ActionResult <IEnumerable <object> > > PatientHistory(decimal patientId, int?limit, int?skip) { if (!await _authorizationService.CanUserAccessPatientData(patientId, this)) { return(Unauthorized(UnauthorizedEmptyJsonResult)); } var illnessHistory = await _repository.PatientHistory(patientId); var oldillnesshistory = await _oldIllnessesHistoryRepository.GetAllSpecificData(patientId); List <object> patientsHistory = new List <object>(); patientsHistory.AddRange(illnessHistory); patientsHistory.AddRange(oldillnesshistory); IEnumerable <object> enumerableHistory = patientsHistory; enumerableHistory = PaginationService <object> .SplitAndLimitIEnumerable(skip, limit, enumerableHistory); return(Ok(enumerableHistory)); }