Beispiel #1
0
        private void butMerge_Click(object sender, EventArgs e)
        {
            string differentFields = "";
            string msgText         = "";

            if (textMedNumInto.Text == textMedNumFrom.Text)
            {
                //do not attempt a merge if the same medication was selected twice, or if one of the fields is blank.
                MsgBox.Show(this, "You must select two different medications to merge.");
                return;
            }
            if (_medFrom.MedicationNum == _medFrom.GenericNum && _medInto.MedicationNum != _medInto.GenericNum)
            {
                msgText = Lan.g(this, "You may not merge a generic medication into a brand") + ".  " +
                          Lan.g(this, "Select the generic version of the medication to merge into instead") + ".";
                MessageBox.Show(msgText);
                return;
            }
            if (textMedNameFrom.Text != textMedNameInto.Text)
            {
                differentFields += "\r\n" + Lan.g(this, "Medication Name");
            }
            if (textGenNumFrom.Text != textGenNumInto.Text)
            {
                differentFields += "\r\n" + Lan.g(this, "GenericNum");
            }
            if (textRxFrom.Text != textRxInto.Text)
            {
                differentFields += "\r\n" + Lan.g(this, "RxCui");
            }
            long numPats = Medications.CountPats(_medFrom.MedicationNum);

            if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Are you sure?  The results are permanent and cannot be undone."))
            {
                return;
            }
            msgText = "";
            if (differentFields != "")
            {
                msgText = Lan.g(this, "The following medication fields do not match") + ": " + differentFields + "\r\n";
            }
            msgText += Lan.g(this, "This change is irreversible") + ".  " + Lan.g(this, "This medication is assigned to") + " " + numPats + " "
                       + Lan.g(this, "patients") + ".  " + Lan.g(this, "Continue anyways?");
            if (MessageBox.Show(msgText, "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            long   rowsChanged = Medications.Merge(_medFrom.MedicationNum, _medInto.MedicationNum);
            string logText     = Lan.g(this, "Medications merged") + ": " + _medFrom.MedName + " " + Lan.g(this, "merged into") + " " + _medInto.MedName + ".\r\n"
                                 + Lan.g(this, "Rows changed") + ": " + POut.Long(rowsChanged);

            SecurityLogs.MakeLogEntry(Permissions.MedicationMerge, 0, logText);
            textRxFrom.Clear();
            textMedNumFrom.Clear();
            textMedNameFrom.Clear();
            textGenNumFrom.Clear();
            MsgBox.Show(this, "Done.");
            DataValid.SetInvalid(InvalidType.Medications);
            CheckUIState();
        }