context: using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.IO;
  using System.Windows.Forms;
  using OpenDentBusiness;
  
  namespace OpenDental.Eclaims{
  	///<summary>Summary description for Renaissance.</summary>
  	public class Renaissance{
  		private static ClaimFormItem[] items;
  		private static FormClaimFormItemEdit FormCFI;
  		private static string[][] DisplayStrings;
  		private static Clearinghouse clearinghouse;
  
  		///<summary>Summary description for Renaissance.</summary>
  		public Renaissance(){
  			
  		}
  
  		///<summary>Called from Eclaims and includes multiple claims.</summary>
  		public static string SendBatch(List<ClaimSendQueueItem> queueItems,int batchNum) {
  			for(int i=0;i<queueItems.Count;i++) {
  				//A setting for the clearinghouse could have changed so we need to always refresh the clearinghouse variable before sending any batches.
  				if(i==0) {
  					clearinghouse=Clearinghouses.GetClearinghouse(queueItems[i].ClearinghouseNum);
  				}
  				if(!CreateClaim(queueItems[i].PatNum,queueItems[i].ClaimNum,batchNum)) {
  					return "";
  				}
  			}
  			return "Sent";
  		}
  
  		///<summary>Called once for each claim to be created.  For claims with a lot of procedures, this may actually create multiple claims.</summary>
  		public static bool CreateClaim(long patNum,long claimNum,int batchNum) {
  			//this can be eliminated later after error checking complete:
  				FormCFI=new FormClaimFormItemEdit();
  				FormCFI.FillFieldNames();
  			items=new ClaimFormItem[241];//0 is not used 
  			Fill(1,"IsPreAuth");
  			Fill(2,"IsStandardClaim");
  			Fill(3,"IsMedicaidClaim");
  			Fill(4,"");//EPSTD
  			Fill(5,"TreatingProviderSpecialty");
  			Fill(6,"PreAuthString");
  			Fill(7,"PriInsCarrierName");
  			Fill(8,"PriInsAddressComplete");
  			Fill(9,"PriInsCity");
  			Fill(10,"PriInsST");
  			Fill(11,"PriInsZip");
  			Fill(12,"PatientLastFirst");
  			Fill(13,"PatientAddressComplete");
  			Fill(14,"PatientCity");
  			Fill(15,"PatientST");
  			Fill(16,"PatientDOB","MM/dd/yyyy");
  			Fill(17,"PatientID-MedicaidOrSSN");
  			Fill(18,"PatientIsMale");
  			Fill(19,"PatientIsFemale");
  			Fill(20,"PatientPhone");
  			Fill(21,"PatientZip");
  			Fill(22,"RelatIsSelf");
  			Fill(23,"RelatIsSpouse");
  			Fill(24,"RelatIsChild");
  			Fill(25,"RelatIsOther");
  			Fill(26,"");//relat other descript
  			Fill(27,"");//pat employer/school
  			Fill(28,"");//pat employer/school address
  			Fill(29,"SubscrID");
  			Fill(30,"EmployerName");
  			Fill(31,"GroupNum");
  			Fill(32,"OtherInsNotExists");
  			Fill(33,"OtherInsExists");
  			Fill(34,"OtherInsExists");//dental
  			Fill(35,"");//other ins exists medical
  			Fill(36,"OtherInsSubscrID");
  			Fill(37,"SubscrLastFirst");
  			Fill(38,"OtherInsSubscrLastFirst");
  			Fill(39,"SubscrAddressComplete");
  			Fill(40,"SubscrPhone");
  			Fill(41,"OtherInsSubscrDOB","MM/dd/yyyy");
  			Fill(42,"OtherInsSubscrIsMale");
  			Fill(43,"OtherInsSubscrIsFemale");
  			Fill(44,"OtherInsGroupNum");//Other Plan/Program name
  			Fill(45,"SubscrCity");
  			Fill(46,"SubscrST");
  			Fill(47,"SubscrZip");
  			Fill(48,"");//other subscr employer/school
  			Fill(49,"");//other subscr emp/school address
  			Fill(50,"SubscrDOB","MM/dd/yyyy");
  			Fill(51,"SubscrIsMarried");
  			Fill(52,"SubscrIsSingle");
  			Fill(53,"");//subscr marital status other
  			Fill(54,"SubscrIsMale");
  			Fill(55,"SubscrIsFemale");
  			Fill(56,"");//subscr is employed
  			Fill(57,"");//subscr is part time
  			Fill(58,"SubscrIsFTStudent");
  			Fill(59,"SubscrIsPTStudent");
  			Fill(60,"");//subsc employer/school
  			Fill(61,"");//subsc employer/school address
  			Fill(62,"PatientRelease");
  			Fill(63,"PatientReleaseDate","MM/dd/yyyy");
  			Fill(64,"PatientAssignment");
  			Fill(65,"PatientAssignmentDate","MM/dd/yyyy");
  			Fill(66,"BillingDentist");
  			Fill(67,"BillingDentistPhoneFormatted");
  			Fill(68,"BillingDentistMedicaidID");
  			Fill(69,"BillingDentistSSNorTIN");
  			Fill(70,"PayToDentistAddress");
  			Fill(71,"PayToDentistAddress2");
  			Fill(72,"BillingDentistLicenseNum");
  			Fill(73,"DateService","MM/dd/yyyy");
  			Fill(74,"PlaceIsOffice");
  			Fill(75,"PlaceIsHospADA2002");
  			Fill(76,"PlaceIsExtCareFacilityADA2002");
  			Fill(77,"PlaceIsOtherADA2002");
  			Fill(78,"PayToDentistCity");
  			Fill(79,"PayToDentistST");
  			Fill(80,"PayToDentistZip");
  			Fill(81,"IsRadiographsAttached");
  			Fill(82,"RadiographsNumAttached");
  			Fill(83,"RadiographsNotAttached");
  			Fill(84,"IsOrtho");
  			Fill(85,"IsNotOrtho");
  			Fill(86,"IsInitialProsth");
  			Fill(87,"IsReplacementProsth");
  			Fill(88,"");//reason for replacement
  			Fill(89,"DatePriorProsthPlaced","MM/dd/yyyy");
  			Fill(90,"DateOrthoPlaced");
  			Fill(91,"MonthsOrthoRemaining");
  			Fill(92,"IsNotOccupational");
  			Fill(93,"IsOccupational");
  			Fill(94,"");//description of occupational injury
  			Fill(95,"IsAutoAccident");
  			Fill(96,"IsOtherAccident");
  			Fill(97,"IsNotAccident");
  			Fill(98,"");//description of accident
  			Fill(99,"TreatingDentistNPI");//Individual NPI
  			Fill(100,"");//''
  			Fill(101,"BillingDentistNPI");//Group NPI
  			Fill(102,"");//''
  			Fill(103,"");//''
  			Fill(104,"");//''
  			Fill(105,"");//''
  			Fill(106,"");//''
  			//proc 1
  			Fill(107,"P1Date","MM/dd/yyyy");
  			Fill(108,"P1ToothNumber");
  			Fill(109,"P1Surface");
  			Fill(110,"");//diag index
  			Fill(111,"P1Code");
  			Fill(112,"");//quantity
  			Fill(113,"P1Description");
  			Fill(114,"P1Fee");
  			//proc 2
  			Fill(115,"P2Date","MM/dd/yyyy");
  			Fill(116,"P2ToothNumber");
  			Fill(117,"P2Surface");
  			Fill(118,"");
  			Fill(119,"P2Code");
  			Fill(120,"");
  			Fill(121,"P2Description");
  			Fill(122,"P2Fee");
  			//proc 3
  			Fill(123,"P3Date","MM/dd/yyyy");
  			Fill(124,"P3ToothNumber");
  			Fill(125,"P3Surface");
  			Fill(126,"");
  			Fill(127,"P3Code");
  			Fill(128,"");
  			Fill(129,"P3Description");
  			Fill(130,"P3Fee");
  			//proc 4
  			Fill(131,"P4Date","MM/dd/yyyy");
  			Fill(132,"P4ToothNumber");
  			Fill(133,"P4Surface");
  			Fill(134,"");
  			Fill(135,"P4Code");
  			Fill(136,"");
  			Fill(137,"P4Description");
  			Fill(138,"P4Fee");
  			//proc 5
  			Fill(139,"P5Date","MM/dd/yyyy");
  			Fill(140,"P5ToothNumber");
  			Fill(141,"P5Surface");
  			Fill(142,"");
  			Fill(143,"P5Code");
  			Fill(144,"");
  			Fill(145,"P5Description");
  			Fill(146,"P5Fee");
  			//proc 6
  			Fill(147,"P6Date","MM/dd/yyyy");
  			Fill(148,"P6ToothNumber");
  			Fill(149,"P6Surface");
  			Fill(150,"");
  			Fill(151,"P6Code");
  			Fill(152,"");
  			Fill(153,"P6Description");
  			Fill(154,"P6Fee");
  			//proc 7
  			Fill(155,"P7Date","MM/dd/yyyy");
  			Fill(156,"P7ToothNumber");
  			Fill(157,"P7Surface");
  			Fill(158,"");
  			Fill(159,"P7Code");
  			Fill(160,"");
  			Fill(161,"P7Description");
  			Fill(162,"P7Fee");
  			//proc 8
  			Fill(163,"P8Date","MM/dd/yyyy");
  			Fill(164,"P8ToothNumber");
  			Fill(165,"P8Surface");
  			Fill(166,"");
  			Fill(167,"P8Code");
  			Fill(168,"");
  			Fill(169,"P8Description");
  			Fill(170,"P8Fee");
  			//end of procs
  			Fill(171,"TotalFee");
  			Fill(172,"");//payment by other plan. Only applicable on secondary insurance.
  			Fill(173,"");//max allowable
  			Fill(174,"");//deductible
  			Fill(175,"");//carrier percent
  			Fill(176,"");//carrier pays
  			Fill(177,"");//patient pays
  
gt: 			Fill(178,"");//Work injury.  Only x is accepted.