예제 #1
0
 /// <summary>Initializes a new instance of the <see cref="ResourcesController" /> class.</summary>
 public ResourcesController()
 {
     this.employeeIt2Manager     = new EmployeeIt2Manager();
     this.officeIt2Manager       = new OfficeIt2Manager();
     this.patientIt2Manager      = new PatientIt2Manager();
     this.logiIntegrationManager = new LogiIntegrationManager();
 }
예제 #2
0
        /// <summary>
        /// The post.
        /// </summary>
        /// <param name="officeNumber">
        /// The office number.
        /// </param>
        /// <param name="patientEyeGlassesRx">
        /// The patient eye glasses rx.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public HttpResponseMessage Put(string officeNumber, [FromBody] EyeGlassesRx patientEyeGlassesRx)
        {
            if (patientEyeGlassesRx == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                var patientExam    = this.eyeGlassesManager.AlslExamToIt2Exam(officeNumber, patientEyeGlassesRx);
                var examDetailAlsl = new List <PatientExamDetailAlsl>
                {
                    new PatientExamDetailAlsl
                    {
                        UnderlyingCondition = Convert.ToInt32(patientEyeGlassesRx.RightUlConditionId)
                    },

                    new PatientExamDetailAlsl
                    {
                        UnderlyingCondition = Convert.ToInt32(patientEyeGlassesRx.LeftUlConditionId)
                    }
                };
                var errors = PatientIt2Manager.ValidateRxExamForCompleteness(examDetailAlsl, patientExam);
                if (errors != null && errors.Count > 0)
                {
                    return(this.Request.CreateResponse(HttpStatusCode.BadRequest, errors));
                }

                var rightValid = this.eyeGlassesManager.ValidateRx(patientEyeGlassesRx, LensRightLeft.Right);
                var leftValid  = this.eyeGlassesManager.ValidateRx(patientEyeGlassesRx, LensRightLeft.Left);

                if (!leftValid || !rightValid)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }

                AccessControl.VerifyUserAccessToPatient(patientEyeGlassesRx.PatientId);
                var examId = this.eyeGlassesManager.SaveExam(patientExam, patientEyeGlassesRx.RightUlConditionId, patientEyeGlassesRx.LeftUlConditionId, patientEyeGlassesRx.HasBeenRechecked, patientEyeGlassesRx.RecheckExamId);
                return(this.Request.CreateResponse(HttpStatusCode.OK, examId));
            }
            catch (Exception ex)
            {
                var error = "Put(examId=" + patientEyeGlassesRx.ExamId + ", patientId=" + patientEyeGlassesRx.PatientId + ")\n" + ex;
                return(HandleExceptions.LogExceptions(error, Logger, ex));
            }
        }