示例#1
0
        private void FormSnomeds_Load(object sender, EventArgs e)
        {
            _showingInfoButton      = CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton;
            _showingInfobuttonShift = (_showingInfoButton?1:0);
            if (IsSelectionMode || IsMultiSelectMode)
            {
                butClose.Text = Lan.g(this, "Cancel");
            }
            else
            {
                butOK.Visible = false;
            }
            if (IsMultiSelectMode)
            {
                gridMain.SelectionMode = GridSelectionMode.MultiExtended;
            }
            ActiveControl = textCode;
            //This check is here to prevent Snomeds from being used in non-member nations.
            List <EhrQuarterlyKey> ehrKeys = EhrQuarterlyKeys.GetAllKeys();

            groupBox1.Visible = false;
            for (int i = 0; i < ehrKeys.Count; i++)
            {
                if (FormEHR.QuarterlyKeyIsValid(ehrKeys[i].YearValue.ToString(), ehrKeys[i].QuarterValue.ToString(), ehrKeys[i].PracticeName, ehrKeys[i].KeyValue))
                {
                    //EHR has been valid.
                    groupBox1.Visible = true;
                    break;
                }
            }
        }
示例#2
0
 private void FormEhrTriggerEdit_Load(object sender, EventArgs e)
 {
     if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).EditBibliography)
     {
         textBibliography.Enabled = false;
         textInstruction.Enabled  = false;
     }
     textDescription.Text  = EhrTriggerCur.Description;
     textBibliography.Text = EhrTriggerCur.Bibliography;
     textInstruction.Text  = EhrTriggerCur.Instructions;
     FillComboCardinality();
     FillGrid();
 }
示例#3
0
 private void FormEhrTriggers_Load(object sender, EventArgs e)
 {
     mainMenu1.MenuItems[0].Enabled = false;
     butAddTrigger.Enabled          = false;
     gridMain.Enabled = false;
     if (CDSPermissions.GetForUser(Security.CurUser.UserNum).SetupCDS || Security.IsAuthorized(Permissions.SecurityAdmin, true))
     {
         mainMenu1.MenuItems[0].Enabled = true;
         butAddTrigger.Enabled          = true;
         gridMain.Enabled = true;
     }
     FillGrid();
 }
 private void butSave_Click(object sender, EventArgs e)
 {
     if (PatCur == null)
     {
         MsgBox.Show(this, "Please attach to patient first.");
         return;
     }
     //Check lab dates to see if these labs already exist.
     for (int i = 0; i < ListEhrLabs.Count; i++)
     {
         EhrLab tempLab = null;              //lab from DB if it exists.
         tempLab = EhrLabs.GetByGUID(ListEhrLabs[i].PlacerOrderUniversalID, ListEhrLabs[i].PlacerOrderNum);
         if (tempLab == null)
         {
             tempLab = EhrLabs.GetByGUID(ListEhrLabs[i].FillerOrderUniversalID, ListEhrLabs[i].FillerOrderNum);
         }
         if (tempLab != null)
         {
             //validate Date of Lab and attached patient.
             //Date
             if (tempLab.ResultDateTime.CompareTo(ListEhrLabs[i].ResultDateTime) < 0)                   //string compare dates will return 1+ if tempLab Date is greater.
             {
                 MsgBox.Show(this, "This lab already exists in the database and has a more recent timestamp.");
                 continue;
             }
             if (PatCur.PatNum != tempLab.PatNum)
             {
                 //do nothing. We are importing an updated lab result and the previous lab result was attached to the wrong patient.
                 //or do something. later maybe.
             }
         }
         ListEhrLabs[i].PatNum = PatCur.PatNum;
         Provider prov = Providers.GetProv(Security.CurUser.ProvNum);
         if (Security.CurUser.ProvNum != 0 && EhrProvKeys.GetKeysByFLName(prov.LName, prov.FName).Count > 0)            //The user who is currently logged in is a provider and has a valid EHR key.
         {
             ListEhrLabs[i].IsCpoe = true;
         }
         ListEhrLabs[i] = EhrLabs.SaveToDB(ListEhrLabs[i]);               //SAVE
         for (int j = 0; j < ListEhrLabs[i].ListEhrLabResults.Count; j++) //EHR TRIGGER
         {
             if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
             {
                 FormCDSIntervention FormCDSI = new FormCDSIntervention();
                 FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(ListEhrLabs[i].ListEhrLabResults[j], PatCur);
                 FormCDSI.ShowIfRequired(false);
             }
         }
     }
     DialogResult = DialogResult.OK;
     //Done!
 }
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)
            {
                return;
            }
            if (e.Col != 0)
            {
                return;                //not infobutton column
            }
            FormInfobutton FormIB = new FormInfobutton((List <KnowledgeRequest>)gridMain.ListGridRows[e.Row].Tag);

            FormIB.ShowDialog();
        }
