示例#1
0
 public void AllotBedToPatient(BedAllotmentModel allotBed)
 {
     if (allotBed.PatientId == 2)
     {
         throw new Exception("");
     }
 }
        public IActionResult AllotBedToPatient([FromBody] BedAllotmentModel bedAllotment)
        {
            Tuple <PatientDataModel, BedInformation> response;
            AllotedBedValidator bedValidator = new AllotedBedValidator();
            bool isDataValid = bedValidator.ValidateBedAlloted(bedAllotment);

            if (!isDataValid)
            {
                return(BadRequest("Please Enter Valid Input"));
            }
            try
            {
                response = _patientBusinessLogic.AllotBedToPatient(bedAllotment);
            }
            catch
            {
                return(StatusCode(500));
            }
            string bedLayout    = "R" + response.Item2.BedInRow.ToString() + "C" + response.Item2.BedInColumn.ToString();
            var    responseData = new Dictionary <string, dynamic>
            {
                { "patientId", response.Item1.PatientId },
                { "patientName", response.Item1.PatientName },
                { "email", response.Item1.Email },
                { "address", response.Item1.Address },
                { "mobile", response.Item1.Mobile },
                { "bedId", response.Item2.BedId },
                { "wardInfo", response.Item2.WardNumber },
                { "bedLayout", bedLayout }
            };

            return(Ok(responseData));
        }
        public Tuple <PatientDataModel, BedInformation> AllotBedToPatient(BedAllotmentModel allotBed)
        {
            _patientDataRepository.AllotBedToPatient(allotBed);
            var objPatientInfo = _patientDataRepository.FetchPatientFromPatientId(allotBed.PatientId);
            var objBedInfo     = _patientDataRepository.FetchBedInfoFromPatientId(allotBed.PatientId);

            return(new Tuple <PatientDataModel, BedInformation>(objPatientInfo, objBedInfo));
        }
        public void TestAllotBedToPatient()
        {
            var patientLogic = new PatientBusinessLogic(_repo);
            var bed          = new BedAllotmentModel();
            var response     = patientLogic.AllotBedToPatient(bed);

            Assert.NotNull(response);
        }
        public bool ValidateBedAlloted(BedAllotmentModel allotedBed)
        {
            bool isDepartmentNull  = IsDepartmentNull(allotedBed.Department);
            bool isPatientIdIsNull = IsPatientIdIsNull(allotedBed.PatientId);

            if (isDepartmentNull == isPatientIdIsNull == true)
            {
                return(true);
            }
            return(false);
        }
示例#6
0
        public void TestAllotPatientUnSuccessful()
        {
            PatientDataController controller   = new PatientDataController(operations);
            BedAllotmentModel     bedAllotment = new BedAllotmentModel {
                PatientId = 2, Department = "Cancer"
            };
            var actualResponse       = controller.AllotBedToPatient(bedAllotment);
            var actualResponseObject = actualResponse as StatusCodeResult;

            Assert.NotNull(actualResponseObject);
            Assert.Equal(500, actualResponseObject.StatusCode);
        }
示例#7
0
        public void TestAllotBedToPatientSuccessful()
        {
            var patientData = new PatientDataRepository(Context);
            var allotBed    = new BedAllotmentModel {
                Department = "Dept", PatientId = 10
            };

            patientData.AllotBedToPatient(allotBed);
            var patientDataInDb = Context.BedInformation.First(bed => bed.WardNumber == "1B");

            Assert.Equal(10, patientDataInDb.PatientId);
        }
示例#8
0
        public void AllotBedToPatient(BedAllotmentModel allotBed)
        {
            var bedInformation = (from wardInfo in _context.IcuWardInformation
                                  join
                                  bedInfo in _context.BedInformation on
                                  wardInfo.WardNumber equals bedInfo.WardNumber
                                  where bedInfo.PatientId == null && wardInfo.Department == allotBed.Department
                                  select bedInfo).FirstOrDefault();

            if (bedInformation != null)
            {
                bedInformation.PatientId = allotBed.PatientId;
            }
            _context.SaveChanges();
        }
        public void TestAllotBedToPatientWithInvalidInput()
        {
            string       bedAllotmentUrl = url + "/AllotBedToPatient";
            IRestClient  restClient      = new RestClient();
            IRestRequest restRequest     = new RestRequest()
            {
                Resource = bedAllotmentUrl
            };
            var bedAllotmentInfo = new BedAllotmentModel()
            {
                PatientId  = null,
                Department = null
            };

            restRequest.AddHeader("Content-Type", "application/json");
            restRequest.AddJsonBody(bedAllotmentInfo);
            IRestResponse restResponse = restClient.Post(restRequest);

            Assert.AreEqual(restResponse.StatusCode, HttpStatusCode.BadRequest);
        }
示例#10
0
        Tuple <PatientDataModel, BedInformation> IPatientBusinessLogic.AllotBedToPatient(BedAllotmentModel allotBed)
        {
            if (allotBed.PatientId == 2)
            {
                throw new Exception();
            }
            var objPatientInfo = new PatientDataModel();
            var objBedInfo     = new BedInformation();

            return(new Tuple <PatientDataModel, BedInformation>(objPatientInfo, objBedInfo));
        }
 public void AllotBedToPatient(BedAllotmentModel allotBed)
 {
 }