Example #1
0
        public static string ValidateVisit(Visit visit)
        {
            if (!string.IsNullOrEmpty(visit.Patient.Mrn))
            {
                if (PatientMethods.Instance.GetPatientByMrn(visit.Patient.Mrn).Dod == null)
                {
                    if (visit.Apartment.Id != 0)
                    {
                        if (DoctorMethods.Instance.GetDoctorByCode(visit.Doctor.Code).Clinic.Id == ApartmentMethods.Instance.GetApartmentById(visit.Apartment.Id).Clinic.Id)
                        {
                            return string.Empty;
                        }
                        else
                        {
                            return "Invalid Doctor for chosen Clinic!";
                        }
                    }
                    else
                    {
                        return "Choose apartment!";
                    }

                }
                else
                {
                    return "Patient is dead!";
                }
            }
            else
            {
                return "Choose patient!";
            }
        }
Example #2
0
        public void ValidateVisit_EmptyStringReturned()
        {
            var visit = new Visit()
            {
                BillingNumber = "1",
                Id = 1,
                Patient = new Patient()
                {
                    Dob = DateTime.Now,
                    Dod = DateTime.Now,
                    FirstName = "FName",
                    LastName = "LName",
                    MiddleName = "MName",
                    Mrn = "2222",
                    Sex = new Sex() { },
                    Ssn = "00-000-00-00"
                },
                Apartment = new Apartment()
                {
                    Id = 1,
                    Clinic = new Clinic1() { },
                    BedId = 2,
                    RoomId = 4,
                },
                Doctor = new Doctor()
                {
                    Code = "w"
                }

            };

            //Mock<PatientMethods> patientMethObject =new  Mock<PatientMethods>();
            //patientMethObject.Setup(x => x.GetPatientByMrn("2222")).Returns(new Patient() { Dod = null });

            Mock<PatientMethods> patientMethObject = new Mock<PatientMethods>();
            patientMethObject.Setup(x => x.GetPatientByMrn("2222")).Returns(new Patient() { Id = 2});

            Mock<DoctorMethods> doctorMethObject =new  Mock<DoctorMethods>();
            doctorMethObject.Setup(x => x.GetDoctorByCode("w")).Returns(new Doctor() { Clinic = new Clinic1 { Id = 1 } });

            Mock<ApartmentMethods> apartmentMethObject =new  Mock<ApartmentMethods>();
            apartmentMethObject.Setup(x => x.GetApartmentById(1)).Returns(new Apartment() { Clinic = new Clinic1 { Id = 1 } });

            string res = VisitMethods.ValidateVisit(visit);
            Assert.IsNullOrEmpty(res);
        }
Example #3
0
 public string EditVisit(string billingNumber, string mrn, string doctorCode, int apartmentId)
 {
     var uniqueVisit = VisitMethods.Instance.GetVisitByBillingNumber(billingNumber);
     if (uniqueVisit == null)
     {
         var visit = new Visit()
         {
             BillingNumber = billingNumber,
             Patient = new Patient()
             {
                 Mrn = mrn
             },
             Doctor = new Doctor()
             {
                 Code = doctorCode
             },
             Apartment = new Apartment()
             {
                 Id = apartmentId
             }
         };
         return VisitMethods.Instance.InsertVisit(visit);
     }
     else
     {
         var visit = new Visit()
         {
             Id = uniqueVisit.Id,
             BillingNumber = billingNumber,
             Patient = new Patient()
             {
                 Mrn = mrn
             },
             Doctor = new Doctor()
             {
                 Code = doctorCode
             },
             Apartment = new Apartment()
             {
                 Id = apartmentId
             }
         };
         return VisitMethods.Instance.UpdateVisit(visit);
     }
 }
Example #4
0
        public string UpdateVisit(Visit visit)
        {
            string message = ValidateVisit(visit);

            if (string.IsNullOrEmpty(message))
            {
                visit.Doctor.Id  = DoctorMethods.Instance.GetDoctorByCode(visit.Doctor.Code).Id;
                visit.Patient.Id = PatientMethods.Instance.GetPatientByMrn(visit.Patient.Mrn).Id;
                bool isProcessDone = UpdateEntity <Visit>(visit);
                if (isProcessDone)
                {
                    log.Info(string.Format("Visit {0} changed", visit.BillingNumber));
                    return(string.Empty);
                }
                else
                {
                    return("Error!");
                }
            }
            else
            {
                return(message);
            }
        }
Example #5
0
 public string InsertVisit(Visit visit)
 {
     string message = ValidateVisit(visit);
     if (string.IsNullOrEmpty(message))
     {
         visit.Doctor.Id = DoctorMethods.Instance.GetDoctorByCode(visit.Doctor.Code).Id;
         visit.Patient.Id = PatientMethods.Instance.GetPatientByMrn(visit.Patient.Mrn).Id;
         bool isProcessDone = InsertEntity<Visit>(visit);
         if (isProcessDone)
         {
             log.Info(string.Format("Visit {0} saved",visit.BillingNumber));
             return string.Empty;
         }
         else
         {
             return "Error!";
         }
     }
     else
     {
         return message;
     }
 }