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); }
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); }