Exemplo n.º 1
0
		///<summary>Not for claim types, just other types, including Eligibility. This function gets run first.  Then, the messagetext is created and an attempt is made to send the message.  Finally, the messagetext is added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each message before creating the message and attempting to send.  If it fails, we will need to roll back.  Provide EITHER a carrierNum OR a canadianNetworkNum.  Many transactions can be sent to a carrier or to a network.</summary>
		public static Etrans CreateCanadianOutput(long patNum,long carrierNum,long canadianNetworkNum
			,long clearinghouseNum,EtransType etype,long planNum,long insSubNum,long userNum,bool hasSecondary=false)
		{
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<Etrans>(MethodBase.GetCurrentMethod(),patNum,carrierNum,canadianNetworkNum,clearinghouseNum,etype,planNum,insSubNum,userNum,hasSecondary);
			}
			//validation of carrier vs network
			if(etype==EtransType.Eligibility_CA){
				//only carrierNum is allowed (and required)
				if(carrierNum==0){
					throw new ApplicationException("Carrier not supplied for Etranss.CreateCanadianOutput.");
				}
				if(canadianNetworkNum!=0){
					throw new ApplicationException("NetworkNum not allowed for Etranss.CreateCanadianOutput.");
				}
			}
			Etrans etrans=new Etrans();
			//etrans.DateTimeTrans handled automatically
			etrans.ClearingHouseNum=clearinghouseNum;
			etrans.Etype=etype;
			etrans.ClaimNum=0;//no claim involved
			etrans.PatNum=patNum;
			//CanadianNetworkNum?
			etrans.CarrierNum=carrierNum;
			etrans.PlanNum=planNum;
			etrans.InsSubNum=insSubNum;
			etrans.UserNum=userNum;
			etrans.BatchNumber=0;
			//Get next OfficeSequenceNumber-----------------------------------------------------------------------------------------
			etrans=SetCanadianEtransFields(etrans,hasSecondary);
			Insert(etrans);
			return GetEtrans(etrans.EtransNum);//Since the DateTimeTrans is set upon insert, we need to read the record again in order to get the date.
		}
Exemplo n.º 2
0
        ///<summary>Returns any EtransMessageText where the MessageText is identical to the given messageText.
        ///Otherwise if none returns null.</summary>
        public static EtransMessageText GetMostRecentForType(EtransType type)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <EtransMessageText>(MethodBase.GetCurrentMethod(), type));
            }
            string command = "SELECT etransmessagetext.* FROM etransmessagetext "
                             + "INNER JOIN etrans ON etrans.EtransMessageTextNum=etransmessagetext.EtransMessageTextNum "
                             + "WHERE Etype=" + POut.Int((int)type) + " "
                             + "ORDER BY etrans.DateTimeTrans DESC";

            command = DbHelper.LimitOrderBy(command, 1);         //Most recent entry if any.
            return(Crud.EtransMessageTextCrud.SelectOne(command));
        }
Exemplo n.º 3
0
        ///<summary>Sets the status of the claim to sent, usually as part of printing.  Also makes an entry in etrans.  If this is Canadian eclaims, then this function gets run first.  If the claim is to be sent elecronically, then the messagetext is created after this method and an attempt is made to send the claim.  Finally, the messagetext is added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each claim before creating the message and attempting to send.  For Canadians, it will always record the attempt as an etrans even if claim is not set to status of sent.</summary>
        public static Etrans SetClaimSentOrPrinted(long claimNum, long patNum, long clearinghouseNum, EtransType etype, int batchNumber)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <Etrans>(MethodBase.GetCurrentMethod(), claimNum, patNum, clearinghouseNum, etype, batchNumber));
            }
            string command;
            Etrans etrans = new Etrans();

            //etrans.DateTimeTrans handled automatically
            etrans.ClearingHouseNum = clearinghouseNum;
            etrans.Etype            = etype;
            etrans.ClaimNum         = claimNum;
            etrans.PatNum           = patNum;
            //Get the primary and secondary carrierNums for this claim.
            command = "SELECT carrier1.CarrierNum,carrier2.CarrierNum AS CarrierNum2 FROM claim "
                      + "LEFT JOIN insplan insplan1 ON insplan1.PlanNum=claim.PlanNum "
                      + "LEFT JOIN carrier carrier1 ON carrier1.CarrierNum=insplan1.CarrierNum "
                      + "LEFT JOIN insplan insplan2 ON insplan2.PlanNum=claim.PlanNum2 "
                      + "LEFT JOIN carrier carrier2 ON carrier2.CarrierNum=insplan2.CarrierNum "
                      + "WHERE claim.ClaimNum=" + POut.Long(claimNum);
            DataTable table = Db.GetTable(command);

            etrans.CarrierNum  = PIn.Long(table.Rows[0][0].ToString());
            etrans.CarrierNum2 = PIn.Long(table.Rows[0][1].ToString());          //might be 0 if no secondary on this claim
            etrans.BatchNumber = batchNumber;
            //if(X837.IsX12(messageText)) {
            //	X837 x837=new X837(messageText);
            //	etrans.TransSetNum=x837.GetTransNum(claimNum);
            //}
            if (etype == EtransType.Claim_CA || etype == EtransType.ClaimCOB_CA || etype == EtransType.Predeterm_CA || etype == EtransType.PredetermEOB_CA)
            {
                etrans.OfficeSequenceNumber = 0;
                //find the next officeSequenceNumber
                command = "SELECT MAX(OfficeSequenceNumber) FROM etrans";
                table   = Db.GetTable(command);
                if (table.Rows.Count > 0)
                {
                    etrans.OfficeSequenceNumber = PIn.Int(table.Rows[0][0].ToString());
                    if (etrans.OfficeSequenceNumber == 999999)                   //if the office has sent > 1 million messages, and has looped back around to 1.
                    {
                        throw new ApplicationException
                                  ("OfficeSequenceNumber has maxed out at 999999.  This program will need to be enhanced.");
                    }
                }
#if DEBUG
                etrans.OfficeSequenceNumber = PIn.Int(File.ReadAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt"));
                File.WriteAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt", (etrans.OfficeSequenceNumber + 1).ToString());
#endif
                etrans.OfficeSequenceNumber++;
                //find the next CarrierTransCounter for the primary carrier
                etrans.CarrierTransCounter = 0;
                command = "SELECT MAX(CarrierTransCounter) FROM etrans "
                          + "WHERE CarrierNum=" + POut.Long(etrans.CarrierNum);
                table = Db.GetTable(command);
                int tempcounter = 0;
                if (table.Rows.Count > 0)
                {
                    tempcounter = PIn.Int(table.Rows[0][0].ToString());
                }
                if (tempcounter > etrans.CarrierTransCounter)
                {
                    etrans.CarrierTransCounter = tempcounter;
                }
                command = "SELECT MAX(CarrierTransCounter2) FROM etrans "
                          + "WHERE CarrierNum2=" + POut.Long(etrans.CarrierNum);
                table = Db.GetTable(command);
                if (table.Rows.Count > 0)
                {
                    tempcounter = PIn.Int(table.Rows[0][0].ToString());
                }
                if (tempcounter > etrans.CarrierTransCounter)
                {
                    etrans.CarrierTransCounter = tempcounter;
                }
                if (etrans.CarrierTransCounter == 99999)
                {
                    throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
                }
                etrans.CarrierTransCounter++;
                if (etrans.CarrierNum2 > 0)               //if there is secondary coverage on this claim
                {
                    etrans.CarrierTransCounter2 = 1;
                    command = "SELECT MAX(CarrierTransCounter) FROM etrans "
                              + "WHERE CarrierNum=" + POut.Long(etrans.CarrierNum2);
                    table = Db.GetTable(command);
                    if (table.Rows.Count > 0)
                    {
                        tempcounter = PIn.Int(table.Rows[0][0].ToString());
                    }
                    if (tempcounter > etrans.CarrierTransCounter2)
                    {
                        etrans.CarrierTransCounter2 = tempcounter;
                    }
                    command = "SELECT MAX(CarrierTransCounter2) FROM etrans "
                              + "WHERE CarrierNum2=" + POut.Long(etrans.CarrierNum2);
                    table = Db.GetTable(command);
                    if (table.Rows.Count > 0)
                    {
                        tempcounter = PIn.Int(table.Rows[0][0].ToString());
                    }
                    if (tempcounter > etrans.CarrierTransCounter2)
                    {
                        etrans.CarrierTransCounter2 = tempcounter;
                    }
                    if (etrans.CarrierTransCounter2 == 99999)
                    {
                        throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
                    }
                    etrans.CarrierTransCounter2++;
                }
            }
            command = "UPDATE claim SET ClaimStatus = 'S',"
                      + "DateSent= " + POut.Date(MiscData.GetNowDateTime())
                      + " WHERE claimnum = " + POut.Long(claimNum);
            Db.NonQ(command);
            EtransMessageText etransMessageText = new EtransMessageText();
            etransMessageText.MessageText = "";
            EtransMessageTexts.Insert(etransMessageText);
            etrans.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            Etranss.Insert(etrans);
            return(GetEtrans(etrans.EtransNum));           //Since the DateTimeTrans is set upon insert, we need to read the record again in order to get the date.
        }