示例#6
0
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)             //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
            {
                return;
            }
            if (e.Col != 0)
            {
                return;
            }
            List <KnowledgeRequest> listKnowledgeRequests = EhrTriggers.ConvertToKnowledgeRequests(Snomeds.GetByCode(gridMain.Rows[e.Row].Cells[1].Text));
            FormInfobutton          FormIB = new FormInfobutton(listKnowledgeRequests);

            FormIB.ShowDialog();
        }
示例#7
0
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)             //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
            {
                return;
            }
            if (e.Col != 0)
            {
                return;
            }
            FormInfobutton FormIB = new FormInfobutton();

            FormIB.ListObjects.Add(Snomeds.GetByCode(gridMain.Rows[e.Row].Cells[1].Text));
            FormIB.ShowDialog();
        }
示例#8
0
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)             //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
            {
                return;
            }
            if (e.Col != 0)
            {
                return;
            }
            List <KnowledgeRequest> listKnowledgeRequests = EhrTriggers.ConvertToKnowledgeRequests(EhrLabCur.ListEhrLabResults[e.Row]);
            FormInfobutton          FormIB = new FormInfobutton(listKnowledgeRequests);

            //if(PatCurNum>0) {
            //	FormIB.PatCur=Patients.GetPat(PatCurNum);
            //}
            FormIB.ShowDialog();
        }
示例#9
0
 private void butOk_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < _listCdsPermissions.Count; i++)
     {
         //TODO:instead of updating all permissions. Update only the permissions neccesary.
         if (_listCdsPermissions[i].UserNum != _listCdsPermissionsOld[i].UserNum)
         {
                                 #if DEBUG
             throw new Exception("If this ever happens, something went wrong. We can explicitly loop through both lists and match patnums.");
                                 #else
             continue;                            //should never happen, but userNums were mismatched.
                                 #endif
         }
         if (_listCdsPermissions[i].SetupCDS == _listCdsPermissionsOld[i].SetupCDS &&
             _listCdsPermissions[i].ShowCDS == _listCdsPermissionsOld[i].ShowCDS &&
             _listCdsPermissions[i].ShowInfobutton == _listCdsPermissionsOld[i].ShowInfobutton &&
             _listCdsPermissions[i].EditBibliography == _listCdsPermissionsOld[i].EditBibliography &&
             _listCdsPermissions[i].ProblemCDS == _listCdsPermissionsOld[i].ProblemCDS &&
             _listCdsPermissions[i].MedicationCDS == _listCdsPermissionsOld[i].MedicationCDS &&
             _listCdsPermissions[i].AllergyCDS == _listCdsPermissionsOld[i].AllergyCDS &&
             _listCdsPermissions[i].DemographicCDS == _listCdsPermissionsOld[i].DemographicCDS &&
             _listCdsPermissions[i].LabTestCDS == _listCdsPermissionsOld[i].LabTestCDS &&
             _listCdsPermissions[i].VitalCDS == _listCdsPermissionsOld[i].VitalCDS)
         {
             continue;                    //nothing to change.
         }
         CDSPermissions.Update(_listCdsPermissions[i]);
         //The following line of code should never be re-ordered, only added to if needed.  Otherwise historical security logs may not be enterpreted correctly.
         string cdsLog = "CDSPermChanged,U:" + _listCdsPermissions[i].UserNum + ","
                         + (_listCdsPermissions[i].SetupCDS                                               ?"T":"F")
                         + (_listCdsPermissions[i].ShowCDS                                                ?"T":"F")
                         + (_listCdsPermissions[i].ShowInfobutton                 ?"T":"F")
                         + (_listCdsPermissions[i].EditBibliography               ?"T":"F")
                         + (_listCdsPermissions[i].ProblemCDS                                     ?"T":"F")
                         + (_listCdsPermissions[i].MedicationCDS                  ?"T":"F")
                         + (_listCdsPermissions[i].AllergyCDS                                     ?"T":"F")
                         + (_listCdsPermissions[i].DemographicCDS                 ?"T":"F")
                         + (_listCdsPermissions[i].LabTestCDS                                     ?"T":"F")
                         + (_listCdsPermissions[i].VitalCDS                                               ?"T":"F")
         ;
         SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, cdsLog);              //Log entry example: CDSPermChanged,33,TTTFFFFFF
     }
     DialogResult = DialogResult.OK;
 }
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)             //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
            {
                return;
            }
            if (e.Col != 0)
            {
                return;
            }
            FormInfobutton FormIB = new FormInfobutton();

            if (PatCurNum != null && PatCurNum > 0)
            {
                FormIB.PatCur = Patients.GetPat(PatCurNum);
            }
            FormIB.ListObjects.Add(EhrLabCur.ListEhrLabResults[e.Row]);
            FormIB.ShowDialog();
        }
