/// <summary>
        /// 
        /// </summary>
        internal void SendMeasurements()
        {
            if (this.Weight.HasValue)
            {
                aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService();
                aladdinService.Measurement Measurement = new aladdinService.Measurement();
                Measurement.DateTime = App.getTaskById(this.ActiveTask.ID).DateTimeAssigned; // System.DateTime.Now;
                Measurement.TaskID = this.ActiveTask.ID;

                aladdinService.SystemParameter measurementType = new aladdinService.SystemParameter();
                measurementType.Code = Convert.ToString((int)Config.MeasurementTypeEnum.Weight);
                measurementType.Description = "Weight";
                Measurement.Type = measurementType;

                Measurement.Value = this.Weight.Value;
                Measurement.Units = "Kg";

                Measurement.LowerLimitSpecified = false;
                Measurement.UpperLimitSpecified = false;

                aladdinService.Measurement[] data = new aladdinService.Measurement[] { Measurement };
                aladdinService.OperationResult res = sc.StoreMeasurements(data, App.CurrentUserID);
                if (res.Status == 1)
                {
                    aladdinService.OperationResult taskChangeStatus = sc.ChangeTaskStatus(Convert.ToInt32(this.ActiveTask.ID), (int)Config.TaskStatusEnum.Completed, App.CurrentUserID);
                }

                AppCommands.MoveToPageCommand.Execute("MyTasksPage", null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// static constructor
        /// </summary>
        static Config()
        {
            // Get VALUES / PROPERTIES
            try
            {
                APP_NAME = ConfigurationManager.AppSettings["AppName"];

                // load database properties values
                aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService();
                stringArray[] res1 = sc.getEhealthParameters();

                if ((res1 != null) && (res1.Length > 0))
                {
                    PROPERTIES_DICTIONARY = new Dictionary<string, string>();

                    for (int i = 0; i < res1.Length; i++)
                    {
                        PROPERTIES_DICTIONARY.Add(res1[i].item[0], res1[i].item[1]);
                    }
                }

                // roles
                stringArray[] res2 = sc.getEhealthRoles();

                if ((res2 != null) && (res2.Length > 0))
                {
                    ROLES_DICTIONARY = new Dictionary<string, string>();

                    for (int i = 0; i < res2.Length; i++)
                    {
                        ROLES_DICTIONARY.Add(res2[i].item[0], res2[i].item[1]);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, Config.APP_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Set VALUES / PROPERTIES from Database
            try
            {
                USERTYPE_ADMIN = ROLES_DICTIONARY["ADMIN"];
                USERTYPE_CLINICIAN = ROLES_DICTIONARY["CLINICIAN"];
                USERTYPE_CARER = ROLES_DICTIONARY["CARER"];
                USERTYPE_PATIENT = ROLES_DICTIONARY["PATIENT"];
            }
             catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, Config.APP_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public ExternalServicePageViewModel(aladdinService.Task activeTask)
 {
     this.ActiveTask = activeTask;
     if (this.ActiveTask != null && this.ActiveTask.URL != null)
     {
         this.Url = this.ActiveTask.URL;
         this.Text = this.ActiveTask.Text;
         using (aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService())
         {
             aladdinService.OperationResult taskChangeStatus = sc.ChangeTaskStatus(Convert.ToInt32(this.ActiveTask.ID), (int)Config.TaskStatusEnum.Completed, App.CurrentUserID);
         }
     }
 }
 public ContactUsPage()
 {
     aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService();
     aladdinService.SystemParameter[] _contactSituations = sc.GetSystemParameterList((int)Config.SystemParameterEnum.ContactReason, App.DefaultLocale);
     if (_contactSituations != null)
         this.ContactSituations = _contactSituations.ToList();
     else
     {
         _contactSituations = sc.GetSystemParameterList((int)Config.SystemParameterEnum.ContactReason, App.DefaultLocale);
         if (_contactSituations != null)
             this.ContactSituations = _contactSituations.ToList();
     }
     this.DataContext = this;
     InitializeComponent();
 }
        /// <summary>
        /// SEND button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // WARNING
            try
            {
                using (aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService())
                {
                    aladdinService.Warning userWarning = new aladdinService.Warning();
                    userWarning.DateTimeOfWarning = System.DateTime.Now;
                    aladdinService.SystemParameter typeOfWarning = new aladdinService.SystemParameter();
                    typeOfWarning.Code = "1";
                    typeOfWarning.Description = "Manual";
                    userWarning.TypeOfWarning = typeOfWarning;
                    aladdinService.SystemParameter situation = this.SituationComboBox.SelectedItem as aladdinService.SystemParameter;
                    string situationStr = "";
                    if (situation != null)
                        situationStr = situation.Description;

                    userWarning.Delivered = false;
                    userWarning.JustificationText = string.Format("Situation:{0}, Description:{1}", situationStr, this.DescriptionBox.Text);
                    aladdinService.Patient patient = new aladdinService.Patient();
                    patient.ID = App.PatientID;
                    userWarning.Patient = patient;
                    aladdinService.OperationResult res = sc.SaveWarning(userWarning, App.CurrentUserID);
                    AppCommands.MoveToPageCommand.Execute("StartPage", null);
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Error : " + ex.Message, Config.APP_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // SEND EMAIL
            try
            {
                thirdpartyService.ServicesComponentImplService tps = new thirdpartyService.ServicesComponentImplService();
                // String subject, String txt, String sendTo
                tps.sendEmail("Healthcare desktop client application", this.DescriptionBox.Text, App.PatientID);
            }
            catch (Exception ex) {
                MessageBox.Show("Error : " + ex.Message, Config.APP_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 internal void UploadQuestionnaire()
 {
     string xml = this.QuestionnaireAnswers.ToXml();
     aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService();
     aladdinService.QuestionnaireAnswers answers = Utils.Convert(this.QuestionnaireAnswers);
     answers.DateTime = this.ActiveTask.DateTimeAssigned;
     answers.DateTimeSpecified = true;
     answers.UserID = App.CurrentUserID;
     answers.ObjectID = this.ActiveTask.ObjectID;
     answers.TaskID = this.ActiveTask.ID;
     //answers.ID = this.ActiveTask.Questionnaire.ID;
     aladdinService.OperationResult res = sc.StoreQuestionnaireAnswers(answers, App.CurrentUserID);
     res = sc.ChangeTaskStatus(Convert.ToInt32(this.ActiveTask.ID), (int)Config.TaskStatusEnum.Completed, App.CurrentUserID);
     AppCommands.MoveToPageCommand.Execute("MyTasksPage", null);
 }
        /// <summary>
        /// 
        /// </summary>
        internal void SendMeasurements()
        {
            aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService();
            aladdinService.SystemParameter measurementType = new aladdinService.SystemParameter();
            aladdinService.OperationResult res1 = new aladdinService.OperationResult();
            aladdinService.OperationResult res2 = new aladdinService.OperationResult();

            if (this.DiastolicBloodPressure.HasValue)
            {
                aladdinService.Measurement diastolicBP = new aladdinService.Measurement();
                diastolicBP.DateTime = App.getTaskById(this.ActiveTask.ID).DateTimeAssigned; // System.DateTime.Now;
                diastolicBP.TaskID = this.ActiveTask.ID;

                measurementType = new aladdinService.SystemParameter();
                measurementType.Code = Convert.ToString((int)Config.MeasurementTypeEnum.DiastolicBloodPressure);
                measurementType.Description = "Diastolic BP";

                diastolicBP.Type = measurementType;
                diastolicBP.Value = this.DiastolicBloodPressure.Value;
                diastolicBP.Units = "mmHg";
                diastolicBP.LowerLimitSpecified = false;
                diastolicBP.UpperLimitSpecified = false;

                aladdinService.Measurement[] diastolicBPData = new aladdinService.Measurement[] { diastolicBP };
                res1 = sc.StoreMeasurements(diastolicBPData, App.CurrentUserID);
            }

            if (this.SystolicBloodPressure.HasValue)
            {
                aladdinService.Measurement systolicBP = new aladdinService.Measurement();
                systolicBP.DateTime = App.getTaskById(this.ActiveTask.ID).DateTimeAssigned; // System.DateTime.Now;
                systolicBP.TaskID = this.ActiveTask.ID;

                measurementType = new aladdinService.SystemParameter();
                measurementType.Code = Convert.ToString((int)Config.MeasurementTypeEnum.SystolicBloodPressure);
                measurementType.Description = "Systolic BP";

                systolicBP.Type = measurementType;
                systolicBP.Value = this.SystolicBloodPressure.Value;
                systolicBP.Units = "mmHg";
                systolicBP.LowerLimitSpecified = false;
                systolicBP.UpperLimitSpecified = false;

                aladdinService.Measurement[] systolicBPData = new aladdinService.Measurement[] { systolicBP };
                res2 = sc.StoreMeasurements(systolicBPData, App.CurrentUserID);
            }

            if (res1.Status == 1 && res2.Status == 1)
            {
                aladdinService.OperationResult taskChangeStatus = sc.ChangeTaskStatus(Convert.ToInt32(this.ActiveTask.ID), (int)Config.TaskStatusEnum.Completed, App.CurrentUserID);
            }

            AppCommands.MoveToPageCommand.Execute("MyTasksPage", null);
        }
        /// <summary>
        /// 
        /// </summary>
        internal void SendMeasurements()
        {
            aladdinService.SystemParameter measurementType = new aladdinService.SystemParameter();
            measurementType.Code = Convert.ToString((int)Config.MeasurementTypeEnum.Activity);
            measurementType.Description = "Activity";

            if (manuallyStepsDay)
            {
                aladdinService.Measurement Measurement = new aladdinService.Measurement();

                Measurement.DateTime = App.getTaskById(this.ActiveTask.ID).DateTimeAssigned; ;
                Measurement.TaskID = this.ActiveTask.ID;
                Measurement.Type = measurementType;
                Measurement.Value = manuallyDataValue;
                Measurement.Units = "steps/day";
                Measurement.LowerLimitSpecified = false;
                Measurement.UpperLimitSpecified = false;

                aladdinService.Measurement[] data = new aladdinService.Measurement[1];
                data[0] = Measurement;

                aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService();
                aladdinService.OperationResult res = sc.StoreMeasurements(data, App.CurrentUserID);
                if (res.Status == 1)
                {
                    aladdinService.OperationResult taskChangeStatus = sc.ChangeTaskStatus(Convert.ToInt32(this.ActiveTask.ID), (int)Config.TaskStatusEnum.Completed, App.CurrentUserID);
                }

                AppCommands.MoveToPageCommand.Execute("MyTasksPage", null);
            }
            else if (this.Activity.Length > 0)
            {
                aladdinService.StorageComponentImplService sc = new aladdinService.StorageComponentImplService();
                List<aladdinService.Measurement> dataList = new List<aladdinService.Measurement>(); // We use a dynamic array first, we still don't know how many (new) measurments we have to submit

                List<string> dateLog = new List<string>(); // List of days for which we have already sent the data (history)
                List<string> dateLogNew = new List<string>(); // List of days for which we have new data to send (will be added to the history at the end)
                string date;

                // Load the history
                string logFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\activity.log";
                if (File.Exists(logFile))
                {
                    StreamReader r = new StreamReader(logFile);
                    while ((date = r.ReadLine()) != null)
                        dateLog.Add(date);
                    r.Close();
                }

                for (int day = 0; day < MAX_DAY; ++day)
                {
                    for (int hour = 0; hour < 24; ++hour)
                    {
                        // Build the timestamp of this measurement
                        DateTime dt = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.Now.Day, hour, 0, 0, 0);
                        dt = dt.AddDays(-1 - day);

                        // Process the measurement only if its day is not present in the history
                        if (dateLog.IndexOf(String.Format("{0:d/M/yyyy}", dt)) == -1)
                        {
                            aladdinService.Measurement Measurement = new aladdinService.Measurement();

                            Measurement.DateTime = dt;
                            Measurement.TaskID = this.ActiveTask.ID;
                            Measurement.Type = measurementType;
                            Measurement.Value = this.Activity[day, hour];
                            Measurement.Units = "steps/day";
                            Measurement.LowerLimitSpecified = false;
                            Measurement.UpperLimitSpecified = false;

                            dataList.Add(Measurement);

                            // Update the list of days with new data
                            date = String.Format("{0:d/M/yyyy}", dt);
                            if (dateLogNew.IndexOf(date) == -1)
                                dateLogNew.Add(date);
                        }
                    }
                }

                // Create an array (StoreMeasurements requires an array parameter) with the right size and fill it with the measurements
                aladdinService.Measurement[] data = new aladdinService.Measurement[dataList.Count()];
                for (int i = 0; i < dataList.Count(); ++i)
                    data[i] = dataList[i];

                aladdinService.OperationResult res = sc.StoreMeasurements(data, App.CurrentUserID);
                if (res.Status == 1)
                {
                    aladdinService.OperationResult taskChangeStatus = sc.ChangeTaskStatus(Convert.ToInt32(this.ActiveTask.ID), (int)Config.TaskStatusEnum.Completed, App.CurrentUserID);

                    // Update the history
                    StreamWriter sw;
                    sw = File.AppendText(logFile);
                    foreach (string s in dateLogNew)
                        sw.WriteLine(s);
                    sw.Close();
                }

                AppCommands.MoveToPageCommand.Execute("MyTasksPage", null);
            }
        }