示例#1
0
        ///<summary>If the message text is X12, then it always normalizes it to include carriage returns for better readability.</summary>
        public static string GetMessageText(long etransMessageTextNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetString(MethodBase.GetCurrentMethod(), etransMessageTextNum));
            }
            if (etransMessageTextNum == 0)
            {
                return("");
            }
            string command = "SELECT MessageText FROM etransmessagetext WHERE EtransMessageTextNum=" + POut.Long(etransMessageTextNum);
            string msgText = Db.GetScalar(command);

            if (!X12object.IsX12(msgText))
            {
                return(msgText);
            }
            Match match = Regex.Match(msgText, "~[^(\n)(\r)]");

            while (match.Success)
            {
                msgText = msgText.Substring(0, match.Index) + "~\r\n" + msgText.Substring(match.Index + 1);
                match   = Regex.Match(msgText, "~[^(\n)(\r)]");
            }
            return(msgText);
            //MatchCollection matches=Regex.Matches(msgText,"~[^(\n)(\r)]");
            //for(int i=0;i<matches.Count;i++) {
            //Regex.
            //	matches[i].
            //}
            //msgText=Regex.Replace(msgText,"~[^(\r\n)(\n)(\r)]","~\r\n");
        }
示例#2
0
        ///<summary>This can take a 277 file of any length and convert it to a human readable format.  It can then be saved to a text file in the same folder as the original. The original file should be immediately archived if this is successful.  Actually includes extra functionality to make an 837 readable.</summary>
        public static string MakeHumanReadable(X12object xobj)
        {
            //List<string> messageLines=new List<string>();
            //X12object xObj=new X12object(File.ReadAllText(fileName));
            string        rn  = "\r\n";
            StringBuilder ret = new StringBuilder();

            foreach (X12FunctionalGroup functGroup in xobj.FunctGroups)
            {
                ret.Append("Functional Group");
                if (functGroup.Header.Get(1) == "HN")
                {
                    ret.Append(" 277-Unsolicited Claim Status Notification");
                }
                ret.Append(rn);
                foreach (X12Transaction trans in functGroup.Transactions)
                {
                    ret.Append("Transaction Set 277-Claim Status Notification" + rn);
                    foreach (X12Segment segment in trans.Segments)
                    {
                        ret.Append(SegmentToString(segment));
                    }
                }
            }
            return(ret.ToString());
        }
示例#3
0
 ///<summary>The new X12object will point to the same data as the x12other.  This is for efficiency and to save memory.  Be careful.</summary>
 public X12object(X12object x12other)
 {
     FilePath        = x12other.FilePath;
     DateInterchange = x12other.DateInterchange;
     Separators      = x12other.Separators;
     FunctGroups     = x12other.FunctGroups;
     Segments        = x12other.Segments;
 }
示例#4
0
 public static bool Is835(X12object xobj) {
   if(xobj.FunctGroups.Count!=1) {//Exactly 1 GS segment in each 835.
     return false;
   }
   if(xobj.FunctGroups[0].Header.Get(1)=="HP") {//GS01 (pg. 279)
     return true;
   }
   return false;
 }
示例#5
0
文件: X277.cs 项目: mnisl/OD
		public static bool Is277(X12object xobj) {
			if(xobj.FunctGroups.Count!=1) {//Exactly 1 GS segment in each 277.
				return false;
			}
			if(xobj.FunctGroups[0].Header.Get(1)=="HN") {//GS01 (pgs. 139 & 7)
				return true;
			}
			return false;
		}
示例#6
0
文件: X277U.cs 项目: nampn/ODental
 public static bool Is277U(X12object xobj)
 {
     if(xobj.FunctGroups.Count!=1) {//Assume only one funct group allowed.  Is this too strict?
         return false;
     }
     if(xobj.FunctGroups[0].Header.Get(1)=="HN") {
         return true;
     }
     return false;
 }
示例#7
0
 public static bool Is277(X12object xobj)
 {
     if (xobj.FunctGroups.Count != 1)           //Exactly 1 GS segment in each 277.
     {
         return(false);
     }
     if (xobj.FunctGroups[0].Header.Get(1) == "HN")           //GS01 (pgs. 139 & 7)
     {
         return(true);
     }
     return(false);
 }
示例#8
0
 public static bool Is277U(X12object xobj)
 {
     if (xobj.FunctGroups.Count != 1)           //Assume only one funct group allowed.  Is this too strict?
     {
         return(false);
     }
     if (xobj.FunctGroups[0].Header.Get(1) == "HN")
     {
         return(true);
     }
     return(false);
 }
示例#9
0
        ///<summary>This function is used to enhance readabilty of the X12 message when displayed.
        ///This function is specifically for X12 messages and not for other formats (ex not for Canadian).</summary>
        private static string TidyMessageTextX12(string msgText)
        {
            if (!X12object.IsX12(msgText))
            {
                return(msgText);
            }
            Match match = Regex.Match(msgText, "~[^(\n)(\r)]");

            while (match.Success)
            {
                msgText = msgText.Substring(0, match.Index) + "~\r\n" + msgText.Substring(match.Index + 1);
                match   = Regex.Match(msgText, "~[^(\n)(\r)]");
            }
            return(msgText);
        }
示例#10
0
文件: X277U.cs 项目: nampn/ODental
 ///<summary>This can take a 277 file of any length and convert it to a human readable format.  It can then be saved to a text file in the same folder as the original. The original file should be immediately archived if this is successful.  Actually includes extra functionality to make an 837 readable.</summary>
 public static string MakeHumanReadable(X12object xobj)
 {
     //List<string> messageLines=new List<string>();
     //X12object xObj=new X12object(File.ReadAllText(fileName));
     string rn="\r\n";
     StringBuilder ret=new StringBuilder();
     foreach(X12FunctionalGroup functGroup in xobj.FunctGroups){
         ret.Append("Functional Group");
         if(functGroup.Header.Get(1)=="HN"){
             ret.Append(" 277-Unsolicited Claim Status Notification");
         }
         ret.Append(rn);
         foreach(X12Transaction trans in functGroup.Transactions){
             ret.Append("Transaction Set 277-Claim Status Notification"+rn);
             foreach(X12Segment segment in trans.Segments){
                 ret.Append(SegmentToString(segment));
             }
         }
     }
     return ret.ToString();
 }
