private void FormReminders_Load(object sender, EventArgs e)
 {
     _listOIDInternal = OIDInternals.GetAll();
     _listOIDInternal.Sort(sortOIDsByIDType);
     _rootOIDString = OIDInternals.GetForType(IdentifierType.Root).IDRoot;
     FillGrid();
 }
        private void butProvPicker_Click(object sender, EventArgs e)
        {
            FormProviderPick FormPP = new FormProviderPick();

            FormPP.ShowDialog();
            if (FormPP.DialogResult != DialogResult.OK)
            {
                return;
            }
            Provider prov = Providers.GetProv(FormPP.SelectedProvNum);

            if (prov.NationalProvID != "")
            {
                textOrderingProvIdentifier.Text       = prov.NationalProvID;
                comboOrderingProvIdType.SelectedIndex = (int)HL70203.NPI + 1;
                textOrderingProvAANID.Text            = "";
                textOrderingProvAAUID.Text            = "2.16.840.1.113883.4.6";   //NPI OID
                textOrderingProvAAUIDType.Text        = "ISO";
            }
            else
            {
                textOrderingProvIdentifier.Text       = prov.ProvNum.ToString();
                comboOrderingProvIdType.SelectedIndex = (int)HL70203.PRN + 1;
                textOrderingProvAANID.Text            = "";
                textOrderingProvAAUID.Text            = OIDInternals.GetForType(IdentifierType.Provider).IDRoot;   //Internal OID
                textOrderingProvAAUIDType.Text        = "ISO";
            }
            comboOrderingProvNameType.SelectedIndex = (int)HL70200.L + 1;
            textOrderingProvFirstName.Text          = prov.FName;
            textOrderingProvLastName.Text           = prov.LName;
            textOrderingProvMiddleName.Text         = prov.MI;
        }
Esempio n. 3
0
 private void FormReminders_Load(object sender, EventArgs e)
 {
     //OIDInternals.InsertMissingValues();
     ListOIDInternal = OIDInternals.GetAll();
     ListOIDInternal.Sort(sortOIDsByIDType);
     rootOIDString = OIDInternals.GetForType(IdentifierType.Root).IDRoot;
     FillGrid();
 }
 private void butOK_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < _listOIDInternal.Count; i++)
     {
         OIDInternals.Update(_listOIDInternal[i]);
     }
     DialogResult = DialogResult.OK;
 }
Esempio n. 5
0
 private void butOk_Click(object sender, EventArgs e)
 {
     //TODO: Validate OIDs and provide warning s if they do not make sense. For instance, if the Actual values do not match the reccomended values.
     //Also if the other OIDs are not children of the root OID.  etc...
     for (int i = 0; i < ListOIDInternal.Count; i++)
     {
         OIDInternals.Update(ListOIDInternal[i]);
     }
     DialogResult = DialogResult.OK;
 }
        ///<summary></summary>
        private bool EntriesAreValid()
        {
            StringBuilder errorMessage = new StringBuilder();

            //Order Numbers
            if (checkAutoID.Checked)
            {
                if (OIDInternals.GetForType(IdentifierType.LabOrder).IDRoot == "")
                {
                    errorMessage.AppendLine("  OID registry must be configured in order to use Automatic Lab Order IDs.");
                }
                //don't validate order numbers... it will be automatically generated when saved.
            }
            else if ((textPlacerOrderNum.Text == "" || (textPlacerOrderNum.Text != "" && textPlacerOrderUniversalID.Text == "")) &&  //Blank placerOrderNum OR OrderNum w/ blank OID
                     (textFillerOrderNum.Text == "" || (textFillerOrderNum.Text != "" && textFillerOrderUniversalID.Text == "")))         //Blank fillerOrderNum OR OrderNum w/blank OID
            {
                errorMessage.AppendLine("  Order must have valid placer or filler order number with universal ID.");
            }
            //Prov Numbers
            if (textOrderingProvAAUID.Text == OIDInternals.GetForType(IdentifierType.Provider).IDRoot)
            {
                Provider prov = null;
                try {
                    prov = Providers.GetProv(PIn.Long(textOrderingProvIdentifier.Text));
                }
                catch { }
                if (prov == null)
                {
                    errorMessage.AppendLine("  Ordering provider identifier or assigning authority is invalid.");
                }
            }
            else
            {
                if (!Regex.IsMatch(textOrderingProvIdentifier.Text, @"^(\d|\w)+$"))
                {
                    errorMessage.AppendLine("  Ordering Provider identifier must only contain numbers and letters.");
                }
            }
            //TODO: validate the controls
            if (errorMessage.ToString() != "")
            {
                errorMessage.Insert(0, "Unable to save current Lab Order for the following reasons:\r\n");
                MessageBox.Show(this, errorMessage.ToString());
                return(false);
            }
            return(true);
        }
        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;
        }
