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 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); }
PutUpdatePatientDataResponse IPatientDataManager.UpdatePatient(PutUpdatePatientDataRequest request) { throw new NotImplementedException(); }
public object FindDuplicatePatient(PutUpdatePatientDataRequest request) { throw new NotImplementedException(); }