private void LoadList(IList<MeasurementInstanceModel> measurements)
		{
			Items.Clear ();

			foreach (var entry in measurements) {
				var item = new MeasurementDashboardItemViewModel () {
					Subject = entry.Subject.Name,
					LastRecordedDate = entry.DateRecorded,
					MeasurementName = entry.Definition.Name,
					MeasurementDefinitionId = entry.MeasurementDefinitionId
				};

				if(entry.MeasurementGroups != null && entry.MeasurementGroups.Any()) {

					item.MeasurementGroups = new ObservableCollection<MeasurementItemGroupViewModel> ();
					var g = new MeasurementItemGroupViewModel ();
					item.MeasurementGroups.Add (g);
					g.MeasurementItems = new ObservableCollection<MeasurementItemViewModel> ();
					foreach (var group in entry.MeasurementGroups) {

						g.DefinitionName = group.MeasurementGroupDefinitionModel.Name;
						g.MeasurementItems.Add (new MeasurementItemViewModel () { 
							Name = group.MeasurementGroupDefinitionModel.Name,
							Uom = group.Unit.Abbreviation,
							Value = group.Value
						});

					}

				}

				Items.Add (item);
			}
		}
		public void Load(int id) {


			IList<MeasurementInstanceModel> measurements = new List<MeasurementInstanceModel> ();

			var profile = _profileRepository.GetAllWithChildren (p => p.MeasurementSubjectId == id, o => o.Id, null, null, null).FirstOrDefault();

			if (profile != null) {
				using(var scope = App.AutoFacContainer.BeginLifetimeScope ()) {	
					foreach (var def in profile.ProfileMeasurementDefinitions) {
						var query = scope.ResolveKeyed<IPredefinedQuery<MeasurementInstanceModel>> (def.MeasurementTypeModel.Name);
						var result = query.Query ((new List<object>() {id, def.MeasurementDefinitionId}).ToArray());
						if (result != null) {
							measurements.Add (result);
						} else {
							measurements.Add (new MeasurementInstanceModel () {MeasurementDefinitionId = def.MeasurementDefinitionId, 
								MeasurementSubjectId = id, Subject = Subjects.FirstOrDefault(f => f.Id == id), 
								Definition = _definitionRepository.GetAll(p => p.Id == def.MeasurementDefinitionId).FirstOrDefault()});
						}
					}
				}
			}

			Items.Clear ();


			foreach (var entry in measurements) {
				var item = new MeasurementDashboardItemViewModel () {
					Subject = entry.Subject.Name,
					MeasurementSubjectId = entry.MeasurementSubjectId,
					LastRecordedDate = entry.DateRecorded,
					MeasurementName = entry.Definition.Name,
					MeasurementDefinitionId = entry.MeasurementDefinitionId
				};

				if (entry.MeasurementGroups != null && entry.MeasurementGroups.Any ()) {

					item.MeasurementGroups = new ObservableCollection<MeasurementItemGroupViewModel> ();
					var g = new MeasurementItemGroupViewModel ();
					item.MeasurementGroups.Add (g);
					g.MeasurementItems = new ObservableCollection<MeasurementItemViewModel> ();
					foreach (var group in entry.MeasurementGroups) {

						g.DefinitionName = group.MeasurementGroupDefinitionModel.Name;
						g.MeasurementItems.Add (new MeasurementItemViewModel () { 
							Name = group.MeasurementGroupDefinitionModel.Name,
							Uom = group.Unit.Abbreviation,
							Value = group.Value
						});

					}

				}

				Items.Add (item);
			}
			
		}
Beispiel #3
0
		private void Load(Tuple<int, int> parameter) {
			Items.Clear ();

			var measurementTypes = new List<string> () { "Average", "Minimum observed", "Maximum observed", "Last Entry" };

			IList<MeasurementInstanceModel> measurements = new List<MeasurementInstanceModel> ();

			using(var scope = App.AutoFacContainer.BeginLifetimeScope ()) {	
				foreach (var type in measurementTypes) {
					var query = scope.ResolveKeyed<IPredefinedQuery<MeasurementInstanceModel>> (type);
					var result = query.Query ((new List<object>() {parameter.Item1, parameter.Item2}).ToArray());
					if (result != null) {

						var str = result.Definition.Name;
						MeasurementName = str;
						result.Definition.Name = type;
						measurements.Add (result);
					}
				}
			}


			foreach (var entry in measurements) {
				var item = new MeasurementDashboardItemViewModel () {
					Subject = entry.Subject.Name,
					MeasurementSubjectId = entry.MeasurementSubjectId,
					LastRecordedDate = entry.DateRecorded,
					MeasurementName = entry.Definition.Name,
					MeasurementDefinitionId = entry.MeasurementDefinitionId
				};

				if(entry.MeasurementGroups != null && entry.MeasurementGroups.Any()) {

					item.MeasurementGroups = new ObservableCollection<MeasurementItemGroupViewModel> ();
					var g = new MeasurementItemGroupViewModel ();
					item.MeasurementGroups.Add (g);
					g.MeasurementItems = new ObservableCollection<MeasurementItemViewModel> ();
					foreach (var group in entry.MeasurementGroups) {

						g.DefinitionName = group.MeasurementGroupDefinitionModel.Name;
						g.MeasurementItems.Add (new MeasurementItemViewModel () { 
							Name = group.MeasurementGroupDefinitionModel.Name,
							Uom = group.Unit.Abbreviation,
							Value = group.Value
						});

					}

				}

				Items.Add (item);
			}

		}