示例#11
0
文件: Etranss.cs 项目: mnisl/OD
		///<summary>Etrans type will be figured out by this class.  Either TextReport, Acknowledge_997, Acknowledge_999, or StatusNotify_277.</summary>
		public static void ProcessIncomingReport(DateTime dateTimeTrans,long clearinghouseNum,string messageText) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),dateTimeTrans,clearinghouseNum,messageText);
				return;
			}
			Etrans etrans=new Etrans();
			etrans.DateTimeTrans=dateTimeTrans;
			etrans.ClearingHouseNum=clearinghouseNum;
			EtransMessageText etransMessageText=new EtransMessageText();
			etransMessageText.MessageText=messageText;
			EtransMessageTexts.Insert(etransMessageText);
			etrans.EtransMessageTextNum=etransMessageText.EtransMessageTextNum;
			string command;
			if(X12object.IsX12(messageText)) {
				X12object Xobj=new X12object(messageText);
				if(Xobj.IsAckInterchange()) {
					etrans.Etype=EtransType.Ack_Interchange;
					Etranss.Insert(etrans);
					//At some point in the future, we should use TA101 to match to batch number and TA104 to get the ack code, 
					//then update historic etrans entries like we do for 997s, 999s and 277s.
				}
				else if(Xobj.Is997()) {
					X997 x997=new X997(messageText);
					etrans.Etype=EtransType.Acknowledge_997;
					etrans.BatchNumber=x997.GetBatchNumber();
					Etranss.Insert(etrans);
					string batchack=x997.GetBatchAckCode();
					if(batchack=="A"||batchack=="R") {//accepted or rejected
						command="UPDATE etrans SET AckCode='"+batchack+"', "
							+"AckEtransNum="+POut.Long(etrans.EtransNum)
							+" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
							+" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
							+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
							+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
							+" AND AckEtransNum=0";
						Db.NonQ(command);
					}
					else {//partially accepted
						List<int> transNums=x997.GetTransNums();
						string ack;
						for(int i=0;i<transNums.Count;i++) {
							ack=x997.GetAckForTrans(transNums[i]);
							if(ack=="A"||ack=="R") {//accepted or rejected
								command="UPDATE etrans SET AckCode='"+ack+"', "
									+"AckEtransNum="+POut.Long(etrans.EtransNum)
									+" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
									+" AND TransSetNum="+POut.Long(transNums[i])
									+" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
									+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
									+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
									+" AND AckEtransNum=0";
								Db.NonQ(command);
							}
						}
					}
					//none of the other fields make sense, because this ack could refer to many claims.
				}
				else if(Xobj.Is999()) {
					X999 x999=new X999(messageText);
					etrans.Etype=EtransType.Acknowledge_999;
					etrans.BatchNumber=x999.GetBatchNumber();
					Etranss.Insert(etrans);
					string batchack=x999.GetBatchAckCode();
					if(batchack=="A"||batchack=="R") {//accepted or rejected
					  command="UPDATE etrans SET AckCode='"+batchack+"', "
					    +"AckEtransNum="+POut.Long(etrans.EtransNum)
					    +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
					    +" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
					    +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
					    +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
					    +" AND AckEtransNum=0";
					  Db.NonQ(command);
					}
					else {//partially accepted
					  List<int> transNums=x999.GetTransNums();
					  string ack;
					  for(int i=0;i<transNums.Count;i++) {
					    ack=x999.GetAckForTrans(transNums[i]);
					    if(ack=="A"||ack=="R") {//accepted or rejected
					      command="UPDATE etrans SET AckCode='"+ack+"', "
					        +"AckEtransNum="+POut.Long(etrans.EtransNum)
					        +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
					        +" AND TransSetNum="+POut.Long(transNums[i])
					        +" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
					        +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
					        +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
					        +" AND AckEtransNum=0";
					      Db.NonQ(command);
					    }
					  }
					}
					//none of the other fields make sense, because this ack could refer to many claims.
				}
				else if(X277.Is277(Xobj)) {
					X277 x277=new X277(messageText);
					etrans.Etype=EtransType.StatusNotify_277;
					Etranss.Insert(etrans);
					List<string> listClaimIdentifiers=x277.GetClaimTrackingNumbers();
					for(int i=0;i<listClaimIdentifiers.Count;i++) {
						string claimIdentifier=listClaimIdentifiers[i];
						string[] arrayClaimInfo=x277.GetClaimInfo(claimIdentifier);
						string patFname=PIn.String(arrayClaimInfo[0]);
						string patLname=PIn.String(arrayClaimInfo[1]);
						DateTime dateServiceStart=PIn.DateT(arrayClaimInfo[6]);
						DateTime dateServiceEnd=PIn.DateT(arrayClaimInfo[7]);
						double claimFee=PIn.Double(arrayClaimInfo[9]);
						string subscriberId=PIn.String(arrayClaimInfo[10]);
						Claim claim=Claims.GetClaimFromX12(claimIdentifier,claimFee,dateServiceStart,dateServiceEnd,patFname,patLname,subscriberId);
						if(claim==null) {
							continue;
						}
						string ack=arrayClaimInfo[3];
						//Locate the latest etrans entries for the claim based on DateTimeTrans with EType of ClaimSent or Claim_Ren and update the AckCode and AckEtransNum.
						//We overwrite existing acks from 997s, 999s and older 277s.
						command="UPDATE etrans SET AckCode='"+ack+"', "
							+"AckEtransNum="+POut.Long(etrans.EtransNum)
							+" WHERE EType IN (0,3) "//ClaimSent and Claim_Ren
							+" AND ClaimNum="+POut.Long(claim.ClaimNum)
							+" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
							+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
							+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1));
						Db.NonQ(command);
					}
					//none of the other fields make sense, because this ack could refer to many claims.
				}
				else if(X835.Is835(Xobj)) {
					etrans.Etype=EtransType.ERA_835;
					List <string> listTranSetIds=Xobj.GetTranSetIds();
					for(int i=0;i<listTranSetIds.Count;i++) {
						etrans.TranSetId835=listTranSetIds[i];
						if(i>0) {
							etrans.EtransNum=0;//To get a new record to insert.
						}
						Etranss.Insert(etrans);
						X835 x835=new X835(messageText,etrans.TranSetId835);
						List<Hx835_Claim> listClaimEOBs=x835.ListClaimsPaid;
						for(int j=0;j<listClaimEOBs.Count;j++) {
							long claimNum=listClaimEOBs[j].ClaimNum;
							//Locate the latest etrans entries for the claim based on DateTimeTrans with EType of ClaimSent or Claim_Ren and update the AckCode and AckEtransNum.
							//We overwrite existing acks from 997s, 999s, and 277s.
							command="UPDATE etrans SET AckCode='A', "
								+"AckEtransNum="+POut.Long(etrans.EtransNum)
								+" WHERE EType IN (0,3) "//ClaimSent and Claim_Ren
								+" AND ClaimNum="+POut.Long(claimNum)
								+" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
								+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
								+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1));
							Db.NonQ(command);
						}
						//none of the other fields make sense, because this ack could refer to many claims.
					}
				}
				else {//unknown type of X12 report.
					etrans.Etype=EtransType.TextReport;
					Etranss.Insert(etrans);
				}
			}
			else {//not X12
				etrans.Etype=EtransType.TextReport;
				Etranss.Insert(etrans);
			}
		}
