public async Task IcuNotAddedSuccessfully()
        {
            var newIcu = new ICUBedDetails
            {
                BedsCount = 3,
                Beds      = new List <BedDetails>
                {
                    new BedDetails
                    {
                        BedId  = "BID50",
                        IcuId  = "ICU04",
                        Status = false
                    },
                    new BedDetails
                    {
                        BedId  = "BID51",
                        IcuId  = "ICU04",
                        Status = false
                    },
                    new BedDetails
                    {
                        BedId  = "BID52",
                        IcuId  = "ICU04",
                        Status = false
                    }
                }
            };
            var response = await _sut.Client.PostAsync(Url + "/IcuWards",
                                                       new StringContent(JsonConvert.SerializeObject(newIcu), Encoding.UTF8, "application/json"));

            Assert.True(response.StatusCode == HttpStatusCode.BadRequest);
        }
        }                                       //ReSharper restore all

        private async System.Threading.Tasks.Task AddIcuDetails_ClickAsync()
        {
            var newBedDetails = new BedDetails
            {
                BedId  = textBoxBedId.Text,
                IcuId  = textBoxIcuId.Text,
                Status = bool.Parse(textBoxStatus.Text)
            };

            var bedDetailsList = new List <BedDetails>
            {
                newBedDetails
            };

            var newIcuDetails = new ICUBedDetails
            {
                IcuId     = textBoxIcuId.Text,
                LayoutId  = textBoxLayoutId.Text,
                BedsCount = int.Parse(textBoxBedsCount.Text),
                Beds      = bedDetailsList
            };

            var response = await Client.PostAsync("http://localhost:5000/api/IcuDetails/IcuWards", new StringContent(JsonConvert.SerializeObject(newIcuDetails), Encoding.UTF8, "application/json"));

            var responseString = await response.Content.ReadAsStringAsync();

            textBoxBedId.Text = responseString;
        }
        public void AddIcu(ICUBedDetails newState)
        {
            var icuList = _creator.ReadIcuDatabase();

            _validator.ValidateNewIcuId(newState.IcuId, newState, icuList);
            icuList.Add(newState);
            _creator.WriteToIcuDatabase(icuList);
        }
        }           //ReSharper disable all

        public void ValidateNewIcuId(string icuId, ICUBedDetails icuRecord, List <ICUBedDetails> icuStore)
        {
            if (icuStore.Any(icu => icu.IcuId == icuId))
            {
                throw new Exception("Invalid Patient Id");
            }

            ValidateIcuRecord(icuRecord);
        }       //ReSharper restore all
