Esempio n. 1
0
        public void Put_Problem_In_CohortPatientView_Response_Test()
        {
            double version        = 1.0;
            string contractNumber = "InHealth001";
            string context        = "NG";
            string patientId      = "52e26f11072ef7191c111c54";
            CohortPatientViewData cohortPatientView = GetCohortPatientView();

            IRestClient client = new JsonServiceClient();

            JsonServiceClient.HttpWebRequestFilter = x =>
                                                     x.Headers.Add(string.Format("{0}: {1}", "x-Phytel-UserID", "531f2df9072ef727c4d2a3df"));

            PutUpdateCohortPatientViewResponse response =
                client.Put <PutUpdateCohortPatientViewResponse>(string.Format("{0}/{1}/{2}/{3}/patient/{4}/cohortpatientview/update",
                                                                              "http://localhost:8888/Patient",
                                                                              context,
                                                                              version,
                                                                              contractNumber,
                                                                              patientId), new PutUpdateCohortPatientViewRequest
            {
                CohortPatientView = cohortPatientView,
                ContractNumber    = contractNumber,
                PatientID         = patientId
            } as object);
        }
Esempio n. 2
0
        internal static void UpdateCohortPatientViewProblem(CohortPatientViewData cpvd, string patientId, IAppDomainRequest request)
        {
            try
            {
                double version        = request.Version;
                string contractNumber = request.ContractNumber;
                string context        = "NG";

                IRestClient client = new JsonServiceClient();

                string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/patient/{4}/cohortpatientview/update",
                                                                  DDPatientServiceUrl,
                                                                  context,
                                                                  version,
                                                                  contractNumber,
                                                                  patientId), request.UserId);

                PutUpdateCohortPatientViewResponse response =
                    client.Put <PutUpdateCohortPatientViewResponse>(url, new PutUpdateCohortPatientViewRequest
                {
                    CohortPatientView = cpvd,
                    ContractNumber    = contractNumber,
                    PatientID         = patientId
                } as object);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:PlanElementEndpointUtil:UpdateCohortPatientViewProblem()::" + ex.Message, ex.InnerException);
            }
        }
Esempio n. 3
0
        public PutUpdateCohortPatientViewResponse UpdateCohortPatientViewProblem(PutUpdateCohortPatientViewRequest request)
        {
            IPatientRepository repo = Factory.GetRepository(request, RepositoryType.CohortPatientView);

            PutUpdateCohortPatientViewResponse result = repo.Update(request) as PutUpdateCohortPatientViewResponse;

            return(result);
        }
        public object Update(object entity)
        {
            PutUpdateCohortPatientViewRequest  p    = (PutUpdateCohortPatientViewRequest)entity;
            PutUpdateCohortPatientViewResponse resp = new PutUpdateCohortPatientViewResponse();

            try
            {
                CohortPatientViewData cpvd = p.CohortPatientView;
                using (PatientMongoContext ctx = new PatientMongoContext(_dbName))
                {
                    var q = MB.Query <MECohortPatientView> .EQ(b => b.Id, ObjectId.Parse(p.CohortPatientView.Id));

                    List <SearchField> sfds = Utils.CloneAppDomainCohortPatientViews(p.CohortPatientView.SearchFields);

                    var uv = new List <MB.UpdateBuilder>();
                    if (!String.IsNullOrEmpty(cpvd.LastName))
                    {
                        uv.Add(MB.Update.Set(MECohortPatientView.LastNameProperty, cpvd.LastName));
                    }
                    if (!String.IsNullOrEmpty(cpvd.PatientID))
                    {
                        uv.Add(MB.Update.Set(MECohortPatientView.PatientIDProperty, ObjectId.Parse(cpvd.PatientID)));
                    }
                    uv.Add(MB.Update.Set(MECohortPatientView.UpdatedByProperty, ObjectId.Parse(this.UserId)));
                    uv.Add(MB.Update.Set(MECohortPatientView.LastUpdatedOnProperty, DateTime.UtcNow));
                    // uv.Add(MB.Update.Set(MECohortPatientView.AssignedToProperty, p.CohortPatientView.AssignedToContactIds.Select(c => BsonValue.Create(c))));

                    if (p.CohortPatientView != null)
                    {
                        uv.Add(MB.Update.SetWrapped <List <SearchField> >(MECohortPatientView.SearchFieldsProperty, sfds));
                    }

                    IMongoUpdate update = MB.Update.Combine(uv);
                    ctx.CohortPatientViews.Collection.Update(q, update);
                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.CohortPatientView.ToString(),
                                             p.CohortPatientView.Id.ToString(),
                                             Common.DataAuditType.Update,
                                             p.ContractNumber);
                }
                resp.CohortPatientViewId = p.CohortPatientView.Id;
                return(resp);
            }
            catch (Exception ex)
            {
                throw new Exception("CohortPatientDD:Update()::" + ex.Message, ex.InnerException);
            }
        }
