Beispiel #1
0
 public static ODTuple <long, DateTime> GetODTuple(ODTuple <long, DateTime> odTuple)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetObject <ODTuple <long, DateTime> >(MethodBase.GetCurrentMethod(), odTuple));
     }
     return(odTuple);
 }
Beispiel #2
0
        ///<summary>Inserts the given medNew.
        ///Given medGennamePair is a medication that we are checking and the given generic name if set.
        ///ListMedsExisting is used to identify the GenericNum for medNew.</summary>
        private static void InsertNewMed(ODTuple <Medication, string> medGenNamePair, List <Medication> listMedsExisting)
        {
            Medication medNew      = medGenNamePair.Item1;
            string     genericName = medGenNamePair.Item2;
            long       genNum      = listMedsExisting.FirstOrDefault(x => x.MedName == genericName)?.MedicationNum ?? 0;

            if (genNum != 0)           //Found a match.
            {
                medNew.GenericNum = genNum;
            }
            Medications.Insert(medNew); //Assigns new primary key.
            if (genNum == 0)            //Found no match initially, assume given medication is the generic.
            {
                medNew.GenericNum = medNew.MedicationNum;
                Medications.Update(medNew);
            }
            listMedsExisting.Add(medNew);            //Keep in memory list and database in sync.
        }
