Esempio n. 1
0
        /// <summary>
        /// Wrapper en Category, Choice og/eller Detail til et kald sammen med Patients CPR-nr og en Status kode på kaldet(Afventende, Udført, Fortrudt)
        /// </summary>
        /// <param name="cprnr">CPR-nr for Patient</param>
        /// <param name="status">Status kode(Active, Completed, Canceled) på kaldet</param>
        /// <param name="categoryEntity">Kategorien</param>
        /// <param name="choiceEntity">Valget</param>
        /// <param name="detailEntity">Tilebør</param>
        /// <returns>Returner et objekt der anses som et kald, klar til at blive sendt afsted til Web API</returns>
        public static CallEntity WrapCall(String cprnr, CallUtil.StatusCode status, CategoryEntity categoryEntity, ChoiceEntity choiceEntity=null, DetailEntity detailEntity=null)
        {
            var callEntity = new CallEntity();

            /* Non-nullable values */
            //callEntity._id = Guid.NewGuid().ToString();
            callEntity.PatientCPR = cprnr;
            callEntity.Status = (int)status;
            callEntity.Category = categoryEntity.Name;

            /* Nullable values*/
            /*
            if (categoryEntity.Picture != null)
            {
                callEntity.Picture = categoryEntity.Picture;
            }
             */

            if (choiceEntity != null)
            {
                callEntity.Choice = choiceEntity.Name;
            }

            /* Nullable values*/
            if (detailEntity != null)
            {
                callEntity.Detail = detailEntity.Name;
            }

            return callEntity;

        }
Esempio n. 2
0
        public void UpdateRow(CategoryEntity category, Single fontSize, SizeF imageViewSize)
        {
            LabelView.Text = category.Name;
            
            if (category.Picture != null && category.Picture != "BsonNull")
            {
                try
                {
                    var webClient = new WebClient();
                    webClient.DownloadDataCompleted += (s, e) =>
                    {
                        var bytes = e.Result; // get the downloaded data
                            ImageView.Image = ImageHandler.BytesToImage(bytes); // convert the data to an actual image
                    };
                    webClient.DownloadDataAsync(new Uri(category.Picture));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Something went wrong loading image for cell..." + ex.Message);
                }
                
            }
     
            LabelView.Font = UIFont.FromName("HelveticaNeue-Bold", fontSize);

            ImageView.Frame = new RectangleF(0, 0, imageViewSize.Width, imageViewSize.Height);
            // Position category label below image
            LabelView.Frame = new RectangleF(0, (float) ImageView.Frame.Bottom+60, imageViewSize.Width, (float) (ContentView.Frame.Height - ImageView.Frame.Bottom));
        }
