/// <summary> /// Navigates to default command. /// </summary> /// <param name="parameters">The parameters.</param> protected override void NavigateToDefaultCommand(KeyValuePair <string, string>[] parameters) { _clinicalCaseKey = parameters.GetValue <long> ("ClinicalCaseKey"); _patientKey = parameters.GetValue <long> ("PatientKey"); IsCreateMode = parameters.GetValue <bool> ("IsCreateMode"); _currentStaffName = new StaffNameDto { FirstName = CurrentUserContext.Staff.FirstName, LastName = CurrentUserContext.Staff.LastName, MiddleInitial = CurrentUserContext.Staff.MiddleName == null ? null : CurrentUserContext.Staff.MiddleName.Substring(0, 1), Key = CurrentUserContext.Staff.Key }; var requestDispatcher = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher(); requestDispatcher.Add(new GetDtoRequest <ClinicalCaseDto> { Key = _clinicalCaseKey }); requestDispatcher.AddLookupValuesRequest("InitialContactMethod"); requestDispatcher.AddLookupValuesRequest("ReferralType"); requestDispatcher.AddLookupValuesRequest("SpecialInitiative"); requestDispatcher.AddLookupValuesRequest("PriorityPopulation"); requestDispatcher.AddLookupValuesRequest("DischargeReason"); requestDispatcher.AddLookupValuesRequest("ClinicalCaseStatus"); IsLoading = true; requestDispatcher.ProcessRequests(HandleInitializationCompleted, HandleInitializationException); }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>A <see cref="Agatha.Common.Response"/></returns> public override Response Handle(CreateNewStaffRequest request) { var agencyKey = request.AgencyKey; var firstName = request.FirstName; var middleInitial = request.MiddleInitial; var lastName = request.LastName; var agency = _agencyRepository.GetByKey(agencyKey); if (agency == null) { throw new ArgumentException(string.Format("Agency Key: {0} was not found.", agencyKey)); } var staffDto = new StaffNameDto { FirstName = firstName, MiddleInitial = middleInitial, LastName = lastName }; var duplicateStaff = _staffRepository.FindDuplicateStaff(firstName, middleInitial, lastName); if (duplicateStaff != null) { staffDto.AddDataErrorInfo( string.IsNullOrEmpty(middleInitial) ? new DataErrorInfo(string.Format("Duplicate Staff {0} {1}. Please enter M.I.", firstName, lastName), ErrorLevel.Error) : new DataErrorInfo( string.Format("Cannot add Duplicate Staff {0} {1} {2}.", firstName, middleInitial, lastName), ErrorLevel.Error)); } else { var staff = _staffFactory.CreateStaff( agency, new StaffProfileBuilder().WithStaffName( new PersonNameBuilder().WithFirst(firstName).WithLast(lastName).WithMiddle(middleInitial))); staffDto = Mapper.Map <Staff, StaffNameDto> (staff); } var response = CreateTypedResponse(); response.StaffNameDto = staffDto; return(response); }