Beispiel #3
0
        ///<summary>Determines if med is a duplicate of another Medication in listMedsExisting.
        ///Given medGenNamePair is a medication that we are checking and the given generic name if set.
        ///A duplicate is defined as MedName is equal, GenericName is equal, RxCui is equal and either Notes is equal or not defined.
        ///A new medication with all properties being equal to an existing medication except with a blank Notes property is considered to be a
        ///duplicate, as it is likely the existing Medication is simply a user edited version of the same Medication.</summary>
        private static bool IsDuplicateMed(ODTuple <Medication, string> medGenNamePair, List <Medication> listMedsExisting)
        {
            Medication med           = medGenNamePair.Item1;
            string     genericName   = medGenNamePair.Item2;
            bool       isNoteChecked = true;

            //If everything is identical, except med.Notes is blank while x.Notes is not blank, we consider this to be a duplicate.
            if (string.IsNullOrEmpty(med.Notes))
            {
                isNoteChecked = false;
            }
            return(listMedsExisting.Any(
                       x => x.MedName.Trim().ToLower() == med.MedName.Trim().ToLower() &&
                       Medications.GetGenericName(x.GenericNum).Trim().ToLower() == genericName.Trim().ToLower() &&
                       x.RxCui == med.RxCui &&
                       (isNoteChecked ? (x.Notes.Trim().ToLower() == med.Notes.Trim().ToLower()) : true)
                       ));
        }
        public void ProcMultiVisitTests_CrownGroupComplete_ClaimDates()
        {
            string           suffix       = MethodBase.GetCurrentMethod().Name;
            Patient          pat          = PatientT.CreatePatient(suffix);
            InsuranceInfo    insInfo      = InsuranceT.AddInsurance(pat, suffix);
            List <Procedure> listProcs    = new List <Procedure>();
            Procedure        procBillable = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.TP, "1", 100, new DateTime(2018, 5, 1));//PFM

            listProcs.Add(procBillable);
            Procedure procDelivery = ProcedureT.CreateProcedure(pat, "N4118", ProcStat.TP, "1", 0, new DateTime(2018, 8, 20));   //Seat - usually completed several months later.

            listProcs.Add(procDelivery);
            List <ClaimProc> listClaimProcs = ProcedureT.ComputeEstimates(pat, insInfo);

            ProcMultiVisits.CreateGroup(listProcs);
            Procedure procBillableOld = procBillable.Copy();

            procBillable.ProcStatus = ProcStat.C;
            Procedures.Update(procBillable, procBillableOld);
            Procedure procDeliveryOld = procDelivery.Copy();

            procDelivery.ProcStatus = ProcStat.C;
            Procedures.Update(procDelivery, procDeliveryOld);
            Assert.AreEqual(ProcMultiVisits.IsProcInProcess(procBillable.ProcNum), false);           //Both procedures complete means the group is now complete (not In Process).
            Assert.AreEqual(ProcMultiVisits.IsProcInProcess(procDelivery.ProcNum), false);           //Both procedures complete means the group is now complete (not In Process).
            Claim claim = new Claim();

            claim.DateSent     = DateTimeOD.Today;
            claim.DateSentOrig = DateTime.MinValue;
            claim.ClaimStatus  = "W";
            //Dates of service are calculated inside AccountModules.CreateClaim().
            //The procDelivery cannot be attached to the claim in the UI, because $0 procs are blocked by UI.  Therefore, we only attach the procBilled to the claim here.
            ODTuple <bool, Claim, string> clmResult = AccountModules.CreateClaim(claim, "P", insInfo.ListPatPlans, insInfo.ListInsPlans, listClaimProcs, listProcs,
                                                                                 insInfo.ListInsSubs, pat, null, new List <Procedure> {
                procBillable
            }, "", insInfo.PriInsPlan, insInfo.PriInsSub, Relat.Self);

            Assert.AreEqual(clmResult.Item3, "");                                //Ensure no validation errors creating the claim.  This is to verify the integrity of the unit test design.
            Assert.AreEqual(clmResult.Item2.DateService, procDelivery.ProcDate); //Claim date of service must always be the greatest date in the multi visit group.
            listClaimProcs = ClaimProcs.RefreshForClaim(clmResult.Item2.ClaimNum);
            Assert.AreEqual(listClaimProcs[0].ProcDate, procDelivery.ProcDate);  //Proc date of service must always be the greatest date in the multi visit group, even if performed on a different day.
        }
        private void Run(DbmMode modeCur)
        {
            if (_patNum < 1)
            {
                MsgBox.Show(this, "Select a patient first.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            //Clear out the result column for all rows before every "run"
            for (int i = 0; i < gridMain.Rows.Count; i++)
            {
                gridMain.Rows[i].Cells[2].Text = "";              //Don't use UpdateResultTextForRow here because users will see the rows clearing out one by one.
            }
            bool          verbose = checkShow.Checked;
            StringBuilder logText = new StringBuilder();
            //Create a thread that will show a window and then stay open until the closing phrase is thrown from this form.
            Action actionCloseCheckTableProgress    = ODProgressOld.ShowProgressStatus("CheckTableProgress", this);
            ODTuple <string, bool> tableCheckResult = DatabaseMaintenances.MySQLTables(verbose, modeCur);

            actionCloseCheckTableProgress();
            logText.Append(tableCheckResult.Item1);
            //No database maintenance methods should be run unless this passes.
            if (!tableCheckResult.Item2)
            {
                Cursor = Cursors.Default;
                MsgBoxCopyPaste msgBoxCP = new MsgBoxCopyPaste(tableCheckResult.Item1); //the Tuples result is already translated.
                msgBoxCP.Show();                                                        //Let this window be non-modal so that they can keep it open while they fix their problems.
                return;
            }
            if (gridMain.SelectedIndices.Length < 1)
            {
                //No rows are selected so the user wants to run all checks.
                gridMain.SetSelected(true);
            }
            string result;

            int[] selectedIndices = gridMain.SelectedIndices;
            for (int i = 0; i < selectedIndices.Length; i++)
            {
                long          userNum          = 0;
                DbmMethodAttr methodAttributes = (DbmMethodAttr)Attribute.GetCustomAttribute(_listDbmMethodsGrid[selectedIndices[i]], typeof(DbmMethodAttr));
                //We always send verbose and modeCur into all DBM methods.
                List <object> parameters = new List <object>()
                {
                    verbose, modeCur
                };
                //There are optional paramaters available to some methods and adding them in the following order is very important.
                if (methodAttributes.HasUserNum)
                {
                    parameters.Add(userNum);
                }
                if (methodAttributes.HasPatNum)
                {
                    parameters.Add(_patNum);
                }
                gridMain.ScrollToIndexBottom(selectedIndices[i]);
                UpdateResultTextForRow(selectedIndices[i], Lan.g("FormDatabaseMaintenance", "Running") + "...");
                try {
                    result = (string)_listDbmMethodsGrid[selectedIndices[i]].Invoke(null, parameters.ToArray());
                    if (modeCur == DbmMode.Fix)
                    {
                        DatabaseMaintenances.UpdateDateLastRun(_listDbmMethodsGrid[selectedIndices[i]].Name);
                    }
                }
                catch (Exception ex) {
                    if (ex.InnerException != null)
                    {
                        ExceptionDispatchInfo.Capture(ex.InnerException).Throw();                        //This preserves the stack trace of the InnerException.
                    }
                    throw;
                }
                string status = "";
                if (result == "")               //Only possible if running a check / fix in non-verbose mode and nothing happened or needs to happen.
                {
                    status = Lan.g("FormDatabaseMaintenance", "Done.  No maintenance needed.");
                }
                UpdateResultTextForRow(selectedIndices[i], result + status);
                logText.Append(result);
            }
            gridMain.SetSelected(selectedIndices, true);           //Reselect all rows that were originally selected.
            try {
                DatabaseMaintenances.SaveLogToFile(logText.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
            }
            Cursor = Cursors.Default;
            if (modeCur == DbmMode.Fix)
            {
                //_isCacheInvalid=true;//Flag cache to be invalidated on closing.  Some DBM fixes alter cached tables.
            }
        }