Ejemplo n.º 1
0
        public PostPatientAllergiesResponse Post(PostPatientAllergiesRequest request)
        {
            PostPatientAllergiesResponse response = new PostPatientAllergiesResponse();
            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.PatientAllergies = AllergyManager.UpdatePatientAllergies(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    AllergyManager.LogException(ex);
                }
            }
            finally
            {
                List <string> patientIds = null;
                if (request.PatientAllergies != null && request.PatientAllergies.Count > 0)
                {
                    patientIds = new List <string>();
                    request.PatientAllergies.ForEach(p =>
                    {
                        patientIds.Add(p.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);
        }
Ejemplo n.º 2
0
        public List <PatientAllergy> UpdatePatientAllergies(PostPatientAllergiesRequest request)
        {
            List <PatientAllergy> patientAllergies = null;

            try
            {
                // Update Allergy collection for any newly initialized allergies & then register in search index.
                if (request.PatientAllergies != null && request.PatientAllergies.Count > 0)
                {
                    request.PatientAllergies.ForEach(p =>
                    {
                        if (p.IsNewAllergy)
                        {
                            PostAllergyRequest req = new PostAllergyRequest
                            {
                                Allergy = new DTO.Allergy {
                                    Id = p.AllergyId, TypeIds = p.AllergyTypeIds, Name = p.AllergyName
                                },
                                ContractNumber = request.ContractNumber,
                                UserId         = request.UserId,
                                Version        = request.Version
                            };
                            AllergyData allergyData = EndpointUtil.UpdateAllergy(req);
                            DTO.Allergy newAllergy  = Mapper.Map <DTO.Allergy>(allergyData);
                            // Register newly initialized allergies in search index.
                            SearchManager.RegisterAllergyDocumentInSearchIndex(newAllergy, req.ContractNumber, request);
                        }
                    });
                }
                List <PatientAllergyData> data = EndpointUtil.UpdatePatientAllergies(request);
                if (data != null && data.Count > 0)
                {
                    patientAllergies = new List <PatientAllergy>();
                    data.ForEach(a => patientAllergies.Add(Mapper.Map <PatientAllergy>(a)));
                }
                return(patientAllergies);
            }
            catch (Exception ex) { throw ex; }
        }
Ejemplo n.º 3
0
        public List <PatientAllergyData> UpdatePatientAllergies(PostPatientAllergiesRequest request)
        {
            try
            {
                List <PatientAllergyData> result = null;
                IRestClient client = new JsonServiceClient();
                //[Route("/{Context}/{Version}/{ContractNumber}/PatientAllergy/Update/Bulk", "PUT")]
                var url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/PatientAllergy/Update/Bulk",
                                                               DDAllergyUrl,
                                                               "NG",
                                                               request.Version,
                                                               request.ContractNumber), request.UserId);

                if (request.PatientAllergies != null && request.PatientAllergies.Count > 0)
                {
                    List <PatientAllergyData> data = new List <PatientAllergyData>();
                    request.PatientAllergies.ForEach(a => data.Add(Mapper.Map <PatientAllergyData>(a)));
                    PutPatientAllergiesDataResponse dataDomainResponse = client.Put <PutPatientAllergiesDataResponse>(url, new PutPatientAllergiesDataRequest
                    {
                        Context              = "NG",
                        ContractNumber       = request.ContractNumber,
                        UserId               = request.UserId,
                        Version              = request.Version,
                        PatientAllergiesData = data
                    } as object);

                    if (dataDomainResponse != null)
                    {
                        result = dataDomainResponse.PatientAllergiesData;
                    }
                }
                return(result);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:UpdatePatientAllergies()::" + ex.Message, ex.InnerException);
            }
        }
Ejemplo n.º 4
0
        public void UpdatePatientAllergies_Test()
        {
            List <PatientAllergy> data = new System.Collections.Generic.List <PatientAllergy>();

            PatientAllergy p1 = new PatientAllergy
            {
                AllergyId    = "54580a9b84ac05021485f632",
                IsNewAllergy = true,
                //AllergyName = "Cat dander",
                EndDate     = DateTime.UtcNow,
                Id          = "54580a9d84ac05021485f637",
                Notes       = "AAAAAAAAA",
                PatientId   = "5325daebd6a4850adcbba7be",
                ReactionIds = new List <string> {
                    "54494b5ad433232a446f7323"
                },
                SeverityId     = "54494a8fd433232a446f7311",
                SourceId       = "544e9976d433231d9c0330ae",
                StartDate      = DateTime.UtcNow,
                StatusId       = 1,
                SystemName     = "Engage",
                UpdatedOn      = DateTime.UtcNow,
                DeleteFlag     = false,
                AllergyTypeIds = new List <string> {
                    "5447d6ddfe7a59146485b512", "5446db5efe7a591e74013b6b", "5446db5efe7a591e74013b6c"
                },
            };

            //PatientAllergy p2 = new PatientAllergy
            //{
            //    AllergyId = "5453e6bfd433230468567d33",
            //    IsNewAllergy = true,
            //    //AllergyName = "Cat dander",
            //    EndDate = DateTime.UtcNow,
            //    Id = "5453e7eb84ac0510a8f3ba88",
            //    Notes = "BBBBBBB",
            //    PatientId = "5325da1fd6a4850adcbba54a",
            //    //ReactionIds = new List<string> { "54494b5ad433232a446f7323" },
            //    //SeverityId = "54494a8fd433232a446f7311",
            //    UtilizationSourceId = "544e9976d433231d9c0330ae",
            //    StartDate = DateTime.UtcNow,
            //    StatusId = 2,
            //    SystemName = "Integration",
            //    UpdatedOn = DateTime.UtcNow,
            //    DeleteFlag = false,
            //    AllergyTypeIds = new List<string> { "5446db5efe7a591e74013b6d" },
            //};
            data.Add(p1);
            //data.Add(p2);
            PostPatientAllergiesRequest request = new PostPatientAllergiesRequest
            {
                ContractNumber   = contractNumber,
                PatientAllergies = data,
                UserId           = userId,
                Version          = version
            };

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

            Assert.IsNotNull(response);
        }