protected override void Handle(AddDtoRequest <OrganizationAddressDto> request, AddDtoResponse <OrganizationAddressDto> response) { var organization = _organizationRepository.GetByKey(request.AggregateKey); var addressDto = request.DataTransferObject.Address; var address = new Address(addressDto.FirstStreetAddress, addressDto.SecondStreetAddress, addressDto.CityName, _lookupProvider.Find <StateProvince>(addressDto.StateProvince.Code), new PostalCode(addressDto.PostalCode)); var organizationAddressType = _lookupProvider.Find <OrganizationAddressType>(request.DataTransferObject.OrganizationAddressType.Code); var organizationAddress = new OrganizationAddress(organizationAddressType, address, request.DataTransferObject.IsPrimary); var originalAddress = organization.OrganizationAddresses.FirstOrDefault(a => a.GetHashCode() == request.DataTransferObject.OriginalHash); if (originalAddress != organizationAddress) { if (originalAddress != null) { organization.RemoveAddress(originalAddress); } organization.AddAddress(organizationAddress); } else if (organizationAddress.IsPrimary) { organization.MakePrimary(organizationAddress); } response.AggregateKey = organization.Key; response.DataTransferObject = Mapper.Map <OrganizationAddress, OrganizationAddressDto>(organizationAddress); response.DataTransferObject.Key = organization.Key; }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(GetPatientScoreRangeReportRequest request, GetReportResponse response) { if (request.PatientScoreRangeParametersDto.AssessmentDefinitionCode != null) { var reportEngine = IoC.CurrentContainer.Resolve <IReportEngine> (ReportNames.PatientScoreRange); var parameters = new PatientScoreRangeParameters { AssessmentDefinitionCode = request.PatientScoreRangeParametersDto.AssessmentDefinitionCode, AssessmentName = request.PatientScoreRangeParametersDto.AssessmentName, EndDate = request.PatientScoreRangeParametersDto.EndDate, PatientKey = request.PatientScoreRangeParametersDto.PatientKey.GetValueOrDefault(), StartDate = request.PatientScoreRangeParametersDto.StartDate, TimePeriod = _lookupProvider.Find <ReportTimePeriod> (request.PatientScoreRangeParametersDto.TimePeriod.Code), AgeRangeHigh = request.PatientScoreRangeParametersDto.AgeRangeHigh, AgeRangeLow = request.PatientScoreRangeParametersDto.AgeRangeLow, Gender = request.PatientScoreRangeParametersDto.Gender.Code == null ? string.Empty : _lookupProvider.Find <Gender> (request.PatientScoreRangeParametersDto.Gender.Code), ScoreType = Mapper.Map <IScoreType> (request.PatientScoreRangeParametersDto.ScoreType), }; var report = reportEngine.Generate( Guid.Empty, ReportNames.PatientScoreRange, parameters ); response.Report = report; new RecentReport( ReportNames.PatientScoreRange, UserContext.Current.SystemAccountKey.Value, request.PatientScoreRangeParametersDto.AssessmentName, DateTime.Now, parameters); } }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(GetPatientsWithSpecificResponseReportRequest request, GetReportResponse response) { if (!request.PatientsWithSpecificResponseParametersDto.Responses.Any()) { return; } var reportEngine = IoC.CurrentContainer.Resolve <IReportEngine> (ReportNames.PatientsWithSpecificResponse); var qr = new List <QuestionResponse> (); if (request.PatientsWithSpecificResponseParametersDto.Responses != null) { qr = request.PatientsWithSpecificResponseParametersDto.Responses.Select( r => new QuestionResponse { AssessmentCode = r.AssessmentCode, AssessmentDefinitionKey = r.AssessmentDefinitionKey, InputType = r.InputType, ItemDefinitionCode = r.ItemDefinitionCode, Responses = r.Responses, IsLookup = r.IsLookup, }).ToList(); } var parameters = new PatientsWithSpecificResponseParameters { ReportName = request.PatientsWithSpecificResponseParametersDto.ReportName, OrganizationKey = request.PatientsWithSpecificResponseParametersDto.OrganizationKey, QuestionResponses = qr, AssessmentDefinitionCode = request.PatientsWithSpecificResponseParametersDto.AssessmentDefinitionCode, AssessmentName = request.PatientsWithSpecificResponseParametersDto.AssessmentName, EndDate = request.PatientsWithSpecificResponseParametersDto.EndDate, StartDate = request.PatientsWithSpecificResponseParametersDto.StartDate, TimePeriod = _lookupProvider.Find <ReportTimePeriod> (request.PatientsWithSpecificResponseParametersDto.TimePeriod.Code), AgeRangeHigh = request.PatientsWithSpecificResponseParametersDto.AgeRangeHigh, AgeRangeLow = request.PatientsWithSpecificResponseParametersDto.AgeRangeLow, Gender = request.PatientsWithSpecificResponseParametersDto.Gender.Code == null ? string.Empty : _lookupProvider.Find <Gender> (request.PatientsWithSpecificResponseParametersDto.Gender.Code), }; var report = reportEngine.Generate( Guid.Empty, parameters.ReportName, parameters ); response.Report = report; new RecentReport( ReportNames.PatientsWithSpecificResponse, UserContext.Current.SystemAccountKey.Value, request.PatientsWithSpecificResponseParametersDto.AssessmentName, DateTime.Now, parameters); }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(GetAssessmentScoreOverTimeReportRequest request, GetReportResponse response) { if (request.AssessmentScoreOverTimeParametersDto.AssessmentDefinitionCode != null) { var reportEngine = IoC.CurrentContainer.Resolve <IReportEngine> (ReportNames.AssessmentScoreOverTime); var parameters = new AssessmentScoreOverTimeParameters { AssessmentDefinitionCode = request.AssessmentScoreOverTimeParametersDto.AssessmentDefinitionCode, AssessmentName = request.AssessmentScoreOverTimeParametersDto.AssessmentName, EndDate = request.AssessmentScoreOverTimeParametersDto.EndDate, PatientKey = request.AssessmentScoreOverTimeParametersDto.PatientKey.GetValueOrDefault(), StartDate = request.AssessmentScoreOverTimeParametersDto.StartDate, TimePeriod = _lookupProvider.Find <ReportTimePeriod> (request.AssessmentScoreOverTimeParametersDto.TimePeriod.Code) }; var report = reportEngine.Generate(Guid.Empty, ReportNames.AssessmentScoreOverTime, parameters ); response.Report = report; new RecentReport(ReportNames.AssessmentScoreOverTime, UserContext.Current.SystemAccountKey.Value, request.AssessmentScoreOverTimeParametersDto.AssessmentName, DateTime.Now, parameters); } }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(AddDtoRequest <OrganizationPhoneDto> request, AddDtoResponse <OrganizationPhoneDto> response) { var organization = _organizationRepository.GetByKey(request.AggregateKey); var originalPhone = organization.OrganizationPhones.FirstOrDefault(p => p.GetHashCode() == request.DataTransferObject.OriginalHash); var organizationPhoneType = _lookupProvider.Find <OrganizationPhoneType> (request.DataTransferObject.OrganizationPhoneType.Code); var phone = new Phone(request.DataTransferObject.Phone.Number, request.DataTransferObject.Phone.Extension); var organizationPhone = new OrganizationPhone(organizationPhoneType, phone, request.DataTransferObject.IsPrimary); if (originalPhone != organizationPhone) { if (originalPhone != null) { organization.RemovePhone(originalPhone); } organization.AddPhone(organizationPhone); } else if (organizationPhone.IsPrimary) { organization.MakePrimary(organizationPhone); } response.AggregateKey = organization.Key; response.DataTransferObject = Mapper.Map <OrganizationPhone, OrganizationPhoneDto> (organizationPhone); response.DataTransferObject.Key = organization.Key; }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(SaveDtoRequest <PatientDto> request, SaveDtoResponse <PatientDto> response) { var patient = _patientRepository.GetByKey(request.DataTransferObject.Key); DataErrorInfo dataErrorInfo = null; if (patient != null) { patient.ReviseName(request.DataTransferObject.Name); patient.ReviseDateOfBirth(request.DataTransferObject.DateOfBirth); patient.ReviseGender(_lookupProvider.Find <Gender> (request.DataTransferObject.Gender.Code)); if (request.DataTransferObject.Ethnicity != null && !string.IsNullOrEmpty(request.DataTransferObject.Ethnicity.Code)) { patient.ReviseEthnicity(_lookupProvider.Find <Ethnicity> (request.DataTransferObject.Ethnicity.Code)); } if (request.DataTransferObject.Religion != null && !string.IsNullOrEmpty(request.DataTransferObject.Religion.Code)) { patient.ReviseReligion(_lookupProvider.Find <Religion> (request.DataTransferObject.Religion.Code)); } Email newEmail = null; try { if (!string.IsNullOrWhiteSpace(request.DataTransferObject.Email)) { newEmail = new Email(request.DataTransferObject.Email); } } catch (ArgumentException ae) { if (!ae.Message.Contains("email address", StringComparison.OrdinalIgnoreCase)) { throw; } dataErrorInfo = new DataErrorInfo(ae.Message, ErrorLevel.Error, PropertyUtil.ExtractPropertyName <PatientDto, string> (s => s.Email)); } patient.ReviseEmail(string.IsNullOrWhiteSpace(request.DataTransferObject.Email) ? null : newEmail); response.DataTransferObject = Mapper.Map <Patient, PatientDto> (patient); if (dataErrorInfo != null) { response.DataTransferObject.AddDataErrorInfo(dataErrorInfo); } } }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(SaveReportTemplateRequest request, SaveReportTemplateResponse response) { var reportTemplateDto = request.ReportTemplate; if (reportTemplateDto.Key == Guid.Empty) { var reportTemplateFactory = new ReportTemplateFactory(); var paramertersType = reportTemplateDto.Parameters.GetType(); var destinationType = Mapper.GetAllTypeMaps().First(typeMap => typeMap.SourceType == paramertersType).DestinationType; var parameters = Mapper.Map(reportTemplateDto.Parameters, paramertersType, destinationType) as BaseReportParameters; if (parameters == null) { return; } parameters.ReportName = reportTemplateDto.Name; var reportTemplate = reportTemplateFactory.Create( reportTemplateDto.SystemAccountKey, reportTemplateDto.Name, reportTemplateDto.ReportType, parameters, _lookupProvider.Find <ReportState> (reportTemplateDto.ReportState.Code)); if (reportTemplate != null) { var dto = Mapper.Map <ReportTemplate, ReportTemplateDto> (reportTemplate); response.ReportTemplate = dto; } } else { //update var reportTemplate = _reportTemplateRepository.GetByKey(reportTemplateDto.Key); if (reportTemplate != null) { reportTemplate.ChangeName(reportTemplateDto.Name); reportTemplate.ChangeReportType(reportTemplateDto.ReportType); reportTemplate.ChangeParameters(reportTemplateDto.Parameters); reportTemplate.ChangeReportState(_lookupProvider.Find <ReportState> (reportTemplateDto.ReportState.Code)); var dto = Mapper.Map <ReportTemplate, ReportTemplateDto> (reportTemplate); response.ReportTemplate = dto; } } }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(CreatePatientRequest request, SaveDtoResponse <PatientDto> response) { var patientFactory = new PatientFactory(); var patient = patientFactory.Create(request.PatientDto.OrganizationKey, request.PatientDto.Name, request.PatientDto.DateOfBirth, _lookupProvider.Find <Gender> (request.PatientDto.Gender.Code)); if (patient != null) { if (request.PatientDto.Religion != null && !string.IsNullOrEmpty(request.PatientDto.Religion.Code)) { patient.ReviseReligion(_lookupProvider.Find <Religion> (request.PatientDto.Religion.Code)); } if (request.PatientDto.Ethnicity != null && !string.IsNullOrEmpty(request.PatientDto.Ethnicity.Code)) { patient.ReviseEthnicity(_lookupProvider.Find <Ethnicity> (request.PatientDto.Ethnicity.Code)); } var patientDto = Mapper.Map <Patient, PatientDto> (patient); response.DataTransferObject = patientDto; } }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(SaveDtoRequest <PatientDto> request, SaveDtoResponse <PatientDto> response) { var patient = _patientRepository.GetByKey(request.DataTransferObject.Key); if (patient != null) { patient.ReviseName(request.DataTransferObject.Name); patient.ReviseDateOfBirth(request.DataTransferObject.DateOfBirth); patient.ReviseGender(_lookupProvider.Find <Gender> (request.DataTransferObject.Gender.Code)); if (request.DataTransferObject.Ethnicity != null && !string.IsNullOrEmpty(request.DataTransferObject.Ethnicity.Code)) { patient.ReviseEthnicity(_lookupProvider.Find <Ethnicity> (request.DataTransferObject.Ethnicity.Code)); } if (request.DataTransferObject.Religion != null && !string.IsNullOrEmpty(request.DataTransferObject.Religion.Code)) { patient.ReviseReligion(_lookupProvider.Find <Religion> (request.DataTransferObject.Religion.Code)); } patient.ReviseEmail(string.IsNullOrWhiteSpace(request.DataTransferObject.Email) ? null : new Email(request.DataTransferObject.Email)); response.DataTransferObject = Mapper.Map <Patient, PatientDto> (patient); } }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(GetNotCompletedAssessmentReportRequest request, GetReportResponse response) { if (request.NotCompletedAssessmentParametersDto != null) { var reportEngine = IoC.CurrentContainer.Resolve <IReportEngine> (ReportNames.NotCompletedAssessment); var parameters = new NotCompletedAssessmentParameters { OrganizationKey = request.NotCompletedAssessmentParametersDto.OrganizationKey, AssessmentDefinitionCode = request.NotCompletedAssessmentParametersDto.AssessmentDefinitionCode, AssessmentName = request.NotCompletedAssessmentParametersDto.AssessmentName, EndDate = request.NotCompletedAssessmentParametersDto.EndDate, PatientKey = request.NotCompletedAssessmentParametersDto.PatientKey.GetValueOrDefault(), StartDate = request.NotCompletedAssessmentParametersDto.StartDate, TimePeriod = _lookupProvider.Find <ReportTimePeriod>(request.NotCompletedAssessmentParametersDto.TimePeriod.Code), AgeRangeHigh = request.NotCompletedAssessmentParametersDto.AgeRangeHigh, AgeRangeLow = request.NotCompletedAssessmentParametersDto.AgeRangeLow, Gender = request.NotCompletedAssessmentParametersDto.Gender.Code == null ? string.Empty : _lookupProvider.Find <Gender>(request.NotCompletedAssessmentParametersDto.Gender.Code), }; var report = reportEngine.Generate( Guid.Empty, ReportNames.NotCompletedAssessment, parameters ); response.Report = report; var assessmentName = request.NotCompletedAssessmentParametersDto.AssessmentName; if (string.IsNullOrWhiteSpace(assessmentName)) { assessmentName = Report.All; } new RecentReport( ReportNames.NotCompletedAssessment, UserContext.Current.SystemAccountKey.Value, assessmentName, DateTime.Now, parameters); } }