Example #1
0
        public PutDeleteMedMapResponse Put(PutDeleteMedMapRequest request)
        {
            PutDeleteMedMapResponse resp   = new PutDeleteMedMapResponse();
            ValidateTokenResponse   result = null;

            try
            {
                if (base.Request != null)
                {
                    request.Token = base.Request.Headers["Token"] as string;
                }
                result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId = result.UserId;
                    MedicationManager.DeleteMedicationMap(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(resp, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    MedicationManager.LogException(ex);
                }
            }
            return(resp);
        }
Example #2
0
        public PostPatientMedFrequencyResponse Post(PostPatientMedFrequencyRequest request)
        {
            PostPatientMedFrequencyResponse response = new PostPatientMedFrequencyResponse();
            ValidateTokenResponse           result   = null;

            try
            {
                if (base.Request != null)
                {
                    request.Token = base.Request.Headers["Token"] as string;
                }
                result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId = result.UserId;
                    response.Id    = MedicationManager.InsertPatientMedFrequency(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    MedicationManager.LogException(ex);
                }
            }
            finally
            {
                List <string> patientIds = null;
                if (request.PatientMedFrequency != null)
                {
                    patientIds = new List <string>();
                    patientIds.Add(request.PatientMedFrequency.PatientId);
                }
                if (result != null)
                {
                    string browser     = (base.Request != null) ? base.Request.UserAgent : unknownBrowserType;
                    string hostAddress = (base.Request != null) ? base.Request.UserHostAddress : unknownUserHostAddress;
                    AuditUtil.LogAuditData(request, result.SQLUserId, patientIds, browser, hostAddress, request.GetType().Name);
                }
            }
            return(response);
        }
Example #3
0
        public DeleteMedicationMapsResponse Delete(DeleteMedicationMapsRequest request)
        {
            DeleteMedicationMapsResponse response = new DeleteMedicationMapsResponse();
            ValidateTokenResponse        result   = null;

            try
            {
                if (base.Request != null)
                {
                    request.Token = base.Request.Headers["Token"] as string;
                }
                result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId = result.UserId;
                    MedicationManager.DeleteMedicationMaps(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatterUtil.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    MedicationManager.LogException(ex);
                }
            }
            finally
            {
                if (result != null)
                {
                    string browser     = (base.Request != null) ? base.Request.UserAgent : unknownBrowserType;
                    string hostAddress = (base.Request != null) ? base.Request.UserHostAddress : unknownUserHostAddress;
                    AuditUtil.LogAuditData(request, result.SQLUserId, null, browser, hostAddress, request.GetType().Name);
                }
            }
            return(response);
        }
        /// <summary>
        /// Creator: Daulton Schilling
        /// Created: 3/3/2020
        /// Approver: Carl Davis, 3/6/2020s
        /// Approver:
        ///
        /// Method to handle quantity alerts
        /// </summary>
        /// <remarks>
        /// Updater:
        /// Updated:
        /// Update:
        /// </remarks>
        private void QuantityAlertManager()
        {
            MedicationManager medicationManager = new MedicationManager();
            int        num        = medicationManager.RetrieveMedicationByLowQauntity().Count();
            int        empty      = medicationManager.RetrieveMedicationByEmptyQauntity().Count();
            Medication medication = new Medication();

            if (Warning.Visibility == Visibility.Hidden)
            {
                Warning2.Visibility = Visibility.Hidden;
            }

            if (Warning2.Visibility == Visibility.Visible)
            {
                Warning.Visibility = Visibility.Visible;
            }

            if (empty >= 1 && num >= 1)
            {
                if (num == 1)
                {
                    Warning2.Content    = "Pet universe is currently running low on " + num + " medication";
                    Warning2.Foreground = new SolidColorBrush(Colors.DarkOrange);
                    Warning2.Visibility = Visibility.Visible;
                }
                else
                {
                    Warning2.Content    = "Pet universe is currently running low on " + num + " medications";
                    Warning2.Foreground = new SolidColorBrush(Colors.DarkOrange);
                    Warning2.Visibility = Visibility.Visible;
                }

                if (empty == 1)
                {
                    Warning.Content    = "Pet universe is currently out of " + empty + " medication";
                    Warning.Foreground = new SolidColorBrush(Colors.Red);
                    Warning.Visibility = Visibility.Visible;
                }
                else
                {
                    Warning.Content    = "Pet universe is currently out of " + empty + " medications";
                    Warning.Foreground = new SolidColorBrush(Colors.Red);
                    Warning.Visibility = Visibility.Visible;
                }
            }
            else if (empty >= 1 && num < 1)
            {
                if (empty == 1)
                {
                    Warning.Content     = "Pet universe is currently out of " + empty + " medication";
                    Warning.Foreground  = new SolidColorBrush(Colors.Red);
                    Warning.Visibility  = Visibility.Visible;
                    Warning2.Visibility = Visibility.Hidden;
                }
                else
                {
                    Warning.Content     = "Pet universe is currently out of " + empty + " medications";
                    Warning.Foreground  = new SolidColorBrush(Colors.Red);
                    Warning.Visibility  = Visibility.Visible;
                    Warning2.Visibility = Visibility.Hidden;
                }
            }
            else if (num >= 1 && empty < 1)
            {
                if (num == 1)
                {
                    Warning.Content     = "Pet universe is currently running low on " + num + " medication";
                    Warning.Foreground  = new SolidColorBrush(Colors.DarkOrange);
                    Warning.Visibility  = Visibility.Visible;
                    Warning2.Visibility = Visibility.Hidden;
                }
                else
                {
                    Warning.Content     = "Pet universe is currently running low on " + num + " medications";
                    Warning.Foreground  = new SolidColorBrush(Colors.DarkOrange);
                    Warning.Visibility  = Visibility.Visible;
                    Warning2.Visibility = Visibility.Hidden;
                }
            }
            if (empty == 1)
            {
                Warning.Content     = "Pet universe is currently out of " + empty + " medication";
                Warning.Foreground  = new SolidColorBrush(Colors.Red);
                Warning.Visibility  = Visibility.Visible;
                Warning2.Visibility = Visibility.Hidden;
            }
        }
Example #5
0
        public void CalculateMedicationSigCode_Test()
        {
            var manager = new MedicationManager();

            manager.EndpointUtil = new MedicationEndpointUtil();
            PostPatientMedSuppRequest request = new PostPatientMedSuppRequest();

            request.ContractNumber = contractNumber;
            request.UserId         = userId;
            request.Version        = version;
            //request.Token = token;
            PatientMedSupp patientMedication = new PatientMedSupp {
                Id         = "55dce59e84ac092884e0960a",
                PatientId  = "5325d9f2d6a4850adcbba4ca",
                Name       = "YOUGREEN F",
                CategoryId = 1,
                DeleteFlag = false,
                NDCs       = new List <string>()
                {
                    "42361-043"
                },
                Notes      = "bla bla",
                Reason     = "the reason",
                SourceId   = "544e9976d433231d9c0330ae",
                StatusId   = 1,
                SystemName = "Engage",
                TypeId     = "545bdfa6d433232248966639",

                StartDate    = DateTime.Parse("2016-03-01T06:00:00.000Z"), //DateTime.Now,
                EndDate      = DateTime.Parse("2016-03-14T05:00:00.000Z"), //DateTime.Now.AddDays(10),
                Route        = "TOPICAL",
                Form         = "OINTMENT",
                Strength     = "7.5 g/30g",
                FreqQuantity = "12 bunches",
                FrequencyId  = "54fa11abd433230404046e6b", //Q4H (every 4 hours)
            };

            request.PatientMedSupp = patientMedication;
            string sigCode = manager.CalculateSigCode(request);

            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sigCode = " + sigCode);

            patientMedication.FrequencyId = "56ddd57f84ac070fc8287596";  //a custom freq -
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sigCode with custom frequency = " + sigCode);

            patientMedication.Route    = null;
            patientMedication.Form     = "";
            patientMedication.Strength = null;
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sigCode with some empty values = " + sigCode);

            //daylight saving time tests:
            patientMedication.StartDate    = DateTime.Parse("2016-03-01T06:00:00.000Z");
            patientMedication.EndDate      = DateTime.Parse("2016-03-14T05:00:00.000Z");
            patientMedication.FreqQuantity = null;
            patientMedication.FrequencyId  = null;
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code for dst w /specific dates: ");
            Console.WriteLine("sig code should be 13 days: " + sigCode);

            patientMedication.StartDate = DateTime.Parse("2016-03-13T06:00:00.0000000Z");
            patientMedication.EndDate   = DateTime.Parse("2016-03-14T05:00:00.0000000Z");
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code should be 1 day: " + sigCode);

            patientMedication.StartDate = DateTime.Parse("2016-03-15T05:00:00.0000000Z");
            patientMedication.EndDate   = DateTime.Parse("2016-03-17T05:00:00.0000000Z");
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code should be 2 days: " + sigCode);

            patientMedication.StartDate = DateTime.Parse("2016-04-01T05:00:00.0000000Z");
            patientMedication.EndDate   = DateTime.Parse("2017-01-01T06:00:00.0000000Z");
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code should be 275 days: " + sigCode);
        }