示例#12
0
		///<summary>The insplan that's passed in need not be properly updated to the database first.</summary>
		public static void RequestBenefits(Clearinghouse clearhouse,InsPlan plan,long patNum,Carrier carrier,List<Benefit> benList,long patPlanNum,InsSub insSub) {
			Patient pat=Patients.GetPat(patNum);
			Patient subsc=Patients.GetPat(insSub.Subscriber);
			Clinic clinic=Clinics.GetClinic(pat.ClinicNum);
			Provider billProv=Providers.GetProv(Providers.GetBillingProvNum(pat.PriProv,pat.ClinicNum));
			//validation.  Throw exception if missing info----------------------------------------
			string validationResult=X270.Validate(clearhouse,carrier,billProv,clinic,plan,subsc,insSub);
			if(validationResult != "") {
				throw new Exception(Lan.g("FormInsPlan","Please fix the following errors first:")+"\r\n"+validationResult);
			}
			//create a 270 message---------------------------------------------------------------
			string x12message=X270.GenerateMessageText(clearhouse,carrier,billProv,clinic,plan,subsc,insSub);
			EtransMessageText etransMessageText=new EtransMessageText();
			etransMessageText.MessageText=x12message;
			EtransMessageTexts.Insert(etransMessageText);
			//attach it to an etrans-------------------------------------------------------------
			Etrans etrans=new Etrans();
			etrans.DateTimeTrans=DateTime.Now;
			etrans.ClearingHouseNum=clearhouse.ClearinghouseNum;
			etrans.Etype=EtransType.BenefitInquiry270;
			etrans.PlanNum=plan.PlanNum;
			etrans.InsSubNum=insSub.InsSubNum;
			etrans.EtransMessageTextNum=etransMessageText.EtransMessageTextNum;
			Etranss.Insert(etrans);
			//send the 270----------------------------------------------------------------------
			string x12response="";
			//a connection error here needs to bubble up
			try {
				if(clearhouse.CommBridge==EclaimsCommBridge.ClaimConnect) {
					x12response=ClaimConnect.Benefits270(clearhouse,x12message);
				}
				if(clearhouse.CommBridge==EclaimsCommBridge.EDS) {
					x12response=EDS.Benefits270(clearhouse,x12message);
				}
			}
			catch(Exception ex) {
				EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
				Etranss.Delete(etrans.EtransNum);
				throw new ApplicationException(Lan.g("FormInsPlan","Connection Error:")+"\r\n"+ex.GetType().Name+"\r\n"+ex.Message);
			}
			//start to process the 271----------------------------------------------------------
			X271 x271=null;
			if(X12object.IsX12(x12response)) {
				X12object x12obj=new X12object(x12response);
				if(x12obj.Is271()) {
					x271=new X271(x12response);
				}
			}
			else {//not a 997, 999, 277 or 271
				EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
				Etranss.Delete(etrans.EtransNum);
				throw new ApplicationException(Lan.g("FormInsPlan","Error:")+"\r\n"+x12response);
			}
			/*
			//In realtime mode, X12 limits the request to one patient.
			//We will always use the subscriber.
			//So all EB segments are for the subscriber.
			List<EB271> listEB=new List<EB271>();
			EB271 eb;
			if(x271 != null) {
				for(int i=0;i<x271.Segments.Count;i++) {
					if(x271.Segments[i].SegmentID != "EB") {
						continue;
					}
					eb=new EB271(x271.Segments[i]);
					listEB.Add(eb);
				}
			}*/
			//create an etrans for the 271------------------------------------------------------
			etransMessageText=new EtransMessageText();
			etransMessageText.MessageText=x12response;
			EtransMessageTexts.Insert(etransMessageText);
			Etrans etrans271=new Etrans();
			etrans271.DateTimeTrans=DateTime.Now;
			etrans271.ClearingHouseNum=clearhouse.ClearinghouseNum;
			etrans271.Etype=EtransType.TextReport;
			if(X12object.IsX12(x12response)) {//this shouldn't need to be tested because it was tested above.
				if(x271==null){
					X12object Xobj=new X12object(x12response);
					if(Xobj.Is997()) {
						etrans271.Etype=EtransType.Acknowledge_997;
					}
					else if(Xobj.Is999()) {
						etrans271.Etype=EtransType.Acknowledge_999;
					}
					else if(X277.Is277(Xobj)) {
						etrans271.Etype=EtransType.StatusNotify_277;
					}
					else if(X835.Is835(Xobj)) {
						etrans271.Etype=EtransType.ERA_835;
					}
				}
				else{
					etrans271.Etype=EtransType.BenefitResponse271;
				}
			}
			etrans271.PlanNum=plan.PlanNum;
			etrans271.InsSubNum=insSub.InsSubNum;
			etrans271.EtransMessageTextNum=etransMessageText.EtransMessageTextNum;
			Etranss.Insert(etrans271);
			etrans.AckEtransNum=etrans271.EtransNum;
			if(etrans271.Etype==EtransType.Acknowledge_997) {
				X997 x997=new X997(x12response);
				string error997=x997.GetHumanReadable();
				etrans.Note="Error: "+error997;//"Malformed document sent.  997 error returned.";
				Etranss.Update(etrans);
				MessageBox.Show(etrans.Note);
				//CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
				//msgbox.ShowDialog();
				//don't show the 270 interface.
				return;
			}
			else if(etrans271.Etype==EtransType.Acknowledge_999) {
				X999 x999=new X999(x12response);
				string error999=x999.GetHumanReadable();
				etrans.Note="Error: "+error999;//"Malformed document sent.  999 error returned.";
				Etranss.Update(etrans);
				MessageBox.Show(etrans.Note);
				//CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
				//msgbox.ShowDialog();
				//don't show the 270 interface.
				return;
			}
			else if(etrans271.Etype==EtransType.StatusNotify_277) { 
				X277 x277=new X277(x12response);
				string error277=x277.GetHumanReadable();
				etrans.Note="Error: "+error277;//"Malformed document sent.  277 error returned.";
				Etranss.Update(etrans);
				MessageBox.Show(etrans.Note);
				//CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
				//msgbox.ShowDialog();
				//don't show the 277 interface.
				return;
			}
			else if(etrans271.Etype==EtransType.ERA_835) {
				X835 x835=new X835(x12response,"");
				string error835=x835.GetHumanReadable();
				etrans.Note="Error: "+error835;//"Malformed document sent.  835 error returned.";
				Etranss.Update(etrans);
				MessageBox.Show(etrans.Note);
				//CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
				//msgbox.ShowDialog();
				//don't show the 835 interface.
				return;
			}
			else { //271
				string processingerror=x271.GetProcessingError();
				if(processingerror != "") {
					etrans.Note=processingerror;
					Etranss.Update(etrans);
					MessageBox.Show(etrans.Note);
					//CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
					//msgbox.ShowDialog();
					//don't show the 270 interface.
					return;
				}
				else {
					etrans.Note="Normal 271 response.";//change this later to be explanatory of content.
				}
			}
			Etranss.Update(etrans);
			//show the user a list of benefits to pick from for import--------------------------
			FormEtrans270Edit formE=new FormEtrans270Edit(patPlanNum,plan.PlanNum,insSub.InsSubNum);
			formE.EtransCur=etrans;
			formE.IsInitialResponse=true;
			formE.benList=benList;
			formE.ShowDialog();
		}
