public void FormatPatientDataStatusResponse <T>(T list, string action) { try { if (list == null) { return; } List <PatientData> pData; if (list.GetType() == typeof(List <HttpObjectResponse <PatientData> >)) { pData = (list as List <HttpObjectResponse <PatientData> >).Select(r => r.Body).ToList(); } else { pData = list as List <PatientData>; } if (pData == null) { return; } LogUtil.LogExternalRecordId(action, pData.Cast <IAppData>().ToList()); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UowBase:FormatPatientDataStatusResponse(): " + ex.Message, false)); throw new ArgumentException("UowBase:FormatPatientDataStatusResponse(): " + ex.Message); } }
public void HandleResponse <T>(T list, string contract) { try { if (list == null) { throw new Exception("response list is null."); } if (list.GetType() == typeof(List <HttpObjectResponse <PatientSystemData> >)) { PatientSystemResults.AddRange(list as List <HttpObjectResponse <PatientSystemData> >); } else if (list.GetType() == typeof(List <HttpObjectResponse <PatientData> >)) { PatientSaveResults.AddRange(list as List <HttpObjectResponse <PatientData> >); SaveIntegrationXref(list, contract); FormatPatientDataStatusResponse(list, "saved"); } } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UowBase:HandleResponse(): " + ex.Message, false)); throw new ArgumentException("UowBase:HandleResponse(): " + ex.Message); } }
internal void BulkOperation <T>(List <T> pocos, string contract, IDataDomain domain, string collection) { try { if (pocos.Count == 0) { return; //throw new Exception("There are no items to page in list."); } if (pocos.Count > 5 && pocos.Count > ProcConstants.TakeCount) { LoggerDomainEvent.Raise(LogStatus.Create("[Batch Process]: Handling " + pocos.Count + " records in batches.", true)); BatchRequest(pocos, contract, domain); } else { HandleResponse(domain.Save(pocos, contract), contract); } LoggerDomainEvent.Raise(LogStatus.Create("[Batch Process]: Saving " + collection + " - success.", true)); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UowBase:BulkOperation(): " + ex.Message, false)); throw new ArgumentException("UowBase:BulkOperation(): " + ex.Message); } }
public void Initialize(string contractDb) { LoggerDomainEvent.Raise(LogStatus.Create("Initializing Integration process for : [" + contractDb + "] contract", true)); InitPCPPhones(contractDb, RepositoryFactory); InitPatients(contractDb, RepositoryFactory); InitPatientSystems(contractDb, RepositoryFactory); InitPatientNotes(contractDb, RepositoryFactory); }
public static bool LogExternalRecordId(string action, List <IAppData> pData) { StringBuilder sb = new StringBuilder(); if (pData == null) { return(true); } pData.ForEach(r => sb.Append(r.ExternalRecordId + ", ")); LoggerDomainEvent.Raise( LogStatus.Create("[Batch Process]: " + pData.Count + " Records " + action + " : (" + sb.ToString() + ")", true)); return(false); }
public void LoadPatientNotes(List <PatientNote> pNotes, List <PatientData> pats, List <PatientNoteData> notes, INoteMapper mapper) { try { var valid = ((List <PatientNote>)pNotes).Select( pn => new { pn, patient = pats.Find(r => r.ExternalRecordId == pn.PatientId.ToString()) }) .Where(@t => @t.patient != null) .Select(@t => mapper.MapPatientNote(@t.patient.Id, @t.pn)); notes.AddRange(valid); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UOWBase: LoadPatientNotes():" + ex.Message, false)); } }
public object SelectAll() { try { List <PatientNote> ptInfo = null; using (var ct = new ContractEntities(ConnStr.GetConnectionStringEF(_contract))) { var query = Implementor.GetPatientNotesQuery(ct); ptInfo = query.ToList(); } return(ptInfo); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("PatientsNotesRepository:SelectAll(): " + ex.Message, false)); throw; } }
public object SelectAll() { try { Dictionary <int, PatientInfo> ptInfo = null; using (var ct = new ContractEntities(ConnStr.GetConnectionStringEF(_contract))) { var query = Implementor.GetPatientInfoQuery(ct); ptInfo = query.ToDictionary(r => Convert.ToInt32(r.PatientId)); } return(ptInfo); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("PatientsContractRepository:SelectAll(): " + ex.Message, false)); throw; } }
public List <ToDoData> ParseToDos(List <HttpObjectResponse <PatientData> > pRes) { try { var list = new List <ToDoData>(); pRes.ForEach(x => { var ptid = Convert.ToInt32(x.Body.ExternalRecordId); var pt = PatientDict[ptid]; var followUpDate = pt.FollowupDueDate.HasValue ? pt.FollowupDueDate.Value.ToShortDateString() : string.Empty; if (String.IsNullOrEmpty(followUpDate)) { return; } var fDate = pt.FollowupDueDate.Value; var val = fDate > DateTime.UtcNow; if (val) { list.Add(new ToDoData { DueDate = fDate.AddHours(12), // add 12hrs to make it land of the middle of the day. PatientId = x.Body.Id, Description = "Follow-up initiated in Coordinate", Title = "Follow-up Date", CategoryId = "562e8f8ad4332315e0a4fffa", //follow up category PriorityId = 0, // notset StatusId = 1, // Open CreatedById = ProcConstants.UserId, CreatedOn = DateTime.UtcNow, ExternalRecordId = x.Body.ExternalRecordId }); } }); return(list); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UOWBase: ParseToDos():" + ex.Message, false)); throw; } }
public void LoadPcpPhones(Repo.Repositories.IRepository xrepo, List <PCPPhone> pcpPhones) { try { var phnList = xrepo.SelectAll(); if (phnList == null) { return; } var final = ((List <PCPPhone>)phnList).Where(x => x.Phone != null && x.Phone.Length == 10); if (final == null) { return; } pcpPhones.AddRange(from xr in final select xr); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UOWBase: LoadPcpPhones():" + ex.Message, false)); } }
public void LoadPatientSystems(Repo.Repositories.IRepository xrepo, List <PatientSystemData> systems) { try { var xrefsDic = xrepo.SelectAll(); systems.AddRange(from xr in (List <PatientXref>) xrefsDic select Mapper.Map <PatientSystemData>(xr)); foreach (var t in systems) { t.CreatedOn = t.CreatedOn.ToUniversalTime(); if (t.UpdatedOn.HasValue) { t.UpdatedById = ProcConstants.UserId; t.UpdatedOn = t.UpdatedOn.Value.ToUniversalTime(); } } } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UOWBase: LoadPatientSystems():" + ex.Message, false)); } }
public object Insert(object list) { LoggerDomainEvent.Raise(LogStatus.Create("3) Register integrationpatientxrefs for patients...", true)); try { var xrefList = (List <EIntegrationPatientXref>)list; using (var bcc = new SqlBulkCopy(ConnStr.GetConnectionString(_contract), SqlBulkCopyOptions.Default)) { using (var objRdr = ObjectReader.Create(xrefList)) { try { bcc.BulkCopyTimeout = 580; bcc.ColumnMappings.Add("SendingApplication", "SendingApplication"); bcc.ColumnMappings.Add("ExternalPatientID", "ExternalPatientID"); bcc.ColumnMappings.Add("PhytelPatientID", "PhytelPatientID"); bcc.ColumnMappings.Add("CreateDate", "CreateDate"); bcc.ColumnMappings.Add("UpdateDate", "UpdateDate"); bcc.ColumnMappings.Add("UpdatedBy", "UpdatedBy"); bcc.ColumnMappings.Add("ExternalDisplayPatientId", "ExternalDisplayPatientId"); bcc.DestinationTableName = "IntegrationPatientXref"; bcc.WriteToServer(objRdr); LoggerDomainEvent.Raise(LogStatus.Create("3) Success", true)); } catch (Exception ex) { Utils.FormatError(ex, bcc); } } } return(null); } catch (Exception ex) { throw new ArgumentException("XrefContractRepository:Insert(): " + ex.Message); } }
public void Process(RegistryCompleteMessage message) { try { if (!IsApplicableContract.IsSatisfiedBy(message)) { return; } LoggerDomainEvent.Raise(LogStatus.Create("*** Atmosphere Import Start ***", true)); LoggerDomainEvent.Raise(LogStatus.Create("Atmosphere Patient Import for " + message.ContractDataBase + " started.", true)); PatientsUow.Initialize(message.ContractDataBase); PatientsUow.Commit(message.ContractDataBase); LoggerDomainEvent.Raise(LogStatus.Create("Atmosphere Patient Import for " + message.ContractDataBase + " completed.", true)); LoggerDomainEvent.Raise(LogStatus.Create("*** Atmosphere Import Completed ***", true)); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("MessageProcessor:Process(): " + ex.Message, false)); throw; } }
public void LoadPatients(Repo.Repositories.IRepository repo, List <PatientData> pats) { try { PatientDict = repo.SelectAll() as Dictionary <int, PatientInfo>; pats.AddRange((from pt in PatientDict select pt.Value).Select(ObjMapper.MapPatientData)); foreach (var t in pats) { t.RecordCreatedOn = t.RecordCreatedOn.ToUniversalTime(); if (!t.LastUpdatedOn.HasValue) { continue; } t.UpdatedByProperty = ProcConstants.UserId; t.LastUpdatedOn = t.LastUpdatedOn.Value.ToUniversalTime(); } } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UOWBase: LoadPatients():" + ex.Message, false)); } }
public void BatchRequest <T>(List <T> pocos, string contract, IDataDomain domain) { try { var take = ProcConstants.TakeCount; var count = 0; var pages = pocos.Pages(take); for (var i = 0; i <= pages; i++) { try { if (count == pocos.Count) { break; } var savePatients = pocos.Batch(take).ToList()[i]; var enumerable = savePatients as IList <T> ?? savePatients.ToList(); FormatPatientDataStatusResponse(savePatients.ToList(), "saving"); HandleResponse(domain.Save(enumerable, contract), contract); count = count + enumerable.Count(); LoggerDomainEvent.Raise(LogStatus.Create("Patients saved:" + count, true)); } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("Failure to save batch [" + i + "]:" + count + " " + ex.Message, false)); } } } catch (Exception ex) { LoggerDomainEvent.Raise(LogStatus.Create("UowBase:BatchRequest(): " + ex.Message, false)); throw new ArgumentException("UowBase:BatchRequest(): " + ex.Message); } }