Ejemplo n.º 1
0
        internal List <PatientData> getAllPatientsById(List <string> PatientIds, string ddUrl, string contract)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "1) Sending get all Patient DD request.", Type = LogType.Debug
            });
            List <PatientData> patients = new List <PatientData>();

            var userid = ProcConstants.UserId; // need to find a valid session id.

            try
            {
                PatientIds.ForEach(pid =>
                {
                    IRestClient client = new JsonServiceClient {
                        Timeout = TimeSpan.FromMinutes(50)
                    };                                                                               //new TimeSpan( 28000000000) };
                    //"/{Context}/{Version}/{ContractNumber}/patient/{PatientID}
                    var url = Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}", ddUrl, "NG", 1, contract, pid), userid);

                    GetPatientDataResponse response = client.Get <GetPatientDataResponse>(url);
                    patients.Add(response.Patient);
                });
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "1) Success", Type = LogType.Debug
                });
                return(patients);
            }
            catch (Exception ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "PatientDataDomain:Save(): " + ex.Message, Type = LogType.Error
                });
                throw new ArgumentException("PatientDataDomain:Save(): " + ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void AssignPatientPCPContactInfo(List <PatientData> Patients, List <PCPPhone> PCPPhones)
        {
            try
            {
                Patients.ForEach(p =>
                {
                    var phones       = PCPPhones.FindAll(f => f.PatientID == Convert.ToInt64(p.ExternalRecordId));
                    StringBuilder sb = new StringBuilder();
                    if (phones != null && phones.Count > 0)
                    {
                        phones.ForEach(
                            pd =>
                        {
                            if (!pd.PCP_Name.IsNullOrEmpty())
                            {
                                sb.Append(pd.PCP_Name + " | " + pd.Phone + " | " + pd.Facility + "; ");
                            }
                        });
                    }

                    p.ClinicalBackground = sb.ToString();
                    if (p.ClinicalBackground.Equals(String.Empty))
                    {
                        p.ClinicalBackground = null;
                    }
                });
            }
            catch (Exception ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "PatientsImportUow:AssignPatientPCPContactInfo(): " + ex.Message, Type = LogType.Error
                });
                throw;
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        private List <PatientNoteData> GetPatientNotesToRegister(List <HttpObjectResponse <PatientData> > patientSaveResults, List <PatientNoteData> patientNotes)
        {
            try
            {
                var cb    = new ConcurrentBag <PatientNoteData>();
                var psl   = patientSaveResults.Where(r => r.Code == HttpStatusCode.Created).ToList();
                var psIds = patientSaveResults.Where(r => r.Code == HttpStatusCode.Created).Select(item => item.Body.ExternalRecordId).Distinct().ToList();

                Parallel.ForEach(psIds, id =>
                                 //foreach (var id in psIds)
                {
                    var pMId = psl.Find(x => x.Body.ExternalRecordId == id).Body.Id;
                    var pn   = patientNotes.FindAll(r => r.PatientId == id);
                    var pnF  = pn.Select(c => { c.PatientId = pMId; return(c); }).ToList();
                    if (pnF.Count > 0)
                    {
                        pnF.ForEach(n => cb.Add(n));
                    }
                });

                return(cb.ToList());
            }
            catch (Exception ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "PatientsImportUow:GetPatientNotesToRegister(): " + ex.Message, Type = LogType.Error
                });
                throw new ArgumentException("PatientsImportUow:GetPatientNotesToRegister(): " + ex.Message);
            }
        }
