///<summary>Searches the field and any repetitions for the ID from the specified source. Possible sources are "U"=UPIN, "P"=Provider Number ///(Medicaid or Commercial Ins Prov ID), "N"=NPI, "L"=Local Physician ID. If the idSource is not a U, P, N, or L or if there is no ID of that ///type in the field, this will return an empty string. If fieldCur==null returns empty string.</summary> public static string OrderingProvIDParse(FieldHL7 fieldCur, string idSource) { if (fieldCur == null) { return(""); } if (fieldCur.GetComponentVal(7).Trim().ToLower() == idSource.ToLower()) { return(fieldCur.GetComponentVal(0).Trim()); } for (int i = 0; i < fieldCur.ListRepeatFields.Count; i++) { if (fieldCur.ListRepeatFields[i].GetComponentVal(7).Trim().ToLower() == idSource.ToLower()) { return(fieldCur.ListRepeatFields[i].GetComponentVal(0).Trim()); } } return(""); //Couldn't locate the ID type in the field or any repetition }
///<summary>Supply in format UPIN^LastName^FirstName^MI. If UPIN(abbr) does not exist, provider gets created. If name has changed, provider gets updated. ProvNum is returned. If blank, then returns 0. If field is NULL, returns 0.</summary> public static long ProvProcess(FieldHL7 field) { if (field == null) { return(0); } string eID = field.GetComponentVal(0); eID = eID.Trim(); if (eID == "") { return(0); } Provider prov = Providers.GetProvByEcwID(eID); bool isNewProv = false; bool provChanged = false; if (prov == null) { isNewProv = true; prov = new Provider(); prov.Abbr = eID; //They can manually change this later. prov.EcwID = eID; prov.FeeSched = FeeSchedC.ListShort[0].FeeSchedNum; } if (prov.LName != field.GetComponentVal(1)) { provChanged = true; prov.LName = field.GetComponentVal(1); } if (prov.FName != field.GetComponentVal(2)) { provChanged = true; prov.FName = field.GetComponentVal(2); } if (prov.MI != field.GetComponentVal(3)) { provChanged = true; prov.MI = field.GetComponentVal(3); } if (isNewProv) { Providers.Insert(prov); Providers.RefreshCache(); } else if (provChanged) { Providers.Update(prov); Providers.RefreshCache(); } return(prov.ProvNum); }
///<summary>Supply in format UPIN^LastName^FirstName^MI (PV1) or UPIN^LastName, FirstName MI (AIG). If UPIN(abbr) does not exist, provider gets created. If name has changed, provider gets updated. ProvNum is returned. If blank, then returns 0. If field is NULL, returns 0. For PV1, the provider.LName field will hold "LastName, FirstName MI". They can manually change later.</summary> public static long ProvProcess(FieldHL7 field) { if(field==null) { return 0; } string eID=field.GetComponentVal(0); eID=eID.Trim(); if(eID=="") { return 0; } Provider prov=Providers.GetProvByEcwID(eID); bool isNewProv=false; bool provChanged=false; if(prov==null) { isNewProv=true; prov=new Provider(); prov.Abbr=eID;//They can manually change this later. prov.EcwID=eID; prov.FeeSched=FeeSchedC.ListShort[0].FeeSchedNum; } if(field.Components.Count==4) {//PV1 segment in format UPIN^LastName^FirstName^MI if(prov.LName!=field.GetComponentVal(1)) { provChanged=true; prov.LName=field.GetComponentVal(1); } if(prov.FName!=field.GetComponentVal(2)) { provChanged=true; prov.FName=field.GetComponentVal(2); } if(prov.MI!=field.GetComponentVal(3)) { provChanged=true; prov.MI=field.GetComponentVal(3); } } else if(field.Components.Count==2) {//AIG segment in format UPIN^LastName, FirstName MI string[] components=field.GetComponentVal(1).Split(' '); if(components.Length>0) { components[0]=components[0].TrimEnd(','); if(prov.LName!=components[0]) { provChanged=true; prov.LName=components[0]; } } if(components.Length>1 && prov.FName!=components[1]) { provChanged=true; prov.FName=components[1]; } if(components.Length>2 && prov.MI!=components[2]) { provChanged=true; prov.MI=components[2]; } } if(isNewProv) { Providers.Insert(prov); Providers.RefreshCache(); } else if(provChanged) { Providers.Update(prov); Providers.RefreshCache(); } return prov.ProvNum; }
///<summary>Supply in format UPIN^LastName^FirstName^MI. If UPIN(abbr) does not exist, provider gets created. If name has changed, provider gets updated. ProvNum is returned. If blank, then returns 0. If field is NULL, returns 0.</summary> public static long ProvProcess(FieldHL7 field) { if(field==null) { return 0; } string eID=field.GetComponentVal(0); eID=eID.Trim(); if(eID=="") { return 0; } Provider prov=Providers.GetProvByEcwID(eID); bool isNewProv=false; bool provChanged=false; if(prov==null) { isNewProv=true; prov=new Provider(); prov.Abbr=eID;//They can manually change this later. prov.EcwID=eID; } if(prov.LName!=field.GetComponentVal(1)) { provChanged=true; prov.LName=field.GetComponentVal(1); } if(prov.FName!=field.GetComponentVal(2)) { provChanged=true; prov.FName=field.GetComponentVal(2); } if(prov.MI!=field.GetComponentVal(3)) { provChanged=true; prov.MI=field.GetComponentVal(3); } if(isNewProv) { Providers.Insert(prov); Providers.RefreshCache(); } else if(provChanged) { Providers.Update(prov); Providers.RefreshCache(); } return prov.ProvNum; }
///<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); }
///<summary>Used by eCW. This will locate a provider by EcwID and update the FName, LName, and MI if necessary. If no provider is found by EcwID, than a new provider is inserted and the FName, LName, and MI are set. Supply in format UPIN^LastName^FirstName^MI (PV1 or AIP) or UPIN^LastName, FirstName MI (AIG). If UPIN(abbr) does not exist, provider gets created. If name has changed, provider gets updated. ProvNum is returned. If blank, then returns 0. If field is NULL, returns 0. For PV1, the provider.LName field will hold "LastName, FirstName MI". They can manually change later.</summary> public static long ProvProcessEcw(FieldHL7 field) { if (field == null) { return(0); } string eID = field.GetComponentVal(0); eID = eID.Trim(); if (eID == "") { return(0); } Provider prov = Providers.GetProvByEcwID(eID); bool isNewProv = false; bool provChanged = false; if (prov == null) { isNewProv = true; prov = new Provider(); prov.Abbr = eID; //They can manually change this later. prov.EcwID = eID; prov.FeeSched = FeeScheds.GetFirst(true).FeeSchedNum; } if (field.Components.Count == 4) //PV1 segment in format UPIN^LastName^FirstName^MI { if (prov.LName != field.GetComponentVal(1)) { provChanged = true; prov.LName = field.GetComponentVal(1); } if (prov.FName != field.GetComponentVal(2)) { provChanged = true; prov.FName = field.GetComponentVal(2); } if (prov.MI != field.GetComponentVal(3)) { provChanged = true; prov.MI = field.GetComponentVal(3); } } else if (field.Components.Count == 2) //AIG segment in format UPIN^LastName, FirstName MI { string[] components = field.GetComponentVal(1).Split(' '); if (components.Length > 0) { components[0] = components[0].TrimEnd(','); if (prov.LName != components[0]) { provChanged = true; prov.LName = components[0]; } } if (components.Length > 1 && prov.FName != components[1]) { provChanged = true; prov.FName = components[1]; } if (components.Length > 2 && prov.MI != components[2]) { provChanged = true; prov.MI = components[2]; } } if (isNewProv) { Providers.Insert(prov); Providers.RefreshCache(); } else if (provChanged) { Providers.Update(prov); Providers.RefreshCache(); } return(prov.ProvNum); }
///<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) { //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) { //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; }
///<summary>Searches the field and any repetitions for the ID from the specified source. Possible sources are "U"=UPIN, "P"=Provider Number ///(Medicaid or Commercial Ins Prov ID), "N"=NPI, "L"=Local Physician ID. If the idSource is not a U, P, N, or L or if there is no ID of that ///type in the field, this will return an empty string. If fieldCur==null returns empty string.</summary> public static string OrderingProvIDParse(FieldHL7 fieldCur,string idSource) { if(fieldCur==null) { return ""; } if(fieldCur.GetComponentVal(7).Trim().ToLower()==idSource.ToLower()) { return fieldCur.GetComponentVal(0).Trim(); } for(int i=0;i<fieldCur.ListRepeatFields.Count;i++) { if(fieldCur.ListRepeatFields[i].GetComponentVal(7).Trim().ToLower()==idSource.ToLower()) { return fieldCur.ListRepeatFields[i].GetComponentVal(0).Trim(); } } return "";//Couldn't locate the ID type in the field or any repetition }