示例#13
0
        ///<summary>Etrans type will be figured out by this class.  Either TextReport, Acknowledge_997, Acknowledge_999, or StatusNotify_277.</summary>
        public static void ProcessIncomingReport(DateTime dateTimeTrans, long clearinghouseNum, string messageText)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), dateTimeTrans, clearinghouseNum, messageText);
                return;
            }
            Etrans etrans = new Etrans();

            etrans.DateTimeTrans    = dateTimeTrans;
            etrans.ClearingHouseNum = clearinghouseNum;
            EtransMessageText etransMessageText = new EtransMessageText();

            etransMessageText.MessageText = messageText;
            EtransMessageTexts.Insert(etransMessageText);
            etrans.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            string command;

            if (X12object.IsX12(messageText))
            {
                X12object Xobj = new X12object(messageText);
                if (Xobj.IsAckInterchange())
                {
                    etrans.Etype = EtransType.Ack_Interchange;
                    Etranss.Insert(etrans);
                    //At some point in the future, we should use TA101 to match to batch number and TA104 to get the ack code,
                    //then update historic etrans entries like we do for 997s, 999s and 277s.
                }
                else if (Xobj.Is997())
                {
                    X997 x997 = new X997(messageText);
                    etrans.Etype       = EtransType.Acknowledge_997;
                    etrans.BatchNumber = x997.GetBatchNumber();
                    Etranss.Insert(etrans);
                    string batchack = x997.GetBatchAckCode();
                    if (batchack == "A" || batchack == "R")               //accepted or rejected
                    {
                        command = "UPDATE etrans SET AckCode='" + batchack + "', "
                                  + "AckEtransNum=" + POut.Long(etrans.EtransNum)
                                  + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber)
                                  + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum)
                                  + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14))
                                  + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1))
                                  + " AND AckEtransNum=0";
                        Db.NonQ(command);
                    }
                    else                      //partially accepted
                    {
                        List <int> transNums = x997.GetTransNums();
                        string     ack;
                        for (int i = 0; i < transNums.Count; i++)
                        {
                            ack = x997.GetAckForTrans(transNums[i]);
                            if (ack == "A" || ack == "R")                       //accepted or rejected
                            {
                                command = "UPDATE etrans SET AckCode='" + ack + "', "
                                          + "AckEtransNum=" + POut.Long(etrans.EtransNum)
                                          + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber)
                                          + " AND TransSetNum=" + POut.Long(transNums[i])
                                          + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum)
                                          + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14))
                                          + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1))
                                          + " AND AckEtransNum=0";
                                Db.NonQ(command);
                            }
                        }
                    }
                    //none of the other fields make sense, because this ack could refer to many claims.
                }
                else if (Xobj.Is999())
                {
                    X999 x999 = new X999(messageText);
                    etrans.Etype       = EtransType.Acknowledge_999;
                    etrans.BatchNumber = x999.GetBatchNumber();
                    Etranss.Insert(etrans);
                    string batchack = x999.GetBatchAckCode();
                    if (batchack == "A" || batchack == "R")               //accepted or rejected
                    {
                        command = "UPDATE etrans SET AckCode='" + batchack + "', "
                                  + "AckEtransNum=" + POut.Long(etrans.EtransNum)
                                  + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber)
                                  + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum)
                                  + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14))
                                  + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1))
                                  + " AND AckEtransNum=0";
                        Db.NonQ(command);
                    }
                    else                      //partially accepted
                    {
                        List <int> transNums = x999.GetTransNums();
                        string     ack;
                        for (int i = 0; i < transNums.Count; i++)
                        {
                            ack = x999.GetAckForTrans(transNums[i]);
                            if (ack == "A" || ack == "R")           //accepted or rejected
                            {
                                command = "UPDATE etrans SET AckCode='" + ack + "', "
                                          + "AckEtransNum=" + POut.Long(etrans.EtransNum)
                                          + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber)
                                          + " AND TransSetNum=" + POut.Long(transNums[i])
                                          + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum)
                                          + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14))
                                          + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1))
                                          + " AND AckEtransNum=0";
                                Db.NonQ(command);
                            }
                        }
                    }
                    //none of the other fields make sense, because this ack could refer to many claims.
                }
                else if (X277.Is277(Xobj))
                {
                    X277 x277 = new X277(messageText);
                    etrans.Etype = EtransType.StatusNotify_277;
                    Etranss.Insert(etrans);
                    List <string> claimTrackingNumbers = x277.GetClaimTrackingNumbers();
                    for (int i = 0; i < claimTrackingNumbers.Count; i++)
                    {
                        string ack      = x277.GetClaimInfo(claimTrackingNumbers[i])[3];
                        long   claimNum = Claims.GetClaimNumForIdentifier(claimTrackingNumbers[i]);
                        //Locate the latest etrans entries for the claim based on DateTimeTrans with EType of ClaimSent or Claim_Ren and update the AckCode and AckEtransNum.
                        //We overwrite existing acks from 997s, 999s and older 277s.
                        command = "UPDATE etrans SET AckCode='" + ack + "', "
                                  + "AckEtransNum=" + POut.Long(etrans.EtransNum)
                                  + " WHERE EType IN (0,3) "                     //ClaimSent and Claim_Ren
                                  + " AND ClaimNum=" + POut.Long(claimNum)
                                  + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum)
                                  + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14))
                                  + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1));
                        Db.NonQ(command);
                    }
                    ////none of the other fields make sense, because this ack could refer to many claims.
                }
                else                  //unknown type of X12 report.
                {
                    etrans.Etype = EtransType.TextReport;
                    Etranss.Insert(etrans);
                }
            }
            else              //not X12
            {
                etrans.Etype = EtransType.TextReport;
                Etranss.Insert(etrans);
            }
        }
