/// <summary>
        ///
        /// </summary>
        /// <param name="chk"></param>
        /// <returns></returns>
        public DoctorDto GetDoctor(Doctor chk)
        {
            MapperConfig.ConfigAutoMapper();

            if (DoctorHelp.GetDoctorByName(chk.DoctorName) == null || DoctorHelp.GetDoctorBySpeciality(chk.DoctorSpeciality) == null)
            {
                System.Diagnostics.Debug.WriteLine("Doctor not found");
                return(null);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Doctor Found!");
                return(null);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="patientVisit"></param>
        /// <param name="Template"></param>

        /// <returns></returns>
        public PatientVisitDto AddNewPatientVisit(PatientVisit patientVisit, TestTemplate Template)
        {
            PatientVisitHelper visithelp = new PatientVisitHelper();

            MapperConfig.ConfigAutoMapper();

            if (this.ValidateVisit(patientVisit))
            {
                patientVisit.CreatedDate  = DateTime.Now;
                patientVisit.CreatedBy    = "EMP";
                patientVisit.ModifiedDate = new DateTime(2017, 12, 2);
                patientVisit.ModifiedBy   = string.Empty;

                // if (DoctorRepository.GetDoctor(patientVisit.Doctor.DoctorId) == null)
                if (DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName) == null ||
                    DoctorHelp.GetDoctorBySpeciality(patientVisit.Doctor.DoctorSpeciality) == null)
                {
                    this.AddNewDoctor(patientVisit.Doctor);

                    System.Diagnostics.Debug.WriteLine("Doctor Added");

                    patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName);
                }
                else
                {
                    patientVisit.DoctorID = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName).DoctorId;

                    patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName);

                    System.Diagnostics.Debug.WriteLine("Doctor Exists");
                }


                if (PatientRepository.GetPatient(patientVisit.Patient.ContactNo) == null)
                {
                    this.AddNewPatient(patientVisit.Patient);

                    patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo);

                    System.Diagnostics.Debug.WriteLine("Patient Added");
                }
                else
                {
                    patientVisit.PatientID = PatientRepository.GetPatient(patientVisit.Patient.ContactNo).PatientId;

                    patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo);

                    System.Diagnostics.Debug.WriteLine("Patient Exists");
                }

                patientVisit.UserId = UserRepository.GetUser(patientVisit.User.Username).UserId;

                patientVisit.User.RoleId = 1;

                patientVisit.User = UserRepository.GetUser(patientVisit.User.Username);

                var NewVisit = PatientVisitRepo.Insert(Mapper.Map <PatientVisit>(patientVisit));
                Mapper.Map <PatientVisitDto>(NewVisit);

                System.Diagnostics.Debug.WriteLine("Visit Added");

                int VisitId = NewVisit.PatientVisitId;

                this.AddNewPatientTest(VisitId, Template);

                System.Diagnostics.Debug.WriteLine("Patient Test Added");

                int testTemplateID = TestTemplateRepository.GetTestTemplate(Template.TemplateName).TestTemplateId;

                IList <TestTemplateAttributeDto> TestAttribute = visithelp.GetTestTemplateAttributes(testTemplateID);

                TestResult results = new TestResult();

                foreach (var x in TestAttribute)
                {
                    results.AttrID  = x.AttrID;
                    results.VisitID = VisitId;
                    results.Status  = "NO STATUS YET";
                    results.Value   = "NO VALUE YET";
                    this.AddNewTestResult(results);
                }

                System.Diagnostics.Debug.WriteLine("Result Added");
            }

            else
            {
                throw new ArgumentNullException("Provided information is not valid.");
            }

            return(null);
        }