public DataTableResponse <AssessmentDefinitionDto> Get(string sEcho, int iDisplayStart, int iDisplayLength, string sSearch = null) { var start = iDisplayStart; var end = start + iDisplayLength; var replaceString = string.IsNullOrWhiteSpace(sSearch) ? "" : WhereConstraintActive; var completeQuery = string.Format(QueryActive, replaceString); using (var connection = _connectionFactory.CreateConnection()) { using (var multiQuery = connection.QueryMultiple(completeQuery, new { start, end, search = sSearch, UserContext.Current.OrganizationKey })) { var totalCount = multiQuery.Read <int>().Single(); var assessmentDefinitionDtos = multiQuery.Read <AssessmentDefinitionDto>().ToList(); foreach (var assessmentDefinitionDto in assessmentDefinitionDtos) { assessmentDefinitionDto.AssessmentName = _resourcesManager.GetResourceManagerByName(assessmentDefinitionDto.AssessmentName) .GetString(SharedStringNames.ResourceKeyPrefix + assessmentDefinitionDto.AssessmentCode); } var dataTableResponse = new DataTableResponse <AssessmentDefinitionDto> { Data = assessmentDefinitionDtos, Echo = sEcho, TotalDisplayRecords = totalCount, TotalRecords = totalCount, }; return(dataTableResponse); } } }
public DataTableResponse <PatientDto> DataTableSearch(string sEcho, int iDisplayStart, int iDisplayLength, string sSearch = null) { var start = iDisplayStart; var end = start + iDisplayLength; var replaceString = string.IsNullOrWhiteSpace(sSearch) ? "" : WhereConstraint; var completeQuery = string.Format(Query, replaceString); using (var connection = _connectionFactory.CreateConnection()) using (var multiQuery = connection.QueryMultiple(completeQuery, new { start, end, UserContext.Current.OrganizationKey, search = sSearch })) { var totalCount = multiQuery.Read <int>().Single(); var patientDtos = multiQuery.Read <PersonName, string, PatientDto, PatientDto>((personName, code, patientDto) => { patientDto.Name = personName; var lookupDto = new LookupDto { Code = code, Name = _resourcesManager.GetResourceManagerByName("Gender").GetString(code) }; patientDto.Gender = lookupDto; return(patientDto); }, "Code,Key"); var dataTableResponse = new DataTableResponse <PatientDto> { Data = patientDtos.ToList(), Echo = sEcho, TotalDisplayRecords = totalCount, TotalRecords = totalCount, }; return(dataTableResponse); } }
/// <summary> /// Edits the specified key. /// </summary> /// <param name="key">The key.</param> /// <param name="patientKey">The patient key.</param> /// <returns> /// A <see cref="ActionResult" />. /// </returns> public virtual async Task <ActionResult> Edit(Guid key, Guid patientKey) { var requestDispatcher = CreateAsyncRequestDispatcher(); requestDispatcher.Add(new GetDtoByKeyRequest <AssessmentSectionSummaryDto> { Key = key }); requestDispatcher.Add(new GetSectionDtoByKeyRequest { Key = key }); requestDispatcher.Add(new GetPatientDtoByKeyRequest { PatientKey = patientKey }); var response = await requestDispatcher.GetAsync <DtoResponse <AssessmentSectionSummaryDto> > (); var sectionDtoResponse = await requestDispatcher.GetAsync <GetSectionDtoByKeyResponse> (); var patientResponse = requestDispatcher.Get <GetPatientDtoResponse> (); ViewData["Patient"] = patientResponse.DataTransferObject; var messages = new List <IMessageDto> ((TempData["Messages"] as IEnumerable <IMessageDto>) ?? Enumerable.Empty <IMessageDto> ()); messages.AddRange(response.DataTransferObject.Messages.Where(m => !messages.Contains(m))); ViewData["Messages"] = messages; var assessmentViewModel = new AssessmentViewModel(response.DataTransferObject, sectionDtoResponse.DataTransferObject); ViewData["ResourceManager"] = _resourcesManager.GetResourceManagerByName(assessmentViewModel.AssessmentSectionSummaryDto.AssessmentName); ViewData["ResourcesManager"] = _resourcesManager; return(View(assessmentViewModel)); }
public async Task <PartialViewResult> Customize(Guid key, string reportName) { var requestDispatcher = CreateAsyncRequestDispatcher(); requestDispatcher.Add(new GetReportCustomizationModelRequest { SourceKey = key, ReportName = reportName }); var response = await requestDispatcher.GetAsync <GetReportCustomizationModelResponse> (); ViewData["ResourceManager"] = _resourcesManager.GetResourceManagerByName(reportName); return(PartialView(response.ReportModelDto)); }
public FinderResults <AssessmentDefinitionDto> FinderSearch(int page, int pageSize, string search = null) { const string WhereConstraint = " AND ([t1].AssessmentName LIKE @search+'%')"; const string Query = @" SELECT COUNT(*) as TotalCount FROM AssessmentModule.AssessmentDefinition [t1] LEFT JOIN OrganizationModule.OrganizationAssessmentDefinition [t2] ON [t1].AssessmentDefinitionKey = [t2].AssessmentDefinitionKey AND OrganizationKey=@OrganizationKey WHERE [t2].AssessmentDefinitionKey IS NULL{0} SELECT [t].AssessmentName, [t].AssessmentDefinitionKey AS 'Key', [t].AssessmentCode FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY [t1].AssessmentName) AS [ROW_NUMBER], [t1].AssessmentName, [t1].AssessmentDefinitionKey, [t1].AssessmentCode FROM AssessmentModule.AssessmentDefinition [t1] LEFT JOIN OrganizationModule.OrganizationAssessmentDefinition [t2] ON [t1].AssessmentDefinitionKey = [t2].AssessmentDefinitionKey AND OrganizationKey=@OrganizationKey WHERE [t2].AssessmentDefinitionKey IS NULL{0} ) AS [t] WHERE [t].[ROW_NUMBER] BETWEEN @start + 1 AND @end ORDER BY [t].[ROW_NUMBER] "; var start = page * pageSize; var end = start + pageSize; var replaceString = string.IsNullOrWhiteSpace(search) ? string.Empty : WhereConstraint; var completeQuery = string.Format(Query, replaceString); using (var connection = _connectionFactory.CreateConnection()) using (var multiQuery = connection.QueryMultiple(completeQuery, new { start, end, search, UserContext.Current.OrganizationKey })) { var totalCount = multiQuery.Read <int> ().Single(); var assessmentDefinitionDtos = multiQuery.Read <AssessmentDefinitionDto> ().ToList(); foreach (var assessmentDefinitionDto in assessmentDefinitionDtos) { assessmentDefinitionDto.AssessmentName = _resourcesManager.GetResourceManagerByName(assessmentDefinitionDto.AssessmentName) .GetString(SharedStringNames.ResourceKeyPrefix + assessmentDefinitionDto.AssessmentCode); } var findResults = new FinderResults <AssessmentDefinitionDto> { Data = assessmentDefinitionDtos, TotalCount = totalCount }; return(findResults); } }
/// <summary> /// Patients the feed. /// </summary> /// <param name="key">The key.</param> /// <returns>A <see cref="ActionResult"/>.</returns> public async Task <ActionResult> PatientFeed(Guid key) { var requestDispatcher = CreateAsyncRequestDispatcher(); requestDispatcher.Add(new GetPatientDashboardRequest { PatientKey = key }); requestDispatcher.Add(new GetPatientDtoByKeyRequest { PatientKey = key }); var response = await requestDispatcher.GetAsync <GetPatientDashboardResponse> (); var patientDtoResponse = await requestDispatcher.GetAsync <GetPatientDtoResponse> (); ViewData["Patient"] = patientDtoResponse.DataTransferObject; ViewData["ResourcesManager"] = _resourcesManager; if (response.DashboardItems != null) { foreach (var dashBoardItem in response.DashboardItems.Where(dashBoardItem => dashBoardItem.GetType() == typeof(AssessmentReminderDto))) { var reminderDto = ((AssessmentReminderDto)dashBoardItem); ((AssessmentReminderDto)dashBoardItem).AssessmentName = _resourcesManager.GetResourceManagerByName(reminderDto.AssessmentName) .GetString(SharedStringNames.ResourceKeyPrefix + reminderDto.AssessmentCode); } } return(PartialView(response.DashboardItems)); }
/// <summary> /// Gets the specified s echo. /// </summary> /// <param name="sEcho">The s echo.</param> /// <param name="iDisplayStart">The i display start.</param> /// <param name="iDisplayLength">Display length of the i.</param> /// <param name="sSearch">The s search.</param> /// <returns>A <see cref="DataTableResponse{AssessmentSummaryDto}"/>.</returns> public DataTableResponse <AssessmentSummaryDto> Get(string sEcho, int iDisplayStart, int iDisplayLength, string sSearch = null) { const string WhereConstraint = "WHERE [p1].OrganizationKey = @OrganizationKey AND ( [p1].FirstName LIKE @search+'%' OR [p1].LastName LIKE @search+'%')"; const string Query = @" SELECT COUNT(*) as TotalCount FROM AssessmentModule.AssessmentInstance SELECT [t].* FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY [t1].CreatedTime DESC) AS [ROW_NUMBER], [t1].AssessmentInstanceKey, [t1].AssessmentName, [t1].AssessmentCode, [t1].PercentComplete, [t1].CreatedTime, [t1].IsSubmitted, [t1].PatientKey, [p1].FirstName AS PatientFirstName, [p1].LastName AS PatientLastName FROM AssessmentModule.AssessmentInstance AS [t1] JOIN PatientModule.Patient AS [p1] ON t1.PatientKey=p1.PatientKey {0} ) AS [t] WHERE [t].[ROW_NUMBER] BETWEEN @start + 1 AND @end ORDER BY [t].[ROW_NUMBER] "; var start = iDisplayStart; var end = start + iDisplayLength; var replaceString = string.IsNullOrWhiteSpace(sSearch) ? string.Empty : WhereConstraint; var completeQuery = string.Format(Query, replaceString); using (var conn = _connectionFactory.CreateConnection()) using (var multiQuery = conn.QueryMultiple(completeQuery, new { start, end, search = sSearch, UserContext.Current.OrganizationKey })) { var totalCount = multiQuery.Read <int> ().Single(); var assessmentSummaryDtos = multiQuery.Read <AssessmentSummaryDto> ().ToList(); foreach (var assessmentSummaryDto in assessmentSummaryDtos) { assessmentSummaryDto.AssessmentName = _resourcesManager.GetResourceManagerByName(assessmentSummaryDto.AssessmentName) .GetString(SharedStringNames.ResourceKeyPrefix + assessmentSummaryDto.AssessmentCode); } var dataTableResponse = new DataTableResponse <AssessmentSummaryDto> { Data = assessmentSummaryDtos, Echo = sEcho, TotalDisplayRecords = totalCount, TotalRecords = totalCount, }; return(dataTableResponse); } }
public IEnumerable <CalendarEventModel> Get(double start, double end, string patientKey = null, string sSearch = null) { var startDate = UnixTimeStampToDateTime(start); var endDate = UnixTimeStampToDateTime(end); const string searchWhereConstraint = " AND (PatientFirstName LIKE @search+'%' OR PatientLastName LIKE @search+'%')"; var patienKeyWhereConstraint = " AND PatientKey = @patientKey"; const string organizationKeyWhereConstraint = " AND OrganizationKey = @organizationKey"; const string query = @" SELECT AssessmentReminderKey AS 'Key', PatientFirstName, PatientLastName, AssessmentDefinitionKey, AssessmentName, AssessmentCode, Title, Start FROM MessageModule.AssessmentReminder WHERE Start BETWEEN @startDate AND @endDate AND Status<>'Cancelled'{0}{1}"; if (UserContext.Current.PatientKey != null && patientKey != UserContext.Current.PatientKey.ToString()) { return(Enumerable.Empty <CalendarEventModel> ()); } if (UserContext.Current.PatientKey != null) { patienKeyWhereConstraint += " AND ForSelfAdministration=1"; } var completeQuery = string.Format(query, string.IsNullOrWhiteSpace(patientKey) ? organizationKeyWhereConstraint : patienKeyWhereConstraint, string.IsNullOrWhiteSpace(sSearch) ? "" : searchWhereConstraint); using (var connection = _connectionFactory.CreateConnection()) { var assessmentReminderDtos = connection.Query <AssessmentReminderDto>(completeQuery, new { startDate, endDate, search = sSearch, organizationKey = UserContext.Current.OrganizationKey, patientKey }).ToList(); return(assessmentReminderDtos.Select(m => new CalendarEventModel { Key = m.Key.ToString(), Title = string.Format("{0}: {1} for {2} {3}", m.Title, _resourcesManager.GetResourceManagerByName(m.AssessmentName).GetString(SharedStringNames.ResourceKeyPrefix + m.AssessmentCode), m.PatientFirstName, m.PatientLastName), Start = DateTimeToUnixTimestamp(m.Start), AllDay = true }).ToList()); } }
public DataTableResponse <MissedRemindersReportDto> GetMissedRemindersForDataTable( string sEcho, int iDisplayStart, int iDisplayLength, string sSearch = null, string systemAccountKey = null, string organizationKey = null, bool showAll = true) { const string MissedRemindersQuery = @"SELECT [RecurrenceKey], [AssessmentReminderKey], [OrganizationKey], [PatientKey], [PatientFirstName], [PatientLastName], [PatientFirstName] + ' ' + [PatientLastName] AS PatientName, [AssessmentDefinitionKey], [AssessmentName], [AssessmentCode], [Title] AS Description, [AssessmentInstanceKey], [Start] AS ReminderStartDate FROM [MessageModule].[AssessmentReminder] WHERE AssessmentInstanceKey IS NULL AND Status = 'Default' AND Start < @today {0} {1} {2}"; using (var connection = _connectionFactory.CreateConnection()) { const string WhereConstraint = " AND ([PatientFirstName] + ' ' + [PatientLastName] LIKE '%' + replace(@search, ' ', '') + " + "'%' OR AssessmentName LIKE '%' + @search + " + "'%' OR Title LIKE '%' + @search + '%')"; var whereSystemAccountKey = string.IsNullOrWhiteSpace(systemAccountKey) || showAll ? string.Empty : " AND SystemAccountKey='" + systemAccountKey + "'"; var whereOrganizationKey = string.IsNullOrWhiteSpace(organizationKey) ? string.Empty : " AND OrganizationKey='" + organizationKey + "'"; var whereString = string.IsNullOrWhiteSpace(sSearch) ? string.Empty : WhereConstraint; var completeQuery = string.Format(MissedRemindersQuery, whereOrganizationKey, whereSystemAccountKey, whereString); var missedRemindersReportDtos = connection.Query <MissedRemindersReportDto> (completeQuery, new { search = sSearch, DateTime.Today }).ToList(); foreach (var missedReminder in missedRemindersReportDtos) { missedReminder.AssessmentName = _resourcesManager.GetResourceManagerByName(missedReminder.AssessmentName) .GetString(SharedStringNames.ResourceKeyPrefix + missedReminder.AssessmentCode); } var dataTableResponse = new DataTableResponse <MissedRemindersReportDto> { Data = missedRemindersReportDtos, Echo = sEcho, TotalDisplayRecords = missedRemindersReportDtos.Count, TotalRecords = missedRemindersReportDtos.Count, }; return(dataTableResponse); } }
protected override void Handle(GetAssessmentReminderByKeyRequest request, DtoResponse <AssessmentReminderDto> response) { var assessmentReminder = _assessmentReminderRepository.GetByKey(request.AssessmentReminderKey); if (assessmentReminder != null) { var patient = _patientRepository.GetByKey(assessmentReminder.PatientKey); var assessmentDefinition = _assessmentDefinitionRepository.GetByKey(assessmentReminder.AssessmentDefinitionKey); var assessmentReminderDto = Mapper.Map <AssessmentReminder, AssessmentReminderDto> (assessmentReminder); assessmentReminderDto.AssessmentName = _resourcesManager.GetResourceManagerByName(assessmentDefinition.CodedConcept.Name).GetString("_" + assessmentDefinition.CodedConcept.Code); assessmentReminderDto.PatientFirstName = patient.Name.FirstName; assessmentReminderDto.PatientLastName = patient.Name.LastName; response.DataTransferObject = assessmentReminderDto; } }
public override ModelMetadata GetMetadataForProperty(Func <object> modelAccessor, Type containerType, string propertyName) { var modelMetadata = base.GetMetadataForProperty(modelAccessor, containerType, propertyName); if (typeof(IPrimitive).IsAssignableFrom(containerType)) { modelMetadata.IsRequired = false; } if (modelMetadata.DisplayName == null) { if (typeof(IPrimitive).IsAssignableFrom(containerType)) { modelMetadata.DisplayName = _resourcesManager.GetResourceManagerByName(containerType.Name).GetString(propertyName); } else { var name = containerType.Namespace.Split('.').Last() + "Resources"; var resourceManager = _resourcesManager.GetResourceManagerByName(name); modelMetadata.DisplayName = resourceManager.GetString(containerType.Name.Replace("Dto", "_") + propertyName); } } return(modelMetadata); }
private CalendarEventModel GetCalenderEventModelFromAssessmentReminderDto(AssessmentReminderDto reminderDto, DateTime date) { var reminderTitleDisplayLength = 50; return(new CalendarEventModel { Key = reminderDto.Key.ToString(), Title = string.Format("{0}: {1} for {2} {3}", reminderDto.Title.Length > reminderTitleDisplayLength ? reminderDto.Title.Substring(0, reminderTitleDisplayLength - 1) + "..." : reminderDto.Title, _resourcesManager.GetResourceManagerByName(reminderDto.AssessmentName).GetString(SharedStringNames.ResourceKeyPrefix + reminderDto.AssessmentCode), reminderDto.PatientFirstName, reminderDto.PatientLastName), Start = DateTimeToUnixTimestamp(date), AllDay = true, RecurrenceKey = reminderDto.RecurrenceKey.GetValueOrDefault().ToString() }); }
private void SetStrings(PatientsWithSpecificResponseData data, PatientsWithSpecificResponseParameters reportParams, string reportName) { if (reportParams == null || data == null) { return; } var originalReportName = reportName; var start = reportParams.StartDate; var end = reportParams.EndDate; var dateRange = start.GetValueOrDefault().ToShortDateString() + " - " + end.GetValueOrDefault().ToShortDateString(); if (reportParams.TimePeriod != null) { reportParams.TimePeriod.GetRange(out start, out end); dateRange = reportParams.TimePeriod.DisplayName; } data.StartDate = start; data.EndDate = end; reportName = ReportNames.PatientsWithSpecificResponse; var ageRange = _resourcesManager.GetResourceManagerByName(reportName).GetString("NA"); if (reportParams.AgeRangeLow != null && reportParams.AgeRangeHigh != null) { ageRange = reportParams.AgeRangeLow + " - " + reportParams.AgeRangeHigh; } var gender = _resourcesManager.GetResourceManagerByName(reportName).GetString("NA"); if (!string.IsNullOrWhiteSpace(reportParams.Gender)) { gender = reportParams.Gender; } var assessment = _resourcesManager.GetResourceManagerByName(reportName).GetString("All"); if (!string.IsNullOrWhiteSpace(reportParams.AssessmentName)) { assessment = GetAssessmentNames(data); } data.AssessmentParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("Assessment") + ": " + assessment; data.DateRangeParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("DateRange") + ": " + dateRange; data.AgeGroupParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("AgeGroup") + ": " + ageRange; data.GenderParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("Gender") + ": " + gender; data.TotalQuestionsForQuery = _resourcesManager.GetResourceManagerByName(reportName).GetString("TotalQuestionsForQuery") + ": " + data.Data.GroupBy(a => a.ItemDefinitionCode).Select(group => group.First()).Count(); data.TotalNumberOfSpecifiedResults = _resourcesManager.GetResourceManagerByName(reportName).GetString("TotalNumberOfSpecificResults") + ": " + data.Data.Count(); data.TotalNumberOfPatients = _resourcesManager.GetResourceManagerByName(reportName).GetString("TotalNumberOfPatients") + ": " + data.Data.GroupBy(a => a.PatientKey).Select(group => group.First()).Count(); data.TotalNumberOfAssessmentsDuringTimeFrame = _resourcesManager.GetResourceManagerByName(reportName).GetString("TotalNumberOfAssessmentsDuringTimeFrame") + ": " + GetTotalNumberOfAssessmentsDuringTimePeriod(data.StartDate, data.EndDate); data.LocalizedQuestionResponses = GetQuestionResponsesFromResource(reportParams); data.ReportName = _resourcesManager.GetResourceManagerByName(reportName).GetString("ReportName" + originalReportName); data.HeaderQuestion = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderQuestion"); data.HeaderSpecificResponseValue = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderSpecificResponse"); data.HeaderName = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderName"); data.HeaderAge = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderAge"); data.HeaderGender = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderGender"); data.HeaderAssessmentName = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderAssessmentName"); data.HeaderAssessmentDate = _resourcesManager.GetResourceManagerByName(reportName).GetString("AssessmentDate"); data.HeaderGivenResponse = _resourcesManager.GetResourceManagerByName(reportName).GetString("GivenResponse"); data.HeaderViewAssessment = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderViewAssessment"); }
private static ReportModel CreateSummarySection(IResourcesManager resourcesManager, AssessmentInstance dastInstance, AssessmentInstance nidaAssessFurtherInstance) { var reportModel = new ReportModel { Name = ReportNames.NidaPatientSummaryReport, IsCustomizable = true }; var reportItems = new List <ReportItem> (); var nidaAssessFurtherResources = resourcesManager == null ? new ResourceManager(typeof(NidaAssessFurther)) : resourcesManager.GetResourceManagerByName(NidaAssessFurther.AssessmentCodedConcept.Code); var nidaAssessFurther = new NidaAssessFurther(nidaAssessFurtherInstance); var displayName = nidaAssessFurtherResources.GetString( "_" + AssessmentPart.GetPropertyCodedConcept <NidaAssessFurther, Lookup>( a => a.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceOpioidPersonalMedicalHistoryFrequency).Code); CheckAddDrugFrequency( reportItems, nidaAssessFurtherResources, nidaAssessFurther.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceOpioidPersonalMedicalHistoryFrequency, displayName); displayName = nidaAssessFurtherResources.GetString( "_" + AssessmentPart.GetPropertyCodedConcept <NidaAssessFurther, Lookup>( a => a.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceCocainePersonalMedicalHistoryFrequency).Code); CheckAddDrugFrequency( reportItems, nidaAssessFurtherResources, nidaAssessFurther.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceCocainePersonalMedicalHistoryFrequency, displayName); displayName = nidaAssessFurtherResources.GetString( "_" + AssessmentPart.GetPropertyCodedConcept <NidaAssessFurther, Lookup>( a => a.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceMarijuanaPersonalMedicalHistoryFrequency).Code); CheckAddDrugFrequency( reportItems, nidaAssessFurtherResources, nidaAssessFurther.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceMarijuanaPersonalMedicalHistoryFrequency, displayName); displayName = nidaAssessFurtherResources.GetString( "_" + AssessmentPart.GetPropertyCodedConcept <NidaAssessFurther, Lookup>( a => a.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceSedativePersonalMedicalHistoryFrequency).Code); CheckAddDrugFrequency( reportItems, nidaAssessFurtherResources, nidaAssessFurther.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceSedativePersonalMedicalHistoryFrequency, displayName); displayName = nidaAssessFurtherResources.GetString( "_" + AssessmentPart.GetPropertyCodedConcept <NidaAssessFurther, Lookup>( a => a.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceStimulantPersonalMedicalHistoryFrequency).Code); CheckAddDrugFrequency( reportItems, nidaAssessFurtherResources, nidaAssessFurther.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceStimulantPersonalMedicalHistoryFrequency, displayName); displayName = nidaAssessFurther.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceOtherSubstanceofAbusePersonalMedicalHistorySpecify; CheckAddDrugFrequency( reportItems, nidaAssessFurtherResources, nidaAssessFurther.DrugUseFrequencyGroup.SubstanceAbuseIllicitSubstanceOtherSubstanceofAbusePersonalMedicalHistoryFrequency, displayName); reportModel.AddReportItem( new ReportItem( PropertyUtil.ExtractPropertyName <NidaReportData, string> (r => r.SummaryHeader), null, new[] { dastInstance.Score.Value }, reportItems.ToArray() ) { ItemMetadata = new ItemMetadata { MetadataItems = new List <IMetadataItem> { new ReadonlyMetadataItem { IsReadonly = true } } } }); return(reportModel); }
private void SetStrings(NotCompletedAssessmentData data, NotCompletedAssessmentParameters reportParams, string reportName) { if (reportParams == null || data == null) { return; } var start = reportParams.StartDate; var end = reportParams.EndDate; var dateRange = start.GetValueOrDefault().ToShortDateString() + " - " + end.GetValueOrDefault().ToShortDateString(); if (reportParams.TimePeriod != null) { reportParams.TimePeriod.GetRange(out start, out end); dateRange = reportParams.TimePeriod.DisplayName; } var ageRange = _resourcesManager.GetResourceManagerByName(reportName).GetString("NA"); if (reportParams.AgeRangeLow != null && reportParams.AgeRangeHigh != null) { ageRange = reportParams.AgeRangeLow + " - " + reportParams.AgeRangeHigh; } var gender = _resourcesManager.GetResourceManagerByName(reportName).GetString("NA"); if (!string.IsNullOrWhiteSpace(reportParams.Gender)) { gender = reportParams.Gender; } var assessment = _resourcesManager.GetResourceManagerByName(reportName).GetString("All"); if (!string.IsNullOrWhiteSpace(reportParams.AssessmentName)) { assessment = reportParams.AssessmentName; } data.AssessmentParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("Assessment") + ": " + assessment; data.DateRangeParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("DateRange") + ": " + dateRange; data.AgeGroupParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("AgeGroup") + ": " + ageRange; data.GenderParameter = _resourcesManager.GetResourceManagerByName(reportName).GetString("Gender") + ": " + gender; data.ReportName = _resourcesManager.GetResourceManagerByName(reportName).GetString("ReportName"); data.HeaderName = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderName"); data.HeaderAge = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderAge"); data.HeaderGender = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderGender"); data.HeaderAssessmentName = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderAssessmentName"); data.HeaderAssessmentStatus = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderAssessmentStatus"); data.HeaderViewAssessment = _resourcesManager.GetResourceManagerByName(reportName).GetString("HeaderViewAssessment"); }
public DataTableResponse <AssessmentSummaryDto> Get(Guid key, string sEcho, int iDisplayStart, int iDisplayLength, string sSearch = null) { const string whereSearchConstraint = " AND (AssessmentName LIKE @search+'%')"; var selfAdminConstraint = "AND CanSelfAdminister=1"; const string query = @" SELECT COUNT(*) as TotalCount FROM AssessmentModule.AssessmentInstance WHERE OrganizationKey=@OrganizationKey AND PatientKey=@PatientKey {0} {1} SELECT [t].* FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY [t1].CreatedTime DESC) AS [ROW_NUMBER], [t1].AssessmentInstanceKey, [t1].AssessmentName, [t1].AssessmentCode, [t1].PercentComplete, [t1].CreatedTime, [t1].IsSubmitted, [t1].PatientKey FROM AssessmentModule.AssessmentInstance AS [t1] WHERE PatientKey=@PatientKey {0} {1} ) AS [t] WHERE [t].[ROW_NUMBER] BETWEEN @start + 1 AND @end ORDER BY [t].[ROW_NUMBER] "; if (UserContext.Current.PatientKey != null && key != UserContext.Current.PatientKey) { return(new DataTableResponse <AssessmentSummaryDto> { Data = Enumerable.Empty <AssessmentSummaryDto>(), Echo = sEcho, TotalDisplayRecords = 0, TotalRecords = 0, }); } if (UserContext.Current.PatientKey == null) { selfAdminConstraint = string.Empty; } var start = iDisplayStart; var end = start + iDisplayLength; using (var connection = _connectionFactory.CreateConnection()) using (var multiQuery = connection.QueryMultiple(string.Format(query, sSearch == null ? "" : whereSearchConstraint, selfAdminConstraint), new { start, end, PatientKey = key, search = sSearch, UserContext.Current.OrganizationKey })) { var totalCount = multiQuery.Read <int>().Single(); var assessmentSummaryDto = multiQuery.Read <AssessmentSummaryDto>().ToList(); var dataTableResponse = new DataTableResponse <AssessmentSummaryDto> { Data = assessmentSummaryDto, Echo = sEcho, TotalDisplayRecords = totalCount, TotalRecords = totalCount, }; foreach (var data in dataTableResponse.Data) { data.AssessmentName = _resourcesManager.GetResourceManagerByName(data.AssessmentName).GetString(SharedStringNames.ResourceKeyPrefix + data.AssessmentCode); } return(dataTableResponse); } }
/// <summary>Gets the report data table.</summary> /// <param name="sEcho">The s echo.</param> /// <param name="iDisplayStart">The i display start.</param> /// <param name="iDisplayLength">Display length of the i.</param> /// <param name="patientKey">The patient key.</param> /// <param name="sSearch">The s search.</param> /// <returns>A <see cref="DataTableResponse{ReportSummaryDto}" />.</returns> public DataTableResponse <ReportSummaryDto> GetReportDataTable(string sEcho, int iDisplayStart, int iDisplayLength, Guid?patientKey = null, string sSearch = null) { const string WhereConstraint = "PatientKey = @patientKey"; const string WhereSearchConstraint = "(Name LIKE @search+'%')"; const string WherePatientViewableConstraint = "IsPatientViewable = 1"; const string Query = @" SELECT COUNT(*) as TotalCount FROM AssessmentModule.Report WHERE ReportType = 0 AND {0} SELECT [t].SourceKey, [t].CreatedTimestamp as 'CreatedTime', [t].Name, [t].NameFormat, [t].CanCustomize, [t].PatientKey, [t].ReportSeverity, [t].ReportStatus, [t].ReportType, [t].ReportKey as 'Key' , [t].OrganizationKey FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY [t1].Name) AS [ROW_NUMBER], [t1].Name, [t1].NameFormat, [t1].CreatedTimestamp, [t1].CanCustomize, [t1].PatientKey , [t1].ReportSeverity, [t1].ReportStatus, [t1].ReportType, [t1].SourceKey , [t1].ReportKey , [t1].OrganizationKey FROM AssessmentModule.Report AS [t1] WHERE ReportType = 0 AND {0} ) AS [t] WHERE [t].[ROW_NUMBER] BETWEEN @start + 1 AND @end ORDER BY [t].[CreatedTimestamp] DESC"; if (UserContext.Current.PatientKey.HasValue && UserContext.Current.PatientKey != patientKey) { return(new DataTableResponse <ReportSummaryDto> { Data = Enumerable.Empty <ReportSummaryDto> (), Echo = sEcho, TotalDisplayRecords = 0, TotalRecords = 0 }); } var start = iDisplayStart; var end = start + iDisplayLength; var whereConstraintBuilder = new StringBuilder("OrganizationKey = @OrganizationKey "); if (patientKey.HasValue || sSearch != null || UserContext.Current.PatientKey.HasValue) { if (patientKey.HasValue) { whereConstraintBuilder.Append(" AND " + WhereConstraint); } if (sSearch != null) { whereConstraintBuilder.Append(" AND " + WhereSearchConstraint); } if (UserContext.Current.PatientKey.HasValue) { whereConstraintBuilder.Append(" AND " + WherePatientViewableConstraint); } } var completeQuery = string.Format(Query, whereConstraintBuilder); var totalCount = 0; IEnumerable <ReportSummaryDto> reportDtos = null; try { using (var connection = _connectionFactory.CreateConnection()) using (var multiQuery = connection.QueryMultiple(completeQuery, new { start, end, patientKey, search = sSearch, UserContext.Current.OrganizationKey })) { totalCount = multiQuery.Read <int> ().Single(); reportDtos = multiQuery.Read <ReportSummaryDto> ().ToList(); foreach (var dto in reportDtos) { dto.DisplayName = string.Format(dto.NameFormat, _resourcesManager.GetResourceManagerByName(dto.Name).GetString(SharedStringNames.ReportName)); } } } catch (Exception) { } return(new DataTableResponse <ReportSummaryDto> { Data = reportDtos, Echo = sEcho, TotalDisplayRecords = totalCount, TotalRecords = totalCount, }); }
private static ReportModel CreateSummarySection(IResourcesManager resourcesManager, AssessmentInstance dastInstance, AssessmentInstance nidaAssessFurtherInstance) { var reportModel = new ReportModel { Name = ReportNames.NidaPatientSummaryReport, IsCustomizable = true }; var reportItems = new List <ReportItem> (); var nidaAssessFurtherResources = resourcesManager == null ? new ResourceManager(typeof(NidaAssessFurther)) : resourcesManager.GetResourceManagerByName(NidaAssessFurther.AssessmentCodedConcept.Code); var otherDrug = string.Empty; foreach (var itemDefinition in NidaAssessFurther.DrugAndFrequencyGroup) { var item = nidaAssessFurtherInstance.ItemInstances.FirstOrDefault(i => i.ItemDefinitionCode == itemDefinition.CodedConcept.Code); if (item == null) { continue; } if (item.Value is Lookup) { if (otherDrug != string.Empty) { reportItems.Add(new ReportItem( PropertyUtil.ExtractPropertyName <NidaReportData, List <ReportString> > (r => r.SummaryItems), null, new object[] { otherDrug, nidaAssessFurtherResources.GetString("_" + ((Lookup)item.Value).CodedConcept.Code) } ) { ItemMetadata = new ItemMetadata { MetadataItems = new List <IMetadataItem> { new ReadonlyMetadataItem { IsReadonly = true } } } }); otherDrug = string.Empty; } else { var lookupName = nidaAssessFurtherResources.GetString("_" + ((Lookup)item.Value).CodedConcept.Code); if (((Lookup)item.Value).Value == 0) { continue; } reportItems.Add(new ReportItem( PropertyUtil.ExtractPropertyName <NidaReportData, List <ReportString> > (r => r.SummaryItems), null, new object[] { nidaAssessFurtherResources.GetString("_" + item.ItemDefinitionCode), lookupName } ) { ItemMetadata = new ItemMetadata { MetadataItems = new List <IMetadataItem> { new ReadonlyMetadataItem { IsReadonly = true } } } }); } } else { otherDrug = item.Value.ToString(); } } reportModel.AddReportItem(new ReportItem( PropertyUtil.ExtractPropertyName <NidaReportData, string> (r => r.SummaryHeader), null, new [] { dastInstance.Score.Value }, reportItems.ToArray() ) { ItemMetadata = new ItemMetadata { MetadataItems = new List <IMetadataItem> { new ReadonlyMetadataItem { IsReadonly = true } } } }); return(reportModel); }