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); } }
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"); } } }
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); }
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); }
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); }
PutUpdateCohortPatientViewResponse IPatientDataManager.UpdateCohortPatientViewProblem(PutUpdateCohortPatientViewRequest request) { throw new NotImplementedException(); }