/// <summary> /// Gets the variables available to the print template. /// </summary> /// <returns></returns> private Dictionary <string, object> GetVariables() { var variables = new Dictionary <string, object>(); var procedure = _report.Procedures.First(); var order = procedure.Order; var patientProfile = procedure.PatientProfile; // letterhead variables["Letterhead"] = new LetterheadFacade(); // patient variables["Patient"] = new PatientFacade(patientProfile); // recipient variables["Recipient"] = new PractitionerFacade(_recipient.Practitioner, _recipient); // order variables["AccessionNumber"] = order.AccessionNumber; variables["OrderingPractitioner"] = new PractitionerFacade(order.OrderingPractitioner, null); // procedures variables["Procedures"] = new ProceduresFacade(_report.Procedures); // report variables["ReportParts"] = new ReportPartsFacade(_report.Parts); return(variables); }
private async Task <string> UpdateHealthCard(HealthCardUpdateModel healthCardUpdateModel) { var identificationNum = Request.QueryString["identificationNumber"]; var patientToUpdate = await PatientFacade.GetPatientByIdentificationNumberAsync(identificationNum); var healthCard = await HealthCardFacade.GetHealthCardAsync(patientToUpdate.Id); if (healthCard == null) { var healthCardDto = new HealthCardDto { Id = patientToUpdate.Id, LastUpdate = DateTime.Now }; await HealthCardFacade.CreateHealthCardAsync(healthCardDto); healthCard = await HealthCardFacade.GetHealthCardAsync(patientToUpdate.Id); } if (healthCardUpdateModel.BloodType != HospitalISDBContext.Enums.BloodType.Unknown) { healthCard.BloodType = healthCardUpdateModel.BloodType; } if (healthCardUpdateModel.DiseaseId != Guid.Empty) { await MatchDiseaseAndHealthCard(await DiseaseFacade.GetDiseaseAsync(healthCardUpdateModel.DiseaseId), healthCard); } healthCard.LastUpdate = DateTime.Now; await HealthCardFacade.EditHealthCardAsync(healthCard); return(identificationNum); }
public async Task <ActionResult> PatientAskForGetInfoPatient() { string username = HttpContext.User.Identity.Name; var patient = await PatientFacade.GetPatientByUsernameAsync(username); return(await GetPatientInfo(patient)); }
public async Task <ActionResult> Create(PatientCreateModel patientCreateModel) { if (!ModelState.IsValid) { return(View(patientCreateModel)); } PatientDto patientDto = new PatientDto { Username = patientCreateModel.Username, Password = patientCreateModel.Password, Name = patientCreateModel.Name, Surname = patientCreateModel.Surname, DateOfBirth = patientCreateModel.DateOfBirth, Email = patientCreateModel.Email, IdentificationNumber = patientCreateModel.IdentificationNumber, ProfileCreationDate = DateTime.Now }; if (await PatientFacade.GetPatientByUsernameAsync(patientCreateModel.Username) != null || await DoctorFacade.GetDoctorByUsernameAsync(patientCreateModel.Username) != null) { ModelState.AddModelError("Username", "Account with that username already exists"); return(View(patientCreateModel)); } var patientId = await PatientFacade.RegisterPatient(patientDto); return(RedirectToAction("Index", "Home")); }
public async Task <JsonResult> Search(string query) { var patients = (await PatientFacade.GetAllPatientsAsync()).Items; var models = patients.Select(patient => new AddDoctorToPatientModel { Name = patient.Name + " " + patient.Surname }).Where(patient => patient.Name.Contains(query)); return(new JsonResult { Data = models, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <ActionResult> UnmatchDoctorAndPatient(string identificationNumber) { var patientDto = await PatientFacade.GetPatientByIdentificationNumberAsync(identificationNumber); var doctorDto = await DoctorFacade.GetDoctorByUsernameAsync(HttpContext.User.Identity.Name); var rowId = await DoctorToPatientFacade.FindJoiningRelationshipId(doctorDto.Id, patientDto.Id); await DoctorToPatientFacade.Delete(rowId); return(RedirectToAction("GetPatientsForDoctor", "Doctor", new { Username = HttpContext.User.Identity.Name })); }
private static PatientFacade CreatePatientFacade(Mock <QueryObjectBase <PatientDto, Patient, PatientFilterDto, IQuery <Patient> > > patientQueryMock, Mock <IRepository <Patient> > patientRepository, Mock <QueryObjectBase <HealthCardDto, HealthCard, HealthCardFilterDto, IQuery <HealthCard> > > healthCardQueryMock, Mock <IRepository <HealthCard> > healthCardRepository) { var uowMock = FacadeMockManager.ConfigureUowMock(); var mapperMock = FacadeMockManager.ConfigureRealMapper(); var patientService = new PatientService(mapperMock, patientRepository.Object, patientQueryMock.Object); var healthCardService = new HealthCardService(mapperMock, healthCardRepository.Object, healthCardQueryMock.Object); var patientFacade = new PatientFacade(uowMock.Object, patientService, healthCardService); return(patientFacade); }
public async Task <ActionResult> Update() { var patientData = await PatientFacade.GetPatientByUsernameAsync(HttpContext.User.Identity.Name); PatientUpdateModel patientUpdateModel = new PatientUpdateModel { Name = patientData.Name, Surname = patientData.Surname, Email = patientData.Email }; return(View(patientUpdateModel)); }
public async Task <ActionResult> AddDoctorToPatient(AddDoctorToPatientModel model) { if (model.Name.IsNullOrEmpty()) { ModelState.AddModelError("Name", "Field cannot be empty"); return(View(model)); } var patients = (await PatientFacade.GetAllPatientsAsync()) .Items .Where(patient => (patient.Name + " " + patient.Surname).Contains(model.Name)) .ToList(); return(View("ShowPatientsForName", patients)); }
public async Task <ActionResult> Update(PatientUpdateModel patientUpdateModel) { if (!ModelState.IsValid) { return(View(patientUpdateModel)); } var username = HttpContext.User.Identity.Name; var patientToUpdate = await PatientFacade.GetPatientByUsernameAsync(username); patientToUpdate.Email = patientUpdateModel.Email; patientToUpdate.Name = patientUpdateModel.Name; patientToUpdate.Surname = patientUpdateModel.Surname; await PatientFacade.EditPatientAsync(patientToUpdate); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> AddClickedPatient() { var username = Request.QueryString["Username"]; var foundPatient = await PatientFacade.GetPatientByUsernameAsync(username); var loggedDoctor = await DoctorFacade.GetDoctorByUsernameAsync(HttpContext.User.Identity.Name); var relationshipGuid = await DoctorToPatientFacade.FindJoiningRelationshipId(loggedDoctor.Id, foundPatient.Id); if (relationshipGuid == Guid.Empty) { var doctorToPatientDto = new DoctorToPatientDto { DoctorDto = loggedDoctor, PatientDto = foundPatient }; await DoctorToPatientFacade.Create(doctorToPatientDto); } return(RedirectToAction("GetPatientsForDoctor", "Doctor", new { Username = loggedDoctor.Username })); }
private async Task <ActionResult> GetPatientInfo(PatientDto patient) { PatientInfoModel model = new PatientInfoModel { Name = patient.Name, Surname = patient.Surname, DateOfBirth = patient.DateOfBirth, Email = patient.Email, IdentificationNumber = patient.IdentificationNumber, ProfileCreationDate = patient.ProfileCreationDate, Doctors = await PatientFacade.GetDoctorsForPatientAsync(patient.Id), }; patient.HealthCard = await PatientFacade.GetPatientWithHealthCardAsync(patient.Id); if (patient.HealthCard != null) { model.Diseases = await HealthCardFacade.GetDiseasesForHealthCard(patient.Id); model.BloodType = patient.HealthCard.BloodType; } return(View("PatientAskForGetInfo", model)); }
/// <summary> /// Gets the variables available to the print template. /// </summary> /// <returns></returns> private Dictionary<string, object> GetVariables() { var variables = new Dictionary<string, object>(); var procedure = _report.Procedures.First(); var order = procedure.Order; var patientProfile = procedure.PatientProfile; // letterhead variables["Letterhead"] = new LetterheadFacade(); // patient variables["Patient"] = new PatientFacade(patientProfile); // recipient variables["Recipient"] = new PractitionerFacade(_recipient.Practitioner, _recipient); // order variables["AccessionNumber"] = order.AccessionNumber; variables["OrderingPractitioner"] = new PractitionerFacade(order.OrderingPractitioner, null); // procedures variables["Procedures"] = new ProceduresFacade(_report.Procedures); // report variables["ReportParts"] = new ReportPartsFacade(_report.Parts); return variables; }
public async Task <ActionResult> PatientAskForGetInfoDoctor(string identificationNumber) { var patient = (await PatientFacade.GetPatientByIdentificationNumberAsync(identificationNumber)); return(await GetPatientInfo(patient)); }