public Object ToObject(Type objectType) { ConstructorInfo constructor = objectType.GetConstructor(System.Type.EmptyTypes); Object obj = constructor.Invoke(null); FieldInfo[] fieldInfo = objectType.GetFields(); for (int f = 0; f < fieldInfo.Length; f++) { if (fieldInfo[f].FieldType == typeof(int)) { fieldInfo[f].SetValue(obj, PIn.Long(this[f])); } else if (fieldInfo[f].FieldType == typeof(bool)) { fieldInfo[f].SetValue(obj, PIn.Bool(this[f])); } else if (fieldInfo[f].FieldType == typeof(string)) { fieldInfo[f].SetValue(obj, PIn.String(this[f])); } else if (fieldInfo[f].FieldType.IsEnum) { object val = ((object[])Enum.GetValues(fieldInfo[f].FieldType))[PIn.Long(this[f])]; fieldInfo[f].SetValue(obj, val); } else { throw new System.NotImplementedException(); } } return(obj); }
protected override List <Operatory> TableToList(DataTable table) { List <Operatory> listOps = Crud.OperatoryCrud.TableToList(table); //The IsInHQView flag is not important enough to cause filling the cache to fail. ODException.SwallowAnyException(() => { for (int i = 0; i < table.Rows.Count; i++) { listOps[i].IsInHQView = PIn.Bool(table.Rows[i]["IsInHQView"].ToString()); } }); //WSNPA operatory defs are important enough that we want this portion to fail if it has problems. //Create a dictionary comprised of Key: OperatoryNum and value: List of definition DefNums. Dictionary <long, List <long> > dictWSNPAOperatoryDefNums = DefLinks.GetDefLinksByType(DefLinkType.Operatory) .GroupBy(x => x.FKey)//FKey for DefLinkType.Operatory is OperatoryNum .ToDictionary(x => x.Key, x => x.Select(y => y.DefNum).ToList()); foreach (long operatoryNum in dictWSNPAOperatoryDefNums.Keys) { Operatory op = listOps.FirstOrDefault(x => x.OperatoryNum == operatoryNum); if (op != null) { op.ListWSNPAOperatoryDefNums = dictWSNPAOperatoryDefNums[operatoryNum]; } } return(listOps); }
///<summary>Gets a pref of type bool without using the cache.</summary> public static bool GetBoolNoCache(PrefName prefName) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { return Meth.GetBool(MethodBase.GetCurrentMethod(),prefName); } string command="SELECT ValueString FROM preference WHERE PrefName = '"+POut.String(prefName.ToString())+"'"; return PIn.Bool(Db.GetScalar(command)); }
///<summary>This is needed because of the extra column that is not part of the database.</summary> private static List <Task> TableToList(DataTable table) { //No need to check RemotingRole; no call to db. List <Task> retVal = Crud.TaskCrud.TableToList(table); for (int i = 0; i < retVal.Count; i++) { if (table.Columns.Contains("IsUnread")) { retVal[i].IsUnread = PIn.Bool(table.Rows[i]["IsUnread"].ToString()); //1 or more will result in true. } if (table.Columns.Contains("ParentDesc")) { retVal[i].ParentDesc = PIn.String(table.Rows[i]["ParentDesc"].ToString()); } if (table.Columns.Contains("LName") && table.Columns.Contains("FName") && table.Columns.Contains("Preferred") ) { string lname = PIn.String(table.Rows[i]["LName"].ToString()); string fname = PIn.String(table.Rows[i]["FName"].ToString()); string preferred = PIn.String(table.Rows[i]["Preferred"].ToString()); retVal[i].PatientName = Patients.GetNameLF(lname, fname, preferred, ""); } } return(retVal); }
///<summary>True if we are in HQ, AvaTax is enabled, we tax the customer's state, and the procedure has a taxable proccode. Note that if the ///customer has an invalid zip but all other conditions are met, we will still return true because this procedure is still taxable by our rules ///we just know we would get an error back from Avalara. This method returning false will result in the procedure being created as before ///but without tax, so we need to return true for an invalid zip and let Avalara produce the error. Can execute two queries.</summary> public static bool DoSendProcToAvalara(Procedure proc, bool isSilent = false) { ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum); if (!IsEnabled()) { return(false); } if (proc.ProcFee == 0) //repeat charges for prepay use ProcFee=0 { return(false); } Patient patient = Patients.GetPat(proc.PatNum); //don't call IsTaxable() here, because that would get pat twice, so duplicating some if its functionality: if (patient == null) { return(false); } if (ListTaxableStates.Count == 0) { return(false); //no taxable states } if (!HasTaxableState(patient)) //if this patient is not in a taxable state { return(false); } if (TaxExemptPatField == null) //no tax exempt pat field entered in setup { return(false); } PatField taxExempt = PatFields.Refresh(patient.PatNum).FirstOrDefault(x => x.FieldName == TaxExemptPatField.FieldName); if (taxExempt != null && PIn.Bool(taxExempt.FieldValue)) //patient field exists and is true { return(false); //so not taxable } //end of the duplicated functionality from IsTaxable(). string procTaxCode = GetTaxOverrideIfNeeded(patient, procCode); //could be an avalara code, an override, or a percent if (string.IsNullOrWhiteSpace(procTaxCode)) //if there is no avalara code or percent for this proc/state { return(false); } if (!Patients.HasValidUSZipCode(patient)) { if (isSilent) { _logger.WriteLine($"Invalid ZipCode for PatNum {proc.PatNum} while running Repeat Charge Tool on {DateTime.Today}", LogLevel.Error); } else { //Remove the message box for now to avoid it from popping up on the server, stopping anyone using middletier to continue //forward, because they can't click OK in the message box. //MessageBox.Show("A valid zip code is required to process sales tax on procedures in this patient's state. " //+"Please update the patient information with a valid zip code before continuing."); } } return(true); }
///<summary>True if we are in HQ, AvaTax is enabled, we tax the customer's state, and either the customer's tax exempt field is not defined or ///they are explicitly not tax exempt. Executes a small query.</summary> public static bool IsTaxable(long patNum) { if (!IsEnabled()) { return(false); //Save a few db calls } Patient pat = Patients.GetPat(patNum); if (pat == null) { return(false); } PatField taxExempt = null; if (TaxExemptPatField != null) { taxExempt = PatFields.Refresh(patNum).FirstOrDefault(x => x.FieldName == TaxExemptPatField.FieldName); } if (ListTaxableStates.Count == 0) { return(false); } if (!HasTaxableState(pat)) //if they aren't taxable, skip them { return(false); } if (taxExempt != null && PIn.Bool(taxExempt.FieldValue)) { return(false); } return(true); }
///<summary>Gets the ValueString as a boolean for this clinic's pref or gets the actual preference if it does not exist.</summary> public static bool GetBool(PrefName prefName, long clinicNum) { ClinicPref pref = GetPref(prefName, clinicNum); if (pref == null) { return(PrefC.GetBool(prefName)); } return(PIn.Bool(pref.ValueString)); }
///<summary>True if the ehrprovkey table has any rows, otherwise false.</summary> public static bool HasEhrKeys() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetBool(MethodBase.GetCurrentMethod())); } string command = "SELECT COUNT(*) FROM ehrprovkey"; return(PIn.Bool(Db.GetScalar(command))); }
///<summary>Called from claimsend window and from Claim edit window. Use 0 to get all waiting claims, or an actual claimnum to get just one claim.</summary> public static ClaimSendQueueItem[] GetQueueList(long claimNum, long clinicNum, long customTracking) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <ClaimSendQueueItem[]>(MethodBase.GetCurrentMethod(), claimNum, clinicNum, customTracking)); } string command = "SELECT claim.ClaimNum,carrier.NoSendElect" + ",CONCAT(CONCAT(CONCAT(concat(patient.LName,', '),patient.FName),' '),patient.MiddleI)" + ",claim.ClaimStatus,carrier.CarrierName,patient.PatNum,carrier.ElectID,MedType,claim.DateService,claim.ClinicNum " + "FROM claim " + "Left join insplan on claim.PlanNum = insplan.PlanNum " + "Left join carrier on insplan.CarrierNum = carrier.CarrierNum " + "Left join patient on patient.PatNum = claim.PatNum "; if (claimNum == 0) { command += "WHERE (claim.ClaimStatus = 'W' OR claim.ClaimStatus = 'P') "; } else { command += "WHERE claim.ClaimNum=" + POut.Long(claimNum) + " "; } if (clinicNum > 0) { command += "AND claim.ClinicNum=" + POut.Long(clinicNum) + " "; } if (customTracking > 0) { command += "AND claim.CustomTracking=" + POut.Long(customTracking) + " "; } command += "ORDER BY claim.DateService,patient.LName"; DataTable table = Db.GetTable(command); ClaimSendQueueItem[] listQueue = new ClaimSendQueueItem[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { listQueue[i] = new ClaimSendQueueItem(); listQueue[i].ClaimNum = PIn.Long(table.Rows[i][0].ToString()); listQueue[i].NoSendElect = PIn.Bool(table.Rows[i][1].ToString()); listQueue[i].PatName = PIn.String(table.Rows[i][2].ToString()); listQueue[i].ClaimStatus = PIn.String(table.Rows[i][3].ToString()); listQueue[i].Carrier = PIn.String(table.Rows[i][4].ToString()); listQueue[i].PatNum = PIn.Long(table.Rows[i][5].ToString()); string payorID = PIn.String(table.Rows[i]["ElectID"].ToString()); EnumClaimMedType medType = (EnumClaimMedType)PIn.Int(table.Rows[i]["MedType"].ToString()); listQueue[i].ClearinghouseNum = Clearinghouses.AutomateClearinghouseSelection(payorID, medType); listQueue[i].MedType = medType; listQueue[i].DateService = PIn.Date(table.Rows[i]["DateService"].ToString()); listQueue[i].ClinicNum = PIn.Long(table.Rows[i]["ClinicNum"].ToString()); } return(listQueue); }
///<summary>Returns a list of all appointments and whether that appointment has a conflict for the given listChildOpNums. ///Used to determine if there are any overlapping appointments for ALL time between a 'master' op appointments and the 'child' ops appointments. ///If an appointment from one of the give child ops has a confilict with the master op, then the appointment.Tag will be true. ///Throws exceptions.</summary> public static List <ODTuple <Appointment, bool> > MergeApptCheck(long masterOpNum, List <long> listChildOpNums) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <ODTuple <Appointment, bool> > >(MethodBase.GetCurrentMethod(), masterOpNum, listChildOpNums)); } if (listChildOpNums == null || listChildOpNums.Count == 0) { return(new List <ODTuple <Appointment, bool> >()); } if (listChildOpNums.Contains(masterOpNum)) { throw new ApplicationException(Lans.g("Operatories", "The operatory to keep cannot be within the selected list of operatories to combine.")); } List <int> listApptStatus = new List <int>(); listApptStatus.Add((int)ApptStatus.Scheduled); listApptStatus.Add((int)ApptStatus.Complete); listApptStatus.Add((int)ApptStatus.Broken); listApptStatus.Add((int)ApptStatus.PtNote); //12/09/2016 - Query below originally created by Allen and moddified for job by Joe. string command = "SELECT childAppointments.*, " + "MAX(CASE WHEN " + "(childAppointments.AptDateTime <= MasterAppointments.AptDateTime AND childAppointments.AptDateTime + INTERVAL (LENGTH(childAppointments.Pattern) * 5) MINUTE > MasterAppointments.AptDateTime) " + "OR " + "(MasterAppointments.AptDateTime <= childAppointments.AptDateTime AND MasterAppointments.AptDateTime + INTERVAL (LENGTH(MasterAppointments.Pattern) * 5) MINUTE > childAppointments.AptDateTime) " + "THEN 1 ELSE 0 END) AS HasConflict " + "FROM ( " + "SELECT * " + "FROM appointment " + "WHERE Op =" + POut.Long(masterOpNum) + " " + "AND aptstatus IN (" + String.Join(",", listApptStatus) + ") " + ") MasterAppointments " + "CROSS JOIN ( " + "SELECT * " + "FROM appointment " + "WHERE Op IN (" + String.Join(",", listChildOpNums) + ") " + "AND aptstatus IN (" + String.Join(",", listApptStatus) + ") " + ") childAppointments " + "GROUP BY childAppointments.AptNum"; DataTable table = Db.GetTable(command); List <Appointment> list = AppointmentCrud.TableToList(table); List <ODTuple <Appointment, bool> > listTuplesAptConflicts = new List <ODTuple <Appointment, bool> >(); for (int i = 0; i < table.Rows.Count; i++) { Appointment appt = list.First(x => x.AptNum == PIn.Long(table.Rows[i]["AptNum"].ToString())); //Safe bool hasConflict = PIn.Bool(table.Rows[i]["HasConflict"].ToString()); listTuplesAptConflicts.Add(new ODTuple <Appointment, bool>(appt, hasConflict)); } return(listTuplesAptConflicts); }
///<Summary>Gets a pref of type bool, but will not throw an exception if null or not found. Indicate whether the silent default is true or false.</Summary> public static bool GetBoolSilent(PrefName prefName, bool silentDefault) { if (Dict == null) { return(silentDefault); } if (!Dict.ContainsKey(prefName.ToString())) { return(silentDefault); } return(PIn.Bool(Dict[prefName.ToString()].ValueString)); }
///<summary>Gets a pref of type bool.</summary> public static bool GetBool(PrefName prefName) { if (Dict == null) { Prefs.RefreshCache(); } if (!Dict.ContainsKey(prefName.ToString())) { throw new Exception(prefName + " is an invalid pref name."); } return(PIn.Bool(Dict[prefName.ToString()].ValueString)); }
///<Summary>Gets a pref of type bool, but will not throw an exception if null or not found. Indicate whether the silent default is true or false.</Summary> public static bool GetBoolSilent(PrefName prefName, bool silentDefault) { if (Prefs.DictIsNull()) { return(silentDefault); } Pref pref = null; ODException.SwallowAnyException(() => { pref = Prefs.GetOne(prefName); }); return(pref == null ? silentDefault : PIn.Bool(pref.ValueString)); }
///<summary>Surround with try/catch.</summary> public static void Update(Carrier carrier) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), carrier); return; } string command; DataTable table; if (CultureInfo.CurrentCulture.Name.EndsWith("CA")) //Canadian. en-CA or fr-CA { if (carrier.IsCDA) { if (carrier.ElectID == "") { throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number required.")); } if (!Regex.IsMatch(carrier.ElectID, "^[0-9]{6}$")) { throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number must be exactly 6 numbers.")); } /*Duplication is allowed * command="SELECT CarrierNum FROM carrier WHERE " +"ElectID = '"+POut.String(Cur.ElectID)+"' " +"AND IsCDA=1 " +"AND CarrierNum != "+POut.Long(Cur.CarrierNum); * table=Db.GetTable(command); * if(table.Rows.Count>0) {//if there already exists a Canadian carrier with that ElectID * throw new ApplicationException(Lans.g("Carriers","EDI Code already in use.")); * } */ } //so the edited carrier looks good, but now we need to make sure that the original was allowed to be changed. command = "SELECT ElectID,IsCDA FROM carrier WHERE CarrierNum = '" + POut.Long(carrier.CarrierNum) + "'"; table = Db.GetTable(command); if (PIn.Bool(table.Rows[0]["IsCDA"].ToString()) && //if original carrier IsCDA PIn.String(table.Rows[0]["ElectID"].ToString()).Trim() != "" && //and the ElectID was already set PIn.String(table.Rows[0]["ElectID"].ToString()) != carrier.ElectID) //and the ElectID was changed { command = "SELECT COUNT(*) FROM etrans WHERE CarrierNum= " + POut.Long(carrier.CarrierNum) + " OR CarrierNum2=" + POut.Long(carrier.CarrierNum); if (Db.GetCount(command) != "0") { throw new ApplicationException(Lans.g("Carriers", "Not allowed to change Carrier Identification Number because it's in use in the claim history.")); } } } Crud.CarrierCrud.Update(carrier); }
///<summary>Checks the manual publisher database to see if the manual pages for a given version exists. ///Used when releasing a new version of the OD FAQ system.</summary> public static bool PageForVersionExists(int manualVersion) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetBool(MethodBase.GetCurrentMethod(), manualVersion)); } string command = $"SELECT COUNT(*)>0 FROM manualpage WHERE VersionOd={manualVersion.ToString()}"; bool retVal = false; DataAction.RunManualPublisherHQ(() => { retVal = PIn.Bool(Db.GetScalar(command)); }); return(retVal); }
///<summary>This is needed because of the extra column that is not part of the database.</summary> private static List <Task> TableToList(DataTable table) { //No need to check RemotingRole; no call to db. List <Task> retVal = Crud.TaskCrud.TableToList(table); for (int i = 0; i < retVal.Count; i++) { if (table.Columns.Contains("IsUnread")) { retVal[i].IsUnread = PIn.Bool(table.Rows[i]["IsUnread"].ToString()); //1 or more will result in true. } if (table.Columns.Contains("ParentDesc")) { retVal[i].ParentDesc = PIn.String(table.Rows[i]["ParentDesc"].ToString()); } } return(retVal); }
///<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) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), clockStatus, extens, employeeNum); return; } string command = @"SELECT phoneempdefault.EmployeeNum,Description,phoneempdefault.EmpName, " + "NoColor " + "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) { return; } long empNum = PIn.Long(tablePhone.Rows[0]["EmployeeNum"].ToString()); string empName = PIn.String(tablePhone.Rows[0]["EmpName"].ToString()); //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 isDefaultNoColor = PIn.Bool(tablePhone.Rows[0]["NoColor"].ToString()); bool isInUse = false; if (tablePhone.Rows[0]["Description"].ToString() == "In use") { isInUse = true; } Color colorBar = GetColorBar(clockStatus, empNum, isInUse, isDefaultNoColor); string clockStatusStr = clockStatus.ToString(); if (clockStatus == ClockStatusEnum.None) { clockStatusStr = ""; } command = "UPDATE phone SET ClockStatus='" + POut.String(clockStatusStr) + "', " + "ColorBar=" + colorBar.ToArgb().ToString() + ", " + "EmployeeNum=" + POut.Long(empNum) + ", " + "EmployeeName='" + POut.String(empName) + "' " + "WHERE Extension=" + extens; Db.NonQ(command); }
public static bool IsGuarSuspended(long guarNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetBool(MethodBase.GetCurrentMethod(), guarNum)); } int[] arrayStatusTransTypes = new[] { (int)TsiTransType.SS, (int)TsiTransType.CN, (int)TsiTransType.RI, (int)TsiTransType.PF, (int)TsiTransType.PT, (int)TsiTransType.PL }; string command = "SELECT (CASE WHEN tsitranslog.TransType=" + (int)TsiTransType.SS + " THEN 1 ELSE 0 END) isGuarSuspended " + "FROM tsitranslog " + "INNER JOIN (" + "SELECT PatNum,MAX(TransDateTime) transDateTime " + "FROM tsitranslog " + "WHERE PatNum=" + POut.Long(guarNum) + " " + "AND TransType IN(" + string.Join(",", arrayStatusTransTypes) + ") " + "AND TransDateTime>" + POut.DateT(DateTime.Now.AddDays(-50)) + " " + "GROUP BY PatNum" + ") mostRecentLog ON tsitranslog.PatNum=mostRecentLog.PatNum AND tsitranslog.TransDateTime=mostRecentLog.transDateTime"; return(PIn.Bool(Db.GetScalar(command))); }
private static List <VersionRelease> RefreshAndFill(string command) { DataTable table = Db.GetTable(command); List <VersionRelease> retVal = new List <VersionRelease>(); VersionRelease vers; for (int i = 0; i < table.Rows.Count; i++) { vers = new VersionRelease(); vers.VersionReleaseId = PIn.Int(table.Rows[i]["VersionReleaseId"].ToString()); vers.MajorNum = PIn.Int(table.Rows[i]["MajorNum"].ToString()); vers.MinorNum = PIn.Int(table.Rows[i]["MinorNum"].ToString()); vers.BuildNum = PIn.Int(table.Rows[i]["BuildNum"].ToString()); vers.IsForeign = PIn.Bool(table.Rows[i]["IsForeign"].ToString()); vers.DateRelease = PIn.Date(table.Rows[i]["DateRelease"].ToString()); vers.IsBeta = PIn.Bool(table.Rows[i]["IsBeta"].ToString()); vers.HasConvertScript = PIn.Bool(table.Rows[i]["HasConvertScript"].ToString()); retVal.Add(vers); } return(retVal); }
public static RegistrationKey GetByKey(string regKey) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <RegistrationKey>(MethodBase.GetCurrentMethod(), regKey)); } if (!Regex.IsMatch(regKey, @"^[A-Z0-9]{16}$")) { throw new ApplicationException("Invalid registration key format."); } string command = "SELECT * FROM registrationkey WHERE RegKey='" + POut.String(regKey) + "'"; DataTable table = Db.GetTable(command); if (table.Rows.Count == 0) { throw new ApplicationException("Invalid registration key."); } RegistrationKey key = null; for (int i = 0; i < table.Rows.Count; i++) { key = new RegistrationKey(); key.RegistrationKeyNum = PIn.Int(table.Rows[i][0].ToString()); key.PatNum = PIn.Int(table.Rows[i][1].ToString()); key.RegKey = PIn.String(table.Rows[i][2].ToString()); key.Note = PIn.String(table.Rows[i][3].ToString()); key.DateStarted = PIn.Date(table.Rows[i][4].ToString()); key.DateDisabled = PIn.Date(table.Rows[i][5].ToString()); key.DateEnded = PIn.Date(table.Rows[i][6].ToString()); key.IsForeign = PIn.Bool(table.Rows[i][7].ToString()); //key.UsesServerVersion =PIn.PBool(table.Rows[i][8].ToString()); key.IsFreeVersion = PIn.Bool(table.Rows[i][9].ToString()); key.IsOnlyForTesting = PIn.Bool(table.Rows[i][10].ToString()); //key.VotesAllotted =PIn.PInt(table.Rows[i][11].ToString()); } //if(key.DateDisabled.Year>1880){ // throw new ApplicationException("This key has been disabled. Please call for assistance."); //} return(key); }
public List <T> ToList <T>() { Type tp = typeof(T); //List<object> list=new List<object>(); List <T> list = new List <T>(); FieldInfo[] fieldInfo = tp.GetFields(); Object obj = default(T); for (int i = 0; i < Rows.Count; i++) { ConstructorInfo constructor = tp.GetConstructor(System.Type.EmptyTypes); obj = constructor.Invoke(null); for (int f = 0; f < fieldInfo.Length; f++) { if (fieldInfo[f].FieldType == typeof(int)) { fieldInfo[f].SetValue(obj, PIn.Long(Rows[i][f])); } else if (fieldInfo[f].FieldType == typeof(bool)) { fieldInfo[f].SetValue(obj, PIn.Bool(Rows[i][f])); } else if (fieldInfo[f].FieldType == typeof(string)) { fieldInfo[f].SetValue(obj, PIn.String(Rows[i][f])); } else if (fieldInfo[f].FieldType.IsEnum) { object val = ((object[])Enum.GetValues(fieldInfo[f].FieldType))[PIn.Long(Rows[i][f])]; fieldInfo[f].SetValue(obj, val); } } list.Add((T)obj); //Collection } return(list); //(List<T>)list.Cast<T>(); }
/// <summary>When starting up, in an attempt to be fast, it will not add a new computer to the list.</summary> public static void UpdateHeartBeat(string computerName, bool isStartup) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), computerName, isStartup); return; } string command; if (!isStartup) { if (_computerCache.ListIsNull()) { RefreshCache(); //adds new computer to list } command = "SELECT LastHeartBeat<" + DbHelper.DateAddMinute(DbHelper.Now(), "-3") + " FROM computer WHERE CompName='" + POut.String(computerName) + "'"; if (!PIn.Bool(Db.GetScalar(command))) //no need to update if LastHeartBeat is already within the last 3 mins { return; //remote app servers with multiple connections would fight over the lock on a single row to update the heartbeat unnecessarily } } command = "UPDATE computer SET LastHeartBeat=" + DbHelper.Now() + " WHERE CompName = '" + POut.String(computerName) + "'"; Db.NonQ(command); }
///<summary>Gets all feature request. Optionally pass in a list of Request IDs to only get those feature requests.</summary> public static List <FeatureRequest> GetAll(List <long> listRequestIDs = null) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <FeatureRequest> >(MethodBase.GetCurrentMethod(), listRequestIDs)); } DataTable table = new DataTable(); DataAction.RunBugsHQ(() => { #region WebServiceCustomerUpdates.FeatureRequestGetList string command = "SELECT request.RequestId,Approval,Description,Difficulty," + "vote.AmountPledged,IFNULL(vote.Points,0) AS points,vote.IsCritical,request.PatNum," + "TotalCritical,TotalPledged,TotalPoints,Weight " + "FROM request " + "LEFT JOIN vote ON vote.PatNum=1486 AND vote.RequestId=request.RequestId " + "WHERE Approval IN (" + POut.Int((int)ApprovalEnum.New) + "," + POut.Int((int)ApprovalEnum.Approved) + "," + POut.Int((int)ApprovalEnum.InProgress) + "," + POut.Int((int)ApprovalEnum.Complete) + ") "; if (!listRequestIDs.IsNullOrEmpty()) { command += $"AND request.RequestId IN ({string.Join(",",listRequestIDs)}) "; } command += "ORDER BY Approval, Weight DESC, points DESC"; DataTable raw = Db.GetTable(command); DataRow row; table.TableName = "Table"; table.Columns.Add("approval"); table.Columns.Add("Description"); table.Columns.Add("Difficulty"); table.Columns.Add("isMine"); table.Columns.Add("myVotes"); table.Columns.Add("RequestId"); table.Columns.Add("totalVotes"); table.Columns.Add("Weight"); table.Columns.Add("personalVotes"); table.Columns.Add("personalCrit"); table.Columns.Add("personalPledged"); double myPledge; bool myCritical; double totalPledged; int totalCritical; for (int i = 0; i < raw.Rows.Count; i++) { row = table.NewRow(); row["RequestId"] = raw.Rows[i]["RequestId"].ToString(); //myVotes,myCritical,myPledge------------------------------------------------------ row["myVotes"] = raw.Rows[i]["Points"].ToString(); row["personalVotes"] = raw.Rows[i]["Points"].ToString(); if (row["myVotes"].ToString() == "0") { row["myVotes"] = ""; } myCritical = PIn.Bool(raw.Rows[i]["IsCritical"].ToString()); if (myCritical == true) { row["personalCrit"] = "1"; if (row["myVotes"].ToString() != "") { row["myVotes"] += "\r\n"; } row["myVotes"] += "Critical"; } else { row["personalCrit"] = "0"; } myPledge = PIn.Double(raw.Rows[i]["AmountPledged"].ToString()); if (myPledge != 0) { if (row["myVotes"].ToString() != "") { row["myVotes"] += "\r\n"; } row["myVotes"] += myPledge.ToString("c0"); row["personalPledged"] = myPledge.ToString(); } else { row["personalPledged"] = "0"; } //TotalPoints,TotalCritical,TotalPledged----------------------------------------------- row["totalVotes"] = raw.Rows[i]["TotalPoints"].ToString(); if (row["totalVotes"].ToString() == "0") { row["totalVotes"] = ""; } totalCritical = PIn.Int(raw.Rows[i]["TotalCritical"].ToString()); if (totalCritical != 0) { if (row["totalVotes"].ToString() != "") { row["totalVotes"] += "\r\n"; } row["totalVotes"] += "Critical:" + totalCritical.ToString(); } totalPledged = PIn.Double(raw.Rows[i]["TotalPledged"].ToString()); if (totalPledged != 0) { if (row["totalVotes"].ToString() != "") { row["totalVotes"] += "\r\n"; } row["totalVotes"] += totalPledged.ToString("c0"); } //end row["approval"] = ((ApprovalEnum)PIn.Int(raw.Rows[i]["Approval"].ToString())).ToString(); if (raw.Rows[i]["PatNum"].ToString() == "1486") { row["isMine"] = "X"; } else { row["isMine"] = ""; } row["Difficulty"] = raw.Rows[i]["Difficulty"].ToString(); row["Description"] = raw.Rows[i]["Description"].ToString(); row["Weight"] = raw.Rows[i]["Weight"].ToString(); table.Rows.Add(row); } #endregion }, false); List <FeatureRequest> listFeatureRequests = new List <FeatureRequest>(); foreach (DataRow dataRow in table.Rows) { FeatureRequest req = new FeatureRequest(); #region Convert DataTable Into FeatureRequest long.TryParse(dataRow["RequestId"].ToString(), out req.FeatReqNum); string[] votes = dataRow["totalVotes"].ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string vote = votes.FirstOrDefault(x => !x.StartsWith("Critical") && !x.StartsWith("$")); if (!string.IsNullOrEmpty(vote)) { long.TryParse(vote, out req.Votes); } vote = votes.FirstOrDefault(x => x.StartsWith("Critical")); if (!string.IsNullOrEmpty(vote)) { long.TryParse(vote, out req.Critical); } vote = votes.FirstOrDefault(x => x.StartsWith("$")); if (!string.IsNullOrEmpty(vote)) { float.TryParse(vote, out req.Pledge); } req.Difficulty = PIn.Long(dataRow["Difficulty"].ToString()); req.Weight = PIn.Float(dataRow["Weight"].ToString()); req.Approval = dataRow["Weight"].ToString(); req.Description = dataRow["Description"].ToString(); #endregion listFeatureRequests.Add(req); } return(listFeatureRequests); }
public static List <FeatureRequest> GetAll() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <FeatureRequest> >(MethodBase.GetCurrentMethod())); } //Create an ODThread so that we can safely change the database connection settings without affecting the calling method's connection. ODThread odThread = new ODThread(new ODThread.WorkerDelegate((ODThread o) => { //Always set the thread static database connection variables to set the serviceshq db conn. #if DEBUG new DataConnection().SetDbT("localhost", "bugs", "root", "", "", "", DatabaseType.MySql, true); #else new DataConnection().SetDbT("server", "bugs", "root", "", "", "", DatabaseType.MySql, true); #endif #region WebServiceCustomerUpdates.FeatureRequestGetList string command = "SELECT request.RequestId,Approval,Description,Difficulty," + "vote.AmountPledged,IFNULL(vote.Points,0) AS points,vote.IsCritical,request.PatNum," + "TotalCritical,TotalPledged,TotalPoints,Weight " + "FROM request " + "LEFT JOIN vote ON vote.PatNum=1486 AND vote.RequestId=request.RequestId " + "WHERE (Approval=" + POut.Int((int)ApprovalEnum.New) + " " + "OR Approval=" + POut.Int((int)ApprovalEnum.Approved) + " " + "OR Approval=" + POut.Int((int)ApprovalEnum.InProgress) + " " + "OR Approval=" + POut.Int((int)ApprovalEnum.Complete) + ") " + "ORDER BY Approval, Weight DESC, points DESC"; DataTable raw = Db.GetTable(command); DataRow row; DataTable table = new DataTable(); table.TableName = "Table"; table.Columns.Add("approval"); table.Columns.Add("Description"); table.Columns.Add("Difficulty"); table.Columns.Add("isMine"); table.Columns.Add("myVotes"); table.Columns.Add("RequestId"); table.Columns.Add("totalVotes"); table.Columns.Add("Weight"); table.Columns.Add("personalVotes"); table.Columns.Add("personalCrit"); table.Columns.Add("personalPledged"); double myPledge; bool myCritical; double totalPledged; int totalCritical; for (int i = 0; i < raw.Rows.Count; i++) { row = table.NewRow(); row["RequestId"] = raw.Rows[i]["RequestId"].ToString(); //myVotes,myCritical,myPledge------------------------------------------------------ row["myVotes"] = raw.Rows[i]["Points"].ToString(); row["personalVotes"] = raw.Rows[i]["Points"].ToString(); if (row["myVotes"].ToString() == "0") { row["myVotes"] = ""; } myCritical = PIn.Bool(raw.Rows[i]["IsCritical"].ToString()); if (myCritical == true) { row["personalCrit"] = "1"; if (row["myVotes"].ToString() != "") { row["myVotes"] += "\r\n"; } row["myVotes"] += "Critical"; } else { row["personalCrit"] = "0"; } myPledge = PIn.Double(raw.Rows[i]["AmountPledged"].ToString()); if (myPledge != 0) { if (row["myVotes"].ToString() != "") { row["myVotes"] += "\r\n"; } row["myVotes"] += myPledge.ToString("c0"); row["personalPledged"] = myPledge.ToString(); } else { row["personalPledged"] = "0"; } //TotalPoints,TotalCritical,TotalPledged----------------------------------------------- row["totalVotes"] = raw.Rows[i]["TotalPoints"].ToString(); if (row["totalVotes"].ToString() == "0") { row["totalVotes"] = ""; } totalCritical = PIn.Int(raw.Rows[i]["TotalCritical"].ToString()); if (totalCritical != 0) { if (row["totalVotes"].ToString() != "") { row["totalVotes"] += "\r\n"; } row["totalVotes"] += "Critical:" + totalCritical.ToString(); } totalPledged = PIn.Double(raw.Rows[i]["TotalPledged"].ToString()); if (totalPledged != 0) { if (row["totalVotes"].ToString() != "") { row["totalVotes"] += "\r\n"; } row["totalVotes"] += totalPledged.ToString("c0"); } //end row["approval"] = ((ApprovalEnum)PIn.Int(raw.Rows[i]["Approval"].ToString())).ToString(); if (raw.Rows[i]["PatNum"].ToString() == "1486") { row["isMine"] = "X"; } else { row["isMine"] = ""; } row["Difficulty"] = raw.Rows[i]["Difficulty"].ToString(); row["Description"] = raw.Rows[i]["Description"].ToString(); row["Weight"] = raw.Rows[i]["Weight"].ToString(); table.Rows.Add(row); } o.Tag = table; #endregion })); odThread.AddExceptionHandler(new ODThread.ExceptionDelegate((Exception e) => { })); //Do nothing odThread.Name = "featureMarkAsInProgressThread"; odThread.Start(true); if (!odThread.Join(2000)) //Give this thread up to 2 seconds to complete. { return(new List <FeatureRequest>()); } DataTable tableRequests = (DataTable)odThread.Tag; List <FeatureRequest> listFeatureRequests = new List <FeatureRequest>(); foreach (DataRow dataRow in tableRequests.Rows) { FeatureRequest req = new FeatureRequest(); #region Convert DataTable Into FeatureRequest long.TryParse(dataRow["RequestId"].ToString(), out req.FeatReqNum); string[] votes = dataRow["totalVotes"].ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string vote = votes.FirstOrDefault(x => !x.StartsWith("Critical") && !x.StartsWith("$")); if (!string.IsNullOrEmpty(vote)) { long.TryParse(vote, out req.Votes); } vote = votes.FirstOrDefault(x => x.StartsWith("Critical")); if (!string.IsNullOrEmpty(vote)) { long.TryParse(vote, out req.Critical); } vote = votes.FirstOrDefault(x => x.StartsWith("$")); if (!string.IsNullOrEmpty(vote)) { float.TryParse(vote, out req.Pledge); } req.Difficulty = PIn.Long(dataRow["Difficulty"].ToString()); req.Weight = PIn.Float(dataRow["Weight"].ToString()); req.Approval = dataRow["Weight"].ToString(); req.Description = dataRow["Description"].ToString(); #endregion listFeatureRequests.Add(req); } return(listFeatureRequests); }
///<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); }
///<summary>Returns a SerializableDictionary with key=PatNum, value=PatAgingData with the filters applied.</summary> public static SerializableDictionary <long, PatAgingData> GetAgingData(bool isSinglePatient, bool includeChanged, bool excludeInsPending, bool excludeIfUnsentProcs, bool isSuperBills, List <long> listClinicNums) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <SerializableDictionary <long, PatAgingData> >(MethodBase.GetCurrentMethod(), isSinglePatient, includeChanged, excludeInsPending, excludeIfUnsentProcs, isSuperBills, listClinicNums)); } SerializableDictionary <long, PatAgingData> dictPatAgingData = new SerializableDictionary <long, PatAgingData>(); string command = ""; string guarOrPat = "guar"; if (isSinglePatient) { guarOrPat = "patient"; } string whereAndClinNum = ""; if (!listClinicNums.IsNullOrEmpty()) { whereAndClinNum = $@"AND {guarOrPat}.ClinicNum IN ({string.Join(",",listClinicNums)})"; } if (includeChanged || excludeIfUnsentProcs) { command = $@"SELECT {guarOrPat}.PatNum,{guarOrPat}.ClinicNum,MAX(procedurelog.ProcDate) MaxProcDate"; if (excludeIfUnsentProcs) { command += ",MAX(CASE WHEN insplan.IsMedical=1 THEN 0 ELSE COALESCE(claimproc.ProcNum,0) END)>0 HasUnsentProcs"; } command += $@" FROM patient INNER JOIN patient guar ON guar.PatNum=patient.Guarantor INNER JOIN procedurelog ON procedurelog.PatNum = patient.PatNum " ; if (excludeIfUnsentProcs) { command += $@"LEFT JOIN claimproc ON claimproc.ProcNum = procedurelog.ProcNum AND claimproc.NoBillIns=0 AND claimproc.Status = {POut.Int((int)ClaimProcStatus.Estimate)} AND procedurelog.ProcDate > CURDATE()-INTERVAL 6 MONTH LEFT JOIN insplan ON insplan.PlanNum=claimproc.PlanNum " ; } command += $@"WHERE procedurelog.ProcFee > 0 AND procedurelog.ProcStatus = {POut.Int((int)ProcStat.C)} {whereAndClinNum} GROUP BY {guarOrPat}.PatNum ORDER BY NULL" ; using (DataTable tableChangedAndUnsent = Db.GetTable(command)) { foreach (DataRow row in tableChangedAndUnsent.Rows) { long patNum = PIn.Long(row["PatNum"].ToString()); if (!dictPatAgingData.ContainsKey(patNum)) { dictPatAgingData[patNum] = new PatAgingData(PIn.Long(row["ClinicNum"].ToString())); } if (includeChanged) { dictPatAgingData[patNum].ListPatAgingTransactions .Add(new PatAgingTransaction(PatAgingTransaction.TransactionTypes.Procedure, PIn.Date(row["MaxProcDate"].ToString()))); } if (excludeIfUnsentProcs) { dictPatAgingData[patNum].HasUnsentProcs = PIn.Bool(row["HasUnsentProcs"].ToString()); } } } } if (includeChanged) { command = $@"SELECT {guarOrPat}.PatNum,{guarOrPat}.ClinicNum,MAX(claimproc.DateCP) maxDateCP FROM claimproc INNER JOIN patient ON patient.PatNum = claimproc.PatNum INNER JOIN patient guar ON guar.PatNum=patient.Guarantor WHERE claimproc.InsPayAmt > 0 {whereAndClinNum} GROUP BY {guarOrPat}.PatNum" ; using (DataTable tableMaxPayDate = Db.GetTable(command)) { foreach (DataRow row in tableMaxPayDate.Rows) { long patNum = PIn.Long(row["PatNum"].ToString()); if (!dictPatAgingData.ContainsKey(patNum)) { dictPatAgingData[patNum] = new PatAgingData(PIn.Long(row["ClinicNum"].ToString())); } dictPatAgingData[patNum].ListPatAgingTransactions .Add(new PatAgingTransaction(PatAgingTransaction.TransactionTypes.ClaimProc, PIn.Date(row["maxDateCP"].ToString()))); } } command = $@"SELECT {guarOrPat}.PatNum,{guarOrPat}.ClinicNum,MAX(payplancharge.ChargeDate) maxDatePPC, MAX(payplancharge.SecDateTEntry) maxDatePPCSDTE FROM payplancharge INNER JOIN patient ON patient.PatNum = payplancharge.PatNum INNER JOIN patient guar ON guar.PatNum=patient.Guarantor INNER JOIN payplan ON payplan.PayPlanNum = payplancharge.PayPlanNum AND payplan.PlanNum = 0 " //don't want insurance payment plans to make patients appear in the billing list + $@"WHERE payplancharge.Principal + payplancharge.Interest>0 AND payplancharge.ChargeType = {(int)PayPlanChargeType.Debit} " //include all charges in the past or due 'PayPlanBillInAdvance' days into the future. + $@"AND payplancharge.ChargeDate <= {POut.Date(DateTime.Today.AddDays(PrefC.GetDouble(PrefName.PayPlansBillInAdvanceDays)))} {whereAndClinNum} GROUP BY {guarOrPat}.PatNum" ; using (DataTable tableMaxPPCDate = Db.GetTable(command)) { foreach (DataRow row in tableMaxPPCDate.Rows) { long patNum = PIn.Long(row["PatNum"].ToString()); if (!dictPatAgingData.ContainsKey(patNum)) { dictPatAgingData[patNum] = new PatAgingData(PIn.Long(row["ClinicNum"].ToString())); } dictPatAgingData[patNum].ListPatAgingTransactions .Add(new PatAgingTransaction( PatAgingTransaction.TransactionTypes.PayPlanCharge, PIn.Date(row["maxDatePPC"].ToString()), secDateTEntryTrans: PIn.Date(row["maxDatePPCSDTE"].ToString())) ); } } } if (excludeInsPending) { command = $@"SELECT {guarOrPat}.PatNum,{guarOrPat}.ClinicNum FROM claim INNER JOIN patient ON patient.PatNum=claim.PatNum INNER JOIN patient guar ON guar.PatNum=patient.Guarantor WHERE claim.ClaimStatus IN ('U','H','W','S') AND claim.ClaimType IN ('P','S','Other') {whereAndClinNum} GROUP BY {guarOrPat}.PatNum" ; using (DataTable tableInsPending = Db.GetTable(command)) { foreach (DataRow row in tableInsPending.Rows) { long patNum = PIn.Long(row["PatNum"].ToString()); if (!dictPatAgingData.ContainsKey(patNum)) { dictPatAgingData[patNum] = new PatAgingData(PIn.Long(row["ClinicNum"].ToString())); } dictPatAgingData[patNum].HasPendingIns = true; } } } DateTime dateAsOf = DateTime.Today; //used to determine when the balance on this date began if (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily)) //if aging calculated monthly, use the last aging date instead of today { dateAsOf = PrefC.GetDate(PrefName.DateLastAging); } List <PatComm> listPatComms = new List <PatComm>(); using (DataTable tableDateBalsBegan = Ledgers.GetDateBalanceBegan(null, dateAsOf, isSuperBills, listClinicNums)) { foreach (DataRow row in tableDateBalsBegan.Rows) { long patNum = PIn.Long(row["PatNum"].ToString()); if (!dictPatAgingData.ContainsKey(patNum)) { dictPatAgingData[patNum] = new PatAgingData(PIn.Long(row["ClinicNum"].ToString())); } dictPatAgingData[patNum].DateBalBegan = PIn.Date(row["DateAccountAge"].ToString()); dictPatAgingData[patNum].DateBalZero = PIn.Date(row["DateZeroBal"].ToString()); } listPatComms = Patients.GetPatComms(tableDateBalsBegan.Select().Select(x => PIn.Long(x["PatNum"].ToString())).ToList(), null); } foreach (PatComm pComm in listPatComms) { if (!dictPatAgingData.ContainsKey(pComm.PatNum)) { dictPatAgingData[pComm.PatNum] = new PatAgingData(pComm.ClinicNum); } dictPatAgingData[pComm.PatNum].PatComm = pComm; } return(dictPatAgingData); }
///<summary>Gets a pref of type bool.</summary> public static bool GetBool(PrefName prefName) { return(PIn.Bool(Prefs.GetOne(prefName).ValueString)); }
///<summary>Used to get a list of carriers to display in the FormCarriers window.</summary> public static DataTable GetBigList(bool isCanadian, bool showHidden, string carrierName) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetTable(MethodBase.GetCurrentMethod(), isCanadian, showHidden, carrierName)); } DataTable tableRaw; DataTable table; string command; //if(isCanadian){ command = "SELECT Address,Address2,canadiannetwork.Abbrev,carrier.CarrierNum," + "CarrierName,CDAnetVersion,City,ElectID," + "COUNT(insplan.PlanNum) insPlanCount,IsCDA," + "carrier.IsHidden,Phone,State,Zip " + "FROM carrier " + "LEFT JOIN canadiannetwork ON canadiannetwork.CanadianNetworkNum=carrier.CanadianNetworkNum " + "LEFT JOIN insplan ON insplan.CarrierNum=carrier.CarrierNum " + "WHERE " + "CarrierName LIKE '%" + POut.String(carrierName) + "%' "; if (isCanadian) { command += "AND IsCDA=1 "; } if (!showHidden) { command += "AND carrier.IsHidden=0 "; } if (DataConnection.DBtype == DatabaseType.MySql) { command += "GROUP BY carrier.CarrierNum "; } else //Oracle { command += "GROUP BY Address,Address2,canadiannetwork.Abbrev,carrier.CarrierNum," + "CarrierName,CDAnetVersion,City,ElectID,IsCDA," + "carrier.IsHidden,Phone,State,Zip "; } command += "ORDER BY CarrierName"; tableRaw = Db.GetTable(command); table = new DataTable(); table.Columns.Add("Address"); table.Columns.Add("Address2"); table.Columns.Add("CarrierNum"); table.Columns.Add("CarrierName"); table.Columns.Add("City"); table.Columns.Add("ElectID"); table.Columns.Add("insPlanCount"); table.Columns.Add("isCDA"); table.Columns.Add("isHidden"); table.Columns.Add("Phone"); //table.Columns.Add("pMP"); //table.Columns.Add("network"); table.Columns.Add("State"); //table.Columns.Add("version"); table.Columns.Add("Zip"); DataRow row; for (int i = 0; i < tableRaw.Rows.Count; i++) { row = table.NewRow(); row["Address"] = tableRaw.Rows[i]["Address"].ToString(); row["Address2"] = tableRaw.Rows[i]["Address2"].ToString(); row["CarrierNum"] = tableRaw.Rows[i]["CarrierNum"].ToString(); row["CarrierName"] = tableRaw.Rows[i]["CarrierName"].ToString(); row["City"] = tableRaw.Rows[i]["City"].ToString(); row["ElectID"] = tableRaw.Rows[i]["ElectID"].ToString(); if (PIn.Bool(tableRaw.Rows[i]["IsCDA"].ToString())) { row["isCDA"] = "X"; } else { row["isCDA"] = ""; } if (PIn.Bool(tableRaw.Rows[i]["IsHidden"].ToString())) { row["isHidden"] = "X"; } else { row["isHidden"] = ""; } row["insPlanCount"] = tableRaw.Rows[i]["insPlanCount"].ToString(); row["Phone"] = tableRaw.Rows[i]["Phone"].ToString(); //if(PIn.Bool(tableRaw.Rows[i]["IsPMP"].ToString())){ // row["pMP"]="X"; //} //else{ // row["pMP"]=""; //} //row["network"]=tableRaw.Rows[i]["Abbrev"].ToString(); row["State"] = tableRaw.Rows[i]["State"].ToString(); //row["version"]=tableRaw.Rows[i]["CDAnetVersion"].ToString(); row["Zip"] = tableRaw.Rows[i]["Zip"].ToString(); table.Rows.Add(row); } return(table); }
public static void AddUnreads(long taskNum, long curUserNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), taskNum, curUserNum); return; } //if the task is done, don't add unreads string command = "SELECT TaskStatus,UserNum,ReminderGroupId,DateTimeEntry," + DbHelper.Now() + " DbTime " + "FROM task WHERE TaskNum = " + POut.Long(taskNum); DataTable table = Db.GetTable(command); if (table.Rows.Count == 0) { return; //only happens when a task was deleted by one user but left open on another user's computer. } TaskStatusEnum taskStatus = (TaskStatusEnum)PIn.Int(table.Rows[0]["TaskStatus"].ToString()); long userNumOwner = PIn.Long(table.Rows[0]["UserNum"].ToString()); if (taskStatus == TaskStatusEnum.Done) // { return; } //Set it unread for the original owner of the task. if (userNumOwner != curUserNum) //but only if it's some other user { SetUnread(userNumOwner, taskNum); } //Set it for this user if a future repeating task, so it will be new when "due". Doing this here so we don't check every row below. //Only for future dates because we don't want to mark as new if it was already "due" and you added a note or something. if ((PIn.String(table.Rows[0]["ReminderGroupId"].ToString()) != "") && //Is a reminder (PIn.DateT(table.Rows[0]["DateTimeEntry"].ToString()) > PIn.DateT(table.Rows[0]["DbTime"].ToString()))) //Is "due" in the future by DbTime { SetUnread(curUserNum, taskNum); //Set unread for current user only, other users dealt with below. } //Then, for anyone subscribed long userNum; bool isUnread; //task subscriptions are not cached yet, so we use a query. //Get a list of all subscribers to this task command = @"SELECT tasksubscription.UserNum, (CASE WHEN taskunread.UserNum IS NULL THEN 0 ELSE 1 END) IsUnread FROM tasksubscription INNER JOIN tasklist ON tasksubscription.TaskListNum = tasklist.TaskListNum INNER JOIN taskancestor ON taskancestor.TaskListNum = tasklist.TaskListNum AND taskancestor.TaskNum = " + POut.Long(taskNum) + " "; command += "LEFT JOIN taskunread ON taskunread.UserNum = tasksubscription.UserNum AND taskunread.TaskNum=taskancestor.TaskNum"; table = Db.GetTable(command); List <long> listUserNums = new List <long>(); for (int i = 0; i < table.Rows.Count; i++) { userNum = PIn.Long(table.Rows[i]["UserNum"].ToString()); isUnread = PIn.Bool(table.Rows[i]["IsUnread"].ToString()); if (userNum == userNumOwner || //already set userNum == curUserNum || //If the current user is subscribed to this task. User has obviously already read it. listUserNums.Contains(userNum) || isUnread) //Unread currently exists { continue; } listUserNums.Add(userNum); } SetUnreadMany(listUserNums, taskNum); //This no longer results in duplicates like it used to }
///<summary></summary> public static DataTable GetOrderTable(long patNum, bool includeDiscontinued) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetTable(MethodBase.GetCurrentMethod(), patNum, includeDiscontinued)); } DataTable table = new DataTable("orders"); DataRow row; table.Columns.Add("date"); table.Columns.Add("DateTime", typeof(DateTime)); table.Columns.Add("description"); table.Columns.Add("MedicalOrderNum"); table.Columns.Add("MedicationPatNum"); table.Columns.Add("prov"); table.Columns.Add("status"); table.Columns.Add("type"); List <DataRow> rows = new List <DataRow>(); string command = "SELECT DateTimeOrder,Description,IsDiscontinued,MedicalOrderNum,MedOrderType,ProvNum " + "FROM medicalorder WHERE PatNum = " + POut.Long(patNum); if (!includeDiscontinued) //only include current orders { command += " AND IsDiscontinued=0"; //false } DataTable rawOrder = Db.GetTable(command); DateTime dateT; MedicalOrderType medOrderType; long medicalOrderNum; bool isDiscontinued; for (int i = 0; i < rawOrder.Rows.Count; i++) { row = table.NewRow(); dateT = PIn.DateT(rawOrder.Rows[i]["DateTimeOrder"].ToString()); medOrderType = (MedicalOrderType)PIn.Int(rawOrder.Rows[i]["MedOrderType"].ToString()); medicalOrderNum = PIn.Long(rawOrder.Rows[i]["MedicalOrderNum"].ToString()); row["DateTime"] = dateT; row["date"] = dateT.ToShortDateString(); row["description"] = PIn.String(rawOrder.Rows[i]["Description"].ToString()); if (medOrderType == MedicalOrderType.Laboratory) { List <LabPanel> listPanelsForOrder = LabPanels.GetPanelsForOrder(medicalOrderNum); for (int p = 0; p < listPanelsForOrder.Count; p++) { row["description"] += "\r\n "; //new row for each panel List <LabResult> listResults = LabResults.GetForPanel(listPanelsForOrder[p].LabPanelNum); if (listResults.Count > 0) { row["description"] += listResults[0].DateTimeTest.ToShortDateString() + " - "; } row["description"] += listPanelsForOrder[p].ServiceName; } } row["MedicalOrderNum"] = medicalOrderNum.ToString(); row["MedicationPatNum"] = "0"; row["prov"] = Providers.GetAbbr(PIn.Long(rawOrder.Rows[i]["ProvNum"].ToString())); isDiscontinued = PIn.Bool(rawOrder.Rows[i]["IsDiscontinued"].ToString()); if (isDiscontinued) { row["status"] = "Discontinued"; } else { row["status"] = "Active"; } row["type"] = medOrderType.ToString(); rows.Add(row); } //Medications are deprecated for 2014 edition //MedicationPats //command="SELECT DateStart,DateStop,MedicationPatNum,CASE WHEN medication.MedName IS NULL THEN medicationpat.MedDescript ELSE medication.MedName END MedName,PatNote,ProvNum " // +"FROM medicationpat " // +"LEFT OUTER JOIN medication ON medication.MedicationNum=medicationpat.MedicationNum " // +"WHERE PatNum = "+POut.Long(patNum); //if(!includeDiscontinued) {//exclude invalid orders // command+=" AND DateStart > "+POut.Date(new DateTime(1880,1,1))+" AND PatNote !='' " // +"AND (DateStop < "+POut.Date(new DateTime(1880,1,1))+" "//no date stop // +"OR DateStop >= "+POut.Date(DateTime.Today)+")";//date stop hasn't happened yet //} //DataTable rawMed=Db.GetTable(command); //DateTime dateStop; //for(int i=0;i<rawMed.Rows.Count;i++) { // row=table.NewRow(); // dateT=PIn.DateT(rawMed.Rows[i]["DateStart"].ToString()); // row["DateTime"]=dateT; // if(dateT.Year<1880) { // row["date"]=""; // } // else { // row["date"]=dateT.ToShortDateString(); // } // row["description"]=PIn.String(rawMed.Rows[i]["MedName"].ToString())+", " // +PIn.String(rawMed.Rows[i]["PatNote"].ToString()); // row["MedicalOrderNum"]="0"; // row["MedicationPatNum"]=rawMed.Rows[i]["MedicationPatNum"].ToString(); // row["prov"]=Providers.GetAbbr(PIn.Long(rawMed.Rows[i]["ProvNum"].ToString())); // dateStop=PIn.Date(rawMed.Rows[i]["DateStop"].ToString()); // if(dateStop.Year<1880 || dateStop>DateTime.Today) {//not stopped or in the future // row["status"]="Active"; // } // else { // row["status"]="Discontinued"; // } // row["type"]="Medication"; // rows.Add(row); //} //Sorting----------------------------------------------------------------------------------------- rows.Sort(new MedicalOrderLineComparer()); for (int i = 0; i < rows.Count; i++) { table.Rows.Add(rows[i]); } return(table); }