Esempio n. 5
0
        public void UpdateCohortPatientView(string patientId, string careMemberContactId)
        {
            GetCohortPatientViewResponse getResponse = GetCohortPatientView(patientId);

            if (getResponse != null && getResponse.CohortPatientView != null)
            {
                CohortPatientViewData cpvd = getResponse.CohortPatientView;
                // check to see if primary care manager's contactId exists in the searchfield
                if (!cpvd.SearchFields.Exists(sf => sf.FieldName == "PCM"))
                {
                    cpvd.SearchFields.Add(new SearchFieldData
                    {
                        Value     = careMemberContactId,
                        Active    = true,
                        FieldName = "PCM"
                    });
                }
                else
                {
                    cpvd.SearchFields.ForEach(sf =>
                    {
                        if (sf.FieldName == "PCM")
                        {
                            sf.Value  = careMemberContactId;
                            sf.Active = true;
                        }
                    });
                }

                PutUpdateCohortPatientViewRequest request = new PutUpdateCohortPatientViewRequest
                {
                    CohortPatientView = cpvd,
                    ContractNumber    = ContractNumber,
                    PatientID         = patientId
                };

                PutUpdateCohortPatientViewResponse response = UpdateCohortPatientView(request, patientId);
                if (string.IsNullOrEmpty(response.CohortPatientViewId))
                {
                    throw new Exception("Unable to update Cohort Patient View");
                }
            }
        }
Esempio n. 6
0
        public void UpdatePatientView_Test()
        {
            double version        = 1.0;
            string contractNumber = "InHealth001";
            string context        = "NG";
            string patientId      = "52f55858072ef709f84e5dee";
            string userId         = "DDTestHarness";
            CohortPatientViewData             view    = GetCohortPatientView();
            PutUpdateCohortPatientViewRequest request = new PutUpdateCohortPatientViewRequest {
                CohortPatientView = view,
                Context           = context,
                ContractNumber    = contractNumber,
                PatientID         = patientId,
                UserId            = userId,
                Version           = version
            };

            IPatientDataManager pm = new PatientDataManager();
            PutUpdateCohortPatientViewResponse response = pm.UpdateCohortPatientViewProblem(request);
        }
Esempio n. 7
0
        public PutUpdateCohortPatientViewResponse UpdateCohortPatientView(PutUpdateCohortPatientViewRequest request, string patientId)
        {
            Uri cohortPatientUri = new Uri(string.Format("{0}/Patient/{1}/{2}/{3}/patient/{4}/cohortpatientview/update?UserId={5}",
                                                         Url,
                                                         Context,
                                                         Version,
                                                         ContractNumber,
                                                         patientId,
                                                         HeaderUserId));
            HttpClient client = GetHttpClient(cohortPatientUri);

            DataContractJsonSerializer jsonSer = new DataContractJsonSerializer(typeof(PutUpdateCohortPatientViewRequest));

            // use the serializer to write the object to a MemoryStream
            MemoryStream ms = new MemoryStream();

            jsonSer.WriteObject(ms, request);
            ms.Position = 0;

            //use a Stream reader to construct the StringContent (Json)
            StreamReader sr = new StreamReader(ms);

            StringContent theContent = new StringContent(sr.ReadToEnd(), System.Text.Encoding.UTF8, "application/json");

            ms.Dispose();

            //Post the data
            var response        = client.PutAsync(cohortPatientUri, theContent);
            var responseContent = response.Result.Content;

            string responseString = responseContent.ReadAsStringAsync().Result;
            PutUpdateCohortPatientViewResponse responseCohortPatientView = null;

            using (var msResponse = new MemoryStream(Encoding.Unicode.GetBytes(responseString)))
            {
                var serializer = new DataContractJsonSerializer(typeof(PutUpdateCohortPatientViewResponse));
                responseCohortPatientView = (PutUpdateCohortPatientViewResponse)serializer.ReadObject(msResponse);
            }

            return(responseCohortPatientView);
        }
Esempio n. 8
0
        public PutUpdateCohortPatientViewResponse Put(PutUpdateCohortPatientViewRequest request)
        {
            PutUpdateCohortPatientViewResponse response = new PutUpdateCohortPatientViewResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("PatientDD:Put()::Unauthorized Access");
                }

                response         = PatientManager.UpdateCohortPatientViewProblem(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatterUtil.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Helpers.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }
Esempio n. 9
0
        private void upsertCohortPatientView(string patientId, string contactId, double version, string contractNumber, string userId)
        {
            string context = "NG";

            try
            {
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/patient/{4}/cohortpatientview/",
                                                                          DDPatientServiceURL,
                                                                          context,
                                                                          version,
                                                                          contractNumber,
                                                                          patientId), userId);

                GetCohortPatientViewResponse getResponse =
                    client.Get <GetCohortPatientViewResponse>(url);

                if (getResponse != null && getResponse.CohortPatientView != null)
                {
                    CohortPatientViewData cpvd = getResponse.CohortPatientView;
                    // check to see if primary care manager's contactId exists in the searchfield
                    if (!cpvd.SearchFields.Exists(sf => sf.FieldName == Constants.PCM))
                    {
                        cpvd.SearchFields.Add(new SearchFieldData
                        {
                            Value     = contactId,
                            Active    = true,
                            FieldName = Constants.PCM
                        });
                    }
                    else
                    {
                        cpvd.SearchFields.ForEach(sf =>
                        {
                            if (sf.FieldName == Constants.PCM)
                            {
                                sf.Value  = contactId;
                                sf.Active = true;
                            }
                        });
                    }

                    string cohortPatientViewURL = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/patient/{4}/cohortpatientview/update",
                                                                                       DDPatientServiceURL,
                                                                                       context,
                                                                                       version,
                                                                                       contractNumber,
                                                                                       patientId), userId);

                    PutUpdateCohortPatientViewResponse putResponse =
                        client.Put <PutUpdateCohortPatientViewResponse>(cohortPatientViewURL, new PutUpdateCohortPatientViewRequest
                    {
                        CohortPatientView = cpvd,
                        ContractNumber    = contractNumber,
                        PatientID         = patientId
                    } as object);
                }
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:UpsertCohortPatientView()::" + ex.Message, ex.InnerException);
            }
        }