public List <PatientEntity> GetPatientsbyNPINumber(string NPINumber) { List <tblPatients> patients = new List <tblPatients>(); List <PatientEntity> patientsEntity = new List <PatientEntity>(); tblReferrer referrer = _unitOfWork.ReferrerRepo.Get(o => o.NPINumber == NPINumber).FirstOrDefault(); if (referrer != null) { string ReferralSource = Convert.ToString(referrer.Rrowid); patients = _unitOfWork.PatientEntityRepo.Get(o => o.ReferralSource.Equals(ReferralSource)).ToList(); } //===============Mapper=========================================== var config = new MapperConfiguration(cfg => { cfg.CreateMap <tblPatients, PatientEntity>(); }); IMapper mapper = config.CreateMapper(); patientsEntity = mapper.Map <List <tblPatients>, List <PatientEntity> >(patients); //===============mapper end========================================== return(patientsEntity); //Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities(); //List<PatientEntity> patients = new List<PatientEntity>(); //patients = (from patient in rehab.tblPatients.Where(a => a.ReferralSource == ReferralSource) // select new PatientEntity // { // Prowid= patient.Prowid // }).ToList(); }
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); }
/// <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; } }
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; } }