public SeriesValueList[] GetElementValues(long patientId, string elementName, int records) { var patientFromRepo = _patientRepository.Get(p => p.Id == patientId); if (patientFromRepo == null) { throw new ArgumentException(nameof(patientId)); } if (string.IsNullOrWhiteSpace(elementName)) { throw new ArgumentException(nameof(elementName)); } var encounters = _encounterRepository.List(e => e.Patient.Id == patientId) .OrderBy(e => e.EncounterDate); var seriesValueArray = new List <SeriesValueList>(); var seriesValueList = new SeriesValueList() { Name = elementName }; var values = new List <SeriesValueListItem>(); foreach (Encounter encounter in encounters) { var datasetInstance = _datasetInstanceRepository.Get(di => di.ContextId == encounter.Id && di.Dataset.ContextType.Id == (int)ContextTypes.Encounter); if (datasetInstance != null) { var value = datasetInstance.GetInstanceValue(elementName); var decimalValue = 0M; Decimal.TryParse(value, out decimalValue); if (!String.IsNullOrWhiteSpace(value)) { var modelItem = new SeriesValueListItem() { Value = decimalValue, //Min = intValue - ((intValue * 20) / 100), //Max = intValue + ((intValue * 20) / 100), Name = encounter.EncounterDate.ToString("yyyy-MM-dd") }; values.Add(modelItem); if (values.Count >= records) { break; } } } } seriesValueList.Series = values; seriesValueArray.Add(seriesValueList); return(seriesValueArray.ToArray()); }
/// <summary> /// Map additional dto detail elements not handled through automapper /// </summary> /// <param name="dto">The dto that the link has been added to</param> /// <param name="analyserTermSetResourceParameters">Standard parameters for representing resource</param> /// <returns></returns> private AnalyserTermDetailDto CustomResultMap(AnalyserTermDetailDto dto, AnalyserTermSetResourceParameters analyserTermSetResourceParameters) { dto.Results = GetAnalyserResultSets <AnalyserResultDto>(dto.TerminologyMeddraId, analyserTermSetResourceParameters); // Generate series for exposed cases var exposedSeriesValueArray = new List <SeriesValueList>(); var exposedSeriesValueList = new SeriesValueList() { Name = "Exposed Cases" }; var exposedValues = new List <SeriesValueListItem>(); var riskSeriesValueArray = new List <SeriesValueList>(); var riskSeriesValueList = new SeriesValueList() { Name = "Unadjused Relative Risks" }; var riskValues = new List <SeriesValueListItem>(); foreach (var result in dto.Results) { var exposedModelItem = new SeriesValueListItem() { Value = result.ExposedIncidenceRate.Cases, //Min = intValue - ((intValue * 20) / 100), //Max = intValue + ((intValue * 20) / 100), Name = result.Medication }; exposedValues.Add(exposedModelItem); var riskModelItem = new SeriesValueListItem() { Value = result.UnadjustedRelativeRisk, //Min = intValue - ((intValue * 20) / 100), //Max = intValue + ((intValue * 20) / 100), Name = result.Medication }; riskValues.Add(riskModelItem); } exposedSeriesValueList.Series = exposedValues; exposedSeriesValueArray.Add(exposedSeriesValueList); riskSeriesValueList.Series = riskValues; riskSeriesValueArray.Add(riskSeriesValueList); dto.ExposedCaseSeries = exposedSeriesValueArray.ToArray(); dto.RelativeRiskSeries = riskSeriesValueArray.ToArray(); return(dto); }