示例#11
0
        private void FormSnomeds_Load(object sender, EventArgs e)
        {
            _showingInfoButton      = CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton;
            _showingInfobuttonShift = (_showingInfoButton?1:0);
            if (IsSelectionMode || IsMultiSelectMode)
            {
                butClose.Text = Lan.g(this, "Cancel");
            }
            else
            {
                butOK.Visible = false;
            }
            if (IsMultiSelectMode)
            {
                gridMain.SelectionMode = GridSelectionMode.MultiExtended;
            }
            ActiveControl = textCode;
            //This check is here to prevent Snomeds from being used in non-member nations.
            groupBox1.Visible = false;
            Provider prov = Providers.GetProv(Security.CurUser.ProvNum);

            if (prov == null)
            {
                return;
            }
            string            ehrKey       = "";
            int               yearValue    = 0;
            List <EhrProvKey> listProvKeys = EhrProvKeys.GetKeysByFLName(prov.LName, prov.FName);

            if (listProvKeys.Count != 0)
            {
                ehrKey    = listProvKeys[0].ProvKey;
                yearValue = listProvKeys[0].YearValue;
            }
            if (FormEHR.ProvKeyIsValid(prov.LName, prov.FName, yearValue, ehrKey))
            {
                //EHR has been valid.
                groupBox1.Visible = true;
            }
        }
