public void Update_Patient_Priority_By_PatientID() { // http://localhost:8888/Patient/NG/1.0/InHealth001/patient/999/priority/2 string patientID = "528f6dc2072ef708ecd90e3a"; string contractNumber = "InHealth001"; string context = "NG"; int priority = 1; double version = 1.0; string firstname = null; IRestClient client = new JsonServiceClient(); JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "x-Phytel-UserID", "531f2df9072ef727c4d2a3df")); PutUpdatePatientDataResponse response = client.Put <PutUpdatePatientDataResponse>( string.Format(@"http://localhost:8888/Patient/{0}/{1}/{2}/patient/{3}", context, version, contractNumber, patientID), new PutUpdatePatientDataRequest { Context = context, ContractNumber = contractNumber, PatientData = new PatientData { PriorityData = 3, DOB = "12-12-2013", FirstName = "Reggie", LastName = "Bobzilla", Gender = "M", PreferredName = "A manny", Suffix = "mr", MiddleName = "Ignacio" }, UserId = "ba9b277d-4b53-4a53-a2c5-15d4969423ec" } as object); }
public PutUpdatePatientDataResponse UpdatePatient(PutUpdatePatientDataRequest request) { PutUpdatePatientDataResponse response = new PutUpdatePatientDataResponse(); try { IPatientRepository repo = Factory.GetRepository(request, RepositoryType.Patient); if (request.PatientData != null) { if (request.Insert) { if (request.InsertDuplicate) // the user has ignored the warning message about a duplicate patient entry. { response = repo.Update(request) as PutUpdatePatientDataResponse; if (!string.IsNullOrEmpty(response.Id)) { //Create Engage system record for the newly created patient in PatientSystem collection. insertEngagePatientSystem(response.Id, request); } } else { if (repo.FindDuplicatePatient(request) == null) { response = repo.Update(request) as PutUpdatePatientDataResponse; if (!string.IsNullOrEmpty(response.Id)) { //Create Engage system record for the newly created patient in PatientSystem collection. insertEngagePatientSystem(response.Id, request); } } else { Outcome outcome = new Outcome { Result = 0, Reason = "An individual by the same first name, last name and date of birth already exists." }; response.Outcome = outcome; } } } else { response = repo.Update(request) as PutUpdatePatientDataResponse; } } } catch (Exception ex) { throw ex; } return(response); }
public object Update <T>(T patients, string contract, string ddServiceurl) { LoggerDomainEvent.Raise(new LogStatus { Message = "1) Sending update Patient DD request.", Type = LogType.Debug }); string patientId = null; var userid = ProcConstants.UserId; // need to find a valid session id. try { IRestClient client = new JsonServiceClient { Timeout = TimeSpan.FromMinutes(50) }; //new TimeSpan( 28000000000) }; //"/{Context}/{Version}/{ContractNumber}/Patient"" var url = Helper.BuildURL( string.Format("{0}/{1}/{2}/{3}/Patient/", ddServiceurl, "NG", 1, contract), userid); var patientList = patients as List <PatientData>; patientList.ForEach(pt => { patientId = pt.ExternalRecordId; pt.UpdatedByProperty = UpdatedBy; pt.DisplayPatientSystemId = null; // set this manually PutUpdatePatientDataResponse response = client.Put <PutUpdatePatientDataResponse>(url, new PutUpdatePatientDataRequest { Context = "NG", ContractNumber = contract, PatientData = pt, UserId = userid, Insert = false, InsertDuplicate = false, Version = 1 }); //LogUtil.FormatOutputDebug<T>(response); LoggerDomainEvent.Raise(new LogStatus { Message = "1) Success", Type = LogType.Debug }); }); return("Success!"); } catch (Exception ex) { LoggerDomainEvent.Raise(new LogStatus { Message = "PatientDataDomain:Update(): " + ex.Message, Type = LogType.Error }); throw new ArgumentException("PatientDataDomain:Update(): " + ex.Message); } }
public void SavePatient_Test() { PatientData data = new PatientData { Id = "53f3c367d6a48508586bbace", FirstName = "Ellaha", LastName = "Bullock" }; PutUpdatePatientDataRequest request = new PutUpdatePatientDataRequest { Insert = true, Context = context, ContractNumber = contractNumber, UserId = userId, Version = version, PatientData = data }; IPatientDataManager pm = new PatientDataManager { Factory = new PatientRepositoryFactory() }; PutUpdatePatientDataResponse response = pm.UpdatePatient(request); Assert.IsNotNull(response); }
public PutUpdatePatientDataResponse UpsertPatient(PutUpdatePatientDataRequest putUpdatePatient, string patientId) { Uri updateUri = new Uri(string.Format("{0}/Patient/{1}/{2}/{3}/patient?UserId={4}", Url, Context, Version, ContractNumber, HeaderUserId)); HttpClient updateClient = GetHttpClient(updateUri); PutUpdatePatientDataResponse updateResponsePatient = null; DataContractJsonSerializer updateJsonSer = new DataContractJsonSerializer(typeof(PutUpdatePatientDataRequest)); // use the serializer to write the object to a MemoryStream MemoryStream updateMs = new MemoryStream(); updateJsonSer.WriteObject(updateMs, putUpdatePatient); updateMs.Position = 0; //use a Stream reader to construct the StringContent (Json) StreamReader updateSr = new StreamReader(updateMs); StringContent updateContent = new StringContent(updateSr.ReadToEnd(), System.Text.Encoding.UTF8, "application/json"); updateMs.Dispose(); //Post the data var updateResponse = updateClient.PutAsync(updateUri, updateContent); var updateResponseContent = updateResponse.Result.Content; string updateResponseString = updateResponseContent.ReadAsStringAsync().Result; using (var updateMsResponse = new MemoryStream(Encoding.Unicode.GetBytes(updateResponseString))) { var updateSerializer = new DataContractJsonSerializer(typeof(PutUpdatePatientDataResponse)); updateResponsePatient = (PutUpdatePatientDataResponse)updateSerializer.ReadObject(updateMsResponse); } return(updateResponsePatient); }
public PutUpdatePatientDataResponse Put(PutUpdatePatientDataRequest request) { PutUpdatePatientDataResponse response = new PutUpdatePatientDataResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("PatientDD:Put()::Unauthorized Access"); } response = PatientManager.UpdatePatient(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); }