public void Retrieve_BloodPressure_Yesterday() { BloodPressureData bpData = client.GetBloodPressure(DateTime.Today.AddDays(-1)); Assert.IsNotNull(bpData); Assert.IsNotNull(bpData.BP); }
public override void OnCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { var record = new BloodPressureData(); var offset = 0; Integer flags = characteristic.GetIntValue(GattFormat.Uint8, offset++); // See BPMManagerCallbacks.UNIT_* for unit options bool timestampPresent = ((int)flags & 0x02) > 0; bool pulseRatePresent = ((int)flags & 0x04) > 0; // following bytes - systolic, diastolic and mean arterial pressure record.Systolic = characteristic.GetFloatValue(GattFormat.Sfloat, offset).FloatValue(); record.Diastolic = characteristic.GetFloatValue(GattFormat.Sfloat, offset + 2) .FloatValue(); offset += 6; if (timestampPresent) { record.RecordDateTime = new DateTime( characteristic.GetIntValue(GattFormat.Uint16, offset).IntValue(), characteristic.GetIntValue(GattFormat.Uint8, offset + 2).IntValue(), characteristic.GetIntValue(GattFormat.Uint8, offset + 3).IntValue(), characteristic.GetIntValue(GattFormat.Uint8, offset + 4).IntValue(), characteristic.GetIntValue(GattFormat.Uint8, offset + 5).IntValue(), characteristic.GetIntValue(GattFormat.Uint8, offset + 6).IntValue()); offset += 7; } if (pulseRatePresent) { record.PulseRate = characteristic.GetFloatValue(GattFormat.Sfloat, offset).FloatValue(); } Records.Add(record); }
private void InitUi() { _btnCancel = FindViewById <Button>(Resource.Id.btn_cancel); _btnRegister = FindViewById <Button>(Resource.Id.btn_add); editTextSystolic = FindViewById <EditText>(Resource.Id.et_sys); editTextDiastolic = FindViewById <EditText>(Resource.Id.et_dia); editTextPulse = FindViewById <EditText>(Resource.Id.et_puls); _editTextSystolicLayout = FindViewById <TextInputLayout>(Resource.Id.et_sys_layout); _editTextDiastolicLayout = FindViewById <TextInputLayout>(Resource.Id.et_dia_layout); _editTextPulseLayout = FindViewById <TextInputLayout>(Resource.Id.et_puls_layout); _btnCancel.Click += (sender, args) => { model = null; Dismiss(); }; _btnRegister.Click += (sender, args) => { if (FormIsValid()) { model.Systolic = string.IsNullOrEmpty(editTextSystolic.Text) ? 0 : float.Parse(editTextSystolic.Text); model.Diastolic = string.IsNullOrEmpty(editTextDiastolic.Text) ? 0 : float.Parse(editTextDiastolic.Text); model.PulseRate = string.IsNullOrEmpty(editTextPulse.Text) ? 0 : float.Parse(editTextPulse.Text); model.RecordDateTime = DateTime.Now; Dismiss(); } }; }
public void AddExaminationToPatient(int patientId, Examination exam, ExaminationType examType, IExaminationType examData, WorkFlow workFlow) { var patient = GetPatient(patientId, true); patient.Examinations.Add(exam); exam.WorkFlow = workFlow; _context.SaveChanges(); if (examType == ExaminationType.BloodPressure) { BloodPressureData ExanData = examData as BloodPressureData; _context.BloodPressureData.Add(examData as BloodPressureData); ExanData.ExaminationId = exam.Id; _context.SaveChanges(); } if (examType == ExaminationType.BloodSpO2) { SpOData ExanData = examData as SpOData; _context.SpOData.Add(examData as SpOData); ExanData.ExaminationId = exam.Id; _context.SaveChanges(); } if (examType == ExaminationType.BodyTemperature) { BodyTemperatureData ExanData = examData as BodyTemperatureData; ExanData.ExaminationId = exam.Id; _context.BodyTemperatureData.Add(examData as BodyTemperatureData); ExanData.ExaminationId = exam.Id; _context.SaveChanges(); } }
private void ValidateBloodPressureData(BloodPressureData bp) { Assert.IsNotNull(bp); Assert.IsNotNull(bp.Average); Assert.IsNotNull(bp.BP); // Average Assert.AreEqual("Prehypertension", bp.Average.Condition); Assert.AreEqual(85, bp.Average.Diastolic); Assert.AreEqual(115, bp.Average.Systolic); // bp var b = bp.BP.First(); bp.BP.Remove(b); Assert.AreEqual(80, b.Diastolic); Assert.AreEqual(120, b.Systolic); Assert.AreEqual(DateTime.MinValue.TimeOfDay, b.Time.TimeOfDay); Assert.AreEqual(483697, b.LogId); b = bp.BP.First(); Assert.AreEqual(90, b.Diastolic); Assert.AreEqual(110, b.Systolic); Assert.AreEqual(DateTime.MinValue.AddHours(8).TimeOfDay, b.Time.TimeOfDay); Assert.AreEqual(483699, b.LogId); }
private void InitEvents() { AnimationView.AddAnimatorListener(this); _manualRegisterButton.Click += delegate { BloodPressureData model = new BloodPressureData(); var cdd = new BloodPressureManualRegisterDialog(this, model); cdd.DialogState += delegate(object o, DialogStateEventArgs eventArgs) { if (eventArgs.Status != DialogStatuses.Dismissed) { return; } if (model != null) { UpdateUi(model); } }; cdd.Show(); cdd.Window.SetBackgroundDrawableResource(Resource.Color.colorPrimaryDark); }; //_scanButton.Click += delegate { // if (_bluetoothManager == null || _bluetoothAdapter == null) return; // BluetoothScanner.StartScan(ScanCallback); // _scanButton.Enabled = false; // _send = false; // LbStatus.Text = "Se efectueaza masuratoarea..."; // AnimationView.PlayAnimation(); //}; }
public void Can_Deserialize_Food() { string content = SampleDataHelper.GetContent("GetBloodPressure.json"); var deserializer = new JsonDotNetSerializer(); BloodPressureData bp = deserializer.Deserialize <BloodPressureData>(content); ValidateBloodPressureData(bp); }
public async Task GetBloodPressureAsync_Success() { string content = SampleDataHelper.GetContent("GetBloodPressure.json"); Func <HttpResponseMessage> responseMessage = new Func <HttpResponseMessage>(() => { return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(content) }); }); Action <HttpRequestMessage, CancellationToken> verification = new Action <HttpRequestMessage, CancellationToken>((message, token) => { Assert.AreEqual(HttpMethod.Get, message.Method); Assert.AreEqual("https://api.fitbit.com/1/user/-/bp/date/2014-09-27.json", message.RequestUri.AbsoluteUri); }); FitbitClient fitbitClient = Helper.CreateFitbitClient(responseMessage, verification); BloodPressureData response = await fitbitClient.GetBloodPressureAsync(new DateTime(2014, 9, 27)); ValidateBloodPressureData(response); }
/// <summary> /// Sort and save to DB HL7 incoming Messages. /// </summary> /// <param name="request"></param> void HadleHL7Message(HL7RequestInfo request, string createdFromHl7Message) { try { // Handle ADT_A01 - incoming patient registration. Also save the raw HL7 Messages. To log and store it. if (request.Message.ToString().Contains("ADT_A01")) { var pateitnToAdd = new Entities.Patient() { Archived = true, Name = ((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.PatientName.GivenName.Value + " " + ((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.PatientName.FamilyName.Value, Gender = ((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.Sex.Value, ExternalId = Convert.ToInt32(((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.PatientAccountNumber.ID.Value), Age = ((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.DateOfBirth.TimeOfAnEvent.Year, BirthDate = new DateTime( ((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.DateOfBirth.TimeOfAnEvent.Year, ((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.DateOfBirth.TimeOfAnEvent.Month, ((NHapi.Model.V23.Message.ADT_A01)request.Message).PID.DateOfBirth.TimeOfAnEvent.Day), OriginalHL7Message = createdFromHl7Message, }; _patientInfoRepository.AddPatient(pateitnToAdd); _patientInfoRepository.Save(); } // Handle ORU_R01 - incoming Examination data. if (request.Message.ToString().Contains("ORU_R01")) { int externalID = Convert.ToInt32(((NHapi.Model.V23.Message.ORU_R01)request.Message).GetRESPONSE().PATIENT.PID.PatientAccountNumber.ID.Value); Patient patient = new Patient(); Examination examToAdd = new Examination(); BloodPressureData newExamData = new BloodPressureData(); SpOData newExaamSPo = new SpOData(); BodyTemperatureData newExamBTD = new BodyTemperatureData(); bool BloodPressureFalg = false; if (_patientInfoRepository.PatientExistsByExtId(externalID)) { patient = _patientInfoRepository.GetPatientByExtID(externalID); } else { // Todo Save Patient. } int obsCount = ((NHapi.Model.V23.Message.ORU_R01)request.Message).GetRESPONSE().ORDER_OBSERVATIONRepetitionsUsed; for (int i = 0; i < obsCount; i++) { var orderObservation = ((NHapi.Model.V23.Message.ORU_R01)request.Message).GetRESPONSE().GetORDER_OBSERVATION(i); int obxCount = ((NHapi.Model.V23.Message.ORU_R01)request.Message).GetRESPONSE().GetORDER_OBSERVATION(i).OBSERVATIONRepetitionsUsed; for (int j = 0; j < obxCount; j++) { NHapi.Model.V23.Segment.OBX obx = orderObservation.GetOBSERVATION(j).OBX; var obxVaries = orderObservation.GetOBSERVATION(j).OBX.GetObservationValue(); if (obx.ObservationIdentifier.Text.Value == "Body temperature") { Examination examToAddBDT = new Examination(); examToAddBDT.Description = String.Empty; examToAddBDT.Archived = true; examToAddBDT.PatientId = patient.Id; examToAddBDT.Value = DateTime.Now.ToString(); examToAddBDT.ExaminationType = "Body temperature"; newExamBTD.TemperatureValue = Convert.ToInt32(((NHapi.Base.Model.AbstractPrimitive)obx.GetObservationValue(0).Data).Value); _patientInfoRepository.AddExaminationToPatient(patient.Id, examToAddBDT, ExaminationType.BodyTemperature, newExamBTD, null); } if (obx.ObservationIdentifier.Text.Value == "SpO2") { Examination examToAddSPO = new Examination(); examToAddSPO.PatientId = patient.Id; examToAddSPO.Description = String.Empty; examToAddSPO.Archived = true; examToAddSPO.Value = DateTime.Now.ToString(); examToAddSPO.ExaminationType = "SpO2"; newExaamSPo.SPOValue = Convert.ToInt32(((NHapi.Base.Model.AbstractPrimitive)obx.GetObservationValue(0).Data).Value); _patientInfoRepository.AddExaminationToPatient(patient.Id, examToAddSPO, ExaminationType.BloodSpO2, newExaamSPo, null); } if (obx.ObservationIdentifier.Text.Value == "Mean blood pressure") { BloodPressureFalg = true; examToAdd.PatientId = patient.Id; examToAdd.Description = String.Empty; examToAdd.Archived = true; examToAdd.Value = DateTime.Now.ToString(); examToAdd.ExaminationType = "BloodPressure"; newExamData.MeanBloodPressure = Convert.ToInt32(((NHapi.Base.Model.AbstractPrimitive)obx.GetObservationValue(0).Data).Value); } if (obx.ObservationIdentifier.Text.Value == "Pulse rate") { BloodPressureFalg = true; examToAdd.PatientId = patient.Id; examToAdd.Archived = true; examToAdd.Description = String.Empty; examToAdd.Value = DateTime.Now.ToString(); examToAdd.ExaminationType = "BloodPressure"; newExamData.PulseRate = Convert.ToInt32(((NHapi.Base.Model.AbstractPrimitive)obx.GetObservationValue(0).Data).Value); } if (obx.ObservationIdentifier.Text.Value == "Diastolic blood pressure") { BloodPressureFalg = true; examToAdd.PatientId = patient.Id; examToAdd.Archived = true; examToAdd.Description = String.Empty; examToAdd.Value = DateTime.Now.ToString(); examToAdd.ExaminationType = "BloodPressure"; newExamData.DiastolicValue = Convert.ToInt32(((NHapi.Base.Model.AbstractPrimitive)obx.GetObservationValue(0).Data).Value); } if (obx.ObservationIdentifier.Text.Value == "Systolic blood pressure") { BloodPressureFalg = true; examToAdd.PatientId = patient.Id; examToAdd.Archived = true; examToAdd.Description = String.Empty; examToAdd.Value = DateTime.Now.ToString(); examToAdd.ExaminationType = "BloodPressure"; newExamData.SystolicValue = Convert.ToInt32(((NHapi.Base.Model.AbstractPrimitive)obx.GetObservationValue(0).Data).Value); } } if (BloodPressureFalg) { _patientInfoRepository.AddExaminationToPatient(patient.Id, examToAdd, ExaminationType.BloodPressure, newExamData, null); } } } } catch (Exception ex) { _logger.LogInformation("HadleHL7Message error: " + ex.Message); } }
public IActionResult CreateExamination(int patientId, [FromBody] ExaminationCreationDTO examinationDTO, int workFlowID) { if (examinationDTO == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest()); } if (!_patientInfoRepository.PatientExists(patientId)) { return(NotFound()); } WorkFlow workFlow = _patientInfoRepository.GetWorkFlow(workFlowID); if (examinationDTO.Description == "Body temperature") { try { Examination examToAddBDT = new Examination(); examToAddBDT.Description = String.Empty; examToAddBDT.Archived = false; examToAddBDT.PatientId = patientId; examToAddBDT.Value = DateTime.Now.ToString(); examToAddBDT.ExaminationType = "Body temperature"; BodyTemperatureData newExamBTD = new BodyTemperatureData() { TemperatureValue = examinationDTO.TemperatureValue.Value }; _patientInfoRepository.AddExaminationToPatient(patientId, examToAddBDT, ExaminationType.BodyTemperature, newExamBTD, workFlow); return(Ok()); } catch (Exception ex) { _logger.LogCritical("CreateExamination() Error: " + ex.Message.ToString()); return(StatusCode(500, "Internal Server Error")); } } if (examinationDTO.Description == "Blood Pressure") { try { Examination examToAddBDT = new Examination(); examToAddBDT.Description = String.Empty; examToAddBDT.Archived = false; examToAddBDT.PatientId = patientId; examToAddBDT.Value = DateTime.Now.ToString(); examToAddBDT.ExaminationType = "BloodPressure"; BloodPressureData newExamBTD = new BloodPressureData() { SystolicValue = examinationDTO.SystolicValue.Value, DiastolicValue = examinationDTO.DiastolicValue.Value, PulseRate = examinationDTO.PulseRate.Value, MeanBloodPressure = examinationDTO.MeanBloodPressure.Value }; _patientInfoRepository.AddExaminationToPatient(patientId, examToAddBDT, ExaminationType.BloodPressure, newExamBTD, workFlow); return(Ok()); } catch (Exception ex) { _logger.LogCritical("CreateExamination() Error: " + ex.Message.ToString()); return(StatusCode(500, "Internal Server Error")); } } if (examinationDTO.Description == "SpO2") { try { Examination examToAddBDT = new Examination(); examToAddBDT.Description = String.Empty; examToAddBDT.Archived = false; examToAddBDT.PatientId = patientId; examToAddBDT.Value = DateTime.Now.ToString(); examToAddBDT.ExaminationType = "SpO2"; SpOData newExamBTD = new SpOData() { SPOValue = examinationDTO.SPOValue.Value }; _patientInfoRepository.AddExaminationToPatient(patientId, examToAddBDT, ExaminationType.BloodSpO2, newExamBTD, workFlow); return(Ok()); } catch (Exception ex) { _logger.LogCritical("CreateExamination() Error: " + ex.Message.ToString()); return(StatusCode(500, "Internal Server Error")); } } return(NotFound()); }
public BloodPressureManualRegisterDialog(Context context, BloodPressureData model) : base(context) { this.model = model; }
internal async void UpdateUi(BloodPressureData data) { var ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.Uk); if (data != null) { if (!Utils.CheckNetworkAvailability()) { await _bleDevicesDataRecords.Insert(new DevicesRecords { Imei = _imei, DateTime = ft.Format(new Date()), BloodPresureSystolic = data.Systolic, BloodPresureDiastolic = data.Diastolic, BloodPresurePulsRate = data.PulseRate }); } else { JSONObject jsonObject; var jsonArray = new JSONArray(); var list = await _bleDevicesDataRecords.QueryValuations("select * from DevicesRecords"); Log.Error("list", list.Count().ToString()); foreach (DevicesRecords el in list) { try { jsonObject = new JSONObject(); jsonObject .Put("imei", el.Imei) .Put("dateTimeISO", el.DateTime) .Put("geolocation", new JSONObject() .Put("latitude", $"{el.Latitude}") .Put("longitude", $"{el.Longitude}")) .Put("lastLocation", el.LastLocation) .Put("sendPanicAlerts", el.SendPanicAlerts) .Put("stepCounter", el.StepCounter) .Put("bloodPressureSystolic", el.BloodPresureSystolic) .Put("bloodPressureDiastolic", el.BloodPresureDiastolic) .Put("bloodPressurePulseRate", el.BloodPresurePulsRate) .Put("bloodGlucose", "" + el.BloodGlucose) .Put("oxygenSaturation", el.OxygenSaturation) .Put("extension", el.Extension); jsonArray.Put(jsonObject); } catch (JSONException e) { e.PrintStackTrace(); } } jsonObject = new JSONObject(); jsonObject .Put("imei", _imei) .Put("dateTimeISO", ft.Format(new Date())) .Put("geolocation", string.Empty) .Put("lastLocation", string.Empty) .Put("sendPanicAlerts", string.Empty) .Put("stepCounter", string.Empty) .Put("bloodPressureSystolic", data.Systolic) .Put("bloodPressureDiastolic", data.Diastolic) .Put("bloodPressurePulseRate", data.PulseRate) .Put("bloodGlucose", string.Empty) .Put("oxygenSaturation", string.Empty) .Put("extension", string.Empty); jsonArray.Put(jsonObject); string result = await WebServices.WebServices.Post(Constants.SaveDeviceDataUrl, jsonArray); if (result == "Succes!") { Toast.MakeText(this, "Succes", ToastLength.Long).Show(); await _bleDevicesDataRecords.DeleteAll(); } else { Toast.MakeText(this, "" + result, ToastLength.Long).Show(); } } } if (data != null) { _systole.Text = GetString(Resource.String.systole) + " " + data.Systolic + " mmHg"; _diastole.Text = GetString(Resource.String.diastole) + " " + data.Diastolic + " mmHg"; _pulse.Text = GetString(Resource.String.pulse) + " " + data.PulseRate + " b/min"; } else { _systole.Text = string.Empty; _diastole.Text = string.Empty; _pulse.Text = string.Empty; } //ActivateScanButton(); }