public async Task <MetricResponse> CreateMetric(MetricCreate metric, string patientId) { MetricResponse responseMessage = null; var uri = new Uri($"http://umc-api.maartenmol.nl:5000/api/v1/metric/patient={patientId}"); try { var json = JsonConvert.SerializeObject(metric); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await _client.PostAsync(uri, content); if (response.StatusCode == System.Net.HttpStatusCode.Created) { Console.WriteLine("Metric aangemaakt"); var responseJson = await response.Content.ReadAsStringAsync(); responseMessage = JsonConvert.DeserializeObject <MetricResponse>(responseJson); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(responseMessage); }
private async void FinishMetric() { DateTime now = DateTime.Now; string deviceBloeddruk = ""; string deviceGewicht = ""; string deviceTemperatuur = ""; foreach (DeviceListItem device in devices) { if (device.DeviceType.ToLower() == "bloeddrukmeters") { deviceBloeddruk = device.DeviceId; } if (device.DeviceType.ToLower() == "thermometer") { deviceTemperatuur = device.DeviceId; } if (device.DeviceType.ToLower() == "weegschaal") { deviceGewicht = device.DeviceId; } } MetricCreate newMetric = new MetricCreate { device_bloeddruk = deviceBloeddruk, device_gewicht = deviceGewicht, device_temperatuur = deviceTemperatuur, metric_type = "", nurse_id = userId, timestamp = now.ToString("yyyy/MM/dd HH:mm:ss"), comment = "Voice Test" }; UserDialogs.Instance.ShowLoading("Opslaan"); var metricResponse = await _metricService.CreateMetric(newMetric, patient._id); foreach (string metric in metrics) { Metric updateMetric = new Metric { raw_text = metric, metric_id = metricResponse.createMetric }; await _metricService.SaveMetric(updateMetric); } var navigationParams = new NavigationParameters { { "metricId", metricResponse.createMetric }, { "patientId", patient._id }, { "userId", userId } }; UserDialogs.Instance.HideLoading(); await _navigationService.NavigateAsync("../MetricResult", navigationParams); }