//public static string GetFull ///<summary>Only documents listed in the corresponding rows of the statement table are uploaded</summary> public static List <long> GetChangedSinceDocumentNums(DateTime changedSince, List <long> statementNumList) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), changedSince, statementNumList)); } string strStatementNums = ""; DataTable table; if (statementNumList.Count > 0) { for (int i = 0; i < statementNumList.Count; i++) { if (i > 0) { strStatementNums += "OR "; } strStatementNums += "StatementNum='" + statementNumList[i].ToString() + "' "; } string command = "SELECT DocNum FROM document WHERE DateTStamp > " + POut.DateT(changedSince) + " AND DocNum IN ( SELECT DocNum FROM statement WHERE " + strStatementNums + ")"; table = Db.GetTable(command); } else { table = new DataTable(); } List <long> documentnums = new List <long>(table.Rows.Count); for (int i = 0; i < table.Rows.Count; i++) { documentnums.Add(PIn.Long(table.Rows[i]["DocNum"].ToString())); } return(documentnums); }
///<summary>Returns the average number of minutes behind rounded down for each half hour from 5:00 AM - 7:00 PM.</summary> public static int[] AverageMinutesBehind(DateTime date) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <int[]>(MethodBase.GetCurrentMethod(), date)); } DateTime startTime = new DateTime(date.Year, date.Month, date.Day, 5, 0, 0); DateTime endTime = new DateTime(date.Year, date.Month, date.Day, 19, 0, 0); if (date.DayOfWeek == DayOfWeek.Saturday) { startTime = new DateTime(date.Year, date.Month, date.Day, 7, 0, 0); endTime = new DateTime(date.Year, date.Month, date.Day, 16, 0, 0); } else if (date.DayOfWeek == DayOfWeek.Sunday) { startTime = new DateTime(date.Year, date.Month, date.Day, 7, 0, 0); endTime = new DateTime(date.Year, date.Month, date.Day, 12, 0, 0); } string command = "SELECT * FROM phonemetric WHERE DateTimeEntry BETWEEN " + POut.DateT(startTime) + " AND " + POut.DateT(endTime); List <PhoneMetric> listPhoneMetrics = Crud.PhoneMetricCrud.SelectMany(command); int[] avgMinBehind = new int[28]; //Used in FormGraphEmployeeTime. One "bucket" every half hour. int numerator; int denominator; startTime = new DateTime(date.Year, date.Month, date.Day, 5, 0, 0); endTime = new DateTime(date.Year, date.Month, date.Day, 5, 30, 0); for (int i = 0; i < 28; i++) { numerator = 0; denominator = 0; //reuse startTime and endTime for 30 minute intervals for (int j = 0; j < listPhoneMetrics.Count; j++) { if (startTime < listPhoneMetrics[j].DateTimeEntry && listPhoneMetrics[j].DateTimeEntry < endTime) //startTime < time < endTime { numerator += listPhoneMetrics[j].MinutesBehind; denominator++; } } if (denominator > 0) { avgMinBehind[i] = numerator / denominator; //denominator should usually be 30. Result will be rounded down due to integer math. } else { avgMinBehind[i] = 0; } startTime = startTime.AddMinutes(30); endTime = endTime.AddMinutes(30); } return(avgMinBehind); }
///<summary>Gets all AptNums for HistAppointments that have a DateTStamp after dateTimeSince.</summary> public static List <long> GetAptNumsChangedSince(DateTime dateTimeSince) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), dateTimeSince)); } string command = "SELECT AptNum FROM histappointment WHERE DateTStamp > " + POut.DateT(dateTimeSince); return(Db.GetListLong(command)); }
///<summary>Fetches StatementNums restricted by the DateTStamp, PatNums and a limit of records per patient. If limitPerPatient is zero all StatementNums of a patient are fetched</summary> public static List <long> GetChangedSinceStatementNums(DateTime changedSince, List <long> eligibleForUploadPatNumList, int limitPerPatient) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), changedSince, eligibleForUploadPatNumList, limitPerPatient)); } List <long> statementnums = new List <long>(); string limitStr = ""; if (limitPerPatient > 0) { limitStr = "LIMIT " + limitPerPatient; } DataTable table; // there are possibly more efficient ways to implement this using a single sql statement but readability of the sql can be compromised if (eligibleForUploadPatNumList.Count > 0) { for (int i = 0; i < eligibleForUploadPatNumList.Count; i++) { string command = "SELECT StatementNum FROM statement WHERE DateTStamp > " + POut.DateT(changedSince) + " AND PatNum='" + eligibleForUploadPatNumList[i].ToString() + "' ORDER BY DateSent DESC, StatementNum DESC " + limitStr; table = Db.GetTable(command); for (int j = 0; j < table.Rows.Count; j++) { statementnums.Add(PIn.Long(table.Rows[j]["StatementNum"].ToString())); } } } return(statementnums); }
///<summary>Gets the XWeb transactions for approved transactions. To get for all clinics, pass in a list of empty clinicNums.</summary> public static DataTable GetApprovedTransactions(List <long> listClinicNums, DateTime dateFrom, DateTime dateTo) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetTable(MethodBase.GetCurrentMethod(), listClinicNums, dateFrom, dateTo)); } string command = "SELECT " + DbHelper.Concat("patient.LName", "', '", "patient.FName") + " Patient,xwebresponse.DateTUpdate,xwebresponse.TransactionID," + "xwebresponse.MaskedAcctNum,xwebresponse.ExpDate,xwebresponse.Amount,xwebresponse.PaymentNum,xwebresponse.TransactionStatus," + "(CASE WHEN payment.PayNum IS NULL THEN 0 ELSE 1 END) doesPaymentExist,COALESCE(clinic.Abbr,'Unassigned') Clinic,xwebresponse.PatNum, " + "xwebresponse.XWebResponseNum,xwebresponse.Alias " + "FROM xwebresponse " + "INNER JOIN patient ON patient.PatNum=xwebresponse.PatNum " + "LEFT JOIN payment ON payment.PayNum=xwebresponse.PaymentNum " + "LEFT JOIN clinic ON clinic.ClinicNum=xwebresponse.ClinicNum " + "WHERE xwebresponse.TransactionStatus IN(" + POut.Int((int)XWebTransactionStatus.DtgPaymentApproved) + "," + POut.Int((int)XWebTransactionStatus.HpfCompletePaymentApproved) + "," + POut.Int((int)XWebTransactionStatus.HpfCompletePaymentApprovedPartial) + "," + POut.Int((int)XWebTransactionStatus.DtgPaymentReturned) + "," + POut.Int((int)XWebTransactionStatus.DtgPaymentVoided) + ") " + "AND xwebresponse.ResponseCode IN(" + POut.Int((int)XWebResponseCodes.Approval) + "," + POut.Int((int)XWebResponseCodes.PartialApproval) + ") " + "AND xwebresponse.DateTUpdate BETWEEN " + POut.DateT(dateFrom) + " AND " + POut.DateT(dateTo.AddDays(1)) + " "; if (listClinicNums.Count > 0) { command += "AND xwebresponse.ClinicNum IN (" + string.Join(",", listClinicNums.Select(x => POut.Long(x))) + ") "; } command += "ORDER BY xwebresponse.DateTUpdate,patient.LName,patient.FName "; return(Db.GetTable(command)); }
///<summary>Deletes all sigmessages older than 2 days. Will fail silently if anything goes wrong.</summary> public static void ClearOldSigMessages() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod()); return; } try { //Get all ack'd messages older than two days. string command = ""; DataTable table; if (DataConnection.DBtype == DatabaseType.MySql) //easier to read that using the DbHelper Functions { command = "SELECT SigMessageNum FROM sigmessage WHERE AckDateTime > " + POut.DateT(new DateTime(1880, 1, 1)) + " " + "AND AckDateTime < DATE_ADD(NOW(),INTERVAL -2 DAY)"; table = Db.GetTable(command); } else //oracle { command = "SELECT SigMessageNum FROM sigmessage WHERE AckDateTime > " + POut.DateT(new DateTime(1880, 1, 1)) + " " + "AND AckDateTime < CURRENT_TIMESTAMP -2"; table = Db.GetTable(command); } if (table.Rows.Count < 1) { return; //Nothing to delete. } //Delete all of the acks. command = "DELETE FROM sigmessage " + "WHERE SigMessageNum IN (" + String.Join(",", table.Select().Select(x => PIn.Long(x["SigMessageNum"].ToString()))) + ")"; Db.NonQ(command); } catch (Exception) { //fail silently } }
///<summary>Surround with try/catch, because it will throw an exception if any appointment is using this def.</summary> public static void Delete(ApptFieldDef apptFieldDef) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), apptFieldDef); return; } string command = "SELECT LName,FName,AptDateTime " + "FROM patient,apptfield,appointment WHERE " + "patient.PatNum=appointment.PatNum " + "AND appointment.AptNum=apptfield.AptNum " + "AND FieldName='" + POut.String(apptFieldDef.FieldName) + "'"; DataTable table = Db.GetTable(command); DateTime aptDateTime; if (table.Rows.Count > 0) { string s = Lans.g("FormApptFieldDefEdit", "Not allowed to delete. Already in use by ") + table.Rows.Count.ToString() + " " + Lans.g("FormApptFieldDefEdit", "appointments, including") + " \r\n"; for (int i = 0; i < table.Rows.Count; i++) { if (i > 5) { break; } aptDateTime = PIn.DateT(table.Rows[i]["AptDateTime"].ToString()); s += table.Rows[i]["LName"].ToString() + ", " + table.Rows[i]["FName"].ToString() + POut.DateT(aptDateTime, false) + "\r\n"; } throw new ApplicationException(s); } command = "DELETE FROM apptfielddef WHERE ApptFieldDefNum =" + POut.Long(apptFieldDef.ApptFieldDefNum); Db.NonQ(command); }
///<summary>Returns the latest ErxLog entry for the specified patient and before the specified dateTimeMax. Can return null. ///Called from Chart when fetching prescriptions from NewCrop to determine the provider on incoming prescriptions.</summary> public static ErxLog GetLatestForPat(long patNum, DateTime dateTimeMax) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <ErxLog>(MethodBase.GetCurrentMethod(), patNum, dateTimeMax)); } string command = DbHelper.LimitOrderBy("SELECT * FROM erxlog WHERE PatNum=" + POut.Long(patNum) + " AND DateTStamp<" + POut.DateT(dateTimeMax) + " ORDER BY DateTStamp DESC", 1); List <ErxLog> listErxLog = Crud.ErxLogCrud.SelectMany(command); if (listErxLog.Count == 0) { return(null); } return(listErxLog[0]); }
///<summary>Sets IsProcessed to true on eService signals of Error severity that are within 15 minutes of the passed in DateTime.</summary> public static void ProcessErrorSignalsAroundTime(DateTime dateTime) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), dateTime); return; } if (dateTime.Year < 1880) { return; //Nothing to do. } string command = "UPDATE eservicesignal SET IsProcessed=1 " + "WHERE Severity=" + POut.Int((int)eServiceSignalSeverity.Error) + " " + "AND SigDateTime BETWEEN " + POut.DateT(dateTime.AddMinutes(-15)) + " AND " + POut.DateT(dateTime.AddMinutes(15)); Db.NonQ(command); }
///<summary>Etrans type will be figured out by this class. Either TextReport, Acknowledge_997, or StatusNotify_277.</summary> public static void ProcessIncomingReport(DateTime dateTimeTrans, long clearinghouseNum, string messageText) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), dateTimeTrans, clearinghouseNum, messageText); return; } Etrans etrans = new Etrans(); etrans.DateTimeTrans = dateTimeTrans; etrans.ClearingHouseNum = clearinghouseNum; EtransMessageText etransMessageText = new EtransMessageText(); etransMessageText.MessageText = messageText; EtransMessageTexts.Insert(etransMessageText); etrans.EtransMessageTextNum = etransMessageText.EtransMessageTextNum; string command; if (X12object.IsX12(messageText)) { X12object Xobj = new X12object(messageText); if (Xobj.Is997()) { X997 x997 = new X997(messageText); etrans.Etype = EtransType.Acknowledge_997; etrans.BatchNumber = x997.GetBatchNumber(); Etranss.Insert(etrans); string batchack = x997.GetBatchAckCode(); if (batchack == "A" || batchack == "R") //accepted or rejected { command = "UPDATE etrans SET AckCode='" + batchack + "', " + "AckEtransNum=" + POut.Long(etrans.EtransNum) + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber) + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum) + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14)) + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1)) + " AND AckEtransNum=0"; Db.NonQ(command); } else //partially accepted { List <int> transNums = x997.GetTransNums(); string ack; for (int i = 0; i < transNums.Count; i++) { ack = x997.GetAckForTrans(transNums[i]); if (ack == "A" || ack == "R") //accepted or rejected { command = "UPDATE etrans SET AckCode='" + ack + "', " + "AckEtransNum=" + POut.Long(etrans.EtransNum) + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber) + " AND TransSetNum=" + POut.Long(transNums[i]) + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum) + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14)) + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1)) + " AND AckEtransNum=0"; Db.NonQ(command); } } } //none of the other fields make sense, because this ack could refer to many claims. } else if (X277U.Is277U(Xobj)) { etrans.Etype = EtransType.StatusNotify_277; //later: analyze to figure out which e-claim is being referenced. Etranss.Insert(etrans); } else //unknown type of X12 report. { etrans.Etype = EtransType.TextReport; Etranss.Insert(etrans); } } else //not X12 { etrans.Etype = EtransType.TextReport; Etranss.Insert(etrans); } }
///<summary>Gets one XChargeTransaction from the db that matches the given fields.</summary> public static XChargeTransaction GetOneMatch(string batchNum, string itemNum, long patNum, DateTime transactionDateT, string transType) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <XChargeTransaction>(MethodBase.GetCurrentMethod(), batchNum, itemNum, patNum, transactionDateT, transType)); } string command = "SELECT * FROM xchargetransaction WHERE BatchNum = '" + POut.String(batchNum) + "' AND ItemNum = '" + POut.String(itemNum) + "' " + "AND PatNum=" + POut.Long(patNum) + " AND TransType='" + POut.String(transType) + "' " //We include transactions that are the same minute because we used to not store the seconds portion. + "AND TransactionDateTime BETWEEN " + POut.DateT(transactionDateT.ToBeginningOfMinute()) + " AND " + POut.DateT(transactionDateT.ToEndOfMinute()); return(Crud.XChargeTransactionCrud.SelectOne(command)); }
///<summary>Returns a comparison clause that is capable of using the index on colName.</summary> public static string DateTConditionColumn(string colName, ConditionOperator compareType, DateTime dateTime) { //Oracle compatible. switch (compareType) { case ConditionOperator.Equals: return(colName + " BETWEEN " + POut.DateT(dateTime.Date) + " AND " + POut.DateT(dateTime.Date.AddDays(1).AddSeconds(-1))); case ConditionOperator.NotEquals: return(colName + " NOT BETWEEN " + POut.DateT(dateTime.Date) + " AND " + POut.DateT(dateTime.Date.AddDays(1).AddSeconds(-1))); case ConditionOperator.GreaterThan: return(colName + ">=" + POut.DateT(dateTime.Date.AddDays(1))); case ConditionOperator.LessThan: return(colName + " < " + POut.DateT(dateTime.Date)); case ConditionOperator.GreaterThanOrEqual: return(colName + ">=" + POut.DateT(dateTime.Date)); case ConditionOperator.LessThanOrEqual: return(colName + "<=" + POut.DateT(dateTime.Date.AddDays(1).AddSeconds(-1))); default: throw new NotImplementedException(compareType + " not implemented yet."); } }
///<summary>Gets the list of patients that need to be on the reactivation list based on the passed in filters.</summary> public static DataTable GetReactivationList(DateTime dateSince, DateTime dateStop, bool groupFamilies, bool showDoNotContact, bool isInactiveIncluded , long provNum, long clinicNum, long siteNum, long billingType, ReactivationListSort sortBy, RecallListShowNumberReminders showReactivations) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateSince, dateStop, groupFamilies, showDoNotContact, isInactiveIncluded, provNum, clinicNum , siteNum, billingType, sortBy, showReactivations)); } //Get information we will need to do the query List <long> listReactCommLogTypeDefNums = Defs.GetDefsForCategory(DefCat.CommLogTypes, isShort: true) .FindAll(x => CommItemTypeAuto.REACT.GetDescription(useShortVersionIfAvailable: true).Equals(x.ItemValue)).Select(x => x.DefNum).ToList(); int contactInterval = PrefC.GetInt(PrefName.ReactivationContactInterval); List <PatientStatus> listPatStatuses = new List <PatientStatus>() { PatientStatus.Patient, PatientStatus.Prospective }; if (isInactiveIncluded) { listPatStatuses.Add(PatientStatus.Inactive); } string strPatStatuses = string.Join(",", listPatStatuses.Select(x => POut.Int((int)x))); //Get the raw set of patients who should be on the reactivation list string cmd = $@"SELECT pat.PatNum, pat.LName, pat.FName, pat.MiddleI, pat.Preferred, pat.Guarantor, pat.PatStatus, pat.Birthdate, pat.PriProv, COALESCE(billingtype.ItemName,'') AS BillingType, pat.ClinicNum, pat.SiteNum, pat.PreferRecallMethod, '' AS ContactMethod, pat.HmPhone, pat.WirelessPhone, pat.WkPhone, {(groupFamilies?"COALESCE(guarantor.Email,pat.Email,'') AS Email,":"pat.Email,")} MAX(proc.ProcDate) AS DateLastProc, COALESCE(comm.DateLastContacted,'') AS DateLastContacted, COALESCE(comm.ContactedCount,0) AS ContactedCount, COALESCE(react.ReactivationNum,0) AS ReactivationNum, COALESCE(react.ReactivationStatus,0) AS ReactivationStatus, COALESCE(react.DoNotContact,0) as DoNotContact, react.ReactivationNote, guarantor.PatNum as GuarNum, guarantor.LName as GuarLName, guarantor.FName as GuarFName FROM patient pat INNER JOIN procedurelog proc ON pat.PatNum=proc.PatNum AND proc.ProcStatus={POut.Int((int)ProcStat.C)} LEFT JOIN appointment appt ON pat.PatNum=appt.PatNum AND appt.AptDateTime >= {DbHelper.Curdate()} LEFT JOIN ( SELECT commlog.PatNum, MAX(commlog.CommDateTime) AS DateLastContacted, COUNT(*) AS ContactedCount FROM commlog WHERE commlog.CommType IN ({string.Join(",",listReactCommLogTypeDefNums)}) GROUP BY commlog.PatNum ) comm ON pat.PatNum=comm.PatNum LEFT JOIN reactivation react ON pat.PatNum=react.PatNum LEFT JOIN definition billingtype ON pat.BillingType=billingtype.DefNum INNER JOIN patient guarantor ON pat.Guarantor=guarantor.PatNum WHERE pat.PatStatus IN ({strPatStatuses}) " ; cmd += provNum > 0?" AND pat.PriProv=" + POut.Long(provNum):""; cmd += clinicNum > -1?" AND pat.ClinicNum=" + POut.Long(clinicNum):""; //might still want to get the 0 clinic pats cmd += siteNum > 0?" AND pat.SiteNum=" + POut.Long(siteNum):""; cmd += billingType > 0?" AND pat.BillingType=" + POut.Long(billingType):""; cmd += showDoNotContact?"":" AND (react.DoNotContact IS NULL OR react.DoNotContact=0)"; cmd += contactInterval > -1?" AND (comm.DateLastContacted IS NULL OR comm.DateLastContacted <= " + POut.DateT(DateTime.Today.AddDays(-contactInterval)) + ") ":""; //set number of contact attempts int maxReminds = PrefC.GetInt(PrefName.ReactivationCountContactMax); if (showReactivations == RecallListShowNumberReminders.SixPlus) { cmd += " AND ContactedCount>=6 "; //don't need to look at pref this only shows in UI if the prefvalue allows it } else if (showReactivations == RecallListShowNumberReminders.Zero) { cmd += " AND (comm.ContactedCount=0 OR comm.ContactedCount IS NULL) "; } else if (showReactivations != RecallListShowNumberReminders.All) { int filter = (int)showReactivations - 1; //if the contactmax pref is not -1 or 0, and the contactmax is smaller than the requested filter, replace the filter with the contactmax cmd += " AND comm.ContactedCount=" + POut.Int((maxReminds > 0 && maxReminds < filter)?maxReminds:filter) + " "; } else if (showReactivations == RecallListShowNumberReminders.All) //get all but filter on the contactmax { cmd += " AND (comm.ContactedCount < " + POut.Int(maxReminds) + " OR comm.ContactedCount IS NULL) "; } cmd += $@" GROUP BY pat.PatNum HAVING MAX(proc.ProcDate) < {POut.Date(dateSince)} AND MAX(proc.ProcDate) >= {POut.Date(dateStop)} AND MIN(appt.AptDateTime) IS NULL " ; //set the sort by switch (sortBy) { case ReactivationListSort.Alphabetical: cmd += " ORDER BY " + (groupFamilies?"guarantor.LName,guarantor.FName,pat.FName":"pat.LName,pat.FName"); break; case ReactivationListSort.BillingType: cmd += " ORDER BY billingtype.ItemName,DateLastContacted" + (groupFamilies?",guarantor.LName,guarantor.FName":""); break; case ReactivationListSort.LastContacted: cmd += " ORDER BY IF(comm.DateLastContacted='' OR comm.DateLastContacted IS NULL,1,0),comm.DateLastContacted" + (groupFamilies?",guarantor.LName,guarantor.FName":""); break; case ReactivationListSort.LastSeen: cmd += " ORDER BY MAX(proc.ProcDate)"; break; } DataTable dtReturn = Db.GetTable(cmd); foreach (DataRow row in dtReturn.Rows) { //FOR REVIEW: currently, we are displaying PreferRecallMethod, which is what RecallList also does. Just want to make sure we don't want to use PreferContactMethod row["ContactMethod"] = Recalls.GetContactFromMethod(PIn.Enum <ContactMethod>(row["PreferRecallMethod"].ToString()), groupFamilies , row["HmPhone"].ToString(), row["WkPhone"].ToString(), row["WirelessPhone"].ToString(), row["Email"].ToString() //guarEmail queried as Email , row["Email"].ToString()); //Pat.Email is also "Email" } return(dtReturn); }
public static List <long> GetChangedSinceLabPanelNums(DateTime changedSince, List <long> eligibleForUploadPatNumList) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), changedSince, eligibleForUploadPatNumList)); } string strEligibleForUploadPatNums = ""; DataTable table; if (eligibleForUploadPatNumList.Count > 0) { for (int i = 0; i < eligibleForUploadPatNumList.Count; i++) { if (i > 0) { strEligibleForUploadPatNums += "OR "; } strEligibleForUploadPatNums += "PatNum='" + eligibleForUploadPatNumList[i].ToString() + "' "; } string command = "SELECT LabPanelNum FROM labpanel WHERE DateTStamp > " + POut.DateT(changedSince) + " AND (" + strEligibleForUploadPatNums + ")"; table = Db.GetTable(command); } else { table = new DataTable(); } List <long> labPanelnums = new List <long>(table.Rows.Count); for (int i = 0; i < table.Rows.Count; i++) { labPanelnums.Add(PIn.Long(table.Rows[i]["LabPanelNum"].ToString())); } return(labPanelnums); }
///<summary>this code is similar to code in the phone tracking server. But here, we frequently only change clockStatus and ColorBar by setting employeeNum=-1. If employeeNum is not -1, then EmployeeName also gets set. If employeeNum==0, then clears employee from that row.</summary> public static void SetPhoneStatus(ClockStatusEnum clockStatus, int extens, long employeeNum = -1) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), clockStatus, extens, employeeNum); return; } string command = @"SELECT phoneempdefault.EmployeeNum,phoneempdefault.IsTriageOperator,Description,phoneempdefault.EmpName,HasColor,phone.ClockStatus " + "FROM phone " + "LEFT JOIN phoneempdefault ON phone.Extension=phoneempdefault.PhoneExt " + "WHERE phone.Extension=" + POut.Long(extens); DataTable tablePhone = Db.GetTable(command); if (tablePhone.Rows.Count == 0) { //It would be nice if we could create a phone row for this extension. return; } long empNum = PIn.Long(tablePhone.Rows[0]["EmployeeNum"].ToString()); bool isTriageOperator = PIn.Bool(tablePhone.Rows[0]["IsTriageOperator"].ToString()); string empName = PIn.String(tablePhone.Rows[0]["EmpName"].ToString()); string clockStatusDb = PIn.String(tablePhone.Rows[0]["ClockStatus"].ToString()); Employee emp = Employees.GetEmp(employeeNum); if (emp != null) //A new employee is going to take over this extension. { empName = emp.FName; empNum = emp.EmployeeNum; } else if (employeeNum == 0) //Clear the employee from that row. { empName = ""; empNum = 0; } //if these values are null because of missing phoneempdefault row, they will default to false //PhoneEmpStatusOverride statusOverride=(PhoneEmpStatusOverride)PIn.Int(tablePhone.Rows[0]["StatusOverride"].ToString()); bool hasColor = PIn.Bool(tablePhone.Rows[0]["HasColor"].ToString()); #region DateTimeStart //When a user shows up as a color on the phone panel, we want a timer to be constantly going to show how long they've been off the phone. string dateTimeStart = ""; //It's possible that a new user has never clocked in before, therefore their clockStatus will be empty. Simply set it to the status that they are trying to go to. if (clockStatusDb == "") { clockStatusDb = clockStatus.ToString(); } if (clockStatus == ClockStatusEnum.Break || clockStatus == ClockStatusEnum.Lunch) { //The user is going on Lunch or Break. Start the DateTimeStart counter so we know how long they have been gone. dateTimeStart = "DateTimeStart=NOW(), "; } else if (clockStatus == ClockStatusEnum.Home) { //User is going Home. Always clear the DateTimeStart column no matter what. dateTimeStart = "DateTimeStart='0001-01-01', "; } else //User shows as a color on big phones and is not going to a status of Home, Lunch, or Break. Example: Available, Training etc. //Get the current clock status from the database. { ClockStatusEnum clockStatusCur = (ClockStatusEnum)Enum.Parse(typeof(ClockStatusEnum), clockStatusDb); //Start the clock if the user is going from a break status to any other non-break status. if (clockStatusCur == ClockStatusEnum.Home || clockStatusCur == ClockStatusEnum.Lunch || clockStatusCur == ClockStatusEnum.Break) { //The user is clocking in from home, lunch, or break. Start the timer up. if (hasColor) //Only start up the timer when someone with color clocks in. { dateTimeStart = "DateTimeStart=NOW(), "; } else //Someone with no color then reset the timer. They are back from break, that's all we need to know. { dateTimeStart = "DateTimeStart='0001-01-01', "; } } } string dateTimeNeedsHelpStart; if (clockStatus == ClockStatusEnum.NeedsHelp) { dateTimeNeedsHelpStart = "DateTimeNeedsHelpStart=NOW(), "; } else { dateTimeNeedsHelpStart = "DateTimeNeedsHelpStart=" + POut.DateT(DateTime.MinValue) + ", "; } #endregion //Update the phone row to reflect the new clock status of the user. string clockStatusNew = clockStatus.ToString(); if (clockStatus == ClockStatusEnum.None) { clockStatusNew = ""; } if (clockStatus == ClockStatusEnum.HelpOnTheWay && clockStatusDb == ClockStatusEnum.HelpOnTheWay.ToString()) //If HelpOnTheWay already { clockStatusNew = ClockStatusEnum.Available.ToString(); } command = "UPDATE phone SET ClockStatus='" + POut.String(clockStatusNew) + "', " + dateTimeStart + dateTimeNeedsHelpStart //+"ColorBar=-1, " //ColorBar is now determined at runtime by OD using Phones.GetPhoneColor. + "EmployeeNum=" + POut.Long(empNum) + ", " + "EmployeeName='" + POut.String(empName) + "' " + "WHERE Extension=" + extens; Db.NonQ(command); //Zero out any duplicate phone table rows for this employee. //This is possible if a user logged off and another employee logs into their computer. This would cause duplicate entries in the big phones window. UpdatePhoneToEmpty(employeeNum, extens); }
public static List <long> GetChangedSincePharmacyNums(DateTime changedSince) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), changedSince)); } string command = "SELECT PharmacyNum FROM pharmacy WHERE DateTStamp > " + POut.DateT(changedSince); DataTable dt = Db.GetTable(command); List <long> provnums = new List <long>(dt.Rows.Count); for (int i = 0; i < dt.Rows.Count; i++) { provnums.Add(PIn.Long(dt.Rows[i]["PharmacyNum"].ToString())); } return(provnums); }
///<summary>Keeps MobileAppDevice table current so we know which patient is on which device and for how long.</summary> public static void SetPatNum(long mobileAppDeviceNum, long patNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), mobileAppDeviceNum, patNum); return; } string command = "UPDATE mobileappdevice SET PatNum=" + POut.Long(patNum) + ",LastCheckInActivity=" + POut.DateT(DateTime.Now) + " WHERE MobileAppDeviceNum=" + POut.Long(mobileAppDeviceNum); Db.NonQ(command); Signalods.SetInvalid(InvalidType.EClipboard); }