Exemplo n.º 4
0
        ///<summary>Not for claim types, just other types, including Eligibility. This function gets run first.  Then, the messagetext is created and an attempt is made to send the message.  Finally, the messagetext is added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each message before creating the message and attempting to send.  If it fails, we will need to roll back.  Provide EITHER a carrierNum OR a canadianNetworkNum.  Many transactions can be sent to a carrier or to a network.</summary>
        public static Etrans CreateCanadianOutput(long patNum, long carrierNum, long canadianNetworkNum, long clearinghouseNum, EtransType etype, long planNum, long insSubNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <Etrans>(MethodBase.GetCurrentMethod(), patNum, carrierNum, canadianNetworkNum, clearinghouseNum, etype, planNum, insSubNum));
            }
            //validation of carrier vs network
            if (etype == EtransType.Eligibility_CA)
            {
                //only carrierNum is allowed (and required)
                if (carrierNum == 0)
                {
                    throw new ApplicationException("Carrier not supplied for Etranss.CreateCanadianOutput.");
                }
                if (canadianNetworkNum != 0)
                {
                    throw new ApplicationException("NetworkNum not allowed for Etranss.CreateCanadianOutput.");
                }
            }
            Etrans etrans = new Etrans();

            //etrans.DateTimeTrans handled automatically
            etrans.ClearingHouseNum = clearinghouseNum;
            etrans.Etype            = etype;
            etrans.ClaimNum         = 0;  //no claim involved
            etrans.PatNum           = patNum;
            //CanadianNetworkNum?
            etrans.CarrierNum = carrierNum;
            etrans.PlanNum    = planNum;
            etrans.InsSubNum  = insSubNum;
            //Get next OfficeSequenceNumber-----------------------------------------------------------------------------------------
            etrans.OfficeSequenceNumber = 0;
            string    command = "SELECT MAX(OfficeSequenceNumber) FROM etrans";
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                etrans.OfficeSequenceNumber = PIn.Int(table.Rows[0][0].ToString());
                if (etrans.OfficeSequenceNumber == 999999)              //if the office has sent > 1 million messages, and has looped back around to 1.
                //get the date of the most recent max
                //This works, but it got even more complex for CarrierTransCounter, so we will just throw an exception for now.

                /*command="SELECT MAX(DateTimeTrans) FROM etrans WHERE OfficeSequenceNumber=999999";
                 * table=Db.GetTable(command);
                 * DateTime maxDateT=PIn.PDateT(table.Rows[0][0].ToString());
                 * //then, just get the max that's newer than that.
                 * command="SELECT MAX(OfficeSequenceNumber) FROM etrans WHERE DateTimeTrans > '"+POut.PDateT(maxDateT)+"'";
                 * table=Db.GetTable(command);
                 * if(table.Rows.Count>0) {
                 *      etrans.OfficeSequenceNumber=PIn.PInt(table.Rows[0][0].ToString());
                 * }*/
                {
                    throw new ApplicationException("OfficeSequenceNumber has maxed out at 999999.  This program will need to be enhanced.");
                }
            }
                        #if DEBUG
            etrans.OfficeSequenceNumber = PIn.Int(File.ReadAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt"));
            File.WriteAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt", (etrans.OfficeSequenceNumber + 1).ToString());
                        #endif
            etrans.OfficeSequenceNumber++;
            //if(etype==EtransType.Eligibility_CA){ //The counter must be incremented for all transaction types, according to the documentation for field A09 Carrier Transaction Counter.
            //find the next CarrierTransCounter------------------------------------------------------------------------------------
            etrans.CarrierTransCounter = 0;
            command = "SELECT MAX(CarrierTransCounter) FROM etrans "
                      + "WHERE CarrierNum=" + POut.Long(etrans.CarrierNum);
            table = Db.GetTable(command);
            int tempcounter = 0;
            if (table.Rows.Count > 0)
            {
                tempcounter = PIn.Int(table.Rows[0][0].ToString());
            }
            if (tempcounter > etrans.CarrierTransCounter)
            {
                etrans.CarrierTransCounter = tempcounter;
            }
            command = "SELECT MAX(CarrierTransCounter2) FROM etrans "
                      + "WHERE CarrierNum2=" + POut.Long(etrans.CarrierNum);
            table = Db.GetTable(command);
            if (table.Rows.Count > 0)
            {
                tempcounter = PIn.Int(table.Rows[0][0].ToString());
            }
            if (tempcounter > etrans.CarrierTransCounter)
            {
                etrans.CarrierTransCounter = tempcounter;
            }
            if (etrans.CarrierTransCounter == 99999)
            {
                throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
                //maybe by adding a reset date to the preference table which will apply to all counters as a whole.
            }
            etrans.CarrierTransCounter++;
            //}
            Insert(etrans);
            return(GetEtrans(etrans.EtransNum));           //Since the DateTimeTrans is set upon insert, we need to read the record again in order to get the date.
        }
