Beispiel #1
0
 /// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 /// <param name="navigationParameter">The parameter value passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
 /// </param>
 /// <param name="pageState">A dictionary of state preserved by this page during an earlier
 /// session.  This will be null the first time a page is visited.</param>
 protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
 {
     try
     {
         BottomAppBar1.IsSticky = true;
         BottomAppBar1.IsOpen = true;
         LoadTaskDetail((PageNavigationParams)navigationParameter);
     }
     catch (Exception ex)
     {
         ErrorHandler eh = new ErrorHandler(ex, "TasksDetail");
         eh.ShowErrorDialog();
         return;
     }
 }
        async void PatientProblemDetail_Loaded(object sender, RoutedEventArgs e)
        {
            bool NoData = true;

           // PageNavigationParams pnp = new PageNavigationParams();
           // ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
           // ApplicationDataCompositeValue compositeValue = localSettings.Values["PatientProblemDetailPage"] as ApplicationDataCompositeValue;
            //pnp.ProblemDescription = compositeValue["strProblemDescription"] as string;
           // pnp.ProblemID = compositeValue["strProblemID"] as string;
           // pnp.PatientID = compositeValue["strPatientID"] as string;

            ViewModel.ProblemDescription = Nike.Core.Data_Services.PageNavigationService.ChartItem.Name;

            try
            {
                int i = 0;
                //  UserObject use = new UserObject();
                List<VitalData> listPulse = new List<VitalData>();
                List<VitalData> listBMI = new List<VitalData>();
                bool bHasResultData = false;
                bool bHasVitalsData = false;
                bool bHasMedsData = false;

                ChartControl ccVital = new ChartControl();
                ChartControl ccResult = new ChartControl();
                ChartControl ccMeds = new ChartControl();

                string sjson = await ViewModel.PatientDataService.GetProblemActivity(ViewModel.UnityDataService.UnityAppUser, PageNavigationService.PatientItem.ID, PageNavigationService.ChartItem.ID);
                JArray obj = JArray.Parse(sjson);
                foreach (JObject jo in obj)
                {
                    string sPrevResult = "";
                    string sPrevOrder = "";
                    //info4 is results
                    JToken activity = jo.SelectToken("getproblemactivityinfo", false);
                    if (activity != null)
                    {
                        if (activity.Count() == 0)
                            continue;

                        List<ResultData> listResults = new List<ResultData>();
                        foreach (JToken joRow in activity)
                        {
                            string sResultName = joRow["ResultName"].ToString().Trim();
                            string sResultValue = joRow["ResultValue"].ToString().Trim();
                            string sResultUnits = joRow["ResultUnits"].ToString().Trim();
                            string sResultDate = joRow["ResultDate"].ToString().Trim();
                            string sOrderName = joRow["OrderName"].ToString().Trim();
                            string sResultDisplayValue = joRow["DisplayResultValue"].ToString().Trim();

                            decimal dResultValue = 0;
                            if (sPrevOrder != sOrderName)
                            {
                                i = 0;
                            }
                            if (i == 0)
                            {
                                sPrevOrder = sOrderName;
                                ccResult.SetOrderList(sOrderName);
                            }

                            if (!string.IsNullOrEmpty(sResultValue))
                            {
                                if (decimal.TryParse(sResultValue, out dResultValue))
                                {
                                    string sDisplayDate = DateTime.Parse(sResultDate).ToString("MM/dd/yy");
                                    DateTime dt = DateTime.Parse(sResultDate);

                                    ResultData rd = new ResultData(dResultValue, dt, sResultName, sResultUnits, sOrderName, sResultDisplayValue);
                                    listResults.Add(rd);
                                }
                            }

                            i++;
                        }
                        if (listResults.Count() > 0)
                        {
                            bHasResultData = true;
                            ccResult.OrdersAndResults = listResults;
                        }
                    }

                    JToken activity1 = jo.SelectToken("getproblemactivityinfo1", false);
                    if (activity1 != null)
                    {
                        if (activity1.Count() == 0)
                            continue;
                        List<VitalData> listChart = new List<VitalData>();
                        i = 0;
                        foreach (JToken joRow in activity1)
                        {

                            string sVitalName = joRow["vital"].ToString().Trim();
                            string sVitalValue = joRow["vitval"].ToString().Trim();
                            string sVitalUnits = joRow["units"].ToString().Trim();
                            string sVitalDate = joRow["vitaldate"].ToString().Trim();
                            string sDisplay = joRow["disp"].ToString().Trim();

                            decimal dVitalValue = 0;

                            if (i == 0)
                            {
                                sPrevResult = sVitalName;

                            }
                            if (sVitalName != sPrevResult && listChart.Count > 0)
                            {
                                sPrevResult = sVitalName;

                                ccVital.VitalsAddSeries(listChart);
                                if (listChart.Count() > 1)
                                {
                                    bHasVitalsData = true;
                                }
                                listChart.Clear();
                            }
                            if (!string.IsNullOrEmpty(sVitalName))
                            {
                                if (decimal.TryParse(sVitalValue, out dVitalValue))
                                {
                                    string sDisplayDate = DateTime.Parse(sVitalDate).ToString("MM/dd/yy");
                                    DateTime dt = DateTime.Parse(sDisplayDate);
                                    VitalData rd = new VitalData(dVitalValue, dt, sVitalName, sDisplay);
                                    listChart.Add(rd);

                                }
                            }

                            i++;
                        }
                        if (listChart.Count() > 0)
                        {
                            ccVital.VitalsAddSeries(listChart);
                        }
                    }
                    //info2 is meds


                    JToken activity2 = jo.SelectToken("getproblemactivityinfo2", false);
                    if (activity2 != null)
                    {
                        if (activity2.Count() == 0)
                            continue;
                        List<MedData> listMed = new List<MedData>();
                        i = 0;
                        foreach (JToken joRow in activity2)
                        {

                            string sMedName = joRow["drugname"].ToString().Trim();
                            string sMedStrength = joRow["drugstrength"].ToString().Trim();
                            string sStartDate = joRow["startdate"].ToString().Trim();
                            string sEndDate = joRow["enddate"].ToString().Trim();
                            string sDays = joRow["days"].ToString().Trim();

                            decimal dStrength = 0;

                            decimal.TryParse(sMedStrength, out dStrength);

                            MedData md = new MedData(sMedName, sMedStrength, sStartDate, sEndDate, int.Parse(sDays));
                            listMed.Add(md);
                            bHasMedsData = true;


                            i++;
                        }
                        ccMeds.MedsAddSeries(listMed);
                    }
                }
                if (bHasMedsData)
                {
                    Grid.SetRow(ccResult, 0);
                    GraphBody.Children.Add(ccMeds);
                    NoData = false;
                }
                if (bHasResultData)
                {

                    Grid.SetRow(ccResult, 1);

                    //GraphBody.Children.Add(ccResult);
                    ccResult.ControlReady = true;
                    NoData = false;
                }
                if (bHasVitalsData)
                {
                    Grid.SetRow(ccVital, 2);
                    ccVital.SetTitle("Vitals");
                    GraphBody.Children.Add(ccVital);
                    NoData = false;
                }

                if (NoData)
                {
                    TextBox tb = new TextBox();
                    tb.Text = "No data for this patient.";
                    tb.FontSize = 24;
                    GraphBody.Children.Add(tb);

                }
                
            }
            catch (Exception ex)
            {
                ErrorHandler eh = new ErrorHandler(ex, "PatientProblemDetail.xaml onnavigatedto");
                eh.ShowErrorDialog();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Invoked when a filter is selected using the ComboBox in snapped view state.
        /// </summary>
        /// <param name="sender">The ComboBox instance.</param>
        /// <param name="e">Event data describing how the selected filter was changed.</param>
        async void Filter_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Determine what filter was selected
            var selectedFilter = e.AddedItems.FirstOrDefault() as Filter;
            
            if (selectedFilter != null)
            {
                // Mirror the results into the corresponding Filter object to allow the
                // RadioButton representation used when not snapped to reflect the change
                selectedFilter.Active = true;

                // TODO: Respond to the change in active filter by setting this.DefaultViewModel["Results"]
                //       to a collection of items with bindable Image, Title, Subtitle, and Description properties


//You will need implement IEnumerable<Person>, that is all that WPF need to make something bindable.? (right now nly displaying description?

                 object objQueryText;
                
                string queryText = string.Empty;

                if (this.DefaultViewModel.TryGetValue("QueryText", out  objQueryText))
                {
                    
                    queryText =  objQueryText.ToString();
                    queryText = queryText.Replace("'\u201c'", String.Empty);
                   
                    Regex r = new Regex("(?:[^a-z0-9, ]|(?<=['\"])s)", RegexOptions.IgnoreCase );
                   queryText= r.Replace(queryText, String.Empty);

                }
                
                PatientObject po = new  PatientObject();
                try
                {
                    Collection<PatientItem> colPatients = await po.SearchPatients(objUnityData.UnityAppUser, queryText);
                    this.DefaultViewModel["Results"] = colPatients;

                }
                catch (Exception ex)
                {
                    ErrorHandler eh = new ErrorHandler(ex, "Patient Search");
                    eh.ShowErrorDialog();
                    return;
                }
             
                // Ensure results are found
                object results;
                ICollection resultsCollection;
                if (this.DefaultViewModel.TryGetValue("Results", out results) &&
                    (resultsCollection = results as ICollection) != null &&
                    resultsCollection.Count != 0)
                {
                    VisualStateManager.GoToState(this, "ResultsFound", true);
                    return;
                }
            }

            // Display informational text when there are no search results.
            VisualStateManager.GoToState(this, "NoResultsFound", true);
        }
Beispiel #4
0
        public async Task<string> Magic(string action, string appuser, string appname, string patientid, string token, string parameter1, string parameter2, string parameter3, string parameter4, string parameter5, string parameter6, string data)
        {
            string sError = "";
            string sJson = "";
            HttpResponseMessage rm = null;
            string reqBody = "";

            using (HttpClient hc = new HttpClient())
            {

                Uri urirest = new Uri(UnityURL);

                hc.BaseAddress = urirest;
             
                string patdata = patientid;

                if (string.IsNullOrEmpty(patientid) && (usedemodata || RecordData.ToLower().Equals("y")))
                {
                    patdata = "NA";
                }
                else
                {
                    patdata = patientid;
                }

                StringBuilder sb = new StringBuilder();
                using (StringWriter sw = new StringWriter())
                {
                    using (JsonTextWriter jtw = new JsonTextWriter(sw))
                    {

                        jtw.Formatting = Formatting.Indented;

                        jtw.WriteStartObject();

                        jtw.WritePropertyName("Action");
                        jtw.WriteValue(action);

                        jtw.WritePropertyName("Appname");
                        jtw.WriteValue(appname);

                        jtw.WritePropertyName("AppUserID");
                        jtw.WriteValue(appuser);

                        jtw.WritePropertyName("PatientID");
                        jtw.WriteValue(patientid);

                        jtw.WritePropertyName("Token");
                        jtw.WriteValue(token);

                        jtw.WritePropertyName("Parameter1");
                        jtw.WriteValue(parameter1);

                        jtw.WritePropertyName("Parameter2");
                        jtw.WriteValue(parameter2);

                        jtw.WritePropertyName("Parameter3");
                        jtw.WriteValue(parameter3);

                        jtw.WritePropertyName("Parameter4");
                        jtw.WriteValue(parameter4);

                        jtw.WritePropertyName("Parameter5");
                        jtw.WriteValue(parameter5);

                        jtw.WritePropertyName("Parameter6");
                        jtw.WriteValue(parameter6);

                        jtw.WritePropertyName("Data");
                        jtw.WriteValue("");

                        jtw.WriteEndObject();

                        reqBody = sw.ToString();

                    }
                }
                //try to make a valid filename for the demo mode.
                Regex r = new Regex("(?:[^a-z0-9 ]|(?<=['\"])s)", RegexOptions.IgnoreCase);
                string fn = r.Replace(parameter1, String.Empty);

                //datetime in parameter 1 is hosing up the filesave for demos.
                if (action.ToLower() == "getschedule")
                    fn = "";

                string filename = action + "_" + appuser + "_" + fn + patdata + ".json";
                StorageFolder storageFolder = ApplicationData.Current.LocalFolder;

                if (!UseDemoData)
                {
                    rm = await hc.PostAsync("MagicJson", new StringContent(reqBody, Encoding.UTF8, "application/json"));

                    if (!rm.IsSuccessStatusCode)
                    {
                        sError = await rm.Content.ReadAsStringAsync();
                        ErrorHandler eh = new ErrorHandler(sError);
                        string sMessage = eh.FormattedError;

                        throw new Exception("execute magic  error :" + sMessage + " status code: " + " error code: " + rm.ToString());


                    }
                    else
                    {
                        Stream s = await rm.Content.ReadAsStreamAsync();
                        StreamReader sr = new StreamReader(s);
                        sJson = await sr.ReadToEndAsync();

                        if (RecordData == "Y" ? true:false)
                        {

                            IStorageFile file = await storageFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
                            await FileIO.WriteTextAsync(file, sJson);
                        }
                    }


                }
                else
                {
                    try
                    {
                        using (Stream s = await storageFolder.OpenStreamForReadAsync(filename))
                        {
                            s.Position = 0;

                            byte[] buff = new byte[s.Length];
                            s.Read(buff, 0, (int)s.Length);

                            s.Dispose();

                            sJson = Encoding.UTF8.GetString(buff, 0, buff.Length);
                            buff = null;

                        }
                    }
                    catch (FileNotFoundException)
                    {
                        throw new Exception("Demo data not found. for action : " + action);

                    }

                }
                return sJson;
            }


        }
Beispiel #5
0
        //public IUserDataService _userDataService
        //{
        //    get
        //    {
        //        return Mvx.Resolve<IUserDataService>();
        //    }
        //}

        //public IUnityDataService _unityDataService
        //{
        //    get
        //    {
        //        return Mvx.Resolve<IUnityDataService>();
        //    }
        //}

        


        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        /// <remarks></remarks>
        /// <author>BD 20120801</author>
        /// <revisions></revisions>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {

            try
            {
            // create a new instance of the flyout
            settings = new SettingsFlyout();

            settings.Closed += settings_Closed;

            SettingsPane.GetForCurrentView().CommandsRequested += BlankPage_CommandsRequested;

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            Object oldURL = localSettings.Values["UnityURL"];

            if (oldURL != null)
            {
                OldURLSetting = oldURL.ToString();

            }

            Object demoMode = localSettings.Values["DemoMode"];

            if (demoMode != null)
            {
                OldDemoModeSetting = demoMode.ToString();
                objUnityData.DemoData = demoMode.ToString();

            }
            else
                demoMode = "N";

            Object RecordData = localSettings.Values["RecordData"];

            if (RecordData != null)
            {
                OldRecordDataSetting = RecordData.ToString();
                objUnityData.RecordData = RecordData.ToString();

            }
            else
                RecordData = "N";



            if (string.IsNullOrEmpty(objUnityData.UnityAppUser))
            {
                    loginOpened = true;

                    // Create a cancellation token from CancellationTokenSource
                    cTokenSource = new CancellationTokenSource();
                    var cToken = cTokenSource.Token;

                    use = new UserObject();

                    bool bOK = false;

                    try
                    {
                        bOK = await use.Logon(cToken);
                    }
                    catch (System.Threading.Tasks.TaskCanceledException )
                    {
                        return;
                        //TaskCanceledException thrown when user opens login screen, goes directly to settings. Need to suppress and log.
                    }


                    //we have a good user, update the tiles.
                    if (bOK)
                    {

                        string providerName = await use.GetUserDetails(objUnityData.UnityAppUser);

                        //Win8 session caching
                        StorageFolder temporaryFolder = ApplicationData.Current.TemporaryFolder;
                        StorageFile providerNameFile = await temporaryFolder.CreateFileAsync("ProviderName.txt", CreationCollisionOption.ReplaceExisting);
                        await FileIO.WriteTextAsync(providerNameFile, providerName);


                        var rootFrame = new Frame();
                        if (!Frame.Navigate(typeof(Hub)))
                        {
                            throw new Exception("Failed to create hub page");
                        }
                        
                        /*MVVM Framework Initialization*/
                        //Frame rootFrame = Window.Current.Content as Frame;
                        //if (rootFrame == null)
                        //    rootFrame = new Frame();
                        //var setup = new Setup(rootFrame);
                        //setup.Initialize();

                        //var start = Mvx.Resolve<IMvxAppStart>();
                        //start.Start();
                        
                    }

                    loginOpened = false;
                }
            }
            catch (Exception ex)
            {
                
                    ErrorHandler eh = new ErrorHandler(ex, "default.xaml on navigate event");
                    eh.ShowErrorDialog();
                
            }
        }
        private async void GetPatientData(string sPatientID, string datatype)
        {
            try
            {
                PatientObject po = new PatientObject();
                List<DocumentListItem> lstDocuments = await PatientDataService.GetDocumentList(UnityDataService.UnityAppUser, sPatientID);

                List<ChartSectionItem> lstChartSection = await PatientDataService.GetChartSections(UnityDataService.UnityAppUser, sPatientID, datatype);


                //MEDS SECTION
                ChartItemCategory listMeds = new ChartItemCategory("Medications");
                //Allergies SECTION
                ChartItemCategory listAllergy = new ChartItemCategory("Allergies");
                //PROBLEM SECTION
                ChartItemCategory listProblems = new ChartItemCategory("Problems");
                //Vitals SECTION
                ChartItemCategory listVitals = new ChartItemCategory("Vitals");
                //Immunizations SECTION
                ChartItemCategory listImmunizations = new ChartItemCategory("Immunizations");
                //History SECTION
                ChartItemCategory listHistory = new ChartItemCategory("History");


                ChartItemCategory listAll = new ChartItemCategory("Test");
                ChartItemCategory listDocuments = new ChartItemCategory("Documents");

                //Documents Section some hardcodes for demo
                if (lstDocuments.Count > 0)
                {

                    foreach (DocumentListItem doc in lstDocuments)
                    {
                        DocumentChartItem newDoc = new DocumentChartItem(doc.DocumentID, doc.DisplayName + " " + doc.SortDate, doc.AuthorName, doc.DocumentType, "Y", "0", doc.Img);
                        listDocuments.AddChartItem(newDoc);
                        listAll.AddChartItem(newDoc);

                    }
                }
                //TODO: replace this with faster LINQ query.
                foreach (ChartSectionItem csi in lstChartSection)
                {
                    ProblemItem pi = new ProblemItem(csi.transid, csi.expdescription, csi.level1);

                    DateTime vitalsDateTime = DateTime.Now;
                    if ((csi.level1.ToUpper() != "Y") && (csi.section.ToUpper() != "VITALS"))//this is skipping vitals...
                    {
                        continue;
                    }
                    switch (csi.section)
                    {
                        case "medications":
                            MedicationChartItem newMed = new MedicationChartItem(csi.transid, csi.expdescription, csi.exp2description, csi.exp2detail, csi.level1, csi.sortorder);
                            listMeds.AddChartItem(newMed);
                            listAll.AddChartItem(newMed);
                            break;
                        case "allergies":
                            AllergyChartItem newAllergy = new AllergyChartItem(csi.transid, csi.expdescription, csi.exp2description, csi.exp2detail, csi.level1, csi.sortorder);
                            listAllergy.AddChartItem(newAllergy);
                            listAll.AddChartItem(newAllergy);
                            break;
                        case "problems":
                            ProblemChartItem newProblem = new ProblemChartItem(csi.transid, csi.expdescription, csi.exp2description, csi.exp2detail, csi.level1, csi.sortorder);
                            listProblems.AddChartItem(newProblem);
                            listAll.AddChartItem(newProblem);
                            break;
                        case "immunizations":
                            ImmunizationChartItem newImmunization = new ImmunizationChartItem(csi.transid, csi.expdescription, csi.exp2description, csi.exp2detail, csi.level1, csi.sortorder);
                            listImmunizations.AddChartItem(newImmunization);
                            listAll.AddChartItem(newImmunization);
                            break;
                        case "history":
                            HistoryChartItem newHistory = new HistoryChartItem(csi.transid, csi.expdescription, csi.exp2description, csi.exp2detail, csi.level1, csi.sortorder);
                            listHistory.AddChartItem(newHistory);
                            break;
                        case "vitals":
                            if (csi.description.ToLower() != "other")
                            {
                                VitalChartItem newVitals = new VitalChartItem("0", csi.description, csi.detail, csi.expright, csi.level1, csi.sortorder);
                                listVitals.AddChartItem(newVitals);
                            }
                            break;
                        default:
                            break;
                    }

                }

                ObservableCollection<ChartItemCategory> newChart = new ObservableCollection<ChartItemCategory>();
                newChart.Add(listProblems);
                newChart.Add(listVitals);
                newChart.Add(listAllergy);
                newChart.Add(listMeds);
                newChart.Add(listDocuments);
                newChart.Add(listImmunizations);
                newChart.Add(listHistory);

                ChartItems cis = new ChartItems();
                cis.AddChartItemCategory(listProblems);
                cis.AddChartItemCategory(listVitals);
                cis.AddChartItemCategory(listAllergy);
                cis.AddChartItemCategory(listMeds);

                if (lstDocuments.Count > 0)
                    cis.AddChartItemCategory(listDocuments);

                cis.AddChartItemCategory(listImmunizations);
                cis.AddChartItemCategory(listHistory);

                ChartItemSource = new ObservableCollection<ChartItemCategory>(cis.Items);


                //This may seem redundant but it prevents the gridview from auto-selecting the first item.
                //gvChartItems.SelectionMode = ListViewSelectionMode.None;
                //gvChartItems.SelectionMode = ListViewSelectionMode.Single;
                //lvChartItems.SelectionMode = ListViewSelectionMode.None;

                //Add context for semantic zoom out.
                //var groupedChartItems = chartItemsViewSource.View.CollectionGroups;
                //var groupedChartItems = chartItemGroupViewSource.View.CollectionGroups;
                //lvChartItems.ItemsSource = cis.Items; 

            }
            catch (Exception ex)
            {
                ErrorHandler eh = new ErrorHandler(ex, "PatientOverview GetData");
                eh.ShowErrorDialog();
            }

        }
        public async void InitializePatientOverview()
        {
            //this.DefaultViewModel["CanGoBack"] = this._previousContent != null;

         //   var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
           // Object value = localSettings.Values["CurrentPatientID"];

           // if (value != null)
           // {
            PageNavigationService pns = new PageNavigationService();

            string currentPatientID = pns.PatientID;
                Patient = await PatientDataService.GetPatient(UnityDataService.UnityAppUser, currentPatientID);
           // }

            Patients = new ObservableCollection<PatientItem>();
            Patients.Add(Patient);

            try
            {
                GetPatientData(Patient.ID, ""); //"426"
            }
            catch (Exception ex)
            {
                ErrorHandler eh = new ErrorHandler(ex, "Patient Overview GetData");
                eh.ShowErrorDialog();
                return;
            }

            List<PatientItem> lstRecentPatients = await PatientDataService.GetRecentPatients(UnityDataService.UnityAppUser);
            RecentPatients = new ObservableCollection<PatientItem>(lstRecentPatients);
        }