Ejemplo n.º 1
0
        private List <DNInsuranceNoteEntity> GetInsuranceNotes(int patientId, int noteId)
        {
            List <DNInsuranceNoteEntity> DNinsurancenoteentity = new List <DNInsuranceNoteEntity>();

            try
            {
                using (var context = new RehabEntities())
                {
                    DNinsurancenoteentity = context.Database.SqlQuery <DNInsuranceNoteEntity>("SP_GetPatInsuranceNote @PTrowid,@Docrowid ",
                                                                                              new SqlParameter("PTrowid", SqlDbType.BigInt)
                    {
                        Value = noteId
                    },
                                                                                              new SqlParameter("Docrowid", SqlDbType.BigInt)
                    {
                        Value = patientId
                    }
                                                                                              ).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(DNinsurancenoteentity);
        }
        public DT_AuthenticateEntity GetUser(string userName, string password)
        {
            using (Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities())
            {
                // string encodedpassword = decode(password);
                password = Encryption.AESEncryptString(password, "", "");
                //password = Encryption.AesDecryptString(password, "", "");
                DT_AuthenticateEntity DTpatients = (from user in rehab.tblUsers.Where(a => a.UserId == userName && a.UserPassword == password)
                                                    join usergrp in rehab.tblUserGroups on user.UserGroup equals usergrp.UGrowid


                                                    select new DT_AuthenticateEntity
                {
                    FirstName = user.FirstName,
                    LastName = user.LastName,
                    UserID = user.UserId,
                    Role = usergrp.UserGroup
                           //PhoneNumber = therapist.LastName,
                           //Email = therapist.LastName
                }
                                                    ).Distinct().ToList().FirstOrDefault();
                return(DTpatients);
                //if (DTpatients != null)
                //{
                //    return DTpatients;
                //}
                //else
                //{

                //    throw new UnauthorizedAccessException();
                //}
            }
        }
        private List <CommReferralEntity> GetCommReferals(int patientId, int noteId)
        {
            List <CommReferralEntity> CommReferral = new List <CommReferralEntity>();

            try
            {
                using (var context = new RehabEntities())
                {
                    CommReferral = context.Database.SqlQuery <CommReferralEntity>("SP_GetPatReferral @Patientid,@Docrowid ",
                                                                                  new SqlParameter("Patientid", SqlDbType.Int)
                    {
                        Value = patientId
                    },
                                                                                  new SqlParameter("Docrowid", SqlDbType.Int)
                    {
                        Value = noteId
                    }
                                                                                  ).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(CommReferral);
        }
        public string CheckClinicisAssigned(string username)
        {
            string referralemail = "*****@*****.**";

            using (RehabEntities rehab = new RehabEntities())
            {
                var clinicnum = (from inc in rehab.tblUsers where inc.UserId == username select inc.DefaultClinic).FirstOrDefault();
                if (clinicnum != null)
                {
                    var clinicnumber = (from inc in rehab.tblClinics where inc.Crowid == clinicnum select inc.ClinicNo).FirstOrDefault();
                    if (clinicnumber != null)
                    {
                        Int32 num        = Convert.ToInt32(clinicnum);
                        var   existsmail = (from inc in rehab.tbl_DT_ClinicUserMapping where inc.ClinicNo == clinicnumber.ToString() select inc.EmailId).FirstOrDefault();
                        if (existsmail == null)
                        {
                            referralemail = "*****@*****.**";
                        }
                        else
                        {
                            referralemail = existsmail;
                        }
                    }
                }
            }
            return(referralemail);
        }
Ejemplo n.º 5
0
        public List <PatientSchedulesEntity> GetPatientsSchedules(int patientId)
        {
            List <PatientSchedulesEntity> schedulesEntity = new List <PatientSchedulesEntity>();

            Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities();
            List <tblSchedules> tblschedulesEntity   = new List <tblSchedules>();

            try
            {
                schedulesEntity = (from schedule in rehab.tblSchedules
                                   where schedule.PatientId == patientId

                                   select new PatientSchedulesEntity
                {
                    Description = "Treatment",
                    TreatmentDate = schedule.StartDateTime
                                    //PhoneNumber = therapist.LastName,
                                    //Email = therapist.LastName
                }
                                   ).ToList();
            }
            catch (Exception ex)
            {
                throw;
            }
            return(schedulesEntity);
        }
        private List <CommDocEntity> GetCommDocID(int patientId, string noteType)
        {
            List <CommDocEntity> CommDocID = new List <CommDocEntity>();

            try
            {
                using (var context = new RehabEntities())
                {
                    CommDocID = context.Database.SqlQuery <CommDocEntity>("SP_GetDoc @patientid,@notetype ",
                                                                          new SqlParameter("patientid", SqlDbType.Int)
                    {
                        Value = patientId
                    },
                                                                          new SqlParameter("notetype", SqlDbType.VarChar)
                    {
                        Value = noteType
                    }

                                                                          ).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(CommDocID);
        }
Ejemplo n.º 7
0
        private List <DNDocTreatDesc> GetTreatDescWithPatientIDZero(int patientId, int noteId)
        {
            List <DNDocTreatDesc> DNDocTreatDescPatientIDZero = new List <DNDocTreatDesc>();

            try
            {
                using (var context = new RehabEntities())
                {
                    DNDocTreatDescPatientIDZero = context.Database.SqlQuery <DNDocTreatDesc>("SP_GetDocTreatDesc @docrowid,@patientid ",
                                                                                             new SqlParameter("docrowid", SqlDbType.BigInt)
                    {
                        Value = noteId
                    },
                                                                                             new SqlParameter("patientid", SqlDbType.BigInt)
                    {
                        Value = patientId
                    }

                                                                                             ).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(DNDocTreatDescPatientIDZero);
        }
Ejemplo n.º 8
0
        public ViewModelPatientTherapist GetPatientsTherapist(string NPINumber)
        {
            // List<tblPatient> patients = _unitOfWork.PatientEntityRepo.Get().ToList();
            List <PatientEntity>      patients       = GetPatientsbyNPINumber(NPINumber);
            ViewModelPatientTherapist patTher        = new ViewModelPatientTherapist();
            List <PatientEntity>      patientsEntity = new List <PatientEntity>();

            Team.Rehab.DataModel.RehabEntities rehab           = new RehabEntities();
            List <TherapistEntity>             therapistEntity = new List <TherapistEntity>();
            //therapistEntity = (from therapist in rehab.tblTherapists

            //                       select new TherapistEntity
            //                       {
            //                           FirstName = therapist.FirstName,
            //                           LastName = therapist.LastName
            //                           //PhoneNumber = therapist.LastName,
            //                           //Email = therapist.LastName

            //                       }
            //).ToList();
            string      ReferralSource = null;
            tblReferrer referrer       = _unitOfWork.ReferrerRepo.Get(o => o.NPINumber == NPINumber).FirstOrDefault();

            if (referrer != null)
            {
                ReferralSource = Convert.ToString(referrer.Rrowid);
            }
            therapistEntity = (from therapist in rehab.tblTherapists
                               join docs in rehab.tblDocMasters on therapist.TherapistID equals docs.TreatingTherapistId

                               join patient in rehab.tblPatients.Where(a => a.ReferralSource == ReferralSource)
                               on docs.PTrowid equals patient.Prowid

                               //join referrer in rehab.tblReferrers on ptint.ReferralSource equals referrer.Rrowid
                               //where referrer.NPINumber = NPINumber
                               select new TherapistEntity
            {
                FirstName = therapist.FirstName,
                LastName = therapist.LastName
                           //PhoneNumber = therapist.LastName,
                           //Email = therapist.LastName
            }
                               ).Distinct().ToList();


            if (patients.Count() > 0)
            {
                patTher.PatientList = patients;
            }
            if (therapistEntity.Count() > 0)
            {
                patTher.Therapist = therapistEntity;
            }
            return(patTher);
        }
Ejemplo n.º 9
0
        private List <DNDescHintsEntity> GetDescHints()
        {
            List <DNDescHintsEntity> DNdeschintsentity = new List <DNDescHintsEntity>();

            try
            {
                using (var context = new RehabEntities())
                {
                    DNdeschintsentity = context.Database.SqlQuery <DNDescHintsEntity>("SP_GetHints ").ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(DNdeschintsentity);
        }
Ejemplo n.º 10
0
        public static void SendExcepToDB(Exception exdb, string exepurl)
        {
            using (RehabEntities context = new RehabEntities())
            {
                string ConnectionString            = context.Database.Connection.ConnectionString;
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(ConnectionString);
                builder.ConnectTimeout = 2500;
                SqlConnection con = new SqlConnection(builder.ConnectionString);

                con.Open();

                SqlCommand com = new SqlCommand("SP_APIExceptions", con);
                com.CommandType = System.Data.CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@ExceptionMsg", exdb.Message.ToString());
                com.Parameters.AddWithValue("@ExceptionType", exdb.GetType().Name.ToString());
                com.Parameters.AddWithValue("@ExceptionURL", exepurl);
                com.Parameters.AddWithValue("@ExceptionSource", exdb.StackTrace.ToString());
                com.ExecuteNonQuery();
                con.Close();
            }
        }
        public DT_AuthenticateEntity GetUserOnUsername(string userName)
        {
            using (Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities())
            {
                // string encodedpassword = decode(password);

                //password = Encryption.AesDecryptString(password, "", "");
                DT_AuthenticateEntity DTpatients = (from user in rehab.tblUsers.Where(a => a.UserEmail == userName)
                                                    join usergrp in rehab.tblUserGroups on user.UserGroup equals usergrp.UGrowid


                                                    select new DT_AuthenticateEntity
                {
                    FirstName = user.FirstName,
                    LastName = user.LastName,
                    UserID = user.UserId,
                    Role = usergrp.UserGroup
                }
                                                    ).Distinct().ToList().FirstOrDefault();
                return(DTpatients);
            }
        }
        public List <NotificationsEntity> GetNotifications(int NPINumber)
        {
            Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities();
            List <NotificationsEntity>         notificationsEntity = new List <NotificationsEntity>();

            notificationsEntity = (from notifications in rehab.tblAppNotifications.Where(a => a.IsViewed == false && a.NPINumber == NPINumber)
                                   join ptint in rehab.tblPatients on notifications.Prowid equals ptint.Prowid

                                   //join refer in rehab.tblReferrers on ptint.ReferralSource equals refer.Rrowid
                                   //join referrer in rehab.tblReferrers on ptint.ReferralSource equals referrer.Rrowid
                                   //where referrer.NPINumber = NPINumber
                                   select new NotificationsEntity
            {
                NotificationId = notifications.Nrowid,
                FirstName = ptint.FirstName,
                LastName = ptint.LastName,
                AlertMessage = notifications.AlertMsg,
                ModifiedDate = notifications.UpdatedTs.ToString()
            }
                                   ).ToList();
            return(notificationsEntity);
        }
Ejemplo n.º 13
0
        public List <PatTherapistEntity> GetDocTherapist(string NPINumber)
        {
            Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities();
            List <PatTherapistEntity>          patTherapistEntity = new List <PatTherapistEntity>();

            patTherapistEntity = (from users in rehab.tblUsers
                                  join thpst in rehab.tblTherapists on
                                  new { users.FirstName, users.LastName } equals new { thpst.FirstName, thpst.LastName }
                                  where thpst.NPINumber == NPINumber
                                  select new PatTherapistEntity
            {
                Name = users.FirstName.ToUpper() + ", " + users.LastName.ToUpper(),
                SignatureFile = thpst.SignatureFile,
                Path = " ",
                FirstName = thpst.FirstName,
                LastName = thpst.LastName,
                NPI = thpst.NPINumber,
                LicenseNumber = thpst.LicenseNumber
            }
                                  ).ToList();
            return(patTherapistEntity);
        }
        private List <CommNoteSummaryEntity> GetCommNoteSummary(int noteId)
        {
            List <CommNoteSummaryEntity> CommNoteSummary = new List <CommNoteSummaryEntity>();

            try
            {
                using (var context = new RehabEntities())
                {
                    CommNoteSummary = context.Database.SqlQuery <CommNoteSummaryEntity>("SP_GetDocNoteSummary @Docrowid ",
                                                                                        new SqlParameter("Docrowid", SqlDbType.Int)
                    {
                        Value = noteId
                    }

                                                                                        ).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(CommNoteSummary);
        }
Ejemplo n.º 15
0
 public EvaluationsRepository(RehabEntities db) : base(db)
 {
 }
Ejemplo n.º 16
0
        public List <NotesSummaryEntity> GetNotesSummary(int patientId)
        {
            List <NotesSummaryEntity> notesSummary      = new List <NotesSummaryEntity>();
            List <NotesSummaryEntity> notesSummaryFinal = new List <NotesSummaryEntity>();

            Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities();
            List <NotificationsEntity>         notificationsEntity = new List <NotificationsEntity>();

            try
            {
                notesSummary = (from notes in rehab.tblDocMasters.Where(a => a.PTrowid == patientId)
                                join thpst in rehab.tblTherapists on notes.TreatingTherapistId equals thpst.TherapistID
                                join clinic in rehab.tblClinics on thpst.DefaultClinic equals clinic.Crowid
                                join usr in rehab.tblUsers on
                                new { thpst.FirstName, thpst.LastName } equals new { usr.FirstName, usr.LastName }
                                select new NotesSummaryEntity
                {
                    Docrowid = notes.Docrowid,
                    NotesType = notes.NoteType,
                    DateOfService = notes.DateOfService,
                    FirstName = thpst.FirstName,
                    LastName = thpst.LastName,
                    //  TherpistPhone = thpst.TherpistPhone,
                    TherapistEmail = usr.UserEmail,
                    ClinicName = clinic.ClinicName,
                    ClinicPhone = clinic.PhoneNumber
                                  //  ClinicEmail = clinic.ClinicEmail,
                }
                                ).ToList();
                foreach (NotesSummaryEntity obj in notesSummary)
                {
                    if (obj.NotesType == "PPOC")
                    {
                        obj.NotesType = "Initial Eval";
                    }
                    if (obj.NotesType == "PPOC2")
                    {
                        obj.NotesType = "Initial Eval2";
                    }
                    if (obj.NotesType == "PPOCRE")
                    {
                        obj.NotesType = "Re-Eval";
                    }

                    if (obj.NotesType == "PTREAT")
                    {
                        obj.NotesType = "Daily Note";
                    }

                    if (obj.NotesType == "PMN")
                    {
                        obj.NotesType = "Medical Necessity";
                    }
                    if (obj.NotesType == "PDIS")
                    {
                        obj.NotesType = "Discharge";
                    }
                    if (obj.NotesType == "PCOMM")
                    {
                        obj.NotesType = "Communication";
                    }
                    if (obj.NotesType == "PMV")
                    {
                        obj.NotesType = "Missed";
                    }
                    if (obj.NotesType == "PFCE")
                    {
                        obj.NotesType = "FCE";
                    }

                    notesSummaryFinal.Add(obj);


                    //WHEN 'PFCE' then 'FCE'

                    //    Else 'Others'
                }
            }
            catch (Exception ex)
            {
                CustomLogger.SendExcepToDB(ex, "PatinetRepository");
                CustomLogger.LogError(Convert.ToString("NoteSummary in PatinetRepository- " + ex.Message));
            }
            return(notesSummaryFinal);
        }
Ejemplo n.º 17
0
 public ContactsRepository(RehabEntities db) : base(db)
 {
 }
Ejemplo n.º 18
0
        //public UnitOfWork(RehabEntities context)
        //{
        //    _context = context;
        //}

        public UnitOfWork()
        {
            _context = new RehabEntities();
        }
Ejemplo n.º 19
0
 public ContextBaseRepository(RehabEntities context) : base(context)
 {
 }
Ejemplo n.º 20
0
 public PatientsRepository(RehabEntities db) : base(db)
 {
 }
        public JArray GetPatientList(string firstName, string lastName, string dateOfBirth, string NPINumber)
        {
            try
            {
                List <PatientEntity> patientEntity       = new List <PatientEntity>();
                List <tblPatients>   tblPatientEntity    = new List <tblPatients>();
                Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities();
                string ReferralSource = string.Empty;
                if (!string.IsNullOrEmpty(NPINumber))
                {
                    tblReferrer referrer = _unitOfWork.ReferrerRepo.Get(o => o.NPINumber == NPINumber).FirstOrDefault();
                    if (referrer != null)
                    {
                        ReferralSource = Convert.ToString(referrer.Rrowid);
                    }
                }
                var query = rehab.tblPatients.AsQueryable();
                if (!string.IsNullOrEmpty(NPINumber))
                {
                    query = query.Where(iv => iv.ReferralSource.Contains(ReferralSource));
                }
                if (!string.IsNullOrEmpty(firstName))
                {
                    query = query.Where(iv => iv.FirstName.Contains(firstName));
                }

                if (!string.IsNullOrEmpty(lastName))
                {
                    query = query.Where(iv => iv.LastName.Contains(lastName));
                }
                if (!string.IsNullOrEmpty(dateOfBirth))
                {
                    query = query.Where(iv => iv.BirthDate.Equals(dateOfBirth));
                }

                patientEntity = (from iv in query
                                 select new PatientEntity {
                    Prowid = iv.Prowid,
                    FirstName = iv.FirstName,
                    LastName = iv.LastName,
                    MiddleInitial = iv.MiddleInitial,
                    Gender = iv.Gender,
                    BirthDate = iv.BirthDate,
                    Address1 = iv.Address1,
                    Address2 = iv.Address2,
                    City = iv.City,
                    State = iv.State,
                    ZipCode = iv.ZipCode,
                    HomePh = iv.HomePh,
                    WorkPh = iv.WorkPh,
                    CellPh = iv.CellPh,
                }).ToList();


                //===============mapper end==========================================
                JArray jResponse = new JArray();
                if (patientEntity.Count() > 0)
                {
                    CCDAGeneration.PatientDemographics _patientDemographics = new CCDAGeneration.PatientDemographics();


                    jResponse = _patientDemographics.ConvertPatientInfo(patientEntity);
                    return(jResponse);
                }
                else
                {
                    JArray  jsonArray = new JArray();
                    JObject rss       =
                        new JObject(
                            new JProperty("No record found"
                                          ));
                    jsonArray.Add(rss);
                    return(jsonArray);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 22
0
        public JArray GetMedicalNcessityNotes(int patientId, int NoteId)
        {
            JObject jResponse   = new JObject();
            string  NoteType    = string.Empty;
            string  NoteTypeDec = string.Empty;
            JArray  jsonPatient = new JArray();

            Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities();

            try
            {
                //MedicalNecessityNotes msNote = new MedicalNecessityNotes();
                TPatientRespository objTrepo     = new TPatientRespository(_unitOfWork);
                tblDocMaster        patientNotes = _unitOfWork.DocMasterRepo.Get(o => o.PTrowid == patientId && o.Docrowid == NoteId).FirstOrDefault();
                tblPatients         patient      = _unitOfWork.PatientEntityRepo.Get(o => o.Prowid == patientId).FirstOrDefault();
                jsonPatient = objTrepo.GetPatientList(patient.FirstName, patient.LastName, patient.BirthDate, "");

                //MSDateOfServiceEntity dateOfService = msNote.GetMSDateOfService(patientId, NoteId, NoteType);
                //MSHints msHints = msNote.GetHints(patientId, NoteId, NoteType);
                //List<MSFunctionalCharEntity> MSFunctionalCharEntity = msNote.GetFunctChar( patientId,  NoteId,  NoteType);
                if (patientNotes != null)
                {
                    NoteType = patientNotes.NoteType;
                    if (NoteType == "PPOC")
                    {
                        NoteTypeDec = "Initial Eval";
                        CCDAGeneration.InitialEval _iniEval = new CCDAGeneration.InitialEval();
                        jResponse = _iniEval.ConvertInitialEval(patientId, NoteId, NoteType);
                    }
                    if (NoteType == "PPOC2")
                    {
                        NoteTypeDec = "Initial Eval2";
                        CCDAGeneration.InitialEval _iniEval = new CCDAGeneration.InitialEval();
                        jResponse = _iniEval.ConvertInitialEval(patientId, NoteId, NoteType);
                        //             jResponse =
                        //new JObject(
                        // new JProperty(NoteTypeDec + " note is under construction"
                        //    ));
                    }
                    if (NoteType == "PPOCRE")
                    {
                        NoteTypeDec = "Re-Eval";
                        CCDAGeneration.InitialEval _iniEval = new CCDAGeneration.InitialEval();
                        jResponse = _iniEval.ConvertInitialEval(patientId, NoteId, NoteType);
                    }
                    if (NoteType == "PTREAT")
                    {
                        NoteTypeDec = "Daily Note";

                        NoteTypeDec = "Medical Necessity";
                        CCDAGeneration.DailyNotes _dailyNotes = new CCDAGeneration.DailyNotes();
                        jResponse = _dailyNotes.ConvertDailyNote(patientId, NoteId, NoteType);
                        //             jResponse =
                        //new JObject(
                        // new JProperty(NoteTypeDec + "  is under construction"
                        //    ));
                    }
                    if (NoteType == "PMN")
                    {
                        NoteTypeDec = "Medical Necessity";
                        CCDAGeneration.MedicalNecessity _patientDemographics = new CCDAGeneration.MedicalNecessity();
                        jResponse = _patientDemographics.MedicalNecessityToCCDA(patientId, NoteId, NoteType);
                    }
                    if (NoteType == "PDIS")
                    {
                        NoteTypeDec = "Discharge";

                        jResponse =
                            new JObject(
                                new JProperty(NoteTypeDec + " note is under construction"
                                              ));
                    }
                    if (NoteType == "PCOMM")
                    {
                        NoteTypeDec = "Communication";
                        CCDAGeneration.Communication _comm = new CCDAGeneration.Communication();
                        jResponse = _comm.ConvertCommunication(patientId, NoteId, NoteType);
                    }
                    if (NoteType == "PMV")
                    {
                        NoteTypeDec = "Missed";
                        jResponse   =
                            new JObject(
                                new JProperty(NoteTypeDec + " note is under construction"
                                              ));
                    }
                    if (NoteType == "PFCE")
                    {
                        NoteTypeDec = "PFCE";
                        jResponse   =
                            new JObject(
                                new JProperty(NoteTypeDec + " note is under construction"
                                              ));
                    }
                }
                else
                {
                    jResponse =
                        new JObject(
                            new JProperty("No record found"
                                          ));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            jsonPatient.Add(jResponse);

            return(jsonPatient);
            // return jResponse;
        }
        /// <summary>
        /// Creates a product
        /// </summary>
        /// <param name="productEntity"></param>
        /// <returns></returns>
        public int CreateDTPatient(int incommingMsgID, string userID, string status, int attachmentID)
        {
            try
            {
                tblPatients patient        = new tblPatients();
                tblReferrer referrerRecord = new tblReferrer();
                tblRefAddr  referrerAddr   = new tblRefAddr();

                //  tbl_DT_Incoming_Message_Individual_Attachments tblAttachment = new tbl_DT_Incoming_Message_Individual_Attachments();
                tbl_DT_PatientReferral_Processed processedPatient = new tbl_DT_PatientReferral_Processed();
                var incomingMessagPprocessEntity = (from p in _unitOfWork.DT_Incoming_MessageRepo.Get()
                                                    join e in _unitOfWork.DT_Individial_AttachRepo.Get()
                                                    on p.ID equals e.InComingMessageID
                                                    where p.ID == incommingMsgID && e.ID == attachmentID
                                                    select new DT_IncomingMessagOperationEntity
                {
                    FileData = e.FileData,
                    EmailID = p.From
                }).ToList().FirstOrDefault();
                var DT_Referrer = (from p in _unitOfWork.DT_Referrer_EmailsRepo.Get()
                                   where p.DT_Email_Address == incomingMessagPprocessEntity.EmailID
                                   select p.Institute_ID).FirstOrDefault();

                string xmlString = incomingMessagPprocessEntity.FileData.ToString();

                //referrer = _unitOfWork.DT_Referrer_EmailsRepo.Get(o => o.Institute_ID == PatientWIP.Institute_ID).FirstOrDefault();

                using (StreamReader reader = new StreamReader(GenerateStreamFromString(xmlString), Encoding.Unicode))
                {
                    string oldstr  = "xmlns=\"urn:hl7-org:v3\"";
                    string oldstr1 = "xmlns:sdtc=\"urn:hl7-org:sdtc\"";

                    xmlString = xmlString.Replace(oldstr, "");
                    xmlString = xmlString.Replace(oldstr1, "");
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(xmlString);

                    var         nameNode          = xmlDoc.SelectNodes("ClinicalDocument/recordTarget/patientRole/patient/name");
                    var         DOBNode           = xmlDoc.SelectNodes("ClinicalDocument/recordTarget/patientRole/patient");
                    var         CityNode          = xmlDoc.SelectNodes("ClinicalDocument/recordTarget/patientRole/addr");
                    var         referrerNode      = xmlDoc.SelectNodes("ClinicalDocument/legalAuthenticator/assignedEntity/assignedPerson/name");
                    var         referrerAddrNode  = xmlDoc.SelectNodes("ClinicalDocument/legalAuthenticator/assignedEntity/addr");
                    var         referrerPhoneNode = xmlDoc.SelectNodes("ClinicalDocument/legalAuthenticator/assignedEntity/telecom");
                    XmlNodeList xnListtelecom     = xmlDoc.SelectNodes("/ClinicalDocument/recordTarget/patientRole/telecom");
                    ////ClinicalDocument//recordTarget//patientRole//patientRole//name
                    foreach (XmlNode subNode in nameNode)
                    {
                        patient.FirstName = subNode["given"].InnerText;
                        patient.LastName  = subNode["family"].InnerText;
                        patient.NickName  = patient.FirstName;
                    }
                    foreach (XmlNode subNode in referrerNode)
                    {
                        string given2 = string.Empty;
                        if (subNode["given"].NextSibling != null)
                        {
                            given2 = subNode["given"].NextSibling.InnerText.ToStringOrEmpty();
                        }
                        referrerRecord.FirstName   = subNode["given"].InnerText.ToStringOrEmpty() + " " + given2;
                        referrerRecord.LastName    = subNode["family"].InnerText.ToStringOrEmpty();
                        referrerRecord.PrintName   = subNode["family"].InnerText.ToStringOrEmpty() + ", " + subNode["given"].InnerText.ToStringOrEmpty() + " " + given2 + subNode["suffix"].InnerText.ToStringOrEmpty();
                        referrerRecord.Credentials = subNode["suffix"].InnerText.ToStringOrEmpty();
                    }
                    referrerRecord.ReferralType      = "DT";
                    referrerRecord.SendPOCBy         = "DT";
                    referrerRecord.createdby         = "DT-Load";
                    referrerRecord.createdts         = DateTime.Now;
                    referrerRecord.updatedby         = "DT-Load";
                    referrerRecord.updatedts         = DateTime.Now;
                    referrerRecord.NoFax             = false;
                    referrerRecord.ReferralInstitute = DT_Referrer;
                    referrerRecord.Title             = "Dr";
                    referrerRecord.NPINumber         = "";
                    referrerRecord.Email             = incomingMessagPprocessEntity.EmailID;
                    foreach (XmlNode subNode in DOBNode)
                    {
                        patient.BirthDate = subNode["birthTime"].Attributes["value"].Value;

                        DateTime dt;
                        if (DateTime.TryParseExact(patient.BirthDate.ToString(), "yyyyMMdd",
                                                   CultureInfo.InvariantCulture,
                                                   DateTimeStyles.None, out dt))
                        {
                            //Console.WriteLine(dt);
                            //  patient.BirthDate = dt.ToString();
                            patient.BirthDate = dt.ToShortDateString();
                        }


                        string gender = subNode["administrativeGenderCode"].Attributes["code"].Value;
                        if (gender.ToLower() == "f")
                        {
                            patient.Gender = "Female";
                        }
                        patient.Title = "Miss";
                        if (gender.ToLower() == "m")
                        {
                            patient.Gender = "Male";
                        }
                        patient.Title = "MR";
                    }
                    foreach (XmlNode subNode in CityNode)
                    {
                        patient.City     = subNode["city"].InnerText;
                        patient.State    = subNode["state"].InnerText;
                        patient.Address1 = subNode["streetAddressLine"].InnerText;
                        patient.ZipCode  = subNode["postalCode"].InnerText;
                    }
                    foreach (XmlNode subNode in referrerAddrNode)
                    {
                        referrerAddr.City          = subNode["city"].InnerText;
                        referrerAddr.State         = subNode["state"].InnerText;
                        referrerAddr.StreetAddress = subNode["streetAddressLine"].InnerText;
                        referrerAddr.ZipCode       = subNode["postalCode"].InnerText;
                        referrerAddr.startdt       = DateTime.Now;
                        referrerAddr.enddt         = DateTime.Now;
                        referrerAddr.createdby     = "DT-Load";
                        referrerAddr.createdts     = DateTime.Now;
                        referrerAddr.updatedby     = "DT-Load";
                        referrerAddr.updatedts     = DateTime.Now;
                    }
                    foreach (XmlNode xn in referrerPhoneNode)
                    {
                        if (xn.Attributes[0].Value == "WP")
                        {
                            var ph = xn.Attributes[1].Value.Replace("-", "").Replace("(", "").Replace(")", "");
                            referrerAddr.PhoneNo = ph.ToStringOrEmpty().Length > 0 ? ph.Substring(6) : "";
                        }
                    }
                    referrerAddr.FaxNo = "";

                    DateTime NowTime         = DateTime.Now;
                    int      M_Current_Day   = NowTime.Day;                           // Current Date with Day Display
                    int      M_Current_Month = Convert.ToInt32(DateTime.Today.Month); //Current Month as a Single Integer Display
                    int      CurrentYear     = DateTime.Today.Year;                   // Display Year as Integer

                    patient.ReferralDate = DateTime.Now.ToShortDateString();          //**what is referral date?

                    patient.updatedts = DateTime.Now.ToShortDateString().StringToDate();
                    patient.createdts = DateTime.Now.ToShortDateString().StringToDate();

                    //patient.ReferralDate = CurrentYear.ToString()+M_Current_Month.ToString()+M_Current_Day.ToString();  //need to find referral date.
                    // patient.ReferralSource = incomingMessagPprocessEntity.EmailID == null ? "noemail" : incomingMessagPprocessEntity.EmailID.Substring(0, 9);

                    // patient.HomePh = "000000000"; //need to find patient phone.

                    foreach (XmlNode xn in xnListtelecom)
                    {
                        if (xn.Attributes[0].Value == "HP")
                        {
                            patient.HomePh = xn.Attributes[1].Value.ToStringOrEmpty().Length > 0 ? xn.Attributes[1].Value.Substring(4) : "";
                        }
                        if (xn.Attributes[0].Value == "WP")
                        {
                            patient.WorkPh = xn.Attributes[1].Value.ToStringOrEmpty().Length > 0 ? xn.Attributes[1].Value.Substring(4) : "";
                        }
                        if (xn.Attributes[0].Value == "MC")
                        {
                            patient.CellPh = xn.Attributes[1].Value.ToStringOrEmpty().Length > 0 ? xn.Attributes[1].Value.Substring(4) : "";
                        }
                    }
                    //patient.ClinicNo = 7;
                    using (RehabEntities rehab = new RehabEntities())
                    {
                        var clinicnumber = (from inc in rehab.tbl_DT_ClinicUserMapping where inc.EmailId == incomingMessagPprocessEntity.EmailID.ToString() select inc.ClinicNo).FirstOrDefault();
                        if (clinicnumber == null)
                        {
                            patient.ClinicNo = Convert.ToInt16(clinicnumber);
                        }
                        else
                        {
                            patient.ClinicNo = 0;
                        }
                    }
                }


                using (var scopeCreate = new TransactionScope())
                {
                    _unitOfWork.ReferrerRepo.Insert(referrerRecord);
                    _unitOfWork.Save();

                    referrerAddr.Rrowid = referrerRecord.Rrowid;
                    _unitOfWork.RefAddrRepo.Insert(referrerAddr);
                    _unitOfWork.Save();



                    patient.ReferralSource = referrerRecord.Rrowid.ToStringOrEmpty();
                    _unitOfWork.PatientEntityRepo.Insert(patient);
                    _unitOfWork.Save();

                    ImportPatient(patient.Prowid, incommingMsgID, userID, status, attachmentID);

                    scopeCreate.Complete();
                    return(patient.Prowid);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 24
0
 public AppUsersRepository()
 {
     this._unitOfWork = new UnitOfWork();
     _ctx             = new RehabEntities();
 }
Ejemplo n.º 25
0
 public ProcedureManagement()
 {
     _context = new RehabEntities();
 }