Esempio n. 8
0
        ///<summary>This field could be a CWE data type or a XCN data type, depending on if it came from an AIG segment, an AIP segment, or a PV1 segment.  The AIG segment would have this as a CWE data type in the format ProvID^LName, FName^^Abbr.  For the AIP and PV1 segments, the data type is XCN and the format would be ProvID^LName^FName^^^Abbr.  The ProvID is used first.  This will contain the root OID and ProvNum extension.  If it has the OD root OID for a provider, the number is assumed to be the OD ProvNum and used to find the provider.  If the root OID is not the OD root, it is used for on oidexternal table lookup.  If the provider is not found from the ID in either the provider table or the oidexternals table, then an attempt is made to find the provider by name and abbreviation.  This will return 0 if the field or segName are null or if no provider can be found.  A new provider will not be inserted with the information provided if not found by ProvID or name and abbr.  This field is repeatable, so we will check all repetitions for valid provider ID's or name/abbr combinations.</summary>
        public static long ProvParse(FieldHL7 field, SegmentNameHL7 segName, bool isVerbose)
        {
            long provNum = 0;
            List <OIDExternal> listOidExt = new List <OIDExternal>();

            if (field == null)
            {
                return(0);
            }
            #region Attempt to Get Provider From ProvIDs
            //Example of an ID using the hierarchic designation would be 2.16.840.1.113883.3.4337.1486.6566.3.1
            //Where 2.16.840.1.113883.3.4337.1486.6566 is the office oidroot, the .3 is to identify this as a provider
            //2.16.840.1.113883.3.4337.1486.6566.3 would be the office's oidinternal entry for IDType=Provider
            //The .1 is "."+ProvNum, where the ProvNum in this example is 1 and is considered the extension
            //We will strip off the ProvNum and if it is connected to the office's oidinternal entry for a provider, we will use it as the OD ProvNum
            //If it is attached to a different hierarchic root, we will try to find it in the oidexternals table linked to an OD ProvNum
            string [] provIdHierarch = field.GetComponentVal(0).Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
            string    strProvId      = "";
            string    strProvIdRoot  = "";
            if (provIdHierarch.Length > 1)           //must have a root and an ID
            {
                strProvId     = provIdHierarch[provIdHierarch.Length - 1];
                strProvIdRoot = field.GetComponentVal(0).Substring(0, field.GetComponentVal(0).Length - strProvId.Length - 1);         //-1 for the last "."
            }
            if (strProvId != "" && strProvIdRoot != "")
            {
                if (strProvIdRoot == OIDInternals.GetForType(IdentifierType.Provider).IDRoot)               //The office's root OID for a provider object, ProvId should be the OD ProvNum
                {
                    try {
                        if (Providers.GetProv(PIn.Long(strProvId)) != null)
                        {
                            provNum = PIn.Long(strProvId);                          //if component is empty string, provNum will be 0
                        }
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        //PIn.Long failed to convert the component to a long, provNum will remain 0 and we will attempt to get by name and abbr below
                    }
                }
                else                  //there was a ProvID and a ProvID root, but the root is not the office's root OID for a provider object, check the oidexternals table
                {
                    OIDExternal oidExtProv = OIDExternals.GetByRootAndExtension(strProvIdRoot, strProvId);
                    if (oidExtProv == null)                   //add to the list of oid's to add to the oidexternal table if we find a provider
                    {
                        OIDExternal oidExtCur = new OIDExternal();
                        oidExtCur.IDType       = IdentifierType.Provider;
                        oidExtCur.rootExternal = strProvIdRoot;
                        oidExtCur.IDExternal   = strProvId;
                        //oidExtCur.IDInteral may not have been found yet
                        listOidExt.Add(oidExtCur);
                    }
                    if (oidExtProv != null && oidExtProv.IDType == IdentifierType.Provider)
                    {
                        //possibly some other validation of name match?
                        provNum = oidExtProv.IDInternal;
                    }
                }
            }
            for (int i = 0; i < field.ListRepeatFields.Count; i++)       //could be repetitions of this field with other IDs
            {
                strProvId      = "";
                strProvIdRoot  = "";
                provIdHierarch = field.ListRepeatFields[i].GetComponentVal(0).Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                if (provIdHierarch.Length < 2)               //must be a root and an ID
                {
                    continue;
                }
                strProvId     = provIdHierarch[provIdHierarch.Length - 1];
                strProvIdRoot = field.ListRepeatFields[i].GetComponentVal(0).Substring(0, field.ListRepeatFields[i].GetComponentVal(0).Length - strProvId.Length - 1);         //-1 for the last "."
                if (strProvId == "" || strProvIdRoot == "")
                {
                    continue;
                }
                if (provNum == 0 && strProvIdRoot == OIDInternals.GetForType(IdentifierType.Provider).IDRoot)             //The office's root OID for a provider object, ProvId should be the OD ProvNum
                {
                    try {
                        if (Providers.GetProv(PIn.Long(strProvId)) != null)
                        {
                            provNum = PIn.Long(strProvId);                          //if component is empty string, provNum will be 0
                        }
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        //PIn.Long failed to convert the component to a long, provNum will remain 0 and we will attempt to get by name and abbr below
                    }
                }
                else if (strProvIdRoot != OIDInternals.GetForType(IdentifierType.Provider).IDRoot)               //there was a ProvID and a ProvID root, but the root is not the office's root OID for a provider object, check the oidexternals table
                {
                    OIDExternal oidExtProv = OIDExternals.GetByRootAndExtension(strProvIdRoot, strProvId);
                    if (oidExtProv == null)                   //add to the list of oid's to add to the oidexternal table if we find a provider
                    {
                        OIDExternal oidExtCur = new OIDExternal();
                        oidExtCur.IDType       = IdentifierType.Provider;
                        oidExtCur.rootExternal = strProvIdRoot;
                        oidExtCur.IDExternal   = strProvId;
                        //oidExtCur.IDInteral may not have been found yet
                        listOidExt.Add(oidExtCur);
                    }
                    else
                    {
                        if (provNum == 0 && oidExtProv.IDType == IdentifierType.Provider)
                        {
                            //possibly some other validation of name match?
                            provNum = oidExtProv.IDInternal;
                        }
                    }
                }
            }
            if (provNum > 0)
            {
                string verboseMsg = "";
                for (int i = 0; i < listOidExt.Count; i++)
                {
                    listOidExt[i].IDInternal = provNum;
                    OIDExternals.Insert(listOidExt[i]);
                    verboseMsg += "\r\nProvNum: " + provNum.ToString() + ", External root: " + strProvIdRoot + ", External Provider ID: " + strProvId;
                }
                if (isVerbose)
                {
                    EventLog.WriteEntry("OpenDentHL7", "Added an external provider ID to the oidexternals table due to an incoming "
                                        + segName.ToString() + " segment." + verboseMsg + ".", EventLogEntryType.Information);
                }
                return(provNum);
            }
            #endregion Attempt to Get Provider From ProvIDs
            #region Attempt to Get Provider From Name and Abbr
            //Couldn't find the provider with the ProvNum provided, we will attempt to find by FName, LName, and Abbr
            string provLName = "";
            string provFName = "";
            string provAbbr  = "";
            if (segName == SegmentNameHL7.AIG)           //AIG is the data type CWE with format ProvNum^LName, FName^^Abbr
            //GetComponentVal will return an empty string if the index is greater than the number of the components for this field minus 1
            {
                string[] components = field.GetComponentVal(1).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (components.Length > 0)
                {
                    provLName = components[0].TrimEnd(',');
                }
                if (components.Length > 1)
                {
                    provFName = components[1];
                }
                provAbbr = field.GetComponentVal(3);
            }
            else if (segName == SegmentNameHL7.AIP || segName == SegmentNameHL7.PV1)         //AIP and PV1 are the data type XCN with the format ProvNum^LName^FName^^^Abbr
            {
                provLName = field.GetComponentVal(1);
                provFName = field.GetComponentVal(2);
                provAbbr  = field.GetComponentVal(5);
            }
            if (provAbbr != "")
            {
                List <Provider> listProvs = Providers.GetProvsByFLName(provLName, provFName);
                for (int i = 0; i < listProvs.Count; i++)
                {
                    if (listProvs[i].Abbr.ToLower() == provAbbr.ToLower())
                    {
                        //There should be only one provider with this Abbr, although we only warn them about the duplication and allow them to have more than one with the same Abbr.
                        //With the LName, FName, and Abbr we can be more certain we retrieve the correct provider.
                        provNum = listProvs[i].ProvNum;
                    }
                }
            }
            //provider not found by provID, or first name/abbr combination, try the name/abbr combos in the repetitions.
            for (int i = 0; i < field.ListRepeatFields.Count; i++)       //could be repetitions of this field with other IDs
            {
                if (provNum > 0)
                {
                    break;
                }
                provLName = "";
                provFName = "";
                provAbbr  = "";
                if (segName == SegmentNameHL7.AIG)
                {
                    string[] components = field.ListRepeatFields[i].GetComponentVal(1).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (components.Length > 0)
                    {
                        provLName = components[0].TrimEnd(',');
                    }
                    if (components.Length > 1)
                    {
                        provFName = components[1];
                    }
                    provAbbr = field.ListRepeatFields[i].GetComponentVal(3);
                }
                else if (segName == SegmentNameHL7.AIP || segName == SegmentNameHL7.PV1)             //AIP and PV1 are the data type XCN with the format ProvNum^LName^FName^^^Abbr
                {
                    provLName = field.ListRepeatFields[i].GetComponentVal(1);
                    provFName = field.ListRepeatFields[i].GetComponentVal(2);
                    provAbbr  = field.ListRepeatFields[i].GetComponentVal(5);
                }
                if (provAbbr == "")
                {
                    continue;                    //there has to be a LName, FName, and Abbr if we are trying to match without a ProvNum.  LName and FName empty string check happens in GetProvsByFLName
                }
                List <Provider> listProvs = Providers.GetProvsByFLName(provLName, provFName);
                for (int p = 0; p < listProvs.Count; p++)
                {
                    if (listProvs[p].Abbr.ToLower() == provAbbr.ToLower())
                    {
                        //There should be only one provider with this Abbr, although we only warn them about the duplication and allow them to have more than one with the same Abbr.
                        //With the LName, FName, and Abbr we can be more certain we retrieve the correct provider.
                        provNum = listProvs[p].ProvNum;
                        break;
                    }
                }
            }
            if (provNum > 0)
            {
                string verboseMsg = "";
                for (int i = 0; i < listOidExt.Count; i++)
                {
                    listOidExt[i].IDInternal = provNum;
                    OIDExternals.Insert(listOidExt[i]);
                    verboseMsg += "\r\nProvNum: " + provNum.ToString() + ", External root: " + strProvIdRoot + ", External Provider ID: " + strProvId;
                }
                if (isVerbose)
                {
                    EventLog.WriteEntry("OpenDentHL7", "Added an external provider ID to the oidexternals table due to an incoming "
                                        + segName.ToString() + " segment." + verboseMsg + ".", EventLogEntryType.Information);
                }
            }
            #endregion Attempt to Get Provider From Name and Abbr
            return(provNum);
        }