Ejemplo n.º 1
0
 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!
 }
Ejemplo n.º 2
0
 private void FormEhrLabOrders_Load(object sender, EventArgs e)
 {
     ListEhrLabs = EhrLabs.ProcessHl7Message(Hl7LabMessage, true);
     AttachPatientHelper();
     FillPatientPicker();
     FillPatientInfo();
     FillGrid();
     for (int i = 0; i < ListEhrLabs.Count; i++)      //check for existing labs in DB.
     {
         if (EhrLabs.GetByGUID(ListEhrLabs[i].PlacerOrderUniversalID, ListEhrLabs[i].PlacerOrderNum) != null ||
             EhrLabs.GetByGUID(ListEhrLabs[i].FillerOrderUniversalID, ListEhrLabs[i].FillerOrderNum) != null)
         {
             labelExistingLab.Visible = true;
             break;
         }
     }
 }
Ejemplo n.º 3
0
        private void butViewParent_Click(object sender, EventArgs e)
        {
            EhrLab ehrLabParent = null;

            ehrLabParent = EhrLabs.GetByGUID(EhrLabCur.ParentPlacerOrderUniversalID, EhrLabCur.ParentPlacerOrderNum);
            if (ehrLabParent == null)
            {
                ehrLabParent = EhrLabs.GetByGUID(EhrLabCur.ParentFillerOrderUniversalID, EhrLabCur.ParentFillerOrderNum);
            }
            if (ehrLabParent == null)
            {
                return;
            }
            FormEhrLabOrderEdit2014 FormELOE = new FormEhrLabOrderEdit2014();

            FormELOE.EhrLabCur  = ehrLabParent;
            FormELOE.IsViewOnly = true;
            FormELOE.Text       = Lan.g(this, "Parent Lab Order - READ ONLY");
            FormELOE.ShowDialog();
        }
Ejemplo n.º 4
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();
        }