Ejemplo n.º 5
0
 public IActionResult Put(string icuId, [FromBody] ICUBedDetails icu)
 {
     try
     {
         _configurationRepository.UpdateIcu(icuId, icu);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
Ejemplo n.º 6
0
        public IActionResult Post([FromBody] ICUBedDetails icu)
        {
            try
            {
                _configurationRepository.AddIcu(icu);

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
        public void UpdateIcu(string icuId, ICUBedDetails state)
        {
            var icuList = _creator.ReadIcuDatabase();

            _validator.ValidateIcuRecord(state);

            for (var i = 0; i < icuList.Count; i++)
            {
                if (icuList[i].IcuId != icuId)
                {
                    continue;
                }
                icuList.Insert(i, state);
                _creator.WriteToIcuDatabase(icuList);
                return;
            }
            throw new Exception("Invalid data field");
        }
 public void ValidateIcuRecord(ICUBedDetails icu)
 {
     _validator.IsWhitespaceOrEmptyOrNull(icu.IcuId);
     _validator.IsWhitespaceOrEmptyOrNull(icu.BedsCount.ToString());
     _validator.IsWhitespaceOrEmptyOrNull(icu.LayoutId);
 }           //ReSharper disable all
Ejemplo n.º 9
0
        public Database()
        {
            var patient1 = new PatientDetails
            {
                PatientId   = "PID001",
                PatientName = "Deepak",
                Age         = 25,
                ContactNo   = "8081170626",
                BedId       = "BID1",
                IcuId       = "ICU01",
                Email       = "*****@*****.**",
                Address     = new PatientAddress
                {
                    HouseNo = "32",
                    Street  = "Adarsh Colony",
                    City    = "Sasaram",
                    State   = "Bihar",
                    Pincode = "821115"
                },
                Vitals = new VitalsCategory
                {
                    PatientId = "PID001",
                    Spo2      = 99,
                    Bpm       = 63,
                    RespRate  = 118
                }
            };

            _patients.Add(patient1);
            var patient2 = new PatientDetails
            {
                PatientId   = "PID002",
                PatientName = "Varshitha",
                Age         = 23,
                ContactNo   = "8310797121",
                BedId       = "BID2",
                IcuId       = "ICU01",
                Email       = "*****@*****.**",
                Address     = new PatientAddress
                {
                    HouseNo = "10",
                    Street  = "karnataka",
                    City    = "karnataka",
                    State   = "karnataka",
                    Pincode = "100000"
                },
                Vitals = new VitalsCategory
                {
                    PatientId = "PID002",
                    Spo2      = 57,
                    Bpm       = 76,
                    RespRate  = 15
                }
            };

            _patients.Add(patient2);

            var patient3 = new PatientDetails
            {
                PatientId   = "PID003",
                PatientName = "Vikash",
                Age         = 50,
                ContactNo   = "8448364728",
                BedId       = "BID3",
                IcuId       = "ICU01",
                Email       = "*****@*****.**",
                Address     = new PatientAddress
                {
                    HouseNo = "15",
                    Street  = "Mico",
                    City    = "Sasaram",
                    State   = "Bihar",
                    Pincode = "821115"
                },
                Vitals = new VitalsCategory
                {
                    PatientId = "PID003",
                    Spo2      = 122,
                    Bpm       = 188,
                    RespRate  = 91
                }
            };

            _patients.Add(patient3);

            _beds1.Add(new BedDetails
            {
                BedId  = "BID1",
                Status = true,
                IcuId  = "ICU01"
            });
            _beds1.Add(new BedDetails
            {
                BedId  = "BID2",
                Status = true,
                IcuId  = "ICU01"
            });
            _beds1.Add(new BedDetails
            {
                BedId  = "BID3",
                Status = true,
                IcuId  = "ICU01"
            });
            _beds1.Add(new BedDetails
            {
                BedId  = "BID4",
                Status = false,
                IcuId  = "ICU01"
            });
            _beds1.Add(new BedDetails
            {
                BedId  = "BID5",
                Status = false,
                IcuId  = "ICU01"
            });
            _beds1.Add(new BedDetails
            {
                BedId  = "BID6",
                Status = false,
                IcuId  = "ICU01"
            });
            _beds1.Add(new BedDetails
            {
                BedId  = "BID7",
                Status = false,
                IcuId  = "ICU01"
            });
            var icu = new ICUBedDetails
            {
                IcuId     = "ICU01",
                LayoutId  = "LID02",
                BedsCount = 7,
                Beds      = _beds1
            };

            _icuList.Add(icu);

            _beds2.Add(new BedDetails
            {
                BedId  = "BID50",
                Status = false,
                IcuId  = "ICU03"
            });
            _beds2.Add(new BedDetails
            {
                BedId  = "BID51",
                Status = false,
                IcuId  = "ICU03"
            });
            _beds2.Add(new BedDetails
            {
                BedId  = "BID52",
                Status = false,
                IcuId  = "ICU03"
            });

            _icuList.Add(new ICUBedDetails
            {
                IcuId     = "ICU03",
                LayoutId  = "LID03",
                BedsCount = 3,
                Beds      = _beds2
            });

            WriteToPatientsDatabase(_patients);
            WriteToIcuDatabase(_icuList);
        }