示例#14
0
文件: Etranss.cs 项目: nampn/ODental
 ///<summary>Etrans type will be figured out by this class.  Either TextReport, Acknowledge_997, or StatusNotify_277.</summary>
 public static void ProcessIncomingReport(DateTime dateTimeTrans,long clearinghouseNum,string messageText)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),dateTimeTrans,clearinghouseNum,messageText);
         return;
     }
     Etrans etrans=new Etrans();
     etrans.DateTimeTrans=dateTimeTrans;
     etrans.ClearingHouseNum=clearinghouseNum;
     EtransMessageText etransMessageText=new EtransMessageText();
     etransMessageText.MessageText=messageText;
     EtransMessageTexts.Insert(etransMessageText);
     etrans.EtransMessageTextNum=etransMessageText.EtransMessageTextNum;
     string command;
     if(X12object.IsX12(messageText)) {
         X12object Xobj=new X12object(messageText);
         if(Xobj.Is997()) {
             X997 x997=new X997(messageText);
             etrans.Etype=EtransType.Acknowledge_997;
             etrans.BatchNumber=x997.GetBatchNumber();
             Etranss.Insert(etrans);
             string batchack=x997.GetBatchAckCode();
             if(batchack=="A"||batchack=="R") {//accepted or rejected
                 command="UPDATE etrans SET AckCode='"+batchack+"', "
                     +"AckEtransNum="+POut.Long(etrans.EtransNum)
                     +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
                     +" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
                     +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
                     +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
                     +" AND AckEtransNum=0";
                 Db.NonQ(command);
             }
             else {//partially accepted
                 List<int> transNums=x997.GetTransNums();
                 string ack;
                 for(int i=0;i<transNums.Count;i++) {
                     ack=x997.GetAckForTrans(transNums[i]);
                     if(ack=="A"||ack=="R") {//accepted or rejected
                         command="UPDATE etrans SET AckCode='"+ack+"', "
                             +"AckEtransNum="+POut.Long(etrans.EtransNum)
                             +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
                             +" AND TransSetNum="+POut.Long(transNums[i])
                             +" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
                             +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
                             +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
                             +" AND AckEtransNum=0";
                         Db.NonQ(command);
                     }
                 }
             }
             //none of the other fields make sense, because this ack could refer to many claims.
         }
         else if(X277U.Is277U(Xobj)) {
             etrans.Etype=EtransType.StatusNotify_277;
             //later: analyze to figure out which e-claim is being referenced.
             Etranss.Insert(etrans);
         }
         else {//unknown type of X12 report.
             etrans.Etype=EtransType.TextReport;
             Etranss.Insert(etrans);
         }
     }
     else {//not X12
         etrans.Etype=EtransType.TextReport;
         Etranss.Insert(etrans);
     }
 }
示例#15
0
		private void FormEtransEdit_Load(object sender,EventArgs e) {
			MessageText=EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
			textMessageText.Text=MessageText;
			textDateTimeTrans.Text=EtransCur.DateTimeTrans.ToString();
			textClaimNum.Text=EtransCur.ClaimNum.ToString();
			textBatchNumber.Text=EtransCur.BatchNumber.ToString();
			textTransSetNum.Text=EtransCur.TransSetNum.ToString();
			textAckCode.Text=EtransCur.AckCode;
			textNote.Text=EtransCur.Note;
			if(EtransCur.Etype==EtransType.ClaimSent){
				if(X12object.IsX12(MessageText)) {
					X12object x12obj=new X12object(MessageText);
					if(x12obj.IsFormat4010()) {
						X837_4010 x837=new X837_4010(MessageText);
						checkAttachments.Checked=x837.AttachmentsWereSent(EtransCur.ClaimNum);//This function does not currently work, so the corresponding checkbox is hidden on the form as well.
					}
					else if(x12obj.IsFormat5010()) {
						X837_5010 x837=new X837_5010(MessageText);
						checkAttachments.Checked=x837.AttachmentsWereSent(EtransCur.ClaimNum);//This function does not currently work, so the corresponding checkbox is hidden on the form as well.
					}
				}
			}
			if(EtransCur.AckEtransNum>0){
				AckCur=Etranss.GetEtrans(EtransCur.AckEtransNum);
				if(AckCur!=null){
					textAckMessage.Text=EtransMessageTexts.GetMessageText(AckCur.EtransMessageTextNum);
					textAckDateTime.Text=AckCur.DateTimeTrans.ToString();
				}
				groupAck.Text=Lan.g(this,"Acknowledgement");
			}
			else{
				AckCur=null;
				groupAck.Visible=false;
			}
			if(!CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Not Canadian.
				butPrintAck.Visible=false;
			}
		}