Ejemplo n.º 7
0
        private readonly string _ddContactServiceUrl = ProcConstants.DdContactServiceUrl; //ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).AppSettings.Settings["DDContactServiceUrl"].Value;
        //ConfigurationManager.AppSettings[""];

        public object Save <T>(T list, string contract)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "4) Sending insert Contact DD request.", Type = LogType.Debug
            });
            var l = list as List <ContactData>;

            if (l != null)
            {
                LogUtil.LogExternalRecordId("Save", l.Cast <IAppData>().ToList());
            }

            InsertBatchContactDataResponse response = null;

            try
            {
                List <HttpObjectResponse <ContactData> > resp = null;
                var         userid = ProcConstants.UserId; // need to find a valid session id.
                IRestClient client = new JsonServiceClient();
                //[Route("/{Context}/{Version}/{ContractNumber}/Batch/Contacts", "POST")]
                var url =
                    Helper.BuildURL(
                        string.Format("{0}/{1}/{2}/{3}/Batch/Contacts/", _ddContactServiceUrl, "NG", 1, contract),
                        userid);

                try
                {
                    response = client.Post <InsertBatchContactDataResponse>(url,
                                                                            new InsertBatchContactDataRequest
                    {
                        Context        = "NG",
                        ContractNumber = contract,
                        ContactsData   = list as List <ContactData>,
                        UserId         = userid,
                        Version        = 1
                    });
                    resp = response.Responses;
                }
                catch (Exception ex)
                {
                    if (response != null)
                    {
                        var status = response.Status;
                    }
                    throw ex;
                }

                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "4) Success", Type = LogType.Debug
                });
                return(resp);
            }
            catch (WebServiceException ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "ContactDataDomain:Save(): " + ex.Message, Type = LogType.Error
                });
                throw new ArgumentException("ContactDataDomain:Save(): " + ex.Message);
            }
        }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
        public void InitPatientSystems(string contractDb, IRepositoryFactory repositoryFactory)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "initializing patient systems.", Type = LogType.Debug
            });
            // load patient xrefs
            var xrepo = repositoryFactory.GetRepository(contractDb, RepositoryType.XrefContractRepository);

            LoadPatientSystems(xrepo, PatientSystems = new List <PatientSystemData>());
        }
Ejemplo n.º 10
0
        public void InitPatients(string contractDb, IRepositoryFactory repositoryFactory)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "initializing patients.", Type = LogType.Debug
            });
            // load patient dictionary
            var repo = repositoryFactory.GetRepository(contractDb, RepositoryType.PatientsContractRepository);

            LoadPatients(repo, Patients = new List <PatientData>());
        }
Ejemplo n.º 11
0
        public void InitPCPPhones(string contractDb, IRepositoryFactory repositoryFactory)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "initializing pcp phones.", Type = LogType.Debug
            });
            // load pcpRepo
            var pcpRepo = repositoryFactory.GetRepository(contractDb, RepositoryType.PCPPhoneRepository);

            LoadPcpPhones(pcpRepo, PCPPhones = new List <PCPPhone>());
        }
Ejemplo n.º 12
0
        public List <ContactData> GetPatientContactsToRegister(List <HttpObjectResponse <PatientData> > saveResults)
        {
            try
            {
                var list = new ConcurrentBag <ContactData>();
                if (PatientDict == null)
                {
                    return(list.ToList());
                }
                var psIds = saveResults.Where(r => r.Code == HttpStatusCode.Created).Select(item => item.Body.ExternalRecordId).Distinct().ToList();
                Parallel.ForEach(psIds, id =>
                {
                    var ptInfo    = PatientDict[Convert.ToInt32(id)];
                    var mongoPtId = saveResults.Find(pt => pt.Body.ExternalRecordId == id).Body.Id;

                    var contactData = new ContactData
                    {
                        PatientId        = mongoPtId,
                        CreatedOn        = ptInfo.CreateDate != null ? Convert.ToDateTime(ptInfo.CreateDate) : default(DateTime),
                        RecentsList      = null,
                        ExternalRecordId = id,
                        FirstName        = ptInfo.FirstName,
                        LastName         = ptInfo.LastName,
                        MiddleName       = ptInfo.MiddleInitial,
                        Gender           = PatientInfoUtils.FormatGender(ptInfo.Gender),
                        Suffix           = ptInfo.Suffix,
                        StatusId         = PatientInfoUtils.GetStatus(ptInfo.Status),
                        DeceasedId       = PatientInfoUtils.GetDeceased(ptInfo.Status),
                        DataSource       = "P-Reg",
                        ContactTypeId    = Phytel.API.DataDomain.Contact.DTO.Constants.PersonContactTypeId
                    };
                    if (!string.IsNullOrEmpty(ptInfo.Phone) && ptInfo.Phone.Length == 10)
                    {
                        contactData.Phones = new List <PhoneData>
                        {
                            new PhoneData
                            {
                                DataSource = "P-Reg",
                                Number     = Convert.ToInt64(ptInfo.Phone),
                                TypeId     = "52e18c2ed433232028e9e3a6"
                            }
                        };
                    }
                    list.Add(contactData);
                });
                return(list.ToList());
            }
            catch (Exception ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "PatientsImportUow:GetPatientContactsToRegister(): " + ex.Message, Type = LogType.Error
                });
                throw new ArgumentException("PatientsImportUow:GetPatientContactsToRegister(): " + ex.Message);
            }
        }
