private List <ReferralDto> CreateReferrals() { var referrals = new List <ReferralDto>(); ReferralDto referral1 = new ReferralDto { Id = 1, IsDeleted = false, PatientId = 1, SpecialistId = 1 }; ReferralDto referral2 = new ReferralDto { Id = 2, IsDeleted = false, PatientId = 2, SpecialistId = 2 }; referrals.Add(referral1); referrals.Add(referral2); return(referrals); }
public void Referral_dto_to_referral() { ReferralDto referral = CreateReferralDto(); Referral myReferral = HospitalApp.Adapters.ReferralAdapter.ReferralDtoToReferral(referral); myReferral.ShouldBeOfType(typeof(Referral)); }
public IActionResult Add(ReferralDto referralDto) { if (_referralService.Add(referralDto) == null) { return(NotFound()); } return(Ok(referralDto)); }
public void Add_referral() { ReferralDto referral = CreateReferral(); HospitalApp.Controllers.ReferralController controller = new HospitalApp.Controllers.ReferralController(this.SetupRepository(referral).Object); var actionResult = controller.Add(referral); ConvertToObject(actionResult).ShouldBeEquivalentTo(referral); }
public void Get_specialist() { PatientDto patient = CreatePatient(); ReferralDto referral = CreateReferral(); DoctorDto doctor = CreateDoctors().Find(d => d.Id == referral.SpecialistId && patient.Id == referral.PatientId); HospitalApp.Controllers.DoctorController controller = new HospitalApp.Controllers.DoctorController(this.SetupRepository(doctor, null).Object); var actionResult = controller.GetSpecialist(patient.Id); ConvertToObject(actionResult).ShouldBeEquivalentTo(doctor); }
public static ReferralDto ReferralToReferralDto(Referral referral) { ReferralDto referralDto = new ReferralDto { Id = referral.Id, PatientId = referral.PatientId, SpecialistId = referral.SpecialistId, IsDeleted = referral.IsDeleted }; return(referralDto); }
public static Referral ReferralDtoToReferral(ReferralDto referralDto) { Referral referral = new Referral { Id = referralDto.Id, PatientId = referralDto.PatientId, SpecialistId = referralDto.SpecialistId, IsDeleted = referralDto.IsDeleted }; return(referral); }
public ReferralDto Add(ReferralDto referralDto) { if (referralDto == null) { return(null); } Referral referral = ReferralAdapter.ReferralDtoToReferral(referralDto); GivePatientReferral(_dbContext.Patients.SingleOrDefault(patient => patient.Id == referralDto.PatientId), referral); _dbContext.Doctors.SingleOrDefault(doctor => doctor.Id == referralDto.SpecialistId).Referrals.Add(referral); _dbContext.Referrals.Add(referral); _dbContext.SaveChanges(); return(referralDto); }
private Mock <IReferralService> SetupRepository(ReferralDto referral) { var repository = CreateRepository(); ReferralDto myReferral = CreateReferrals().Find(r => r.Id == 1); if (GetCallingMethod() == "Get_all_referrals") { repository.Setup(r => r.GetAll()).Returns(CreateReferrals()); } if (GetCallingMethod() == "Get_by_id") { repository.Setup(r => r.GetById(1)).Returns(myReferral); } if (GetCallingMethod() == "Add_referral") { repository.Setup(r => r.Add(referral)).Returns(referral); } return(repository); }
public async Task <ResponseDto> Add(ReferralDto referral) { var user = await UnitOfWork.UserRepository.GetByMail(referral.User.Email); if (user == null) { user = User.CreateUser(referral.User.Email, referral.User.Name, (Language)referral.User.Language); await UnitOfWork.UserRepository.Add(user); UnitOfWork.SaveChanges(); } var patient = await UnitOfWork.PatientRepository.GetByNihii(referral.Patient.Nihii); if (patient == null) { patient = Patient.CreatePatient(referral.Patient.Email, referral.Patient.Nihii, referral.Patient.Name, (Language)referral.Patient.Language, (Gender)referral.Patient.Gender, referral.Patient.DateOfBirth, referral.Patient.Remarks); await UnitOfWork.PatientRepository.Add(patient); UnitOfWork.SaveChanges(); } var newReferral = Referral.CreateReferral(user.Id, patient.Id, ReferralStatus.Open); await UnitOfWork.ReferralRepository.Add(newReferral); foreach (var fileName in referral.FileNames) { newReferral.AddFile(ReferralFile.CreateReferralFile(newReferral.Id, $"{patient.AnonymizationId}-{fileName}")); } UnitOfWork.SaveChanges(); await CopyBlobItems(patient.Nihii, patient.AnonymizationId, referral.FileNames); //await AddMessageToQueueAsync(JsonConvert.SerializeObject(new { user = user, patient = patient, referral = newReferral })); _searchClient.Indexers.Run(_configuration["IndexerName"]); await CheckIndexerStatus(newReferral.ReferralFiles.Select(p => p.FileName).ToArray(), patient.AnonymizationId, newReferral.Id); return(ResponseDto.CreateSuccessResponseDto()); }
public ReferralDtoBuilder() { _referralDto = new ReferralDto(); }
public async Task <IActionResult> AddReferralInformation(ReferralDto referral) { return(await GenerateApiResponse(() => _referralService.Add(referral))); }
public AppointmentsDto FilterAppointments(AppointmentResourcePatientDto patient, ReferralDto referral, AppointmentResourcePhysicianDto dictator, DateTime startTime, DateTime endTime) { throw new NotImplementedException(); }