示例#16
0
文件: Etranss.cs 项目: nampn/ODental
        ///<summary>Etrans type will be figured out by this class.  Either TextReport, Acknowledge_997, or StatusNotify_277.</summary>
        public static void ProcessIncomingReport(DateTime dateTimeTrans, long clearinghouseNum, string messageText)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), dateTimeTrans, clearinghouseNum, messageText);
                return;
            }
            Etrans etrans = new Etrans();

            etrans.DateTimeTrans    = dateTimeTrans;
            etrans.ClearingHouseNum = clearinghouseNum;
            EtransMessageText etransMessageText = new EtransMessageText();

            etransMessageText.MessageText = messageText;
            EtransMessageTexts.Insert(etransMessageText);
            etrans.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            string command;

            if (X12object.IsX12(messageText))
            {
                X12object Xobj = new X12object(messageText);
                if (Xobj.Is997())
                {
                    X997 x997 = new X997(messageText);
                    etrans.Etype       = EtransType.Acknowledge_997;
                    etrans.BatchNumber = x997.GetBatchNumber();
                    Etranss.Insert(etrans);
                    string batchack = x997.GetBatchAckCode();
                    if (batchack == "A" || batchack == "R")               //accepted or rejected
                    {
                        command = "UPDATE etrans SET AckCode='" + batchack + "', "
                                  + "AckEtransNum=" + POut.Long(etrans.EtransNum)
                                  + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber)
                                  + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum)
                                  + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14))
                                  + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1))
                                  + " AND AckEtransNum=0";
                        Db.NonQ(command);
                    }
                    else                      //partially accepted
                    {
                        List <int> transNums = x997.GetTransNums();
                        string     ack;
                        for (int i = 0; i < transNums.Count; i++)
                        {
                            ack = x997.GetAckForTrans(transNums[i]);
                            if (ack == "A" || ack == "R")                       //accepted or rejected
                            {
                                command = "UPDATE etrans SET AckCode='" + ack + "', "
                                          + "AckEtransNum=" + POut.Long(etrans.EtransNum)
                                          + " WHERE BatchNumber=" + POut.Long(etrans.BatchNumber)
                                          + " AND TransSetNum=" + POut.Long(transNums[i])
                                          + " AND ClearinghouseNum=" + POut.Long(clearinghouseNum)
                                          + " AND DateTimeTrans > " + POut.DateT(dateTimeTrans.AddDays(-14))
                                          + " AND DateTimeTrans < " + POut.DateT(dateTimeTrans.AddDays(1))
                                          + " AND AckEtransNum=0";
                                Db.NonQ(command);
                            }
                        }
                    }
                    //none of the other fields make sense, because this ack could refer to many claims.
                }
                else if (X277U.Is277U(Xobj))
                {
                    etrans.Etype = EtransType.StatusNotify_277;
                    //later: analyze to figure out which e-claim is being referenced.
                    Etranss.Insert(etrans);
                }
                else                  //unknown type of X12 report.
                {
                    etrans.Etype = EtransType.TextReport;
                    Etranss.Insert(etrans);
                }
            }
            else              //not X12
            {
                etrans.Etype = EtransType.TextReport;
                Etranss.Insert(etrans);
            }
        }
示例#17
0
		///<summary>Etrans type will be figured out by this class.  Either TextReport, Acknowledge_997, Acknowledge_999, or StatusNotify_277.</summary>
		public static void ProcessIncomingReport(DateTime dateTimeTrans,long clearinghouseNum,string messageText) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),dateTimeTrans,clearinghouseNum,messageText);
				return;
			}
			Etrans etrans=new Etrans();
			etrans.DateTimeTrans=dateTimeTrans;
			etrans.ClearingHouseNum=clearinghouseNum;
			EtransMessageText etransMessageText=new EtransMessageText();
			etransMessageText.MessageText=messageText;
			EtransMessageTexts.Insert(etransMessageText);
			etrans.EtransMessageTextNum=etransMessageText.EtransMessageTextNum;
			string command;
			if(X12object.IsX12(messageText)) {
				X12object Xobj=new X12object(messageText);
				if(Xobj.IsAckInterchange()) {
					etrans.Etype=EtransType.Ack_Interchange;
					Etranss.Insert(etrans);
					//At some point in the future, we should use TA101 to match to batch number and TA104 to get the ack code, 
					//then update historic etrans entries like we do for 997s, 999s and 277s.
				}
				else if(Xobj.Is997()) {
					X997 x997=new X997(messageText);
					etrans.Etype=EtransType.Acknowledge_997;
					etrans.BatchNumber=x997.GetBatchNumber();
					Etranss.Insert(etrans);
					string batchack=x997.GetBatchAckCode();
					if(batchack=="A"||batchack=="R") {//accepted or rejected
						command="UPDATE etrans SET AckCode='"+batchack+"', "
							+"AckEtransNum="+POut.Long(etrans.EtransNum)
							+" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
							+" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
							+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
							+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
							+" AND AckEtransNum=0";
						Db.NonQ(command);
					}
					else {//partially accepted
						List<int> transNums=x997.GetTransNums();
						string ack;
						for(int i=0;i<transNums.Count;i++) {
							ack=x997.GetAckForTrans(transNums[i]);
							if(ack=="A"||ack=="R") {//accepted or rejected
								command="UPDATE etrans SET AckCode='"+ack+"', "
									+"AckEtransNum="+POut.Long(etrans.EtransNum)
									+" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
									+" AND TransSetNum="+POut.Long(transNums[i])
									+" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
									+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
									+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
									+" AND AckEtransNum=0";
								Db.NonQ(command);
							}
						}
					}
					//none of the other fields make sense, because this ack could refer to many claims.
				}
				else if(Xobj.Is999()) {
					X999 x999=new X999(messageText);
					etrans.Etype=EtransType.Acknowledge_999;
					etrans.BatchNumber=x999.GetBatchNumber();
					Etranss.Insert(etrans);
					string batchack=x999.GetBatchAckCode();
					if(batchack=="A"||batchack=="R") {//accepted or rejected
					  command="UPDATE etrans SET AckCode='"+batchack+"', "
					    +"AckEtransNum="+POut.Long(etrans.EtransNum)
					    +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
					    +" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
					    +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
					    +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
					    +" AND AckEtransNum=0";
					  Db.NonQ(command);
					}
					else {//partially accepted
					  List<int> transNums=x999.GetTransNums();
					  string ack;
					  for(int i=0;i<transNums.Count;i++) {
					    ack=x999.GetAckForTrans(transNums[i]);
					    if(ack=="A"||ack=="R") {//accepted or rejected
					      command="UPDATE etrans SET AckCode='"+ack+"', "
					        +"AckEtransNum="+POut.Long(etrans.EtransNum)
					        +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
					        +" AND TransSetNum="+POut.Long(transNums[i])
					        +" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
					        +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
					        +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
					        +" AND AckEtransNum=0";
					      Db.NonQ(command);
					    }
					  }
					}
					//none of the other fields make sense, because this ack could refer to many claims.
				}
				else if(X277.Is277(Xobj)) {
					X277 x277=new X277(messageText);
					etrans.Etype=EtransType.StatusNotify_277;
					Etranss.Insert(etrans);
					List<string> claimTrackingNumbers=x277.GetClaimTrackingNumbers();
					for(int i=0;i<claimTrackingNumbers.Count;i++) {
						string ack=x277.GetClaimInfo(claimTrackingNumbers[i])[3];
						long claimNum=Claims.GetClaimNumForIdentifier(claimTrackingNumbers[i]);
						//Locate the latest etrans entries for the claim based on DateTimeTrans with EType of ClaimSent or Claim_Ren and update the AckCode and AckEtransNum.
						//We overwrite existing acks from 997s, 999s and older 277s.
						command="UPDATE etrans SET AckCode='"+ack+"', "
							+"AckEtransNum="+POut.Long(etrans.EtransNum)
							+" WHERE EType IN (0,3) "//ClaimSent and Claim_Ren
							+" AND ClaimNum="+POut.Long(claimNum)
							+" AND ClearinghouseNum="+POut.Long(clearinghouseNum)
							+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
							+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1));
						Db.NonQ(command);
					}
					////none of the other fields make sense, because this ack could refer to many claims.
				}
				else {//unknown type of X12 report.
					etrans.Etype=EtransType.TextReport;
					Etranss.Insert(etrans);
				}
			}
			else {//not X12
				etrans.Etype=EtransType.TextReport;
				Etranss.Insert(etrans);
			}
		}
