///<summary>Returns a list of BugSubmissionHashes based on DateTimeEntry and given date range.</summary> public static List <BugSubmissionHash> GetMany(DateTime dateTimeFrom = default, DateTime dateTimeTo = default, bool useConnectionStore = false) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <BugSubmissionHash> >(MethodBase.GetCurrentMethod(), dateTimeFrom, dateTimeTo, useConnectionStore)); } List <BugSubmissionHash> listRetVals = new List <BugSubmissionHash>(); DataAction.RunBugsHQ(() => { string command = $@"SELECT * FROM bugsubmissionhash "; if (dateTimeFrom != DateTime.MinValue && dateTimeTo != DateTime.MinValue) { command += $@"WHERE " + DbHelper.BetweenDates("DateTimeEntry", dateTimeFrom, dateTimeTo); } command += "ORDER BY DateTimeEntry DESC"; listRetVals = Crud.BugSubmissionHashCrud.SelectMany(command); }, useConnectionStore); return(listRetVals); }
///<summary>Usually, set just the extension before passing in the doc. Inserts a new document into db, creates a filename based on Cur.DocNum, and then updates the db with this filename. Should always refresh the document after calling this method in order to get the correct filename for RemotingRole.ClientWeb.</summary> public static long Insert(Document doc, Patient pat) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { doc.DocNum = Meth.GetLong(MethodBase.GetCurrentMethod(), doc, pat); return(doc.DocNum); } doc.DocNum = Crud.DocumentCrud.Insert(doc); //If the current filename is just an extension, then assign it a unique name. if (doc.FileName == Path.GetExtension(doc.FileName)) { string extension = doc.FileName; doc.FileName = ""; string s = pat.LName + pat.FName; for (int i = 0; i < s.Length; i++) { if (Char.IsLetter(s, i)) { doc.FileName += s.Substring(i, 1); } } doc.FileName += doc.DocNum.ToString() + extension; //ensures unique name //there is still a slight chance that someone manually added a file with this name, so quick fix: string command = "SELECT FileName FROM document WHERE PatNum=" + POut.Long(doc.PatNum); DataTable table = Db.GetTable(command); string[] usedNames = new string[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { usedNames[i] = PIn.String(table.Rows[i][0].ToString()); } while (IsFileNameInList(doc.FileName, usedNames)) { doc.FileName = "x" + doc.FileName; } /*Document[] docList=GetAllWithPat(doc.PatNum); * while(IsFileNameInList(doc.FileName,docList)) { * doc.FileName="x"+doc.FileName; * }*/ Update(doc); } return(doc.DocNum); }
///<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); 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>Surround by try catch, because it will throw an exception if trying to delete a claimpayment attached to a deposit or if there are eobs attached.</summary> public static void Delete(ClaimPayment cp) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), cp); return; } //validate deposits string command = "SELECT DepositNum FROM claimpayment " + "WHERE ClaimPaymentNum=" + POut.Long(cp.ClaimPaymentNum); DataTable table = Db.GetTable(command); if (table.Rows.Count == 0) { return; } if (table.Rows[0][0].ToString() != "0") //if claimpayment is already attached to a deposit { #if !DEBUG throw new ApplicationException(Lans.g("ClaimPayments", "Not allowed to delete a payment attached to a deposit.")); #endif } //validate eobs command = "SELECT COUNT(*) FROM eobattach WHERE ClaimPaymentNum=" + POut.Long(cp.ClaimPaymentNum); if (Db.GetScalar(command) != "0") { throw new ApplicationException(Lans.g("ClaimPayments", "Not allowed to delete this payment because EOBs are attached.")); } command = "UPDATE claimproc SET " + "DateInsFinalized='0001-01-01' " + "WHERE ClaimPaymentNum=" + POut.Long(cp.ClaimPaymentNum) + " " + "AND (SELECT SecDateEntry FROM claimpayment WHERE ClaimPaymentNum=" + POut.Long(cp.ClaimPaymentNum) + ")=CURDATE()"; Db.NonQ(command); command = "UPDATE claimproc SET " + "ClaimPaymentNum=0 " + "WHERE claimpaymentNum=" + POut.Long(cp.ClaimPaymentNum); //MessageBox.Show(string command); Db.NonQ(command); command = "DELETE FROM claimpayment " + "WHERE ClaimPaymentnum =" + POut.Long(cp.ClaimPaymentNum); //MessageBox.Show(string command); Db.NonQ(command); }
///<summary>Returns the clinic-level clearinghouse for the passed in Clearinghouse. Usually used in conjunction with ReplaceFields(). ///Can return null.</summary> public static Clearinghouse GetForClinic(Clearinghouse clearinghouseHq, long clinicNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <Clearinghouse>(MethodBase.GetCurrentMethod(), clearinghouseHq, clinicNum)); } if (clinicNum == 0) //HQ { return(null); } string command = "SELECT * FROM clearinghouse WHERE HqClearinghouseNum=" + clearinghouseHq.ClearinghouseNum + " AND ClinicNum=" + clinicNum; Clearinghouse clearinghouseRetVal = Crud.ClearinghouseCrud.SelectOne(command); if (clearinghouseRetVal != null) { clearinghouseRetVal.Password = GetRevealPassword(clearinghouseRetVal.Password); } return(clearinghouseRetVal); }
///<summary>Retrieves all registration keys for a particular customer's family. There can be multiple keys assigned to a single customer, or keys assigned to individual family members, since the customer may have multiple physical locations of business.</summary> public static RegistrationKey[] GetForPatient(long patNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <RegistrationKey[]>(MethodBase.GetCurrentMethod(), patNum)); } string command = "SELECT * FROM registrationkey WHERE "; Family fam = Patients.GetFamily(patNum); for (int i = 0; i < fam.ListPats.Length; i++) { command += "PatNum=" + POut.Long(fam.ListPats[i].PatNum) + " "; if (i < fam.ListPats.Length - 1) { command += "OR "; } } return(Crud.RegistrationKeyCrud.SelectMany(command).ToArray()); }
///<summary>Inserts one row per UserOD if they do not have one already.</summary> private static void InsertMissingValues() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod()); return; } string command = "SELECT * FROM userod WHERE IsHidden=0 AND UserNum NOT IN (SELECT UserNum from cdsPermission)"; List <Userod> uods = Crud.UserodCrud.SelectMany(command); CDSPermission cdsp; for (int i = 0; i < uods.Count; i++) { cdsp = new CDSPermission(); cdsp.UserNum = uods[i].UserNum; CDSPermissions.Insert(cdsp); } return; }
///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Does not save any drawings. Does not save signatures. Does not save any parameters (PatNum parameters never get saved anyway).</Summary> public static void SaveNewSheet(Sheet sheet) { //This remoting role check is technically unnecessary but it significantly speeds up the retrieval process for Middle Tier users due to looping. if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheet); return; } if (!sheet.IsNew) { throw new Exception("Only new sheets allowed"); } Insert(sheet); foreach (SheetField fld in sheet.SheetFields) { fld.SheetNum = sheet.SheetNum; SheetFields.Insert(fld); } }
///<summary>Sets the IsDeleted flag to true (1) for the specified sheetNum. The sheet and associated sheetfields are not deleted.</summary> public static void Delete(long sheetNum, long patNum = 0, byte showInTerminal = 0) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheetNum, patNum, showInTerminal); return; } string command = "UPDATE sheet SET IsDeleted=1,ShowInTerminal=0 WHERE SheetNum=" + POut.Long(sheetNum); Db.NonQ(command); if (patNum > 0 && showInTerminal > 0) //showInTerminal must be at least 1, so decrementing those that are at least 2 { command = "UPDATE sheet SET ShowInTerminal=ShowInTerminal-1 " + "WHERE PatNum=" + POut.Long(patNum) + " " + "AND IsDeleted=0 " + "AND ShowInTerminal>" + POut.Byte(showInTerminal); //decrement ShowInTerminal for all sheets with a bigger ShowInTerminal than the one deleted Db.NonQ(command); } }
///<summary></summary> public static EhrLabSpecimen InsertItem(EhrLabSpecimen ehrLabSpecimen) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <EhrLabSpecimen>(MethodBase.GetCurrentMethod(), ehrLabSpecimen)); } ehrLabSpecimen.EhrLabNum = Crud.EhrLabSpecimenCrud.Insert(ehrLabSpecimen); for (int i = 0; i < ehrLabSpecimen.ListEhrLabSpecimenCondition.Count; i++) { ehrLabSpecimen.ListEhrLabSpecimenCondition[i].EhrLabSpecimenNum = ehrLabSpecimen.EhrLabSpecimenNum; EhrLabSpecimenConditions.Insert(ehrLabSpecimen.ListEhrLabSpecimenCondition[i]); } for (int i = 0; i < ehrLabSpecimen.ListEhrLabSpecimenRejectReason.Count; i++) { ehrLabSpecimen.ListEhrLabSpecimenRejectReason[i].EhrLabSpecimenNum = ehrLabSpecimen.EhrLabSpecimenNum; EhrLabSpecimenRejectReasons.Insert(ehrLabSpecimen.ListEhrLabSpecimenRejectReason[i]); } return(ehrLabSpecimen); }
public static void EnsureComputerInDB(string computerName) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), computerName); return; } string command = "SELECT * from computer " + "WHERE compname = '" + computerName + "'"; DataTable table = Db.GetTable(command); if (table.Rows.Count == 0) { Computer Cur = new Computer(); Cur.CompName = computerName; Computers.Insert(Cur); } }
///<summary>Surround with try-catch. Handles ItemOrders below this supply.</summary> public static void DeleteObject(Supply supply) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), supply); return; } //validate that not already in use. string command = "SELECT COUNT(*) FROM supplyorderitem WHERE SupplyNum=" + POut.Long(supply.SupplyNum); int count = PIn.Int(Db.GetCount(command)); if (count > 0) { throw new ApplicationException(Lans.g("Supplies", "Supply is already in use on an order. Not allowed to delete.")); } Crud.SupplyCrud.Delete(supply.SupplyNum); command = "UPDATE supply SET ItemOrder=(ItemOrder-1) WHERE Category=" + POut.Long(supply.Category) + " AND ItemOrder>" + POut.Int(supply.ItemOrder); Db.NonQ(command); }
///<summary></summary> private static void InsertRow(long patNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), patNum); return; } //Random keys not necessary to check because of 1:1 patNum. //However, this is a lazy insert, so multiple locations might attempt it. //Just in case, we will have it fail silently. try { string command = "INSERT INTO patientnote (patnum" + ") VALUES('" + patNum + "')"; Db.NonQ(command); } catch { //Fail Silently. } }
///<summary>Must supply the old field name so that the apptFields attached to appointments can be updated. Will throw exception if new FieldName is already in use.</summary> public static void Update(ApptFieldDef apptFieldDef, string oldFieldName) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), apptFieldDef, oldFieldName); return; } string command = "SELECT COUNT(*) FROM apptfielddef WHERE FieldName='" + POut.String(apptFieldDef.FieldName) + "' " + "AND ApptFieldDefNum != " + POut.Long(apptFieldDef.ApptFieldDefNum); if (Db.GetCount(command) != "0") { throw new ApplicationException(Lans.g("FormApptFieldDefEdit", "Field name already in use.")); } Crud.ApptFieldDefCrud.Update(apptFieldDef); command = "UPDATE apptfield SET FieldName='" + POut.String(apptFieldDef.FieldName) + "' " + "WHERE FieldName='" + POut.String(oldFieldName) + "'"; Db.NonQ(command); }
///<summary>Gets all task lists for one of the 3 dated trunks.</summary> public static List <TaskList> RefreshDatedTrunk(DateTime date, TaskDateType dateType) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <TaskList> >(MethodBase.GetCurrentMethod(), date, dateType)); } DateTime dateFrom = DateTime.MinValue; DateTime dateTo = DateTime.MaxValue; if (dateType == TaskDateType.Day) { dateFrom = date; dateTo = date; } else if (dateType == TaskDateType.Week) { dateFrom = date.AddDays(-(int)date.DayOfWeek); dateTo = dateFrom.AddDays(6); } else if (dateType == TaskDateType.Month) { dateFrom = new DateTime(date.Year, date.Month, 1); dateTo = dateFrom.AddMonths(1).AddDays(-1); } string command = "SELECT tasklist.*," + "(SELECT COUNT(*) FROM taskancestor,task WHERE taskancestor.TaskListNum=tasklist.TaskListNum " + "AND task.TaskNum=taskancestor.TaskNum "; //if(PrefC.GetBool(PrefName.TasksNewTrackedByUser)) { // command+="AND EXISTS(SELECT * FROM taskunread WHERE taskunread.TaskNum=task.TaskNum)"; //} //else { command += "AND task.TaskStatus=0"; //} command += ") " + "FROM tasklist " + "WHERE DateTL >= " + POut.Date(dateFrom) + " AND DateTL <= " + POut.Date(dateTo) + " AND DateType=" + POut.Long((int)dateType) + " ORDER BY DateTimeEntry"; return(TableToList(Db.GetTable(command))); }
///<summary>Returns all sheets for the given patient in the given date range which have a description matching the examDescript in a case insensitive manner. If examDescript is blank, then sheets with any description are returned.</summary> public static List <Sheet> GetExamSheetsTable(long patNum, DateTime startDate, DateTime endDate, string examDescript) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <Sheet> >(MethodBase.GetCurrentMethod(), patNum, startDate, endDate, examDescript)); } string command = "SELECT * " + "FROM sheet WHERE IsDeleted=0 " + "AND PatNum=" + POut.Long(patNum) + " " + "AND SheetType=" + POut.Int((int)SheetTypeEnum.ExamSheet) + " "; if (examDescript != "") { command += "AND Description LIKE '%" + POut.String(examDescript) + "%' "; //case insensitive text matches } command += "AND " + DbHelper.DtimeToDate("DateTimeSheet") + ">=" + POut.Date(startDate) + " AND " + DbHelper.DtimeToDate("DateTimeSheet") + "<=" + POut.Date(endDate) + " " + "ORDER BY DateTimeSheet"; return(Crud.SheetCrud.SelectMany(command)); }
///<summary>Gets all task lists for the repeating trunk.</summary> public static List <TaskList> RefreshRepeatingTrunk() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <TaskList> >(MethodBase.GetCurrentMethod())); } string command = "SELECT tasklist.*," + "(SELECT COUNT(*) FROM taskancestor,task WHERE taskancestor.TaskListNum=tasklist.TaskListNum " + "AND task.TaskNum=taskancestor.TaskNum AND task.TaskStatus=0) " //I don't think the repeating trunk would ever track by user, so no special treatment here. //Acutual behavior in both cases needs to be tested. + "FROM tasklist " + "WHERE Parent=0 " + "AND DateTL < " + POut.Date(new DateTime(1880, 01, 01)) + " " + "AND IsRepeating=1 " + "ORDER BY DateTimeEntry"; return(TableToList(Db.GetTable(command))); }
///<summary>Gets all of the customers of the reseller (family members) that have active services. ///Only used from FormResellerEdit to fill the grid.</summary> public static DataTable GetResellerCustomersList(long patNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetTable(MethodBase.GetCurrentMethod(), patNum)); } string command = "SELECT patient.PatNum,RegKey,procedurecode.ProcCode,procedurecode.Descript,resellerservice.Fee,repeatcharge.DateStart,repeatcharge.DateStop,repeatcharge.Note " + "FROM patient " + "INNER JOIN registrationkey ON patient.PatNum=registrationkey.PatNum AND IsResellerCustomer=1 " + "LEFT JOIN repeatcharge ON patient.PatNum=repeatcharge.PatNum " + "LEFT JOIN procedurecode ON repeatcharge.ProcCode=procedurecode.ProcCode " + "LEFT JOIN reseller ON patient.Guarantor=reseller.PatNum OR patient.SuperFamily=reseller.PatNum " + "LEFT JOIN resellerservice ON reseller.ResellerNum=resellerservice.resellerNum AND resellerservice.CodeNum=procedurecode.CodeNum " + "WHERE patient.PatNum!=" + POut.Long(patNum) + " " + "AND (patient.Guarantor=" + POut.Long(patNum) + " OR patient.SuperFamily=" + POut.Long(patNum) + ") " + "ORDER BY registrationkey.RegKey "; return(Db.GetTable(command)); }
///<summary>Supply claimnums. Called from X12 to begin the sorting process on claims going to one clearinghouse.</summary> public static List <X12TransactionItem> GetX12TransactionInfo(List <long> claimNums) //ArrayList queueItemss){ { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <X12TransactionItem> >(MethodBase.GetCurrentMethod(), claimNums)); } StringBuilder str = new StringBuilder(); for (int i = 0; i < claimNums.Count; i++) { if (i > 0) { str.Append(" OR"); } str.Append(" claim.ClaimNum=" + POut.Long(claimNums[i])); //((ClaimSendQueueItem)queueItems[i]).ClaimNum.ToString()); } string command; command = "SELECT carrier.ElectID,claim.ProvBill,inssub.Subscriber," + "claim.PatNum,claim.ClaimNum,CASE WHEN inssub.Subscriber!=claim.PatNum THEN 1 ELSE 0 END AS subscNotPatient " + "FROM claim,insplan,inssub,carrier " + "WHERE claim.PlanNum=insplan.PlanNum " + "AND claim.InsSubNum=inssub.InsSubNum " + "AND carrier.CarrierNum=insplan.CarrierNum " + "AND (" + str.ToString() + ") " + "ORDER BY carrier.ElectID,claim.ProvBill,inssub.Subscriber,subscNotPatient,claim.PatNum"; DataTable table = Db.GetTable(command); List <X12TransactionItem> retVal = new List <X12TransactionItem>(); //object[,] myA=new object[5,table.Rows.Count]; X12TransactionItem item; for (int i = 0; i < table.Rows.Count; i++) { item = new X12TransactionItem(); item.PayorId0 = PIn.String(table.Rows[i][0].ToString()); item.ProvBill1 = PIn.Long(table.Rows[i][1].ToString()); item.Subscriber2 = PIn.Long(table.Rows[i][2].ToString()); item.PatNum3 = PIn.Long(table.Rows[i][3].ToString()); item.ClaimNum4 = PIn.Long(table.Rows[i][4].ToString()); retVal.Add(item); } return(retVal); }
///<summary></summary> public static List <Loinc> GetBySearchString(string searchText) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <Loinc> >(MethodBase.GetCurrentMethod(), searchText)); } string command; if (DataConnection.DBtype == DatabaseType.MySql) { command = "SELECT * FROM loinc WHERE LoincCode LIKE '%" + POut.String(searchText) + "%' OR NameLongCommon LIKE '%" + POut.String(searchText) + "%' ORDER BY RankCommonTests=0, RankCommonTests"; //common tests are at top of list. } else //oracle { command = "SELECT * FROM loinc WHERE LoincCode LIKE '%" + POut.String(searchText) + "%' OR NameLongCommon LIKE '%" + POut.String(searchText) + "%'"; } return(Crud.LoincCrud.SelectMany(command)); }
///<summary></summary> public static void Delete(long medicalOrderNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), medicalOrderNum); return; } string command; //validation command = "SELECT COUNT(*) FROM labpanel WHERE MedicalOrderNum=" + POut.Long(medicalOrderNum); if (Db.GetCount(command) != "0") { throw new ApplicationException(Lans.g("MedicalOrders", "Not allowed to delete a lab order that has attached lab panels.")); } //end of validation command = "DELETE FROM medicalorder WHERE MedicalOrderNum = " + POut.Long(medicalOrderNum); Db.NonQ(command); }
///<summary>Gets all PatientRace entries from the db for the specified patient and includes the non-db fields Description, IsEthnicity, and ///HiearchicalCode.</summary> public static List <PatientRace> GetForPatient(long patNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <PatientRace> >(MethodBase.GetCurrentMethod(), patNum)); } string command = @"SELECT patientrace.*,COALESCE(cdcrec.Description,'') Description, (CASE WHEN cdcrec.HeirarchicalCode LIKE 'E%' THEN 1 ELSE 0 END) IsEthnicity, COALESCE(cdcrec.HeirarchicalCode,'') HeirarchicalCode FROM patientrace LEFT JOIN cdcrec ON cdcrec.CdcrecCode=patientrace.CdcrecCode WHERE PatNum=" + POut.Long(patNum); DataTable table = Db.GetTable(command); List <PatientRace> listPatientRaces = Crud.PatientRaceCrud.TableToList(table); for (int i = 0; i < table.Rows.Count; i++) { switch (listPatientRaces[i].CdcrecCode) { case PatientRace.DECLINE_SPECIFY_RACE_CODE: listPatientRaces[i].Description = Lans.g("PatientRaces", "DECLINED TO SPECIFY"); listPatientRaces[i].IsEthnicity = false; break; case PatientRace.DECLINE_SPECIFY_ETHNICITY_CODE: listPatientRaces[i].Description = Lans.g("PatientRaces", "DECLINED TO SPECIFY"); listPatientRaces[i].IsEthnicity = true; break; case PatientRace.MULTI_RACE_CODE: listPatientRaces[i].Description = Lans.g("PatientRaces", "MULTIRACIAL"); listPatientRaces[i].IsEthnicity = false; break; default: listPatientRaces[i].Description = PIn.String(table.Rows[i]["Description"].ToString()); listPatientRaces[i].IsEthnicity = (table.Rows[i]["IsEthnicity"].ToString() == "1"); listPatientRaces[i].HeirarchicalCode = PIn.String(table.Rows[i]["HeirarchicalCode"].ToString()); break; } } return(listPatientRaces); }
///<summary>Returns the number of payments from the passed in claimpaymentnums that are attached to a deposit other than IgnoreDepositNum.</summary> public static int GetCountAttachedToDeposit(List <long> listClaimPaymentNums, long ignoreDepositNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetInt(MethodBase.GetCurrentMethod(), listClaimPaymentNums, ignoreDepositNum)); } if (listClaimPaymentNums.Count == 0) { return(0); } string command = ""; command = "SELECT COUNT(*) FROM claimpayment WHERE ClaimPaymentNum IN(" + string.Join(",", listClaimPaymentNums) + ") AND DepositNum!=0"; if (ignoreDepositNum != 0) { command += " AND DepositNum!=" + POut.Long(ignoreDepositNum); } return(PIn.Int(Db.GetCount(command))); }
///<summary>Manually sync the database on the lists passed in. This does not check the PKs of the items in either list. ///Instead, it only cares about info in the UserGroupNum and UserNum columns. ///Returns the number of rows that were changed. Currently only used in the CEMT tool.</summary> public static long SyncCEMT(List <UserGroupAttach> listNew, List <UserGroupAttach> listOld) { //This remoting role check isn't necessary but will save on network traffic if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetLong(MethodBase.GetCurrentMethod(), listNew, listOld)); } //the users and usergroups in listNew correspond to UserNumCEMTs and UserGroupNumCEMTs. // - If a row with the same UserGroupNum and UserNum exists in ListNew that does not exist in list Old, add it to listAdd. // - If a row with the same UserGroupNum and UserNum exists in ListOld that does not exist in ListNew, add it to listDel. List <UserGroupAttach> listAdd = new List <UserGroupAttach>(); List <UserGroupAttach> listDel = new List <UserGroupAttach>(); long rowsChanged = 0; foreach (UserGroupAttach userGroupAtt in listNew) { if (!listOld.Exists(x => x.UserGroupNum == userGroupAtt.UserGroupNum && x.UserNum == userGroupAtt.UserNum)) { listAdd.Add(userGroupAtt); } } foreach (UserGroupAttach userGroupAtt in listOld) { if (!listNew.Exists(x => x.UserGroupNum == userGroupAtt.UserGroupNum && x.UserNum == userGroupAtt.UserNum)) { listDel.Add(userGroupAtt); } } //make sure that there is only one unique (UserGroup, UserGroupNum) row in the add list. (this is precautionary) listAdd = listAdd.GroupBy(x => new { x.UserNum, x.UserGroupNum }).Select(x => x.First()).ToList(); foreach (UserGroupAttach userGroupAdd in listAdd) { rowsChanged++; UserGroupAttaches.Insert(userGroupAdd); } foreach (UserGroupAttach userGroupDel in listDel) { rowsChanged++; UserGroupAttaches.Delete(userGroupDel); } return(rowsChanged); }
///<summary>Gets the most recent deleted popups for a single family. If patient is part of a superfamily, it will get all popups for the entire superfamily. </summary> public static List <Popup> GetDeletedForFamily(Patient pat) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <Popup> >(MethodBase.GetCurrentMethod(), pat)); } string command = "SELECT * FROM popup " + "WHERE PatNum IN (SELECT PatNum FROM patient " + "WHERE Guarantor = " + POut.Long(pat.Guarantor) + ") "; if (pat.SuperFamily != 0) //They are part of a super family { command += "OR PatNum IN (SELECT PatNum FROM patient " + "WHERE SuperFamily = " + POut.Long(pat.SuperFamily) + ") "; } command += "AND PopupNumArchive = 0 " //The most recent pop up in the archives. + "ORDER BY PatNum"; return(Crud.PopupCrud.SelectMany(command)); }
///<summary>Gets all AllergyDefs based on hidden status.</summary> public static List <AllergyDef> GetAll(bool isHidden) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <AllergyDef> >(MethodBase.GetCurrentMethod(), isHidden)); } string command = ""; if (!isHidden) { command = "SELECT * FROM allergydef WHERE IsHidden=" + POut.Bool(isHidden) + " ORDER BY Description"; } else { command = "SELECT * FROM allergydef ORDER BY Description"; } return(Crud.AllergyDefCrud.SelectMany(command)); }
///<summary>If the message text is X12, then it always normalizes it to include carriage returns for better readability.</summary> public static string GetMessageText(long etransMessageTextNum, bool isFormattingNeededX12 = true) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetString(MethodBase.GetCurrentMethod(), etransMessageTextNum, isFormattingNeededX12)); } if (etransMessageTextNum == 0) { return(""); } string command = "SELECT MessageText FROM etransmessagetext WHERE EtransMessageTextNum=" + POut.Long(etransMessageTextNum); string msgText = Db.GetScalar(command); if (isFormattingNeededX12) { return(TidyMessageTextX12(msgText)); } return(msgText); }
///<summary>For the ReferralsPatient window. showAll is only used for the referred procs view.</summary> public static List <RefAttach> RefreshFiltered(long patNum, bool showAll, long procNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <RefAttach> >(MethodBase.GetCurrentMethod(), patNum, showAll, procNum)); } string command = "SELECT * FROM refattach " + "WHERE PatNum = " + POut.Long(patNum) + " "; if (procNum != 0) //for procedure { if (!showAll) //hide regular referrals { command += "AND ProcNum=" + POut.Long(procNum) + " "; } } command += "ORDER BY ItemOrder"; return(Crud.RefAttachCrud.SelectMany(command)); }
///<summary>Moves all subscriptions from taskListOld to taskListNew. Used when cutting and pasting a tasklist. Can also be used when deleting a tasklist to remove all subscriptions from the tasklist by sending in 0 as taskListNumNew.</summary> public static void UpdateTaskListSubs(long taskListNumOld, long taskListNumNew) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), taskListNumOld, taskListNumNew); return; } string command = ""; if (taskListNumNew == 0) { command = "DELETE FROM tasksubscription WHERE TaskListNum=" + POut.Long(taskListNumOld); } else { command = "UPDATE tasksubscription SET TaskListNum=" + POut.Long(taskListNumNew) + " WHERE TaskListNum=" + POut.Long(taskListNumOld); } Db.NonQ(command); }
/// <summary> /// Updates the BugSubmissionHash.BugId to the given bugId for all hash rows associated to the given listSubs. /// </summary> public static void UpdateBugIds(List <BugSubmission> listSubs, long bugId, bool useConnectionStore = false) { if (listSubs.IsNullOrEmpty()) { return; } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), listSubs, bugId, useConnectionStore); return; } DataAction.RunBugsHQ(() => { Db.NonQ($@" UPDATE bugsubmissionhash SET BugId={POut.Long(bugId)} WHERE BugSubmissionHashNum IN({string.Join(",",listSubs.Select(x => POut.Long(x.BugSubmissionHashNum)))})" ); }, useConnectionStore); }