Esempio n. 3
0
        public void SendingCallJSONCategory_JSONConverted()
        {
            try
            {
                // Arrange
                var testString = "Test";
                CategoryEntity categoryEntity = new CategoryEntity
                {
                    CategoryId = Guid.NewGuid().ToString(),
                    Name = "TestTestTest"
                };
                CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, categoryEntity, null,
                    null);

                //Act
                PatientCall call = new PatientCall();

                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                //Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gemmer alle Categories, tilknyttet Choices og Details til PatientApp'ens egen lokale SQL database
        /// </summary>
        /// <param name="db">Den delte database PCL</param>
        /// <param name="categories">Et array med Categories, tilknyttet Choices og Details som skal gemmes</param>
        public static void SaveCategoriesToLocalDatabase(SharedLocalDB db, CategoryEntity[] categories)
        {

            if (categories != null)
            {
                db.SaveCategories(categories.ToList());
            }

        }
Esempio n. 5
0
        public List<CategoryEntity> GetCategoriesTESTDATA()
        {
            // TEST DATA 

           var categoryEntities = new List<CategoryEntity>();

            // CATEGORY -> CHOICES -> DETAILS
           var d1 = new DetailEntity()
           {
               DetailId = Guid.NewGuid().ToString(),
               Name = "Mælk",
           };

           var d2 = new DetailEntity()
           {
               DetailId = Guid.NewGuid().ToString(),
               Name = "Sukker"
           };

           var d3 = new DetailEntity()
           {
               DetailId = Guid.NewGuid().ToString(),
               Name = "Sort kaffe"
           };

           var d4 = new DetailEntity()
           {
               DetailId = Guid.NewGuid().ToString(),
               Name = "Sukkerfri"
           };

           var d5 = new DetailEntity()
           {
               DetailId = Guid.NewGuid().ToString(),
               Name = "Tun og æg"
           };

           var d6= new DetailEntity()
           {
               DetailId = Guid.NewGuid().ToString(),
               Name = "Skinke og ost"
           };

           var ch1 = new ChoiceEntity()
           {
               ChoiceId = Guid.NewGuid().ToString(),
               Name = "Kaffe",
               Details = new List<DetailEntity> { d1, d2, d3 } // 1-M
           };

           var ch2 = new ChoiceEntity()
           {
               ChoiceId = Guid.NewGuid().ToString(),
               Name = "Cola",
               Details = new List<DetailEntity> { d2, d4 } // 1-M
           };

           d1.Choices = new List<ChoiceEntity> {ch1};
           d2.Choices = new List<ChoiceEntity> { ch1, ch2 }; // M-M

           d3.Choices = new List<ChoiceEntity> { ch1 };

           d4.Choices = new List<ChoiceEntity> { ch2 };

           var ch3 = new ChoiceEntity()
           {
               ChoiceId = Guid.NewGuid().ToString(),
               Name = "Sandwich",
               Details = new List<DetailEntity> { d5, d6 }
           };

           d5.Choices = new List<ChoiceEntity> { ch3 };
           d6.Choices = new List<ChoiceEntity> { ch3 };

           var cat1 = new CategoryEntity()
           {
               CategoryId = Guid.NewGuid().ToString(),
               Name = "Mad/Drikke",
               //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
               Choices = new List<ChoiceEntity> {ch1, ch2, ch3}
           };

           ch1.CategoryId = cat1.CategoryId;
           ch2.CategoryId = cat1.CategoryId;

           categoryEntities.Add(cat1);

           // CATEGORY -> CHOICES
           var ch4 = new ChoiceEntity()
           {
               ChoiceId = Guid.NewGuid().ToString(),
               Name = "Morfin"
           };

           var ch5 = new ChoiceEntity()
           {
               ChoiceId = Guid.NewGuid().ToString(),
               Name = "Panodil"
           };

           var cat2 = new CategoryEntity()
           {
               CategoryId = Guid.NewGuid().ToString(),
               Name = "Smertestillende",
               //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
               Choices = new List<ChoiceEntity> { ch4, ch5 }
           };

           ch2.CategoryId = cat2.CategoryId;

           categoryEntities.Add(cat2);

           // CATEGORY -> OBS EMPTY CHOICE
           var cat3 = new CategoryEntity()
           {
               CategoryId = Guid.NewGuid().ToString(),
               Name = "Toilet",
               //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
           };

           ch3.CategoryId = cat3.CategoryId;

           categoryEntities.Add(cat3);

           return categoryEntities;
          
        } 
        private void CategoryTapped(CategoryEntity category)
        {
            // The category tapped
            Category = category;

            // Hvis der ikke er nogle typer, så start kaldet her
            if (Category.Choices == null || Category.Choices.Count == 0 || String.IsNullOrEmpty(Category.Choices[0].Name)) // Dummy, hvis der er en tom Choice liste uden et navn
            {
                CallEntity callEntity = CallWrapper.WrapCall(UserData.CPRNR, CallUtil.StatusCode.Active, Category);
                AppDelegate.MakeCall(callEntity, this);
            }

            // Ellers gå videre til næste view.
            else
            {
                PerformSegue("CategorySegue", this);
            }

        }
Esempio n. 7
0
        public void SendingCallJSONCategoryChoice_JSONConverted()
        {
            // Arrange
            var testString = "Test";

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name = "Morfin"
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name = "Smertestillende",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List<ChoiceEntity> { choice }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, null);

            try
            {
                //Act
                PatientCall call = new PatientCall();
                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                // Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
Esempio n. 8
0
        public void UpdatingCallJSON_CalledUpdated()
        {
            //Arrange
            // Arrange
            var testString = "Test";

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name = "Morfin"
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name = "Smertestillende",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List<ChoiceEntity> { choice }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, null);

            //Act
            PatientCall call = new PatientCall();

            try
            {
                callEntity._id = "5641c5dd02a93d27a8910f9c";
                callEntity.Status = (int) CallUtil.StatusCode.Canceled;
                call.UpdateCall(callEntity);
            }
            catch (Exception e)
            {
                // Assert
                Assert.Fail("No calls has been updated");
            }
        }
Esempio n. 9
0
 // Constructor
 public CategoryAdapter(Context c, CategoryEntity[] categories)
 {
     mContext = c;
     Categories = categories;
 }