Exemplo n.º 5
0
 ///<summary>Sets the status of the claim to sent, usually as part of printing.  Also makes an entry in etrans.  If this is Canadian eclaims, then this function gets run first, and it doesn't actually set the claim as sent.  If the claim is to be sent elecronically, then the messagetext is created after this method and an attempt is made to send the claim.  Finally, the messagetext is added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each claim before creating the message and attempting to send.  For Canadians, it will always record the attempt as an etrans even if claim is not set to status of sent.</summary>
 public static Etrans SetClaimSentOrPrinted(long claimNum,long patNum,long clearinghouseNum,EtransType etype,int batchNumber)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         return Meth.GetObject<Etrans>(MethodBase.GetCurrentMethod(),claimNum,patNum,clearinghouseNum,etype,batchNumber);
     }
     string command;
     Etrans etrans=new Etrans();
     //etrans.DateTimeTrans handled automatically
     etrans.ClearingHouseNum=clearinghouseNum;
     etrans.Etype=etype;
     etrans.ClaimNum=claimNum;
     etrans.PatNum=patNum;
     //Get the primary and secondary carrierNums for this claim.
     command="SELECT carrier1.CarrierNum,carrier2.CarrierNum AS CarrierNum2 FROM claim "
         +"LEFT JOIN insplan insplan1 ON insplan1.PlanNum=claim.PlanNum "
         +"LEFT JOIN carrier carrier1 ON carrier1.CarrierNum=insplan1.CarrierNum "
         +"LEFT JOIN insplan insplan2 ON insplan2.PlanNum=claim.PlanNum2 "
         +"LEFT JOIN carrier carrier2 ON carrier2.CarrierNum=insplan2.CarrierNum "
         +"WHERE claim.ClaimNum="+POut.Long(claimNum);
     DataTable table=Db.GetTable(command);
     etrans.CarrierNum=PIn.Long(table.Rows[0][0].ToString());
     etrans.CarrierNum2=PIn.Long(table.Rows[0][1].ToString());//might be 0 if no secondary on this claim
     etrans.BatchNumber=batchNumber;
     //if(X837.IsX12(messageText)) {
     //	X837 x837=new X837(messageText);
     //	etrans.TransSetNum=x837.GetTransNum(claimNum);
     //}
     if(etype==EtransType.Claim_CA || etype==EtransType.ClaimCOB_CA || etype==EtransType.Predeterm_CA || etype==EtransType.PredetermEOB_CA) {
         etrans.OfficeSequenceNumber=0;
         //find the next officeSequenceNumber
         command="SELECT MAX(OfficeSequenceNumber) FROM etrans";
         table=Db.GetTable(command);
         if(table.Rows.Count>0) {
             etrans.OfficeSequenceNumber=PIn.Int(table.Rows[0][0].ToString());
             if(etrans.OfficeSequenceNumber==999999) {//if the office has sent > 1 million messages, and has looped back around to 1.
                 throw new ApplicationException
                     ("OfficeSequenceNumber has maxed out at 999999.  This program will need to be enhanced.");
             }
         }
     #if DEBUG
         etrans.OfficeSequenceNumber=PIn.Int(File.ReadAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt"));
         File.WriteAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt",(etrans.OfficeSequenceNumber+1).ToString());
     #endif
         etrans.OfficeSequenceNumber++;
         //find the next CarrierTransCounter for the primary carrier
         etrans.CarrierTransCounter=0;
         command="SELECT MAX(CarrierTransCounter) FROM etrans "
             +"WHERE CarrierNum="+POut.Long(etrans.CarrierNum);
         table=Db.GetTable(command);
         int tempcounter=0;
         if(table.Rows.Count>0) {
             tempcounter=PIn.Int(table.Rows[0][0].ToString());
         }
         if(tempcounter>etrans.CarrierTransCounter) {
             etrans.CarrierTransCounter=tempcounter;
         }
         command="SELECT MAX(CarrierTransCounter2) FROM etrans "
             +"WHERE CarrierNum2="+POut.Long(etrans.CarrierNum);
         table=Db.GetTable(command);
         if(table.Rows.Count>0) {
             tempcounter=PIn.Int(table.Rows[0][0].ToString());
         }
         if(tempcounter>etrans.CarrierTransCounter) {
             etrans.CarrierTransCounter=tempcounter;
         }
         if(etrans.CarrierTransCounter==99999) {
             throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
         }
         etrans.CarrierTransCounter++;
         if(etrans.CarrierNum2>0) {//if there is secondary coverage on this claim
             etrans.CarrierTransCounter2=1;
             command="SELECT MAX(CarrierTransCounter) FROM etrans "
                 +"WHERE CarrierNum="+POut.Long(etrans.CarrierNum2);
             table=Db.GetTable(command);
             if(table.Rows.Count>0) {
                 tempcounter=PIn.Int(table.Rows[0][0].ToString());
             }
             if(tempcounter>etrans.CarrierTransCounter2) {
                 etrans.CarrierTransCounter2=tempcounter;
             }
             command="SELECT MAX(CarrierTransCounter2) FROM etrans "
                 +"WHERE CarrierNum2="+POut.Long(etrans.CarrierNum2);
             table=Db.GetTable(command);
             if(table.Rows.Count>0) {
                 tempcounter=PIn.Int(table.Rows[0][0].ToString());
             }
             if(tempcounter>etrans.CarrierTransCounter2) {
                 etrans.CarrierTransCounter2=tempcounter;
             }
             if(etrans.CarrierTransCounter2==99999) {
                 throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
             }
             etrans.CarrierTransCounter2++;
         }
     }
     command="UPDATE claim SET ClaimStatus = 'S',"
         +"DateSent= "+POut.Date(MiscData.GetNowDateTime())
         +" WHERE claimnum = "+POut.Long(claimNum);
     Db.NonQ(command);
     EtransMessageText etransMessageText=new EtransMessageText();
     etransMessageText.MessageText="";
     EtransMessageTexts.Insert(etransMessageText);
     etrans.EtransMessageTextNum=etransMessageText.EtransMessageTextNum;
     Etranss.Insert(etrans);
     return GetEtrans(etrans.EtransNum);//Since the DateTimeTrans is set upon insert, we need to read the record again in order to get the date.
 }