Ejemplo n.º 13
0
        public List <PCPPhone> InitPatientPhonesGeneral(string contractDb, IRepositoryFactory repositoryFactory)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "initializing general pcp phones.", Type = LogType.Debug
            });
            // load pcpRepo
            var pcpRepo = repositoryFactory.GetRepository(contractDb, RepositoryType.PCPPhoneRepository);
            var phones  = LoadGeneralPcpPhones(pcpRepo);

            return(phones);
        }
Ejemplo n.º 14
0
        public void InitPatientNotes(string contractDb, IRepositoryFactory repositoryFactory)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "initializing patient notes.", Type = LogType.Debug
            });
            // load patient notes
            var pnRepo = repositoryFactory.GetRepository(contractDb, RepositoryType.PatientNotesRepository);
            List <PatientNote> pnRes = pnRepo.SelectAll() as List <PatientNote>;
            var nMap = MapperFactory.NoteMapper(contractDb);

            LoadPatientNotes(pnRes, Patients, PatientNotes = new List <PatientNoteData>(), nMap);
        }
Ejemplo n.º 15
0
        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);
            }
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        private void SaveIntegrationXref <T>(T list, string contract)
        {
            // save integrationpatientxref
            var atmoXrefList = GetIntegrationXrefToSave(list as List <HttpObjectResponse <PatientData> >);
            var repo         = new RepositoryFactory().GetRepository(contract, RepositoryType.XrefContractRepository);

            if (atmoXrefList != null && atmoXrefList.Count > 0)
            {
                repo.Insert(atmoXrefList.ToList());
            }
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "Register patients in IntegrationPatientXref - success", Type = LogType.Debug
            });
        }
Ejemplo n.º 18
0
        public List <PatientSystemData> GetPatientSystemsToLoad(List <PatientSystemData> patientSyss, List <HttpObjectResponse <PatientData> > patientResults)
        {
            try
            {
                var pdList      = new ConcurrentBag <PatientSystemData>();
                var patientsIds = patientResults.Where(r => r.Code == HttpStatusCode.Created).Select(item => item.Body.ExternalRecordId).ToList();

                //Parallel.ForEach(patientsIds, r =>
                patientsIds.ForEach(r =>
                {
                    // find all relevant patient system entries.
                    var pslist = patientSyss.FindAll(x => x.PatientId == r).ToList();
                    var pd     = patientResults.Where(x => x.Body.ExternalRecordId == r).Select(p => p.Body).FirstOrDefault();


                    // set the mongoid patient on patientsystem.
                    var fPsList = pslist.Select(c => { if (pd != null)
                                                       {
                                                           c.PatientId = pd.Id;
                                                       }
                                                       c.Id = null; return(c); }).ToList();

                    var list = fPsList.OrderByDescending(x => x.CreatedOn).OrderedDistinct(new PsDMyEqualityComparer()).ToList();
                    list.ForEach(x => pdList.Add(x));

                    // add a registration for atmosphere
                    pdList.Add(new PatientSystemData
                    {
                        ExternalRecordId = Guid.NewGuid().ToString(),
                        PatientId        = pd.Id,               // what is this?
                        Value            = pd.ExternalRecordId, // this will set the actual value for the record.
                        CreatedOn        = DateTime.UtcNow,
                        CreatedById      = API.DataDomain.Patient.Constants.SystemContactId,
                        DataSource       = "P-Reg",                    //"Integration",
                        SystemId         = "55e47fb9d433232058923e87", // atmosphere
                        StatusId         = 1
                    });
                });

                return(pdList.ToList());
            }
            catch (Exception ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "PatientsImportUow:GetPatientSystemsToLoad(): " + ex.Message, Type = LogType.Error
                });
                throw new ArgumentException("PatientsImportUow:GetPatientSystemsToLoad(): " + ex.Message);
            }
        }
