Esempio n. 1
0
        public void SavePatientMedSupp_Test()
        {
            PatientMedSupp pms = new PatientMedSupp
            {
                //FamilyId = "54dd28e784ac0714f0cef2cb",
                CategoryId = 1,
                DeleteFlag = false,
                // Dosage = "Two",
                //EndDate = DateTime.UtcNow,
                //FreqHowOftenId = "545be059d43323224896663a",
                //FreqQuantity = "4",
                //   FreqWhenId = "545be126d433232248966643",
                Id       = "54dd2d63d43328283844e107",
                Name     = "ARMES",//"NICOTINE",
                Form     = "TABLET",
                Route    = "ORAL",
                Strength = "56 l",
                //NDCs = ,
                // Notes = "note for Acetomophine 2",
                PatientId = "54dd289384ac0511987c998e",
                //PharmClasses = ,
                //  PrescribedBy = "Dr Basu",
                // Reason = "Reason for Acetomophine 2",
                //SigCode = ,
                SourceId  = "544e9976d433231d9c0330ae",
                StartDate = DateTime.UtcNow,
                StatusId  = 1,
                //  SystemName = "Engage",
                TypeId = "545bdfa1d433232248966638"
            };

            PostPatientMedSuppRequest request = new PostPatientMedSuppRequest
            {
                ContractNumber = contractNumber,
                PatientMedSupp = pms,
                RecalculateNDC = false,
                Insert         = false,
                UserId         = userId,
                Version        = version
            };

            JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "Token", token));
            //[Route("/{Version}/{ContractNumber}/PatientMedSupp/Save", "POST")]
            PostPatientMedSuppResponse response = client.Post <PostPatientMedSuppResponse>(
                string.Format("{0}/{1}/{2}/PatientMedSupp/Save", url, version, contractNumber), request);

            Assert.IsNotNull(response);
        }
Esempio n. 2
0
        public PostPatientMedSuppResponse Post(PostPatientMedSuppRequest request)
        {
            PostPatientMedSuppResponse response = new PostPatientMedSuppResponse();
            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.PatientMedSupp = MedicationManager.SavePatientMedSupp(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.PatientMedSupp != null)
                {
                    patientIds = new List <string>();
                    patientIds.Add(request.PatientMedSupp.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);
        }