Exemplo n.º 6
0
 ///<summary>Not for claim types, just other types, including Eligibility. This function gets run first.  Then, the messagetext is created and an attempt is made to send the message.  Finally, the messagetext is added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each message before creating the message and attempting to send.  If it fails, we will need to roll back.  Provide EITHER a carrierNum OR a canadianNetworkNum.  Many transactions can be sent to a carrier or to a network.</summary>
 public static Etrans CreateCanadianOutput(long patNum,long carrierNum,long canadianNetworkNum,long clearinghouseNum,EtransType etype,long planNum,long insSubNum)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         return Meth.GetObject<Etrans>(MethodBase.GetCurrentMethod(),patNum,carrierNum,canadianNetworkNum,clearinghouseNum,etype,planNum,insSubNum);
     }
     //validation of carrier vs network
     if(etype==EtransType.Eligibility_CA){
         //only carrierNum is allowed (and required)
         if(carrierNum==0){
             throw new ApplicationException("Carrier not supplied for Etranss.CreateCanadianOutput.");
         }
         if(canadianNetworkNum!=0){
             throw new ApplicationException("NetworkNum not allowed for Etranss.CreateCanadianOutput.");
         }
     }
     Etrans etrans=new Etrans();
     //etrans.DateTimeTrans handled automatically
     etrans.ClearingHouseNum=clearinghouseNum;
     etrans.Etype=etype;
     etrans.ClaimNum=0;//no claim involved
     etrans.PatNum=patNum;
     //CanadianNetworkNum?
     etrans.CarrierNum=carrierNum;
     etrans.PlanNum=planNum;
     etrans.InsSubNum=insSubNum;
     //Get next OfficeSequenceNumber-----------------------------------------------------------------------------------------
     etrans.OfficeSequenceNumber=0;
     string command="SELECT MAX(OfficeSequenceNumber) FROM etrans";
     DataTable table=Db.GetTable(command);
     if(table.Rows.Count>0) {
         etrans.OfficeSequenceNumber=PIn.Int(table.Rows[0][0].ToString());
         if(etrans.OfficeSequenceNumber==999999){//if the office has sent > 1 million messages, and has looped back around to 1.
             //get the date of the most recent max
             //This works, but it got even more complex for CarrierTransCounter, so we will just throw an exception for now.
             /*command="SELECT MAX(DateTimeTrans) FROM etrans WHERE OfficeSequenceNumber=999999";
             table=Db.GetTable(command);
             DateTime maxDateT=PIn.PDateT(table.Rows[0][0].ToString());
             //then, just get the max that's newer than that.
             command="SELECT MAX(OfficeSequenceNumber) FROM etrans WHERE DateTimeTrans > '"+POut.PDateT(maxDateT)+"'";
             table=Db.GetTable(command);
             if(table.Rows.Count>0) {
                 etrans.OfficeSequenceNumber=PIn.PInt(table.Rows[0][0].ToString());
             }*/
             throw new ApplicationException("OfficeSequenceNumber has maxed out at 999999.  This program will need to be enhanced.");
         }
     }
     #if DEBUG
         etrans.OfficeSequenceNumber=PIn.Int(File.ReadAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt"));
         File.WriteAllText(@"..\..\..\TestCanada\LastOfficeSequenceNumber.txt",(etrans.OfficeSequenceNumber+1).ToString());
     #endif
     etrans.OfficeSequenceNumber++;
     //if(etype==EtransType.Eligibility_CA){ //The counter must be incremented for all transaction types, according to the documentation for field A09 Carrier Transaction Counter.
         //find the next CarrierTransCounter------------------------------------------------------------------------------------
         etrans.CarrierTransCounter=0;
         command="SELECT MAX(CarrierTransCounter) FROM etrans "
             +"WHERE CarrierNum="+POut.Long(etrans.CarrierNum);
         table=Db.GetTable(command);
         int tempcounter=0;
         if(table.Rows.Count>0) {
             tempcounter=PIn.Int(table.Rows[0][0].ToString());
         }
         if(tempcounter>etrans.CarrierTransCounter) {
             etrans.CarrierTransCounter=tempcounter;
         }
         command="SELECT MAX(CarrierTransCounter2) FROM etrans "
             +"WHERE CarrierNum2="+POut.Long(etrans.CarrierNum);
         table=Db.GetTable(command);
         if(table.Rows.Count>0) {
             tempcounter=PIn.Int(table.Rows[0][0].ToString());
         }
         if(tempcounter>etrans.CarrierTransCounter) {
             etrans.CarrierTransCounter=tempcounter;
         }
         if(etrans.CarrierTransCounter==99999){
             throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
             //maybe by adding a reset date to the preference table which will apply to all counters as a whole.
         }
         etrans.CarrierTransCounter++;
     //}
     Insert(etrans);
     return GetEtrans(etrans.EtransNum);//Since the DateTimeTrans is set upon insert, we need to read the record again in order to get the date.
 }
