示例#1
0
        private void CreateAndPlaceBeds(IcuModel icu)
        {
            var index    = BedLayoutFunctionCall[icu.Layout].Invoke(icu.MaxBeds);
            var noOfBeds = icu.NoOfBeds;

            V1StackPanel.Children.Clear();
            HStackPanel.Children.Clear();
            V2StackPanel.Children.Clear();

            //var index = UBedLayout(BedList);
            for (int i = 0; i < index[0] && i < noOfBeds; i++)
            {
                V1StackPanel.Children.Add(CreateSingleBed(i));
            }

            index[1] = index[1] + index[0];
            for (int i = index[0]; i < index[1] && i < noOfBeds; i++)
            {
                HStackPanel.Children.Add(CreateSingleBed(i));
            }

            index[2] = index[2] + index[1];
            for (int i = index[1]; i < index[2] && i < noOfBeds; i++)
            {
                V2StackPanel.Children.Add(CreateSingleBed(i));
            }
        }
示例#2
0
        public Dictionary <string, IcuModel> GetAllIcuFromDb()
        {
            var allIcus = new Dictionary <string, IcuModel>();

            try
            {
                DbConnection.Open();
                using var command = DbConnection.CreateCommand();
                EnableForeignKey(command);
                command.CommandText = "Select * from Icu";
                command.Prepare();
                command.ExecuteNonQuery();
                var result = command.ExecuteReader();
                while (result.Read())
                {
                    var icu = new IcuModel()
                    {
                        IcuId    = result.GetString(0),
                        BedCount = result.GetInt32(1)
                    };
                    allIcus.Add(icu.IcuId, icu);
                }
                return(allIcus);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
            finally
            {
                CloseDb();
            }
        }
示例#3
0
 public object AddIcuToDb(IcuModel newIcu)
 {
     DbConnection.Open();
     using var command = DbConnection.CreateCommand();
     EnableForeignKey(command);
     try
     {
         command.CommandText =
             @"INSERT INTO Icu(IcuId, BedCount)" +
             "VALUES (@IcuId, @BedCount);";
         command.Parameters.AddWithValue(@"IcuId", newIcu.IcuId);
         command.Parameters.AddWithValue(@"BedCount", newIcu.BedCount);
         command.Prepare();
         command.ExecuteNonQuery();
         return(HttpStatusCode.OK);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(HttpStatusCode.InternalServerError);
     }
     finally
     {
         CloseDb();
     }
 }
示例#4
0
        public IActionResult PostIcuModelData([FromBody] IcuModel newIcuModel)
        {
            var statusCode = this._config.AddNewIcuConfiguration(newIcuModel, DbOps.GetDbPath());

            if (statusCode.Equals(HttpStatusCode.InternalServerError))
            {
                return(BadRequest());
            }
            return(Ok());
        }
示例#5
0
        public void UpdateIcuDetails(IcuModel icu)
        {
            if (icu != null)
            {
                this.IcuId    = icu.IcuId;
                this.Layout   = icu.Layout;
                this.MaxBeds  = icu.MaxBeds;
                this.NoOfBeds = icu.NoOfBeds;

                List <Backend.Models.BedModel> beds = new BedApiCalls().GetAllBedsFromAnIcu(icu.IcuId).ToList();
                this.FreeBeds = beds.FindAll(bed => bed.BedOccupancyStatus == "Free").Count;
            }
        }
示例#6
0
 public void AddIcu(IcuModel icuModel)
 {
     Client  = new RestClient(BaseUrl);
     Request = new RestRequest("Configuration/PostIcuModelData", Method.POST)
     {
         RequestFormat = DataFormat.Json
     };
     Request.AddJsonBody(icuModel);
     Response = Client.Execute(Request);
     MessageBox.Show(Response.StatusCode.Equals(HttpStatusCode.OK)
         ? "ICU is Added."
         : "Unable To Add ICU");
 }
        public string AddIcu(IcuModel icuModel)
        {
            HttpWebRequest _httpPostReq = WebRequest.CreateHttp(_url);

            _httpPostReq.Method      = "POST";
            _httpPostReq.ContentType = "application/json";
            DataContractJsonSerializer userDataJsonSerializer =
                new DataContractJsonSerializer(typeof(IcuModel));

            userDataJsonSerializer.WriteObject(_httpPostReq.GetRequestStream(), icuModel);
            HttpWebResponse response = _httpPostReq.GetResponse() as HttpWebResponse;

            _jsonSerializer = new DataContractJsonSerializer(typeof(string));
            return(_jsonSerializer.ReadObject(response.GetResponseStream()) as string);
        }
        public void ValidateIcu(IcuModel icu)
        {
            var  b1 = BasicValidator.basicValid.Invoke(icu.IcuId);
            var  b2 = BasicValidator.basicValid.Invoke(icu.Layout);
            bool b3 = BasicValidator.basicValid.Invoke(icu.NoOfBeds.ToString());
            var  b4 = BasicValidator.basicValid(icu.MaxBeds.ToString());

            int val = Convert.ToInt32(b1) + Convert.ToInt32(b2) + Convert.ToInt32(b3) + Convert.ToInt32(b4);

            if (val == 4)
            {
                return;
            }
            else
            {
                throw new Exception("INVALID ICU DATA");
            }
        }
示例#9
0
        public void WhenQueryServerToAddNewIcuAndRemoveAddedIcuAssertNoException()
        {
            var icuModel = new IcuModel()
            {
                IcuId    = "Dummy",
                BedCount = 10
            };

            _request = new RestRequest("Configuration/PostIcuModelData", Method.POST)
            {
                RequestFormat = DataFormat.Json
            };
            _request.AddJsonBody(icuModel);
            var response = _client.Execute(_request);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            RemoveIcu(icuModel.IcuId);
        }
        public object AddNewIcuConfiguration(IcuModel newIcu, string dbPath)
        {
            var icuDbObj = new IcuDbOps(dbPath);

            return(icuDbObj.AddIcuToDb(newIcu));
        }
示例#11
0
        private void InitializeDatabase(DbContext context)
        {
            #region Beds
            var icu1Beds = new List <BedModel>()
            {
                new BedModel()
                {
                    BedId = "ICU01L001", BedOccupancyStatus = "Occupied", Location = "First bed"
                },
                new BedModel()
                {
                    BedId = "ICU01L002", BedOccupancyStatus = "Free", Location = "Second bed"
                },
                new BedModel()
                {
                    BedId = "ICU01L003", BedOccupancyStatus = "Occupied", Location = "Third bed"
                }
            };
            var icu2Beds = new List <BedModel>()
            {
                new BedModel()
                {
                    BedId = "ICU02U001", BedOccupancyStatus = "Free", Location = "First bed"
                },
                new BedModel()
                {
                    BedId = "ICU02U002", BedOccupancyStatus = "Free", Location = "Second bed"
                },
                new BedModel()
                {
                    BedId = "ICU02U003", BedOccupancyStatus = "Free", Location = "Third bed"
                }
            };
            #endregion

            #region Vitals

            var patient1Vitals = new List <VitalsModel>()
            {
                new VitalsModel()
                {
                    Name = "Resp", Value = 80, LowerLimit = 70, UpperLimit = 150
                },
                new VitalsModel()
                {
                    Name = "Bp", Value = 80, LowerLimit = 80, UpperLimit = 150
                },
                new VitalsModel()
                {
                    Name = "Spo2", Value = 80, LowerLimit = 90, UpperLimit = 100
                },
            };
            var patient2Vitals = new List <VitalsModel>()
            {
                new VitalsModel()
                {
                    Name = "Resp", Value = 80, LowerLimit = 70, UpperLimit = 150
                },
                new VitalsModel()
                {
                    Name = "Bp", Value = 80, LowerLimit = 80, UpperLimit = 150
                },
                new VitalsModel()
                {
                    Name = "Spo2", Value = 80, LowerLimit = 90, UpperLimit = 100
                },
            };

            #endregion

            #region ICU's
            var icu1 = new IcuModel()
            {
                IcuId    = "ICU01",
                Layout   = "L00",
                Beds     = icu1Beds,
                MaxBeds  = 3,
                NoOfBeds = 3
            };
            var icu2 = new IcuModel()
            {
                IcuId    = "ICU02",
                Layout   = "U00",
                Beds     = icu2Beds,
                MaxBeds  = 15,
                NoOfBeds = 3
            };
            #endregion

            #region Patients

            var patient1 = new PatientModel()
            {
                PatientId = "P001",
                Name      = "Suresh",
                Age       = 25,
                Address   = "Hyderabad",
                IcuId     = "ICU01",
                BedId     = "ICU01L001",
                Vitals    = patient1Vitals
            };

            var patient2 = new PatientModel()
            {
                PatientId = "P002",
                Name      = "Naresh",
                Age       = 25,
                Address   = "Hyderabad",
                IcuId     = "ICU01",
                BedId     = "ICU01L003",
                Vitals    = patient2Vitals
            };
            #endregion


            context.Icu.Add(icu1);
            context.Icu.Add(icu2);
            context.Patients.Add(patient1);
            context.Patients.Add(patient2);

            context.SaveChanges();
        }