示例#18
0
		///<summary>Etrans type will be figured out by this class.  Either TextReport, Acknowledge_997, Acknowledge_999, or StatusNotify_277.</summary>
		public static void ProcessIncomingReport(DateTime dateTimeTrans,long hqClearinghouseNum,string messageText,long userNum) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),dateTimeTrans,hqClearinghouseNum,messageText,userNum);
				return;
			}
			Etrans etrans=CreateEtrans(dateTimeTrans,hqClearinghouseNum,messageText,userNum);
			string command;
			X12object Xobj=X12object.ToX12object(messageText);
			if(Xobj!=null) {//Is a correctly formatted X12 message.
				if(Xobj.IsAckInterchange()) {
					etrans.Etype=EtransType.Ack_Interchange;
					Etranss.Insert(etrans);
					//At some point in the future, we should use TA101 to match to batch number and TA104 to get the ack code, 
					//then update historic etrans entries like we do for 997s, 999s and 277s.
				}
				else if(Xobj.Is997()) {
					X997 x997=new X997(messageText);
					etrans.Etype=EtransType.Acknowledge_997;
					etrans.BatchNumber=x997.GetBatchNumber();
					Etranss.Insert(etrans);
					string batchack=x997.GetBatchAckCode();
					if(batchack=="A"||batchack=="R") {//accepted or rejected
						command="UPDATE etrans SET AckCode='"+batchack+"', "
							+"AckEtransNum="+POut.Long(etrans.EtransNum)
							+" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
							+" AND ClearinghouseNum="+POut.Long(hqClearinghouseNum)
							+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
							+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
							+" AND AckEtransNum=0";
						Db.NonQ(command);
					}
					else {//partially accepted
						List<int> transNums=x997.GetTransNums();
						string ack;
						for(int i=0;i<transNums.Count;i++) {
							ack=x997.GetAckForTrans(transNums[i]);
							if(ack=="A"||ack=="R") {//accepted or rejected
								command="UPDATE etrans SET AckCode='"+ack+"', "
									+"AckEtransNum="+POut.Long(etrans.EtransNum)
									+" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
									+" AND TransSetNum="+POut.Long(transNums[i])
									+" AND ClearinghouseNum="+POut.Long(hqClearinghouseNum)
									+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
									+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
									+" AND AckEtransNum=0";
								Db.NonQ(command);
							}
						}
					}
					//none of the other fields make sense, because this ack could refer to many claims.
				}
				else if(Xobj.Is999()) {
					X999 x999=new X999(messageText);
					etrans.Etype=EtransType.Acknowledge_999;
					etrans.BatchNumber=x999.GetBatchNumber();
					Etranss.Insert(etrans);
					string batchack=x999.GetBatchAckCode();
					if(batchack=="A"||batchack=="R") {//accepted or rejected
					  command="UPDATE etrans SET AckCode='"+batchack+"', "
					    +"AckEtransNum="+POut.Long(etrans.EtransNum)
					    +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
					    +" AND ClearinghouseNum="+POut.Long(hqClearinghouseNum)
					    +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
					    +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
					    +" AND AckEtransNum=0";
					  Db.NonQ(command);
					}
					else {//partially accepted
					  List<int> transNums=x999.GetTransNums();
					  string ack;
					  for(int i=0;i<transNums.Count;i++) {
					    ack=x999.GetAckForTrans(transNums[i]);
					    if(ack=="A"||ack=="R") {//accepted or rejected
					      command="UPDATE etrans SET AckCode='"+ack+"', "
					        +"AckEtransNum="+POut.Long(etrans.EtransNum)
					        +" WHERE BatchNumber="+POut.Long(etrans.BatchNumber)
					        +" AND TransSetNum="+POut.Long(transNums[i])
					        +" AND ClearinghouseNum="+POut.Long(hqClearinghouseNum)
					        +" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
					        +" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1))
					        +" AND AckEtransNum=0";
					      Db.NonQ(command);
					    }
					  }
					}
					//none of the other fields make sense, because this ack could refer to many claims.
				}
				else if(X277.Is277(Xobj)) {
					X277 x277=new X277(messageText);
					etrans.Etype=EtransType.StatusNotify_277;
					Etranss.Insert(etrans);
					List<string> listClaimIdentifiers=x277.GetClaimTrackingNumbers();
					//Dictionary to run one update command per ack code for many claims.
					Dictionary <string,List<X12ClaimMatch>> dictClaimMatchesByAck=new Dictionary<string,List<X12ClaimMatch>>();
					for(int i=0;i<listClaimIdentifiers.Count;i++) {
						X12ClaimMatch claimMatch=new X12ClaimMatch();
						claimMatch.ClaimIdentifier=listClaimIdentifiers[i];
						string[] arrayClaimInfo=x277.GetClaimInfo(claimMatch.ClaimIdentifier);
						claimMatch.PatFname=PIn.String(arrayClaimInfo[0]);
						claimMatch.PatLname=PIn.String(arrayClaimInfo[1]);
						claimMatch.DateServiceStart=PIn.DateT(arrayClaimInfo[6]);
						claimMatch.DateServiceEnd=PIn.DateT(arrayClaimInfo[7]);
						claimMatch.ClaimFee=PIn.Double(arrayClaimInfo[9]);
						claimMatch.SubscriberId=PIn.String(arrayClaimInfo[10]);
						claimMatch.EtransNum=etrans.EtransNum;
						string ack=arrayClaimInfo[3];
						if(!dictClaimMatchesByAck.ContainsKey(ack)) {
							dictClaimMatchesByAck.Add(ack,new List<X12ClaimMatch>());
						}
						dictClaimMatchesByAck[ack].Add(claimMatch);
					}
					foreach(string ack in dictClaimMatchesByAck.Keys) {
						List <long> listClaimNums=Claims.GetClaimFromX12(dictClaimMatchesByAck[ack]);
						if(listClaimNums!=null) {
							listClaimNums=listClaimNums.Where(x => x!=0).ToList();
							if(listClaimNums.Count > 0) {
								//Locate the latest etrans entries for the claims based on DateTimeTrans with EType of ClaimSent or Claim_Ren and update the AckCode and AckEtransNum.
								//We overwrite existing acks from 997s, 999s and older 277s.
								command="UPDATE etrans SET AckCode='"+ack+"', "
									+"AckEtransNum="+POut.Long(etrans.EtransNum)
									+" WHERE EType IN ("+POut.Int((int)EtransType.ClaimSent)+","+POut.Int((int)EtransType.Claim_Ren)+") "
									+" AND ClaimNum IN("+String.Join(",",listClaimNums.Select(x => POut.Long(x)))+")"
									+" AND ClearinghouseNum="+POut.Long(hqClearinghouseNum)
									+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
									+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1));
								Db.NonQ(command);
							}
						}
						//none of the other fields make sense, because this ack could refer to many claims.
					}
				}
				else if(X835.Is835(Xobj)) {
					etrans.Etype=EtransType.ERA_835;
					List <string> listTranSetIds=Xobj.GetTranSetIds();
					List <Etrans> listEtrans=new List<Etrans>();
					List <X835> list835s=new List<X835>();
					//We pull in the 835 data in two loops so that we can ensure the 835 is fully parsed before we create any etrans entries.
					for(int i=0;i<listTranSetIds.Count;i++) {
						etrans.TranSetId835=listTranSetIds[i];
						if(i>0) {
							etrans.EtransNum=0;//To get a new record to insert.
						}
						X835 x835=new X835(etrans,messageText,etrans.TranSetId835);//parse. If parsing fails, then no etrans entries will be inserted.
						etrans.CarrierNameRaw=x835.PayerName;
						List<string> listUniquePatientNames=new List<string>();
						for(int j=0;j<x835.ListClaimsPaid.Count;j++) {
							string patName=x835.ListClaimsPaid[j].PatientName.ToString(false);
							if(!listUniquePatientNames.Contains(patName)) {
								listUniquePatientNames.Add(patName);
							}
						}
						if(listUniquePatientNames.Count==1) {
							etrans.PatientNameRaw=listUniquePatientNames[0];
						}
						else {
							etrans.PatientNameRaw="("+listUniquePatientNames.Count+" "+Lans.g("Etranss","patients")+")";
						}
						listEtrans.Add(etrans.Copy());
						list835s.Add(x835);
					}
					//The 835 was completely parsed.  Create etrans entries.
					for(int i=0;i<listEtrans.Count;i++) {
						etrans=listEtrans[i];
						X835 x835=list835s[i];
						Etranss.Insert(etrans);//insert
						List<long> listClaimNums=x835.ListClaimsPaid.Select(x => x.ClaimNum).Where(x => x!=0).ToList();
						if(listClaimNums.Count > 0) {
							//Locate the latest etrans entries for the claim based on DateTimeTrans with EType of ClaimSent or Claim_Ren and update the AckCode and AckEtransNum.
							//We overwrite existing acks from 997s, 999s, and 277s.
							command="UPDATE etrans SET AckCode='A', "
								+"AckEtransNum="+POut.Long(etrans.EtransNum)
								+" WHERE EType IN (0,3) "//ClaimSent and Claim_Ren
								+" AND ClaimNum IN("+String.Join(",",listClaimNums.Select(x => POut.Long(x)))+")"
								+" AND ClearinghouseNum="+POut.Long(hqClearinghouseNum)
								+" AND DateTimeTrans > "+POut.DateT(dateTimeTrans.AddDays(-14))
								+" AND DateTimeTrans < "+POut.DateT(dateTimeTrans.AddDays(1));
							Db.NonQ(command);
						}
						//none of the other fields make sense, because this ack could refer to many claims.
					}
				}
				else {//unknown type of X12 report.
					etrans.Etype=EtransType.TextReport;
					Etranss.Insert(etrans);
				}
			}
			else {//not X12
				etrans.Etype=EtransType.TextReport;
				Etranss.Insert(etrans);
			}
		}