Exemplo n.º 7
0
        ///<summary>Supply a list of ClaimSendQueueItems.  Called from FormClaimSend.  Can only send to one clearinghouse at a time.
        ///The queueItems must contain at least one item.  Each item in queueItems must have the same ClinicNum.  Cannot include Canadian.</summary>
        public static void SendBatch(Clearinghouse clearinghouseClin, List <ClaimSendQueueItem> queueItems, EnumClaimMedType medType,
                                     IFormClaimFormItemEdit formClaimFormItemEdit, Renaissance.FillRenaissanceDelegate fillRenaissance, ITerminalConnector terminalConnector)
        {
            string messageText = "";

            if (clearinghouseClin.Eformat == ElectronicClaimFormat.Canadian)
            {
                MessageBox.Show(Lans.g("Eclaims", "Cannot send Canadian claims as part of Eclaims.SendBatch."));
                return;
            }
            //get next batch number for this clearinghouse
            int batchNum = Clearinghouses.GetNextBatchNumber(clearinghouseClin);

            //---------------------------------------------------------------------------------------
            //Create the claim file for this clearinghouse
            if (clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_4010 ||
                clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_5010_dental ||
                clearinghouseClin.Eformat == ElectronicClaimFormat.x837_5010_med_inst)
            {
                messageText = x837Controller.SendBatch(clearinghouseClin, queueItems, batchNum, medType, false);
            }
            else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Renaissance)
            {
                messageText = Renaissance.SendBatch(clearinghouseClin, queueItems, batchNum, formClaimFormItemEdit, fillRenaissance);
            }
            else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Dutch)
            {
                messageText = Dutch.SendBatch(clearinghouseClin, queueItems, batchNum);
            }
            else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Ramq)
            {
                messageText = Ramq.SendBatch(clearinghouseClin, queueItems, batchNum);
            }
            else
            {
                messageText = "";      //(ElectronicClaimFormat.None does not get sent)
            }
            if (messageText == "")     //if failed to create claim file properly,
            {
                return;                //don't launch program or change claim status
            }
            //----------------------------------------------------------------------------------------
            //Launch Client Program for this clearinghouse if applicable
            if (clearinghouseClin.CommBridge == EclaimsCommBridge.None)
            {
                AttemptLaunch(clearinghouseClin, batchNum);
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.WebMD)
            {
                if (!WebMD.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + WebMD.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.BCBSGA)
            {
                if (!BCBSGA.Launch(clearinghouseClin, batchNum, terminalConnector))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + BCBSGA.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.Renaissance)
            {
                AttemptLaunch(clearinghouseClin, batchNum);
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.ClaimConnect)
            {
                if (ClaimConnect.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show("Upload successful.");
                }
                else
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + ClaimConnect.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.RECS)
            {
                if (!RECS.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but could not launch RECS client.") + "\r\n" + RECS.ErrorMessage);
                    //continue;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.Inmediata)
            {
                if (!Inmediata.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but could not launch Inmediata client.") + "\r\n" + Inmediata.ErrorMessage);
                    //continue;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.AOS)           // added by SPK 7/13/05
            {
                if (!AOS.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but could not launch AOS Communicator.") + "\r\n" + AOS.ErrorMessage);
                    //continue;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.PostnTrack)
            {
                AttemptLaunch(clearinghouseClin, batchNum);
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.MercuryDE)
            {
                if (!MercuryDE.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + MercuryDE.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.ClaimX)
            {
                if (!ClaimX.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but encountered an error while launching ClaimX Client.") + ":\r\n" + ClaimX.ErrorMessage);
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.EmdeonMedical)
            {
                if (!EmdeonMedical.Launch(clearinghouseClin, batchNum, medType))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + EmdeonMedical.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.DentiCal)
            {
                if (!DentiCal.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + DentiCal.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.NHS)
            {
                if (!NHS.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + NHS.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.EDS)
            {
                if (!EDS.Launch(clearinghouseClin, messageText))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + EDS.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.Ramq)
            {
                if (!Ramq.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + Ramq.ErrorMessage);
                    return;
                }
            }
            //----------------------------------------------------------------------------------------
            //finally, mark the claims sent. (only if not Canadian)
            EtransType etype = EtransType.ClaimSent;

            if (clearinghouseClin.Eformat == ElectronicClaimFormat.Renaissance)
            {
                etype = EtransType.Claim_Ren;
            }
            //Canadians cannot send in batches (see above).  RAMQ is performing a similar algorithm but the steps are in a different order in Ramq.cs.
            if (clearinghouseClin.Eformat != ElectronicClaimFormat.Canadian && clearinghouseClin.Eformat != ElectronicClaimFormat.Ramq)
            {
                //Create the etransmessagetext that all claims in the batch will point to.
                EtransMessageText etransMsgText = new EtransMessageText();
                etransMsgText.MessageText = messageText;
                EtransMessageTexts.Insert(etransMsgText);
                for (int j = 0; j < queueItems.Count; j++)
                {
                    Etrans etrans = Etranss.SetClaimSentOrPrinted(queueItems[j].ClaimNum, queueItems[j].PatNum,
                                                                  clearinghouseClin.HqClearinghouseNum, etype, batchNum, Security.CurUser.UserNum);
                    etrans.EtransMessageTextNum = etransMsgText.EtransMessageTextNum;
                    Etranss.Update(etrans);
                    //Now we need to update our cache of claims to reflect the change that took place in the database above in Etranss.SetClaimSentOrPrinted()
                    queueItems[j].ClaimStatus = "S";
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>claimType="P" or "S".</summary>
        public static Claim CreateClaim(string claimType, List <PatPlan> PatPlanList, List <InsPlan> InsPlanList, List <ClaimProc> ClaimProcList, List <Procedure> procsForPat, Patient pat, List <Procedure> procsForClaim, List <Benefit> benefitList, List <InsSub> SubList)
        {
            //Claim ClaimCur=CreateClaim("P",PatPlanList,InsPlanList,ClaimProcList,procsForPat);
            long       claimFormNum = 0;
            EtransType eFormat      = 0;
            InsPlan    PlanCur1     = new InsPlan();
            InsSub     SubCur1      = new InsSub();
            InsPlan    PlanCur2     = new InsPlan();
            InsSub     SubCur2      = new InsSub();
            Relat      relatOther   = Relat.Self;

            switch (claimType)
            {
            case "P":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null
                break;

            case "S":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null
                break;
            }
            //DataTable table=DataSetMain.Tables["account"];
            Procedure proc;

            //proc=Procedures.GetProcFromList(procsForPat,PIn.Long(table.Rows[gridAccount.SelectedIndices[0]]["ProcNum"].ToString()));
            //long clinicNum=proc.ClinicNum;
            ClaimProc[] claimProcs = new ClaimProc[procsForClaim.Count];          //1:1 with procs
            long        procNum;

            for (int i = 0; i < procsForClaim.Count; i++)       //loop through selected procs
            //and try to find an estimate that can be used
            {
                procNum       = procsForClaim[i].ProcNum;
                claimProcs[i] = Procedures.GetClaimProcEstimate(procNum, ClaimProcList, PlanCur1, SubCur1.InsSubNum);
            }
            for (int i = 0; i < claimProcs.Length; i++)       //loop through each claimProc
            //and create any missing estimates. This handles claims to 3rd and 4th ins co's.
            {
                if (claimProcs[i] == null)
                {
                    claimProcs[i] = new ClaimProc();
                    proc          = procsForClaim[i];
                    ClaimProcs.CreateEst(claimProcs[i], proc, PlanCur1, SubCur1);
                }
            }
            Claim claim = new Claim();

            Claims.Insert(claim);            //to retreive a key for new Claim.ClaimNum
            claim.PatNum      = pat.PatNum;
            claim.DateService = claimProcs[claimProcs.Length - 1].ProcDate;
            claim.ClinicNum   = procsForClaim[0].ClinicNum;
            claim.DateSent    = DateTime.Today;
            claim.ClaimStatus = "S";
            //datereceived
            switch (claimType)
            {
            case "P":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 1);
                claim.ClaimType  = "P";
                claim.PlanNum2   = SubCur2.PlanNum;                    //might be 0 if no sec ins
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 2);
                break;

            case "S":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 2);
                claim.ClaimType  = "S";
                claim.PlanNum2   = SubCur2.PlanNum;
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 1);
                break;
            }
            claim.ProvTreat     = procsForClaim[0].ProvNum;
            claim.IsProsthesis  = "I";
            claim.ProvBill      = Providers.GetBillingProvNum(claim.ProvTreat, claim.ClinicNum);
            claim.EmployRelated = YN.No;
            //attach procedures
            Procedure ProcCur;

            for (int i = 0; i < claimProcs.Length; i++)
            {
                ProcCur = procsForClaim[i];
                claimProcs[i].ClaimNum = claim.ClaimNum;
                claimProcs[i].Status   = ClaimProcStatus.NotReceived;            //status for claims unsent or sent.
                //writeoff handled in ClaimL.CalculateAndUpdate()
                claimProcs[i].CodeSent = ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode;
                if (claimProcs[i].CodeSent.Length > 5 && claimProcs[i].CodeSent.Substring(0, 1) == "D")
                {
                    claimProcs[i].CodeSent = claimProcs[i].CodeSent.Substring(0, 5);
                }
                claimProcs[i].LineNumber = (byte)(i + 1);
                ClaimProcs.Update(claimProcs[i]);
            }
            ClaimProcList = ClaimProcs.Refresh(pat.PatNum);
            ClaimL.CalculateAndUpdate(procsForPat, InsPlanList, claim, PatPlanList, benefitList, pat.Age, SubList);
            return(claim);
        }
Exemplo n.º 9
0
		///<summary>Returns an etrans that has not been inserted into the DB.
		///Should only be called with etrans is related an EtransType that is of claim type, currently no validation is done in this function to ensure this.</summary>
		public static Etrans CreateEtransForClaim(long claimNum,long patNum,long clearinghouseNum,EtransType etype,int batchNumber,long userNum) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<Etrans>(MethodBase.GetCurrentMethod(),claimNum,patNum,clearinghouseNum,etype,batchNumber,userNum);
			}
			Etrans etrans=new Etrans();
			//etrans.DateTimeTrans handled automatically
			etrans.ClearingHouseNum=clearinghouseNum;
			etrans.Etype=etype;
			etrans.ClaimNum=claimNum;
			etrans.PatNum=patNum;
			etrans.UserNum=userNum;
			//Get the primary and secondary carrierNums for this claim.
			string command="SELECT carrier1.CarrierNum,carrier2.CarrierNum AS CarrierNum2 FROM claim "
				+"LEFT JOIN insplan insplan1 ON insplan1.PlanNum=claim.PlanNum "
				+"LEFT JOIN carrier carrier1 ON carrier1.CarrierNum=insplan1.CarrierNum "
				+"LEFT JOIN insplan insplan2 ON insplan2.PlanNum=claim.PlanNum2 "
				+"LEFT JOIN carrier carrier2 ON carrier2.CarrierNum=insplan2.CarrierNum "
				+"WHERE claim.ClaimNum="+POut.Long(claimNum);
			DataTable table=Db.GetTable(command);
			if(table.Rows.Count > 0) {//The claim could have been deleted by someone else.  Don't worry about preserving the carrier information.  Set to 0.
				etrans.CarrierNum=PIn.Long(table.Rows[0][0].ToString());
				etrans.CarrierNum2=PIn.Long(table.Rows[0][1].ToString());//might be 0 if no secondary on this claim
			}
			else {
				etrans.Note=Lans.g(nameof(Etrans),"Primry carrier and secondary carrier are unknown due to missing claim.  Invalid ClaimNum.  "
					+"Claim may have been deleted during sending.");
			}
			etrans.BatchNumber=batchNumber;
			return etrans;
		}
Exemplo n.º 10
0
		///<summary>Sets the status of the claim to sent, usually as part of printing.  Also makes an entry in etrans.  If this is Canadian eclaims, then this function gets run first.  If the claim is to be sent elecronically, then the messagetext is created after this method and an attempt is made to send the claim.  Finally, the messagetext is added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each claim before creating the message and attempting to send.  For Canadians, it will always record the attempt as an etrans even if claim is not set to status of sent.</summary>
		public static Etrans SetClaimSentOrPrinted(long claimNum,long patNum,long clearinghouseNum,EtransType etype,int batchNumber,long userNum) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<Etrans>(MethodBase.GetCurrentMethod(),claimNum,patNum,clearinghouseNum,etype,batchNumber,userNum);
			}
			Etrans etrans=CreateEtransForClaim(claimNum,patNum,clearinghouseNum,etype,batchNumber,userNum);
			etrans=SetCanadianEtransFields(etrans);//etrans.CarrierNum, etrans.CarrierNum2 and etrans.EType all set prior to calling this.
			Claims.SetClaimSent(claimNum);
			Insert(etrans);
			return GetEtrans(etrans.EtransNum);//Since the DateTimeTrans is set upon insert, we need to read the record again in order to get the date.
		}
Exemplo n.º 11
0
        ///<summary>Supply a list of ClaimSendQueueItems. Called from FormClaimSend.  Can only send to one clearinghouse at a time.  Able to send just send one claim.  Cannot include Canadian.</summary>
        public static void SendBatch(List <ClaimSendQueueItem> queueItems, Clearinghouse clearhouse, EnumClaimMedType medType)
        {
            string messageText = "";

            if (clearhouse.Eformat == ElectronicClaimFormat.Canadian)
            {
                MsgBox.Show("Eclaims", "Cannot send Canadian claims as part of Eclaims.SendBatch.");
                return;
            }
            //get next batch number for this clearinghouse
            int batchNum = Clearinghouses.GetNextBatchNumber(clearhouse);

            //---------------------------------------------------------------------------------------
            //Create the claim file for this clearinghouse
            if (clearhouse.Eformat == ElectronicClaimFormat.x837D_4010 ||
                clearhouse.Eformat == ElectronicClaimFormat.x837D_5010_dental ||
                clearhouse.Eformat == ElectronicClaimFormat.x837_5010_med_inst)
            {
                messageText = x837Controller.SendBatch(queueItems, batchNum, clearhouse, medType);
            }
            else if (clearhouse.Eformat == ElectronicClaimFormat.Renaissance)
            {
                messageText = Renaissance.SendBatch(queueItems, batchNum);
            }
            else if (clearhouse.Eformat == ElectronicClaimFormat.Dutch)
            {
                messageText = Dutch.SendBatch(queueItems, batchNum);
            }
            else
            {
                messageText = "";      //(ElectronicClaimFormat.None does not get sent)
            }
            if (messageText == "")     //if failed to create claim file properly,
            {
                return;                //don't launch program or change claim status
            }
            //----------------------------------------------------------------------------------------
            //Launch Client Program for this clearinghouse if applicable
            if (clearhouse.CommBridge == EclaimsCommBridge.None)
            {
                AttemptLaunch(clearhouse, batchNum);
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.WebMD)
            {
                if (!WebMD.Launch(clearhouse, batchNum))
                {
                    MessageBox.Show(Lan.g("Eclaims", "Error sending."));
                    return;
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.BCBSGA)
            {
                if (!BCBSGA.Launch(clearhouse, batchNum))
                {
                    MessageBox.Show(Lan.g("Eclaims", "Error sending."));
                    return;
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.Renaissance)
            {
                AttemptLaunch(clearhouse, batchNum);
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.ClaimConnect)
            {
                if (!ClaimConnect.Launch(clearhouse, batchNum))
                {
                    MessageBox.Show(Lan.g("Eclaims", "Error sending."));
                    return;
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.RECS)
            {
                if (!RECS.Launch(clearhouse, batchNum))
                {
                    MessageBox.Show("Claim file created, but could not launch RECS client.");
                    //continue;
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.Inmediata)
            {
                if (!Inmediata.Launch(clearhouse, batchNum))
                {
                    MessageBox.Show("Claim file created, but could not launch Inmediata client.");
                    //continue;
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.AOS)           // added by SPK 7/13/05
            {
                if (!AOS.Launch(clearhouse, batchNum))
                {
                    MessageBox.Show("Claim file created, but could not launch AOS Communicator.");
                    //continue;
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.PostnTrack)
            {
                AttemptLaunch(clearhouse, batchNum);
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.MercuryDE)
            {
                if (!MercuryDE.Launch(clearhouse, batchNum))
                {
                    MsgBox.Show("Eclaims", "Error sending.");
                    return;
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.ClaimX)
            {
                if (!ClaimX.Launch(clearhouse, batchNum))
                {
                    MessageBox.Show("Claim file created, but encountered an error while launching ClaimX Client.");
                }
            }
            else if (clearhouse.CommBridge == EclaimsCommBridge.EmdeonMedical)
            {
                if (!EmdeonMedical.Launch(clearhouse, batchNum, medType))
                {
                    MessageBox.Show(Lan.g("Eclaims", "Error sending."));
                    return;
                }
            }
            //----------------------------------------------------------------------------------------
            //finally, mark the claims sent. (only if not Canadian)
            EtransType etype = EtransType.ClaimSent;

            if (clearhouse.Eformat == ElectronicClaimFormat.Renaissance)
            {
                etype = EtransType.Claim_Ren;
            }
            if (clearhouse.Eformat != ElectronicClaimFormat.Canadian)
            {
                for (int j = 0; j < queueItems.Count; j++)
                {
                    Etrans etrans = Etranss.SetClaimSentOrPrinted(queueItems[j].ClaimNum, queueItems[j].PatNum, clearhouse.ClearinghouseNum, etype, batchNum);
                    Etranss.SetMessage(etrans.EtransNum, messageText);
                }
            }
        }
Exemplo n.º 12
0
        ///<summary>Supply an arrayList of type ClaimSendQueueItem. Called from FormClaimSend.  Can send to multiple clearinghouses simultaneously.</summary>
        public static void SendBatches(ArrayList queueItems)
        {
            //claimsByCHouse is of type ClaimSendQueueItem
            ArrayList[] claimsByCHouse = new ArrayList[Clearinghouses.List.Length];
            for (int i = 0; i < claimsByCHouse.Length; i++)
            {
                claimsByCHouse[i] = new ArrayList();
            }
            //divide the items by clearinghouse:
            for (int i = 0; i < queueItems.Count; i++)
            {
                claimsByCHouse[Clearinghouses.GetIndex(((ClaimSendQueueItem)queueItems[i]).ClearinghouseNum)]
                .Add(queueItems[i]);
            }
            //for any clearinghouses with claims, send them:
            int  batchNum;
            bool result = true;

            for (int i = 0; i < claimsByCHouse.Length; i++)
            {
                if (claimsByCHouse[i].Count == 0)
                {
                    continue;
                }
                //get next batch number for this clearinghouse
                batchNum = Clearinghouses.GetNextBatchNumber(Clearinghouses.List[i]);
                //---------------------------------------------------------------------------------------
                //Create the claim file(s) for this clearinghouse
                if (Clearinghouses.List[i].Eformat == ElectronicClaimFormat.X12)
                {
                    result = X12.SendBatch(claimsByCHouse[i], batchNum);
                }
                else if (Clearinghouses.List[i].Eformat == ElectronicClaimFormat.Renaissance)
                {
                    result = Renaissance.SendBatch(claimsByCHouse[i], batchNum);
                }
                else if (Clearinghouses.List[i].Eformat == ElectronicClaimFormat.Canadian)
                {
                    //Canadian is a little different because we need the sequence numbers.
                    //So all programs are launched and statuses changed from within Canadian.SendBatch()
                    //We don't care what the result is.
                    Canadian.SendBatch(claimsByCHouse[i], batchNum);
                    continue;
                }
                else
                {
                    result = false;         //(ElectronicClaimFormat.None does not get sent)
                }
                if (!result)                //if failed to create claim file properly,
                {
                    continue;               //don't launch program or change claim status
                }
                //----------------------------------------------------------------------------------------
                //Launch Client Program for this clearinghouse if applicable
                if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.None)
                {
                    AttemptLaunch(Clearinghouses.List[i], batchNum);
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.WebMD)
                {
                    if (!WebMD.Launch(Clearinghouses.List[i], batchNum))
                    {
                        MessageBox.Show(Lan.g("Eclaims", "Error sending."));
                        continue;
                    }
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.BCBSGA)
                {
                    if (!BCBSGA.Launch(Clearinghouses.List[i], batchNum))
                    {
                        MessageBox.Show(Lan.g("Eclaims", "Error sending."));
                        continue;
                    }
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.Renaissance)
                {
                    AttemptLaunch(Clearinghouses.List[i], batchNum);
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.ClaimConnect)
                {
                    if (!WebClaim.Launch(Clearinghouses.List[i], batchNum))
                    {
                        MessageBox.Show(Lan.g("Eclaims", "Error sending."));
                        continue;
                    }
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.RECS)
                {
                    if (!RECS.Launch(Clearinghouses.List[i], batchNum))
                    {
                        MessageBox.Show("Claim file created, but could not launch RECS client.");
                        //continue;
                    }
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.Inmediata)
                {
                    if (!Inmediata.Launch(Clearinghouses.List[i], batchNum))
                    {
                        MessageBox.Show("Claim file created, but could not launch Inmediata client.");
                        //continue;
                    }
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.AOS)               // added by SPK 7/13/05
                {
                    if (!AOS.Launch(Clearinghouses.List[i], batchNum))
                    {
                        MessageBox.Show("Claim file created, but could not launch AOS Communicator.");
                        //continue;
                    }
                }
                else if (Clearinghouses.List[i].CommBridge == EclaimsCommBridge.PostnTrack)
                {
                    AttemptLaunch(Clearinghouses.List[i], batchNum);
                    //if(!PostnTrack.Launch(Clearinghouses.List[i],batchNum)){
                    //	MessageBox.Show("Claim file created, but could not launch AOS Communicator.");
                    //continue;
                    //}
                }
                //----------------------------------------------------------------------------------------
                //finally, mark the claims sent. (only if not Canadian)
                EtransType etype = EtransType.ClaimSent;
                if (Clearinghouses.List[i].Eformat == ElectronicClaimFormat.Renaissance)
                {
                    etype = EtransType.Claim_Ren;
                }
                if (Clearinghouses.List[i].Eformat != ElectronicClaimFormat.Canadian)
                {
                    for (int j = 0; j < claimsByCHouse[i].Count; j++)
                    {
                        Etranss.SetClaimSentOrPrinted(((ClaimSendQueueItem)claimsByCHouse[i][j]).ClaimNum,
                                                      ((ClaimSendQueueItem)claimsByCHouse[i][j]).PatNum,
                                                      Clearinghouses.List[i].ClearinghouseNum, etype);
                    }
                }
            }            //for(int i=0;i<claimsByCHouse.Length;i++){
        }
Exemplo n.º 13
0
        ///<summary>Not for claim types, just other types, including Eligibility. This function gets run first.  Then, the messagetext is created and an attempt is made to send the message.  Finally, the messagetext is added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each message before creating the message and attempting to send.  If it fails, we will need to roll back.  Provide EITHER a carrierNum OR a canadianNetworkNum.  Many transactions can be sent to a carrier or to a network.</summary>
        public static Etrans CreateCanadianOutput(int patNum, int carrierNum, int canadianNetworkNum, int clearinghouseNum, EtransType etype)
        {
            //validation of carrier vs network
            if (etype == EtransType.Eligibility_CA)
            {
                //only carrierNum is allowed (and required)
                if (carrierNum == 0)
                {
                    throw new ApplicationException("Carrier not supplied for Etranss.CreateCanadianOutput.");
                }
                if (canadianNetworkNum != 0)
                {
                    throw new ApplicationException("NetworkNum not allowed for Etranss.CreateCanadianOutput.");
                }
            }
            Etrans etrans = new Etrans();

            //etrans.DateTimeTrans handled automatically
            etrans.ClearinghouseNum = clearinghouseNum;
            etrans.Etype            = etype;
            etrans.ClaimNum         = 0;  //no claim involved
            etrans.PatNum           = patNum;
            //CanadianNetworkNum?
            etrans.CarrierNum = carrierNum;
            //InsPlanNum? (for eligibility)
            //Get next OfficeSequenceNumber-----------------------------------------------------------------------------------------
            etrans.OfficeSequenceNumber = 0;
            string    command = "SELECT MAX(OfficeSequenceNumber) FROM etrans";
            DataTable table   = General.GetTable(command);

            if (table.Rows.Count > 0)
            {
                etrans.OfficeSequenceNumber = PIn.PInt(table.Rows[0][0].ToString());
                if (etrans.OfficeSequenceNumber == 999999)              //if the office has sent > 1 million messages, and has looped back around to 1.
                //get the date of the most recent max
                //This works, but it got even more complex for CarrierTransCounter, so we will just throw an exception for now.

                /*command="SELECT MAX(DateTimeTrans) FROM etrans WHERE OfficeSequenceNumber=999999";
                 * table=General.GetTable(command);
                 * DateTime maxDateT=PIn.PDateT(table.Rows[0][0].ToString());
                 * //then, just get the max that's newer than that.
                 * command="SELECT MAX(OfficeSequenceNumber) FROM etrans WHERE DateTimeTrans > '"+POut.PDateT(maxDateT)+"'";
                 * table=General.GetTable(command);
                 * if(table.Rows.Count>0) {
                 *      etrans.OfficeSequenceNumber=PIn.PInt(table.Rows[0][0].ToString());
                 * }*/
                {
                    throw new ApplicationException("OfficeSequenceNumber has maxed out at 999999.  This program will need to be enhanced.");
                }
            }
            etrans.OfficeSequenceNumber++;
            if (etype == EtransType.Eligibility_CA)
            {
                //find the next CarrierTransCounter------------------------------------------------------------------------------------
                etrans.CarrierTransCounter = 0;
                command = "SELECT MAX(CarrierTransCounter) FROM etrans"
                          + "WHERE CarrierNum=" + POut.PInt(etrans.CarrierNum);
                table = General.GetTable(command);
                int tempcounter = 0;
                if (table.Rows.Count > 0)
                {
                    tempcounter = PIn.PInt(table.Rows[0][0].ToString());
                }
                if (tempcounter > etrans.CarrierTransCounter)
                {
                    etrans.CarrierTransCounter = tempcounter;
                }
                command = "SELECT MAX(CarrierTransCounter2) FROM etrans "
                          + "WHERE CarrierNum2=" + POut.PInt(etrans.CarrierNum);
                table = General.GetTable(command);
                if (table.Rows.Count > 0)
                {
                    tempcounter = PIn.PInt(table.Rows[0][0].ToString());
                }
                if (tempcounter > etrans.CarrierTransCounter)
                {
                    etrans.CarrierTransCounter = tempcounter;
                }
                if (etrans.CarrierTransCounter == 99999)
                {
                    throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
                    //maybe by adding a reset date to the preference table which will apply to all counters as a whole.
                }
                etrans.CarrierTransCounter++;
            }
            Insert(etrans);
            return(etrans);
        }
Exemplo n.º 14
0
        ///<summary>Sets the status of the claim to sent.  Also makes an entry in etrans.  If this is canadian eclaims, then this function gets run first.  Then, the messagetext is created and an attempt is made to send the claim.  Finally, the messagetext and added to the etrans.  This is necessary because the transaction numbers must be incremented and assigned to each claim before creating the message and attempting to send.  If it fails, Canadians will need to delete the etrans entries (or we will need to roll back the changes).</summary>
        public static Etrans SetClaimSentOrPrinted(int claimNum, int patNum, int clearinghouseNum, EtransType etype)
        {
            string command = "UPDATE claim SET ClaimStatus = 'S' WHERE claimnum = " + POut.PInt(claimNum);

            General.NonQ(command);
            Etrans etrans = new Etrans();

            //etrans.DateTimeTrans handled automatically
            etrans.ClearinghouseNum = clearinghouseNum;
            etrans.Etype            = etype;
            etrans.ClaimNum         = claimNum;
            etrans.PatNum           = patNum;
            //Get the primary and secondary carrierNums for this claim.
            command = "SELECT carrier1.CarrierNum,carrier2.CarrierNum AS CarrierNum2 FROM claim "
                      + "LEFT JOIN insplan insplan1 ON insplan1.PlanNum=claim.PlanNum "
                      + "LEFT JOIN carrier carrier1 ON carrier1.CarrierNum=insplan1.CarrierNum "
                      + "LEFT JOIN insplan insplan2 ON insplan2.PlanNum=claim.PlanNum2 "
                      + "LEFT JOIN carrier carrier2 ON carrier2.CarrierNum=insplan2.CarrierNum "
                      + "WHERE claim.ClaimNum=" + POut.PInt(claimNum);
            DataTable table = General.GetTable(command);

            etrans.CarrierNum  = PIn.PInt(table.Rows[0][0].ToString());
            etrans.CarrierNum2 = PIn.PInt(table.Rows[0][1].ToString());          //might be 0 if no secondary on this claim
            if (etype == EtransType.Claim_CA)
            {
                etrans.OfficeSequenceNumber = 0;
                //find the next officeSequenceNumber
                command = "SELECT MAX(OfficeSequenceNumber) FROM etrans";
                table   = General.GetTable(command);
                if (table.Rows.Count > 0)
                {
                    etrans.OfficeSequenceNumber = PIn.PInt(table.Rows[0][0].ToString());
                    if (etrans.OfficeSequenceNumber == 999999)                   //if the office has sent > 1 million messages, and has looped back around to 1.
                    {
                        throw new ApplicationException
                                  ("OfficeSequenceNumber has maxed out at 999999.  This program will need to be enhanced.");
                    }
                }
                etrans.OfficeSequenceNumber++;
                //find the next CarrierTransCounter for the primary carrier
                etrans.CarrierTransCounter = 0;
                command = "SELECT MAX(CarrierTransCounter) FROM etrans "
                          + "WHERE CarrierNum=" + POut.PInt(etrans.CarrierNum);
                table = General.GetTable(command);
                int tempcounter = 0;
                if (table.Rows.Count > 0)
                {
                    tempcounter = PIn.PInt(table.Rows[0][0].ToString());
                }
                if (tempcounter > etrans.CarrierTransCounter)
                {
                    etrans.CarrierTransCounter = tempcounter;
                }
                command = "SELECT MAX(CarrierTransCounter2) FROM etrans "
                          + "WHERE CarrierNum2=" + POut.PInt(etrans.CarrierNum);
                table = General.GetTable(command);
                if (table.Rows.Count > 0)
                {
                    tempcounter = PIn.PInt(table.Rows[0][0].ToString());
                }
                if (tempcounter > etrans.CarrierTransCounter)
                {
                    etrans.CarrierTransCounter = tempcounter;
                }
                if (etrans.CarrierTransCounter == 99999)
                {
                    throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
                }
                etrans.CarrierTransCounter++;
                if (etrans.CarrierNum2 > 0)              //if there is secondary coverage on this claim
                {
                    etrans.CarrierTransCounter2 = 1;
                    command = "SELECT MAX(CarrierTransCounter) FROM etrans "
                              + "WHERE CarrierNum=" + POut.PInt(etrans.CarrierNum2);
                    table = General.GetTable(command);
                    if (table.Rows.Count > 0)
                    {
                        tempcounter = PIn.PInt(table.Rows[0][0].ToString());
                    }
                    if (tempcounter > etrans.CarrierTransCounter2)
                    {
                        etrans.CarrierTransCounter2 = tempcounter;
                    }
                    command = "SELECT MAX(CarrierTransCounter2) FROM etrans "
                              + "WHERE CarrierNum2=" + POut.PInt(etrans.CarrierNum2);
                    table = General.GetTable(command);
                    if (table.Rows.Count > 0)
                    {
                        tempcounter = PIn.PInt(table.Rows[0][0].ToString());
                    }
                    if (tempcounter > etrans.CarrierTransCounter2)
                    {
                        etrans.CarrierTransCounter2 = tempcounter;
                    }
                    if (etrans.CarrierTransCounter2 == 99999)
                    {
                        throw new ApplicationException("CarrierTransCounter has maxed out at 99999.  This program will need to be enhanced.");
                    }
                    etrans.CarrierTransCounter2++;
                }
            }
            Insert(etrans);
            return(etrans);
        }