示例#12
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormEhrLabOrderEdit2014 FormLOE = new FormEhrLabOrderEdit2014();

            FormLOE.EhrLabCur        = new EhrLab();
            FormLOE.EhrLabCur.PatNum = PatCur.PatNum;
            FormLOE.IsNew            = true;
            FormLOE.ShowDialog();
            if (FormLOE.DialogResult != DialogResult.OK)
            {
                return;
            }
            EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();

            newMeasureEvent.DateTEvent = DateTime.Now;
            newMeasureEvent.EventType  = EhrMeasureEventType.CPOE_LabOrdered;         //default
            Loinc loinc = Loincs.GetByCode(FormLOE.EhrLabCur.UsiID);

            if (loinc != null && loinc.ClassType == "RAD")         //short circuit logic
            {
                newMeasureEvent.EventType = EhrMeasureEventType.CPOE_RadOrdered;
            }
            newMeasureEvent.PatNum   = FormLOE.EhrLabCur.PatNum;
            newMeasureEvent.MoreInfo = "";
            newMeasureEvent.FKey     = FormLOE.EhrLabCur.EhrLabNum;
            EhrMeasureEvents.Insert(newMeasureEvent);
            EhrLabs.SaveToDB(FormLOE.EhrLabCur);
            for (int i = 0; i < FormLOE.EhrLabCur.ListEhrLabResults.Count; i++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
                {
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(FormLOE.EhrLabCur.ListEhrLabResults[i], PatCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            FillGrid();
        }
示例#13
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)
            {
                col           = new ODGridColumn("", 18);   //infobutton
                col.ImageList = imageListInfoButton;
                gridMain.Columns.Add(col);
            }
            col = new ODGridColumn("Conditions", 300);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Instructions", 400);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Bibliography", 120);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < _table.Rows.Count; i++)
            {
                row = new ODGridRow();
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)
                {
                    row.Cells.Add(_table.Rows[i][0].ToString());        //infobutton
                }
                row.Cells.Add(_table.Rows[i][1].ToString());            //Trigger Text
                row.Cells.Add(_table.Rows[i][2].ToString());            //TriggerInstructions
                row.Cells.Add(_table.Rows[i][3].ToString());            //Bibliography
                row.Tag = (List <object>)_table.Rows[i][4];             //List of objects to be sent to FormInfobutton;
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
示例#14
0
        private void butImport_Click(object sender, EventArgs e)
        {
            MsgBoxCopyPaste MBCP = new MsgBoxCopyPaste("Paste HL7 Lab Message Text Here.");

            MBCP.textMain.SelectAll();
            MBCP.ShowDialog();
            if (MBCP.DialogResult != DialogResult.OK)
            {
                return;
            }
            List <EhrLab> listEhrLabs;

            try {
                listEhrLabs = EhrLabs.ProcessHl7Message(MBCP.textMain.Text); //Not a typical use of the msg box copy paste
                if (listEhrLabs[0].PatNum == PatCur.PatNum)                  //only need to check the first lab.
                //nothing to do here. Imported lab matches the current patient.
                {
                }
                else                 //does not match current patient, redirect to import form which displays patient information and is build for importing.
                {
                    FormEhrLabOrderImport FormLOI = new FormEhrLabOrderImport();
                    FormLOI.PatCur        = PatCur;
                    FormLOI.Hl7LabMessage = MBCP.textMain.Text;
                    FormLOI.ShowDialog();
                    FillGrid();
                    return;
                }
                //else if(listEhrLabs[0].PatNum==0) {
                //	if(MessageBox.Show("Lab patient does not match current patient. Lab patient name is "
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//first name
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//last name
                //		+"\r\nWould you like to import lab for the current patient?","",MessageBoxButtons.OKCancel)!=DialogResult.OK)
                //	{
                //		return;
                //	}
                //	//User agreed to import current lab(s) for current patient.
                //	for(int i=0;i<listEhrLabs.Count;i++) {
                //		listEhrLabs[i].PatNum=PatCur.PatNum;
                //		//TODO: Import external OIDs and PatIDs so that we can identify this patient next time.
                //	}
                //}
                //else {//Patnum is already associated with another patient.
                //	MessageBox.Show("This lab contains patient information for a different patient. Lab patient name is "
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//first name
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]);
                //	return;
                //}
            }
            catch (Exception Ex) {
                MessageBox.Show(this, "Unable to import lab.\r\n" + Ex.Message);
                return;
            }
            for (int i = 0; i < listEhrLabs.Count; i++)
            {
                EhrLab tempLab = null;              //lab from DB if it exists.
                tempLab = EhrLabs.GetByGUID(listEhrLabs[i].PlacerOrderUniversalID, listEhrLabs[i].PlacerOrderNum);
                if (tempLab == null)
                {
                    tempLab = EhrLabs.GetByGUID(listEhrLabs[i].FillerOrderUniversalID, listEhrLabs[i].FillerOrderNum);
                }
                if (tempLab != null)
                {
                    //Date validation.
                    //if(tempLab.ResultDateTime.CompareTo(listEhrLabs[i].ResultDateTime)<=0) {//string compare dates will return 1+ if tempLab Date is greater.
                    //	MsgBox.Show(this,"This lab already exists in the database and has a more recent timestamp.");
                    //	continue;
                    //}
                    //TODO: The code above works, but ignores more recent lab results. Although the lab order my be unchanged there may be updated lab results.
                    //It would be better to check for updated results, unfortunately results have no unique identifiers.
                }
                Provider prov = Providers.GetProv(Security.CurUser.ProvNum);
                if (Security.CurUser.ProvNum != 0 && EhrProvKeys.GetKeysByFLName(prov.LName, prov.FName).Count > 0)            //The user who is currently logged in is a provider and has a valid EHR key.
                {
                    ListEhrLabs[i].IsCpoe = true;
                }
                listEhrLabs[i] = EhrLabs.SaveToDB(listEhrLabs[i]);               //SAVE
                for (int j = 0; j < listEhrLabs[i].ListEhrLabResults.Count; j++) //EHR TRIGGER
                {
                    if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
                    {
                        FormCDSIntervention FormCDSI = new FormCDSIntervention();
                        FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(listEhrLabs[i].ListEhrLabResults[j], PatCur);
                        FormCDSI.ShowIfRequired(false);
                    }
                }
            }
            FillGrid();
        }
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listProblemReconcile.Count == 0)
            {
                if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing problems to be removed.  Continue?"))
                {
                    return;
                }
            }
            Disease    dis;
            DiseaseDef disD;
            bool       isActive;

            //Discontinue any current medications that are not present in the reconcile list.
            for (int i = 0; i < _listProblemCur.Count; i++)       //Start looping through all current problems
            {
                isActive = false;
                dis      = _listProblemCur[i];
                disD     = DiseaseDefs.GetItem(dis.DiseaseDefNum);
                for (int j = 0; j < _listProblemReconcile.Count; j++)           //Compare each reconcile problem to the current problem
                {
                    DiseaseDef disDR = DiseaseDefs.GetItem(_listProblemReconcile[j].DiseaseDefNum);
                    if (_listProblemReconcile[j].DiseaseDefNum == _listProblemCur[i].DiseaseDefNum)                   //Has identical DiseaseDefNums
                    {
                        isActive = true;
                        break;
                    }
                    if (disDR == null)
                    {
                        continue;
                    }
                    if (disDR.SnomedCode != "" && disDR.SnomedCode == disD.SnomedCode)                 //Has a Snomed code and they are equal
                    {
                        isActive = true;
                        break;
                    }
                }
                if (!isActive)                 //Update current problems.
                {
                    dis.ProbStatus = ProblemStatus.Inactive;
                    Diseases.Update(_listProblemCur[i]);
                }
            }
            //Always update every current problem for the patient so that DateTStamp reflects the last reconcile date.
            if (_listProblemCur.Count > 0)
            {
                Diseases.ResetTimeStamps(_patCur.PatNum, ProblemStatus.Active);
            }
            DiseaseDef disDU = null;
            int        index;

            for (int j = 0; j < _listProblemReconcile.Count; j++)
            {
                index = ListProblemNew.IndexOf(_listProblemReconcile[j]);
                if (index < 0)
                {
                    continue;
                }
                if (_listProblemReconcile[j] == ListProblemNew[index])
                {
                    disDU = DiseaseDefs.GetItem(DiseaseDefs.GetNumFromCode(ListProblemDefNew[index].SnomedCode));
                    if (disDU == null)
                    {
                        ListProblemNew[index].DiseaseDefNum = DiseaseDefs.Insert(ListProblemDefNew[index]);
                    }
                    else
                    {
                        ListProblemNew[index].DiseaseDefNum = disDU.DiseaseDefNum;
                    }
                    Diseases.Insert(ListProblemNew[index]);
                }
            }
            DataValid.SetInvalid(InvalidType.Diseases);
            //EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
            //newMeasureEvent.DateTEvent=DateTime.Now;
            //newMeasureEvent.EventType=EhrMeasureEventType.ProblemReconcile;
            //newMeasureEvent.PatNum=PatCur.PatNum;
            //newMeasureEvent.MoreInfo="";
            //EhrMeasureEvents.Insert(newMeasureEvent);
            for (int inter = 0; inter < _listProblemReconcile.Count; inter++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).ProblemCDS)
                {
                    DiseaseDef          disDInter = DiseaseDefs.GetItem(_listProblemReconcile[inter].DiseaseDefNum);
                    FormCDSIntervention FormCDSI  = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(disDInter, _patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }
        private void butOk_Click(object sender, EventArgs e)
        {
            if (IsImport || IsViewOnly)
            {
                DialogResult = DialogResult.OK;
                return;
            }
            if (!EntriesAreValid())
            {
                return;
            }
            if (Security.CurUser.ProvNum != 0 && Providers.GetProv(Security.CurUser.ProvNum).EhrKey != "")         //The user who is currently logged in is a provider and has a valid EHR key.
            {
                EhrLabCur.IsCpoe = true;
            }
            if (EhrLabCur.PatNum == 0 && PatCurNum != null)
            {
                EhrLabCur.PatNum = PatCurNum;
            }
            //EhrLabCur.OrderControlCode=((HL70119)comb);//TODO:UI and this value.
            if (checkAutoID.Checked)
            {
                EhrLabCur.PlacerOrderNum             = EhrLabs.GetNextOrderNum().ToString();
                EhrLabCur.PlacerOrderNamespace       = "";
                EhrLabCur.PlacerOrderUniversalID     = OIDInternals.GetForType(IdentifierType.LabOrder).IDRoot;
                EhrLabCur.PlacerOrderUniversalIDType = "ISO";
            }
            else
            {
                EhrLabCur.PlacerOrderNum             = textPlacerOrderNum.Text;
                EhrLabCur.PlacerOrderNamespace       = textPlacerOrderNamespace.Text;
                EhrLabCur.PlacerOrderUniversalID     = textPlacerOrderUniversalID.Text;
                EhrLabCur.PlacerOrderUniversalIDType = textPlacerOrderUniversalIDType.Text;
            }
            EhrLabCur.FillerOrderNum              = textFillerOrderNum.Text;
            EhrLabCur.FillerOrderNamespace        = textFillerOrderNamespace.Text;
            EhrLabCur.FillerOrderUniversalID      = textFillerOrderUniversalID.Text;
            EhrLabCur.FillerOrderUniversalIDType  = textFillerOrderUniversalIDType.Text;
            EhrLabCur.PlacerGroupNum              = textPlacerGroupNum.Text;
            EhrLabCur.PlacerGroupNamespace        = textPlacerGroupNamespace.Text;
            EhrLabCur.PlacerGroupUniversalID      = textPlacerGroupUniversalID.Text;
            EhrLabCur.PlacerGroupUniversalIDType  = textPlacerGroupUniversalIDType.Text;
            EhrLabCur.OrderingProviderID          = textOrderingProvIdentifier.Text;
            EhrLabCur.OrderingProviderLName       = textOrderingProvLastName.Text;
            EhrLabCur.OrderingProviderFName       = textOrderingProvFirstName.Text;
            EhrLabCur.OrderingProviderMiddleNames = textOrderingProvMiddleName.Text;
            EhrLabCur.OrderingProviderSuffix      = textOrderingProvSuffix.Text;
            EhrLabCur.OrderingProviderPrefix      = textOrderingProvPrefix.Text;
            EhrLabCur.OrderingProviderAssigningAuthorityNamespaceID = textOrderingProvAANID.Text;
            EhrLabCur.OrderingProviderAssigningAuthorityUniversalID = textOrderingProvAAUID.Text;
            EhrLabCur.OrderingProviderAssigningAuthorityIDType      = textOrderingProvAAUIDType.Text;
            EhrLabCur.OrderingProviderNameTypeCode       = ((HL70200)comboOrderingProvNameType.SelectedIndex - 1);
            EhrLabCur.OrderingProviderIdentifierTypeCode = ((HL70203)comboOrderingProvIdType.SelectedIndex - 1);
            //EhrLabCur.SetIdOBR=PIn.Long("");//TODO: UI and Save
            EhrLabCur.UsiID                    = textUsiID.Text;
            EhrLabCur.UsiText                  = textUsiText.Text;
            EhrLabCur.UsiCodeSystemName        = textUsiCodeSystemName.Text;
            EhrLabCur.UsiIDAlt                 = textUsiIDAlt.Text;
            EhrLabCur.UsiTextAlt               = textUsiTextAlt.Text;
            EhrLabCur.UsiCodeSystemNameAlt     = textUsiCodeSystemNameAlt.Text;
            EhrLabCur.UsiTextOriginal          = textUsiTextOriginal.Text;
            EhrLabCur.ObservationDateTimeStart = EhrLab.formatDateToHL7(textObservationDateTimeStart.Text.Trim());
            EhrLabCur.ObservationDateTimeEnd   = EhrLab.formatDateToHL7(textObservationDateTimeEnd.Text.Trim());
            EhrLabCur.SpecimenActionCode       = ((HL70065)comboSpecimenActionCode.SelectedIndex - 1);
            EhrLabCur.ResultDateTime           = EhrLab.formatDateToHL7(textResultDateTime.Text.Trim());//upper right hand corner of form.
            EhrLabCur.ResultStatus             = ((HL70123)comboResultStatus.SelectedIndex - 1);
            //TODO: parent result.

            /*
             * EhrLabCur.ParentObservationID=
             * EhrLabCur.ParentObservationText=
             * EhrLabCur.ParentObservationCodeSystemName=
             * EhrLabCur.ParentObservationIDAlt=
             * EhrLabCur.ParentObservationTextAlt=
             * EhrLabCur.ParentObservationCodeSystemNameAlt=
             * EhrLabCur.ParentObservationTextOriginal=
             * EhrLabCur.ParentObservationSubID=
             * EhrLabCur.ParentPlacerOrderNum=
             * EhrLabCur.ParentPlacerOrderNamespace=
             * EhrLabCur.ParentPlacerOrderUniversalID=
             * EhrLabCur.ParentPlacerOrderUniversalIDType=
             * EhrLabCur.ParentFillerOrderNum=
             * EhrLabCur.ParentFillerOrderNamespace=
             * EhrLabCur.ParentFillerOrderUniversalID=
             * EhrLabCur.ParentFillerOrderUniversalIDType=
             */
            EhrLabCur.ListEhrLabResultsHandlingF = checkResultsHandlingF.Checked;
            EhrLabCur.ListEhrLabResultsHandlingN = checkResultsHandlingN.Checked;
            //EhrLabCur.TQ1SetId=//TODO:this
            EhrLabCur.TQ1DateTimeStart = EhrLab.formatDateToHL7(textTQ1Start.Text);
            EhrLabCur.TQ1DateTimeEnd   = EhrLab.formatDateToHL7(textTQ1Stop.Text);
            EhrLabs.SaveToDB(EhrLabCur);
            Patient patCur = Patients.GetPat(EhrLabCur.PatNum);

            for (int i = 0; i < EhrLabCur.ListEhrLabResults.Count; i++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
                {
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(EhrLabCur.ListEhrLabResults[i], patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }
        ///<summary>Lab Results</summary>
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton) //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
            {
                col           = new ODGridColumn("", 18);                           //infoButton
                col.ImageList = imageListInfoButton;
                gridMain.Columns.Add(col);
            }
            col = new ODGridColumn("Test Date", 70);
            col.SortingStrategy = GridSortingStrategy.DateParse;
            gridMain.Columns.Add(col);
            col = new ODGridColumn("LOINC", 60);           //LoincCode
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Test Performed", 230); //ShortDescription
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Result Value", 160);   //Complicated
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Units", 60);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Flags", 40);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < EhrLabCur.ListEhrLabResults.Count; i++)
            {
                row = new ODGridRow();
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton) //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
                {
                    row.Cells.Add("0");                                                 //index of infobutton
                }
                if (EhrLabCur.ListEhrLabResults[i].ObservationDateTime == null || EhrLabCur.ListEhrLabResults[i].ObservationDateTime == "")
                {
                    row.Cells.Add("");                    //null date
                }
                else
                {
                    string   dateSt = EhrLabCur.ListEhrLabResults[i].ObservationDateTime.Substring(0, 8); //stored in DB as yyyyMMdd[hh[mm[ss]]], []==optional components
                    DateTime dateT  = PIn.Date(dateSt.Substring(4, 2) + "/" + dateSt.Substring(6, 2) + "/" + dateSt.Substring(0, 4));
                    row.Cells.Add(dateT.ToShortDateString());                                             //date only
                }
                if (EhrLabCur.ListEhrLabResults[i].ObservationIdentifierID != "")
                {
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationIdentifierID);
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationIdentifierText);
                }
                else if (EhrLabCur.ListEhrLabResults[i].ObservationIdentifierIDAlt != "")
                {
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationIdentifierIDAlt);
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationIdentifierTextAlt);
                }
                else
                {
                    row.Cells.Add("UNK");
                    row.Cells.Add("Unknown, could not find valid test code.");
                }
                switch (EhrLabCur.ListEhrLabResults[i].ValueType)
                {
                case HL70125.CE:
                case HL70125.CWE:
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationValueCodedElementText);
                    break;

                case HL70125.DT:
                case HL70125.TS:
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationValueDateTime);
                    break;

                case HL70125.TM:
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationValueTime.ToString());
                    break;

                case HL70125.NM:
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationValueNumeric.ToString());
                    break;

                case HL70125.SN:
                    row.Cells.Add(
                        EhrLabCur.ListEhrLabResults[i].ObservationValueComparator
                        + EhrLabCur.ListEhrLabResults[i].ObservationValueNumber1
                        + (EhrLabCur.ListEhrLabResults[i].ObservationValueSeparatorOrSuffix == ""
                                                                        ?"":EhrLabCur.ListEhrLabResults[i].ObservationValueSeparatorOrSuffix + EhrLabCur.ListEhrLabResults[i].ObservationValueNumber2)
                        );
                    break;

                case HL70125.FT:
                case HL70125.ST:
                case HL70125.TX:
                    row.Cells.Add(EhrLabCur.ListEhrLabResults[i].ObservationValueText);
                    break;
                }
                row.Cells.Add(EhrLabCur.ListEhrLabResults[i].UnitsID);
                row.Cells.Add(EhrLabCur.ListEhrLabResults[i].AbnormalFlags.Replace("N", ""));               //abnormal flags, show blank if flag is "Normal"
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
示例#18
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listAllergyReconcile.Count == 0)
            {
                if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing allergies to be removed.  Continue?"))
                {
                    return;
                }
            }
            Allergy    al;
            AllergyDef alD;
            bool       isActive;

            //Discontinue any current medications that are not present in the reconcile list.
            for (int i = 0; i < _listAllergyCur.Count; i++)       //Start looping through all current allergies
            {
                isActive = false;
                al       = _listAllergyCur[i];
                alD      = AllergyDefs.GetOne(al.AllergyDefNum, _listAllergyDefCur);
                for (int j = 0; j < _listAllergyReconcile.Count; j++)           //Compare each reconcile allergy to the current allergy
                {
                    AllergyDef alDR = AllergyDefs.GetOne(_listAllergyReconcile[j].AllergyDefNum, _listAllergyDefCur);
                    if (_listAllergyReconcile[j].AllergyDefNum == _listAllergyCur[i].AllergyDefNum)                   //Has identical AllergyDefNums
                    {
                        isActive = true;
                        break;
                    }
                    if (alDR == null)
                    {
                        continue;
                    }
                    //if(alDR.SnomedAllergyTo!="" && alDR.SnomedAllergyTo==alD.SnomedAllergyTo) {//TODO: Change to UNII
                    //	isActive=true;
                    //	break;
                    //}
                    if (alDR.MedicationNum != 0 && alDR.MedicationNum == alD.MedicationNum)                 //Has a Snomed code and they are equal
                    {
                        isActive = true;
                        break;
                    }
                }
                if (!isActive)
                {
                    _listAllergyCur[i].StatusIsActive = isActive;
                    Allergies.Update(_listAllergyCur[i]);
                }
            }
            //Always update every current allergy for the patient so that DateTStamp reflects the last reconcile date.
            if (_listAllergyCur.Count > 0)
            {
                Allergies.ResetTimeStamps(_patCur.PatNum, true);
            }
            AllergyDef alDU;
            int        index;

            for (int j = 0; j < _listAllergyReconcile.Count; j++)
            {
                if (!_listAllergyReconcile[j].IsNew)
                {
                    continue;
                }
                index = ListAllergyNew.IndexOf(_listAllergyReconcile[j]);              //Returns -1 if not found.
                if (index < 0)
                {
                    continue;
                }
                //Insert the AllergyDef and Allergy if needed.
                if (ListAllergyDefNew[index].MedicationNum != 0)
                {
                    alDU = AllergyDefs.GetAllergyDefFromMedication(ListAllergyDefNew[index].MedicationNum);
                }
                else
                {
                    alDU = null;                  //remove once UNII is implemented
                    //alDU=AllergyDefs.GetAllergyDefFromCode(ListAllergyDefNew[index].SnomedAllergyTo);//TODO: Change to UNII
                }
                if (alDU == null)               //db is missing the def
                {
                    ListAllergyNew[index].AllergyDefNum = AllergyDefs.Insert(ListAllergyDefNew[index]);
                }
                else
                {
                    ListAllergyNew[index].AllergyDefNum = alDU.AllergyDefNum;                  //Set the allergydefnum on the allergy.
                }
                Allergies.Insert(ListAllergyNew[index]);
            }
            //TODO: Make an allergy measure event if one is needed for MU3.
            //EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
            //newMeasureEvent.DateTEvent=DateTime.Now;
            //newMeasureEvent.EventType=EhrMeasureEventType.AllergyReconcile;
            //newMeasureEvent.PatNum=PatCur.PatNum;
            //newMeasureEvent.MoreInfo="";
            //EhrMeasureEvents.Insert(newMeasureEvent);
            for (int inter = 0; inter < _listAllergyReconcile.Count; inter++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).AllergyCDS)
                {
                    AllergyDef          alDInter = AllergyDefs.GetOne(_listAllergyReconcile[inter].AllergyDefNum);
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(alDInter, _patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listMedicationPatReconcile.Count == 0)
            {
                if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing medications to be removed.  Continue?"))
                {
                    return;
                }
            }
            MedicationPat medP;
            bool          isActive;

            //Discontinue any current medications that are not present in the reconcile list.
            for (int i = 0; i < _listMedicationPatCur.Count; i++)       //Start looping through all current medications
            {
                isActive = false;
                medP     = _listMedicationPatCur[i];
                for (int j = 0; j < _listMedicationPatReconcile.Count; j++)                                                                                                             //Compare each reconcile medication to the current medication
                {
                    if (medP.RxCui > 0 && medP.RxCui == _listMedicationPatReconcile[j].RxCui && _listMedicationPatReconcile[j].MedicationNum == _listMedicationPatCur[i].MedicationNum) //Has an RxNorm code and they are equal
                    {
                        isActive = true;
                        break;
                    }
                }
                if (!isActive)                                        //Update current medications.
                {
                    _listMedicationPatCur[i].DateStop = DateTime.Now; //Set the current DateStop to today (to set the medication as discontinued)
                    MedicationPats.Update(_listMedicationPatCur[i]);
                }
            }
            //Always update every current medication for the patient so that DateTStamp reflects the last reconcile date.
            if (_listMedicationPatCur.Count > 0)
            {
                MedicationPats.ResetTimeStamps(_patCur.PatNum, true);
            }
            Medication med;
            int        index;

            for (int j = 0; j < _listMedicationPatReconcile.Count; j++)
            {
                index = ListMedicationPatNew.IndexOf(_listMedicationPatReconcile[j]);
                if (index < 0)
                {
                    continue;
                }
                if (_listMedicationPatReconcile[j] == ListMedicationPatNew[index])
                {
                    med = Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[j].RxCui);
                    if (med == null)
                    {
                        med         = new Medication();
                        med.MedName = ListMedicationPatNew[index].MedDescript;
                        med.RxCui   = ListMedicationPatNew[index].RxCui;
                        ListMedicationPatNew[index].MedicationNum = Medications.Insert(med);
                        med.GenericNum = med.MedicationNum;
                        Medications.Update(med);
                    }
                    else
                    {
                        ListMedicationPatNew[index].MedicationNum = med.MedicationNum;
                    }
                    ListMedicationPatNew[index].ProvNum = 0;                  //Since imported, set provnum to 0 so it does not affect CPOE.
                    MedicationPats.Insert(ListMedicationPatNew[index]);
                }
            }
            EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();

            newMeasureEvent.DateTEvent = DateTime.Now;
            newMeasureEvent.EventType  = EhrMeasureEventType.MedicationReconcile;
            newMeasureEvent.PatNum     = _patCur.PatNum;
            newMeasureEvent.MoreInfo   = "";
            EhrMeasureEvents.Insert(newMeasureEvent);
            for (int inter = 0; inter < _listMedicationPatReconcile.Count; inter++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).MedicationCDS)
                {
                    Medication          medInter = Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[inter].RxCui);
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(medInter, _patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }
示例#20
0
 private void FormCDSSetup_Load(object sender, EventArgs e)
 {
     _listCdsPermissions    = CDSPermissions.GetAll();
     _listCdsPermissionsOld = CDSPermissions.GetAll();
     FillGrid();
 }