Ejemplo n.º 19
0
        private readonly string _ddPatientNotesServiceUrl = ProcConstants.DdPatientNoteUrl; //ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).AppSettings.Settings["DDPatientNoteUrl"].Value; //ConfigurationManager.AppSettings[""];

        public object Save <T>(T patientNotes, string contract)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "5) Sending insert PatientNotes DD request.", Type = LogType.Debug
            });
            var l = patientNotes as List <PatientNoteData>;

            if (l != null)
            {
                LogUtil.LogExternalRecordId("Save", l.Cast <IAppData>().ToList());
            }

            var userid = ProcConstants.UserId; // need to find a valid session id.

            try
            {
                IRestClient client = new JsonServiceClient();
                //[Route("/{Context}/{Version}/{ContractNumber}/Batch/PatientNotes", "POST")]
                var url =
                    Helper.BuildURL(
                        string.Format("{0}/{1}/{2}/{3}/Batch/PatientNotes/", _ddPatientNotesServiceUrl, "NG", 1,
                                      contract), userid);

                InsertBatchPatientNotesDataResponse response = client.Post <InsertBatchPatientNotesDataResponse>(url,
                                                                                                                 new InsertBatchPatientNotesDataRequest
                {
                    Context          = "NG",
                    ContractNumber   = contract,
                    PatientNotesData = patientNotes as List <PatientNoteData>,
                    UserId           = userid,
                    Version          = 1
                });

                //new Helpers().SerializeObject<List<PatientNoteData>>(patientNotes as List<PatientNoteData>, Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\PatientNotesExample.txt");
                //var lPsd = Helpers.DeserializeObject<List<PatientSystemData>>(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\PatientsSystemExample.txt");

                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "5) Success", Type = LogType.Debug
                });
                return(response.Responses);
            }
            catch (Exception ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "PatientNoteDataDomain:Save(): " + ex.Message, Type = LogType.Error
                });
                throw new ArgumentException("PatientNoteDataDomain:Save(): " + ex.Message);
            }
        }
Ejemplo n.º 20
0
        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));
            }
        }
Ejemplo n.º 21
0
        public static void FormatOutputDebug <T>(IDomainResponse response)
        {
            //InsertBatchPatientsDataResponse
            //Helpers.SerializeObject<List<PatientData>>(patients as List<PatientData>, System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\PatientsExample.txt");
            //var lPsd = Helpers.DeserializeObject<List<PatientSystemData>>(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\PatientsSystemExample.txt");
            StringBuilder sb = new StringBuilder();

            ((InsertBatchPatientsDataResponse)response).Responses.ForEach(r =>
            {
                sb.Append("Id: " + r.Body.Id + " ,");
                sb.Append("ExternalRecordId: " + r.Body.ExternalRecordId + " ,");
                sb.Append("EngageId: " + r.Body.EngagePatientSystemValue + " |");
            });

            LoggerDomainEvent.Raise(new LogStatus {
                Message = "patient save result: " + sb.ToString(), Type = LogType.Debug
            });
        }
Ejemplo n.º 22
0
        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;
            }
        }
Ejemplo n.º 23
0
        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;
            }
        }
Ejemplo n.º 24
0
        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;
            }
        }
Ejemplo n.º 25
0
        public object Save <T>(T patients, string contract)
        {
            LoggerDomainEvent.Raise(new LogStatus {
                Message = "1) Sending insert Patient DD request.", Type = LogType.Debug
            });

            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}/Batch/Patients"
                var url =
                    Helper.BuildURL(
                        string.Format("{0}/{1}/{2}/{3}/Batch/Patients/", DDPatientServiceUrl, "NG", 1, contract), userid);

                InsertBatchPatientsDataResponse response = client.Post <InsertBatchPatientsDataResponse>(url,
                                                                                                         new InsertBatchPatientsDataRequest
                {
                    Context        = "NG",
                    ContractNumber = contract,
                    PatientsData   = patients as List <PatientData>,
                    UserId         = userid,
                    Version        = 1
                });

                LogUtil.FormatOutputDebug <T>(response);
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "1) Success", Type = LogType.Debug
                });
                return(response.Responses);
            }
            catch (Exception ex)
            {
                LoggerDomainEvent.Raise(new LogStatus {
                    Message = "PatientDataDomain:Save(): " + ex.Message, Type = LogType.Error
                });
                throw new ArgumentException("PatientDataDomain:Save(): " + ex.Message);
            }
        }
Ejemplo n.º 26
0
 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));
     }
 }
Ejemplo n.º 27
0
 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));
     }
 }
Ejemplo n.º 28
0
        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);
            }
        }
Ejemplo n.º 29
0
        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;
            }
        }
Ejemplo n.º 30
0
        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));
            }
        }