示例#19
0
		private void gridHistory_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			Etrans et=Etranss.GetEtrans(PIn.Long(tableHistory.Rows[e.Row]["EtransNum"].ToString()));
			if(et.Etype==EtransType.StatusNotify_277) {
				FormEtrans277Edit Form277=new FormEtrans277Edit();
				Form277.EtransCur=et;
				Form277.ShowDialog();
				return;//No refresh needed because 277s are not editable, they are read only.
			}
			if(et.Etype==EtransType.ERA_835) {
				string messageText835=EtransMessageTexts.GetMessageText(et.EtransMessageTextNum);
				X12object x835=new X12object(messageText835);
				List<string> listTranSetIds=x835.GetTranSetIds();
				if(et.TranSetId835=="" && listTranSetIds.Count>=2) {
					FormEtrans835PickEob formPickEob=new FormEtrans835PickEob(listTranSetIds,messageText835,et);
					formPickEob.ShowDialog();
				}
				else {//Only one EOB in the 835.
					FormEtrans835Edit Form835=new FormEtrans835Edit();
					Form835.EtransCur=et;
					Form835.MessageText835=messageText835;
					Form835.TranSetId835="";//Empty string will cause the first EOB in the 835 to display.
					Form835.ShowDialog();
				}
			}
			else {
				FormEtransEdit FormE=new FormEtransEdit();
				FormE.EtransCur=et;
				FormE.ShowDialog();
				if(FormE.DialogResult!=DialogResult.OK) {
					return;
				}
			}
			int scroll=gridHistory.ScrollValue;
			FillHistory();
			for(int i=0;i<tableHistory.Rows.Count;i++){
				if(tableHistory.Rows[i]["EtransNum"].ToString()==et.EtransNum.ToString()){
					gridHistory.SetSelected(i,true);
				}
			}
			gridHistory.ScrollValue=scroll;
		}