using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using OpenDentBusiness;
using CodeBase;

namespace OpenDental{
	///<summary></summary>
	public class FormClaimPrint : System.Windows.Forms.Form{
		private OpenDental.UI.Button butClose;
		private System.Windows.Forms.PrintPreviewControl Preview2;
		private System.Drawing.Printing.PrintDocument pd2;
		private OpenDental.UI.Button butPrint;
		private System.ComponentModel.Container components = null;
		///<summary></summary>
		public long ClaimNumCur;
		///<summary></summary>
		public long PatNumCur;
		//<summary>This will be 0 unless the user is trying to print a batch e-claim with a predefined ClaimForm.</summary>
		//public int ClaimFormNum;
		///<summary></summary>
		public bool PrintBlank;
		///<summary></summary>
		public bool PrintImmediately;
    private string[] displayStrings;
		///<summary>The claimprocs for this claim, not including payments and duplicates.</summary>
		private List<ClaimProc> ListClaimProcs;
		///<summary>For batch generic e-claims, this just prints the data and not the background.</summary>
		public bool HideBackground;
		private System.Windows.Forms.Label labelTotPages;
		private OpenDental.UI.Button butBack;
		private OpenDental.UI.Button butFwd;
		private int pagesPrinted;
		private int totalPages;
		//<summary>Set to true if using this class just to generate strings for the Renaissance link.</summary>
		//private bool IsRenaissance;
		private List<ClaimProc> ClaimProcsForClaim;
		private List<ClaimProc> ClaimProcsForPat;
		///<summary>All procedures for the patient.</summary>
		private List<Procedure> ListProc;
		///<summary>This is set externally for Renaissance and generic e-claims.  If it was not set ahead of time, it will set in FillDisplayStrings according to the insPlan.</summary>
		public ClaimForm ClaimFormCur;
		private List <InsPlan> ListInsPlan;
		//private InsPlan[] MedPlanList;
		private List<PatPlan> ListPatPlans;
		private Claim ClaimCur;
		///<summary>Filled with the first four diagnoses codes in the list of procedures associated with the claim. Always length of 4.</summary>
		private string[] diagnoses;
		///<summary>Complete list of all diagnoses.  Maximum unique length of array will be 12 due to the requirements of the medical 1500 (02-12) claim form.</summary>
		private string[] arrayDiagnoses;
		//private Claim[] ClaimsArray;
		//private Claim[] MedClaimsArray;
		private List<ClaimValCodeLog> ListClaimValCodeLog;
		private Referral ClaimReferral;
		private List<InsSub> ListInsSub2;
		private InsSub subCur;
		private InsPlan planCur;
		private Carrier carrier;

		///<summary></summary>
		public FormClaimPrint(){
			InitializeComponent();
			Lan.F(this,new Control[] 
			{
				this.labelTotPages//exclude
			});
		}

		///<summary></summary>
		protected override void Dispose( bool disposing ){
			if( disposing ){
				if(components != null){
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code

		private void InitializeComponent(){
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormClaimPrint));
			this.butClose = new OpenDental.UI.Button();
			this.Preview2 = new System.Windows.Forms.PrintPreviewControl();
			this.pd2 = new System.Drawing.Printing.PrintDocument();
			this.butPrint = new OpenDental.UI.Button();
			this.labelTotPages = new System.Windows.Forms.Label();
			this.butBack = new OpenDental.UI.Button();
			this.butFwd = new OpenDental.UI.Button();
			this.SuspendLayout();
			// 
			// butClose
			// 
			this.butClose.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.butClose.Autosize = true;
			this.butClose.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butClose.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butClose.CornerRadius = 4F;
			this.butClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.butClose.Location = new System.Drawing.Point(770,768);
			this.butClose.Name = "butClose";
			this.butClose.Size = new System.Drawing.Size(75,25);
			this.butClose.TabIndex = 0;
			this.butClose.Text = "&Close";
			this.butClose.Click += new System.EventHandler(this.butClose_Click);
			// 
			// Preview2
			// 
			this.Preview2.AutoZoom = false;
			this.Preview2.Location = new System.Drawing.Point(0,0);
			this.Preview2.Name = "Preview2";
			this.Preview2.Size = new System.Drawing.Size(738,798);
			this.Preview2.TabIndex = 1;
			this.Preview2.Zoom = 1;
			// 
			// butPrint
			// 
			this.butPrint.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.butPrint.Autosize = true;
			this.butPrint.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butPrint.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butPrint.CornerRadius = 4F;
			this.butPrint.Location = new System.Drawing.Point(769,728);
			this.butPrint.Name = "butPrint";
			this.butPrint.Size = new System.Drawing.Size(75,25);
			this.butPrint.TabIndex = 2;
			this.butPrint.Text = "&Print";
			this.butPrint.Click += new System.EventHandler(this.butPrint_Click);
			// 
			// labelTotPages
			// 
			this.labelTotPages.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.labelTotPages.Font = new System.Drawing.Font("Microsoft Sans Serif",9F,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,((byte)(0)));
			this.labelTotPages.Location = new System.Drawing.Point(774,679);
			this.labelTotPages.Name = "labelTotPages";
			this.labelTotPages.Size = new System.Drawing.Size(54,18);
			this.labelTotPages.TabIndex = 22;
			this.labelTotPages.Text = "1 / 2";
			this.labelTotPages.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// butBack
			// 
			this.butBack.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.butBack.Autosize = true;
			this.butBack.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butBack.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butBack.CornerRadius = 4F;
			this.butBack.Image = global::OpenDental.Properties.Resources.Left;
			this.butBack.Location = new System.Drawing.Point(752,676);
			this.butBack.Name = "butBack";
			this.butBack.Size = new System.Drawing.Size(18,23);
			this.butBack.TabIndex = 23;
			this.butBack.Click += new System.EventHandler(this.butBack_Click);
			// 
			// butFwd
			// 
			this.butFwd.AdjustImageLocation = new System.Drawing.Point(1,0);
			this.butFwd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.butFwd.Autosize = true;
			this.butFwd.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butFwd.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butFwd.CornerRadius = 4F;
			this.butFwd.Image = global::OpenDental.Properties.Resources.Right;
			this.butFwd.Location = new System.Drawing.Point(830,676);
			this.butFwd.Name = "butFwd";
			this.butFwd.Size = new System.Drawing.Size(18,23);
			this.butFwd.TabIndex = 24;
			this.butFwd.Click += new System.EventHandler(this.butFwd_Click);
			// 
			// FormClaimPrint
			// 
			this.AcceptButton = this.butPrint;
			this.AutoScaleBaseSize = new System.Drawing.Size(5,13);
			this.CancelButton = this.butClose;
			this.ClientSize = new System.Drawing.Size(860,816);
			this.Controls.Add(this.labelTotPages);
			this.Controls.Add(this.butBack);
			this.Controls.Add(this.butFwd);
			this.Controls.Add(this.butPrint);
			this.Controls.Add(this.Preview2);
			this.Controls.Add(this.butClose);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "FormClaimPrint";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Print Claim";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.FormClaimPrint_Load);
			this.Layout += new System.Windows.Forms.LayoutEventHandler(this.FormClaimPrint_Layout);
			this.ResumeLayout(false);

		}
		#endregion

		private void FormClaimPrint_Layout(object sender, System.Windows.Forms.LayoutEventArgs e) {
			Preview2.Height=ClientRectangle.Height;
			Preview2.Width=ClientRectangle.Width-160;
			//butClose.Location=new Point(ClientRectangle.Width-100,ClientRectangle.Height-70);
			//butPrint.Location=new Point(ClientRectangle.Width-100,ClientRectangle.Height-140);
		}
		private void FormClaimPrint_Load(object sender, System.EventArgs e) {
			if(PrinterSettings.InstalledPrinters.Count==0) {
				MessageBox.Show(Lan.g(this,"No printer installed"));
				return;
			}
			pd2=new PrintDocument();
			pagesPrinted=0;
			pd2.OriginAtMargins=true;
			pd2.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			if(pd2.DefaultPageSettings.PrintableArea.Width==0 || pd2.DefaultPageSettings.PrintableArea.Height<400) {//some printers report page size of 0.
				//prevents bug in some printers that do not specify paper size
				pd2.DefaultPageSettings.PaperSize=new PaperSize("default",850,1100);
			}
			pd2.PrintPage+=new PrintPageEventHandler(this.pd2_PrintPage);
			Preview2.Document=pd2;//display document
			Preview2.InvalidatePreview();
		}

		///<summary>Only called from external forms without ever loading this form.  Prints without showing any print preview.  Returns true if printed successfully.  Make sure to call PrinterL.SetPrinter() before calling this method so that a printer name is set for when printing batch claims.</summary>
		public bool PrintImmediate(PrinterSettings ps) {
			if(PrintBlank) {
				//Get the default claim form for the practice.
				ClaimFormCur=ClaimForms.GetClaimForm(PrefC.GetLong(PrefName.DefaultClaimForm));
				if(ClaimFormCur==null) {//Could happen if printing a blank form and no default claim form is set.
					MsgBox.Show(this,"No default claim form set.  Set a default in Setup | Family / Insurance | Claim Forms.");
					return false;
				}
			}
			pd2=new PrintDocument();
			pd2.PrinterSettings=ps;
			pagesPrinted=0;
			pd2.OriginAtMargins=true;
			pd2.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			if(pd2.DefaultPageSettings.PrintableArea.Width==0 || pd2.DefaultPageSettings.PrintableArea.Height<400) {//some printers report page size of 0.
				//prevents bug in some printers that do not specify paper size
				pd2.DefaultPageSettings.PaperSize=new PaperSize("default",850,1100);
			}
			pd2.PrintPage+=new PrintPageEventHandler(this.pd2_PrintPage);
			try{
				pd2.Print();
			}
			catch(Exception ex){
				MessageBox.Show(ex.Message);//Lan.g("Printer","Printer not available"));
				return false;
			}
			return true;
		}

		private void pd2_PrintPage(object sender, PrintPageEventArgs ev){//raised for each page to be printed.
			FillDisplayStrings(false);
			int procLimit=ProcLimitForFormat();
			//claimprocs is filled in FillDisplayStrings
			if(ListClaimProcs.Count==0){
			totalPages=1;
			//js Some other programmer added this variable and implemented it.  We couldn't figure out why.  For example, in the line above, why would claimprocs ever be zero?  Due to many style and logic issues, we were forced to remove the function of this variable.  It would have to be written from scratch to implement it in the future.  Claims were never designed for multi-page.	
			//Jason - this code we don't understand worked so I added it back until we get time to rewrite it correctly.
			}
			else{
				totalPages=(int)Math.Ceiling((double)ListClaimProcs.Count/(double)procLimit);
			}
			bool HasMedical = false;
			if(!PrintBlank){
				FillProcStrings(pagesPrinted*procLimit,procLimit);
				for(int i=0;i<ListInsPlan.Count;i++){
					if(ListInsPlan[i].IsMedical){
						HasMedical=true;
					}
				}
			}
			if(HasMedical){
				FillMedInsStrings();
				FillMedValueCodes();
				FillMedCondCodes();
			}
			Graphics grfx=ev.Graphics;
			float xPosText;
			for(int i=0;i<ClaimFormCur.Items.Length;i++){
				if(ClaimFormCur.Items[i].ImageFileName==""){//field
					xPosText=ClaimFormCur.Items[i].XPos+ClaimFormCur.OffsetX;
					if(ClaimFormCur.Items[i].FieldName=="P1Fee"
						|| ClaimFormCur.Items[i].FieldName=="P2Fee"
						|| ClaimFormCur.Items[i].FieldName=="P3Fee"
						|| ClaimFormCur.Items[i].FieldName=="P4Fee"
						|| ClaimFormCur.Items[i].FieldName=="P5Fee"
						|| ClaimFormCur.Items[i].FieldName=="P6Fee"
						|| ClaimFormCur.Items[i].FieldName=="P7Fee"
						|| ClaimFormCur.Items[i].FieldName=="P8Fee"
						|| ClaimFormCur.Items[i].FieldName=="P9Fee"
						|| ClaimFormCur.Items[i].FieldName=="P10Fee"
						|| ClaimFormCur.Items[i].FieldName=="P1Lab"
						|| ClaimFormCur.Items[i].FieldName=="P2Lab"
						|| ClaimFormCur.Items[i].FieldName=="P3Lab"
						|| ClaimFormCur.Items[i].FieldName=="P4Lab"
						|| ClaimFormCur.Items[i].FieldName=="P5Lab"
						|| ClaimFormCur.Items[i].FieldName=="P6Lab"
						|| ClaimFormCur.Items[i].FieldName=="P7Lab"
						|| ClaimFormCur.Items[i].FieldName=="P8Lab"
						|| ClaimFormCur.Items[i].FieldName=="P9Lab"
						|| ClaimFormCur.Items[i].FieldName=="P10Lab"
						|| ClaimFormCur.Items[i].FieldName=="P1FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P2FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P3FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P4FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P5FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P6FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P7FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P8FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P9FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="P10FeeMinusLab"
						|| ClaimFormCur.Items[i].FieldName=="TotalFee"
						|| ClaimFormCur.Items[i].FieldName=="MedInsAAmtDue"
						|| ClaimFormCur.Items[i].FieldName=="MedInsBAmtDue"
						|| ClaimFormCur.Items[i].FieldName=="MedInsCAmtDue"
						|| ClaimFormCur.Items[i].FieldName=="MedInsAPriorPmt"
						|| ClaimFormCur.Items[i].FieldName=="MedInsBPriorPmt"
						|| ClaimFormCur.Items[i].FieldName=="MedInsCPriorPmt"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount39a"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount39b"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount39c"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount39d"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount40a"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount40b"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount40c"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount40d"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount41a"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount41b"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount41c"
						|| ClaimFormCur.Items[i].FieldName=="MedValAmount41d"
						|| ClaimFormCur.Items[i].FieldName=="ICDindicatorAB")
					{
						//this aligns it to the right
						xPosText-=grfx.MeasureString(displayStrings[i],new Font(ClaimFormCur.FontName,ClaimFormCur.FontSize)).Width;
					}
					grfx.DrawString(displayStrings[i],
						new Font(ClaimFormCur.FontName,ClaimFormCur.FontSize),
						new SolidBrush(Color.Black),
						new RectangleF(xPosText,ClaimFormCur.Items[i].YPos+ClaimFormCur.OffsetY,ClaimFormCur.Items[i].Width,ClaimFormCur.Items[i].Height));
				}
				else{//image
					if(!ClaimFormCur.PrintImages){
						continue;
					}
					if(HideBackground){
						continue;
					}
					Image thisImage;
					string extension;
					if(ClaimFormCur.Items[i].ImageFileName=="ADA2006.gif"){
						thisImage=CDT.Class1.GetADA2006();
						extension=".gif";
					}
					else if(ClaimFormCur.Items[i].ImageFileName=="ADA2012.gif") {
						thisImage=CDT.Class1.GetADA2012();
						extension=".gif";
					}
					else if(ClaimFormCur.Items[i].ImageFileName=="1500_02_12.gif") {
						thisImage=Properties.Resources._1500_02_12;
						extension=".gif";
					}
					else{
						//In the case when the A to Z folders are not being used, an invalid form image path is returned
						//and we simply print without the background image (just as if the background image were removed
						//from the A to Z folders where it was expected.
						string fileName=ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(),ClaimFormCur.Items[i].ImageFileName);
						if(!File.Exists(fileName)){
							//MessageBox.Show("File not found.");
							continue;
						}
						thisImage=Image.FromFile(fileName);
						extension=Path.GetExtension(fileName);
					}
					if(extension==".jpg"){
						grfx.DrawImage(thisImage,
							ClaimFormCur.Items[i].XPos+ClaimFormCur.OffsetX,
							ClaimFormCur.Items[i].YPos+ClaimFormCur.OffsetY,
							(int)(thisImage.Width/thisImage.HorizontalResolution*100),
							(int)(thisImage.Height/thisImage.VerticalResolution*100));
					}
					else if(extension==".gif"){
						grfx.DrawImage(thisImage,
							ClaimFormCur.Items[i].XPos+ClaimFormCur.OffsetX,
							ClaimFormCur.Items[i].YPos+ClaimFormCur.OffsetY,
							ClaimFormCur.Items[i].Width,
							ClaimFormCur.Items[i].Height);
					}
					else if(extension==".emf"){
						grfx.DrawImage(thisImage,
							ClaimFormCur.Items[i].XPos+ClaimFormCur.OffsetX,
							ClaimFormCur.Items[i].YPos+ClaimFormCur.OffsetY,
							thisImage.Width,thisImage.Height);
					}
				}
			}
			pagesPrinted++;
			if(totalPages==pagesPrinted){
				ev.HasMorePages=false;
				labelTotPages.Text="1 / "+totalPages.ToString();
			}
			else{
				//MessageBox.Show(pagesPrinted.ToString()+","+totalPages.ToString());
				ev.HasMorePages=true;
			}
		}

		///<summary>Only used when the print button is clicked from within this form during print preview.</summary>
		public bool PrintClaim(){
			pd2.OriginAtMargins=true;
			pd2.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			pagesPrinted=0;
			if(PrinterL.SetPrinter(pd2,PrintSituation.Claim,PatNumCur,"Claim from "+ClaimCur.DateService.ToShortDateString()+" printed")) {
				try {
					pd2.Print();
				}
				catch {
					MessageBox.Show(Lan.g("Printer","Printer not available."));
					return false;
				}
			}
			else {
				return false;//if they hit cancel
			}
			return true;
		}

		///<summary>Called from Bridges.Renaissance, this takes the supplied ClaimFormItems.ListForForm, and generates an array of strings that will get saved into a text file.  First dimension of array is the pages. Second dimension is the lines in the page.</summary>
		public string[][] FillRenaissance() {
			//IsRenaissance=true;
			int procLimit=10;
			FillDisplayStrings(true);//claimprocs is filled in FillDisplayStrings
														//, so this is just a little extra work
			totalPages=(int)Math.Ceiling((double)ListClaimProcs.Count/(double)procLimit);
			string[][] retVal=new string[totalPages][];
			for(int i=0;i<totalPages;i++){
				pagesPrinted=i;
				//not sure if I also need to do FillDisplayStrings here
				FillProcStrings(pagesPrinted*procLimit,procLimit);
				retVal[i]=(string[])displayStrings.Clone();
			}
			return retVal;
		}

		///<summary>Gets all necessary info from db based on ThisPatNum and ThisClaimNum.  Then fills displayStrings with the actual text that will display on claim.  The isRenaissance flag is very temporary.</summary>
		private void FillDisplayStrings(bool isRenaissance){
			if(PrintBlank){
				displayStrings=new string[ClaimFormCur.Items.Length];
				ListClaimProcs=new List<ClaimProc>();
				return;
			}
			Family FamCur=Patients.GetFamily(PatNumCur);
			Patient PatCur=FamCur.GetPatient(PatNumCur);
			List<Claim> ClaimList=Claims.Refresh(PatCur.PatNum);
			ClaimCur=Claims.GetFromList(ClaimList,ClaimNumCur);
				//((Claim)Claims.HList[ThisClaimNum]).Clone();
			ListInsSub2=InsSubs.RefreshForFam(FamCur);
			ListInsPlan=InsPlans.RefreshForSubList(ListInsSub2);
			ListPatPlans=PatPlans.Refresh(ClaimCur.PatNum);
			InsPlan otherPlan=InsPlans.GetPlan(ClaimCur.PlanNum2,ListInsPlan);
			InsSub otherSub=InsSubs.GetSub(ClaimCur.InsSubNum2,ListInsSub2);
			if(otherPlan==null){
				otherPlan=new InsPlan();//easier than leaving it null
			}
			Carrier otherCarrier=new Carrier();
			if(otherPlan.PlanNum!=0){
				otherCarrier=Carriers.GetCarrier(otherPlan.CarrierNum);
			}
			//Employers.GetEmployer(otherPlan.EmployerNum);
			//Employer otherEmployer=Employers.Cur;//not actually used
			//then get the main plan
			subCur=InsSubs.GetSub(ClaimCur.InsSubNum,ListInsSub2);
			planCur=InsPlans.GetPlan(ClaimCur.PlanNum,ListInsPlan);
			Clinic clinic=Clinics.GetClinic(ClaimCur.ClinicNum);
			carrier=Carriers.GetCarrier(planCur.CarrierNum);
			//Employers.GetEmployer(InsPlans.Cur.EmployerNum);
			Patient subsc;
			if(FamCur.GetIndex(subCur.Subscriber)==-1) {//from another family
				subsc=Patients.GetPat(subCur.Subscriber);
				//Patients.Cur;
				//Patients.GetFamily(ThisPatNum);//return to current family
			}
			else{
				subsc=FamCur.ListPats[FamCur.GetIndex(subCur.Subscriber)];
			}
			Patient otherSubsc=new Patient();
			if(otherPlan.PlanNum!=0){//if secondary insurance exists
				if(FamCur.GetIndex(otherSub.Subscriber)==-1) {//from another family
					otherSubsc=Patients.GetPat(otherSub.Subscriber);
					//Patients.Cur;
					//Patients.GetFamily(ThisPatNum);//return to current family
				}
				else{
					otherSubsc=FamCur.ListPats[FamCur.GetIndex(otherSub.Subscriber)];
				}				
			}	
			if(ClaimCur.ReferringProv>0){
				ClaimReferral=Referrals.GetReferral(ClaimCur.ReferringProv);
			}
			ListProc=Procedures.Refresh(PatCur.PatNum);
			List<ToothInitial> initialList=ToothInitials.Refresh(PatCur.PatNum);
      //List<ClaimProc> ClaimProcList=ClaimProcs.Refresh(PatCur.PatNum);
			ClaimProcsForPat=ClaimProcs.Refresh(ClaimCur.PatNum);
      ClaimProcsForClaim=ClaimProcs.RefreshForClaim(ClaimCur.ClaimNum); 
			ListClaimProcs=new List<ClaimProc>();
			bool includeThis;
			Procedure proc;
			for(int i=0;i<ClaimProcsForClaim.Count;i++){//fill the arraylist
				if(ClaimProcsForClaim[i].ProcNum==0){
					continue;//skip payments
				}
				if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
					proc=Procedures.GetProcFromList(ListProc,ClaimProcsForClaim[i].ProcNum);
					if(proc.ProcNumLab!=0) { //This is a lab fee procedure.
						continue;//skip lab fee procedures in Canada, because they will show up on the same line as the procedure that they are attached to.
					}
				}
				includeThis=true;
				for(int j=0;j<ListClaimProcs.Count;j++){//loop through existing claimprocs
					if(ListClaimProcs[j].ProcNum==ClaimProcsForClaim[i].ProcNum){
						includeThis=false;//skip duplicate procedures
					}
				}
				if(includeThis){
					ListClaimProcs.Add(ClaimProcsForClaim[i]);	
				}
			}
			List<string> missingTeeth=ToothInitials.GetMissingOrHiddenTeeth(initialList);
			ProcedureCode procCode;
			for(int j=missingTeeth.Count-1;j>=0;j--) {//loop backwards to keep index accurate as items are removed
				//if the missing tooth is missing because of an extraction being billed here, then exclude it
				for(int p=0;p<ListClaimProcs.Count;p++) {
					proc=Procedures.GetProcFromList(ListProc,ListClaimProcs[p].ProcNum);
					procCode=ProcedureCodes.GetProcCode(proc.CodeNum);
					if(procCode.PaintType==ToothPaintingType.Extraction && proc.ToothNum==missingTeeth[j]) {
						missingTeeth.RemoveAt(j);
						break;
					}
				}
			}
			//diagnoses---------------------------------------------------------------------------------------
			diagnoses=new string[4];
			for(int i=0;i<4;i++){
				diagnoses[i]="";
			}
			for(int i=0;i<ListClaimProcs.Count;i++){
				proc=Procedures.GetProcFromList(ListProc,ListClaimProcs[i].ProcNum);
				if(proc.DiagnosticCode==""){
					continue;
				}
				for(int d=0;d<4;d++){
					if(diagnoses[d]==proc.DiagnosticCode){
						break;//if it's already been added
					}
					if(diagnoses[d]==""){//we're at the end of the list of existing diagnoses, and no match
						diagnoses[d]=proc.DiagnosticCode;//so add it.
						break;
					}
				}
				//There's still a chance that the diagnosis didn't get added, if there were more than 4.
			}
			arrayDiagnoses=Procedures.GetUniqueDiagnosticCodes(Procedures.GetProcsFromClaimProcs(ListClaimProcs),true).ToArray();
			Provider treatDent=ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvTreat)];
			if(ClaimFormCur==null){
				if(ClaimCur.ClaimForm>0){
					ClaimFormCur=ClaimForms.GetClaimForm(ClaimCur.ClaimForm);
				} 
				else {
					ClaimFormCur=ClaimForms.GetClaimForm(planCur.ClaimFormNum);
				}
			}
			List<PatPlan> patPlans=null;
			displayStrings=new string[ClaimFormCur.Items.Length];
			//a value is set for every item, but not every case will have a matching claimform item.
			for(int i=0;i<ClaimFormCur.Items.Length;i++){
				if(ClaimFormCur.Items[i]==null){//Renaissance does not use [0]
					displayStrings[i]="";
					continue;
				}
				switch(ClaimFormCur.Items[i].FieldName){
					default://image. or procedure which gets filled in FillProcStrings.
						displayStrings[i]="";
						break;
					case "FixedText":
						displayStrings[i]=ClaimFormCur.Items[i].FormatString;
						break;
					case "IsPreAuth":
						if(ClaimCur.ClaimType=="PreAuth") {
							displayStrings[i]="X";
						}
						break;
					case "IsStandardClaim":
						if(ClaimCur.ClaimType!="PreAuth") {
							displayStrings[i]="X";
						}
						break;
					case "ShowPreauthorizationIfPreauth":
						if(ClaimCur.ClaimType=="PreAuth") {
							displayStrings[i]="Preauthorization";
						}
						break;
					case "IsMedicaidClaim"://this should later be replaced with an insplan field.
						if(PatCur.MedicaidID!="") {
							displayStrings[i]="X";
						}
						break;
					case "IsGroupHealthPlan":
						string eclaimcode=InsFilingCodes.GetEclaimCode(planCur.FilingCode);
						if(PatCur.MedicaidID=="" 
							&& eclaimcode != "MC"//medicaid
							&& eclaimcode != "CH"//champus
							&& eclaimcode != "VA")//veterans
							//&& eclaimcode != ""//medicare?
						{
							displayStrings[i]="X";
						}
						break;
					case "PreAuthString":
						displayStrings[i]=ClaimCur.PreAuthString;
						break;
					case "PriorAuthString":
						displayStrings[i]=ClaimCur.PriorAuthorizationNumber;
						break;
					case "PriInsCarrierName":
						displayStrings[i]=carrier.CarrierName;
						break;
					case "PriInsAddress":
						displayStrings[i]=carrier.Address;
						break;
					case "PriInsAddress2":
						displayStrings[i]=carrier.Address2;
						break;
					case "PriInsAddressComplete":
						displayStrings[i]=carrier.Address+" "+carrier.Address2;
						break;
					case "PriInsCity":
						displayStrings[i]=carrier.City;
						break;
					case "PriInsST":
						displayStrings[i]=carrier.State;
						break;
					case "PriInsZip":
						displayStrings[i]=carrier.Zip;
						break;
					case "OtherInsExists":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]="X";
						}
						break;
					case "OtherInsNotExists":
						if(otherPlan.PlanNum==0) {
							displayStrings[i]="X";
						}
						break;
					case "OtherInsExistsDent":
						if(otherPlan.PlanNum!=0) {
							if(!otherPlan.IsMedical) {
								displayStrings[i]="X";
							}
						}
						break;
					case "OtherInsExistsMed":
						if(otherPlan.PlanNum!=0) {
							if(otherPlan.IsMedical) {
								displayStrings[i]="X";
							}
						}
						break;
					case "OtherInsSubscrLastFirst":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherSubsc.LName+", "+otherSubsc.FName+" "+otherSubsc.MiddleI;
						}
						break;
					case "OtherInsSubscrDOB":
						if(otherPlan.PlanNum!=0) {
							if(ClaimFormCur.Items[i].FormatString=="") {
								displayStrings[i]=otherSubsc.Birthdate.ToShortDateString();
							}
							else {
								displayStrings[i]=otherSubsc.Birthdate.ToString(ClaimFormCur.Items[i].FormatString);
							}
						}
						break;
					case "OtherInsSubscrIsMale":
						if(otherPlan.PlanNum!=0 && otherSubsc.Gender==PatientGender.Male) {
							displayStrings[i]="X";
						}
						break;
					case "OtherInsSubscrIsFemale":
						if(otherPlan.PlanNum!=0 && otherSubsc.Gender==PatientGender.Female) {
							displayStrings[i]="X";
						}
						break;
					case "OtherInsSubscrID":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherSub.SubscriberID;
						}
						break;
						//if(otherPlan.PlanNum!=0 && otherSubsc.SSN.Length==9){
						//	displayStrings[i]=otherSubsc.SSN.Substring(0,3)
						//		+"-"+otherSubsc.SSN.Substring(3,2)
						//		+"-"+otherSubsc.SSN.Substring(5);
						//}
						//break;
					case "OtherInsGroupNum":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherPlan.GroupNum;
						}
						break;
					case "OtherInsRelatIsSelf":
						if(otherPlan.PlanNum!=0 && ClaimCur.PatRelat2==Relat.Self) {
							displayStrings[i]="X";
						}
						break;
					case "OtherInsRelatIsSpouse":
						if(otherPlan.PlanNum!=0 && ClaimCur.PatRelat2==Relat.Spouse) {
							displayStrings[i]="X";
						}
						break;
					case "OtherInsRelatIsChild":
						if(otherPlan.PlanNum!=0 && ClaimCur.PatRelat2==Relat.Child) {
							displayStrings[i]="X";
						}
						break;
					case "OtherInsRelatIsOther":
						if(otherPlan.PlanNum!=0 && (
							ClaimCur.PatRelat2==Relat.Dependent
							|| ClaimCur.PatRelat2==Relat.Employee
							|| ClaimCur.PatRelat2==Relat.HandicapDep
							|| ClaimCur.PatRelat2==Relat.InjuredPlaintiff
							|| ClaimCur.PatRelat2==Relat.LifePartner
							|| ClaimCur.PatRelat2==Relat.SignifOther
							))
							displayStrings[i]="X";
						break;
					case "OtherInsCarrierName":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherCarrier.CarrierName;
						}
						break;
					case "OtherInsAddress":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherCarrier.Address;
						}
						break;
					case "OtherInsCity":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherCarrier.City;
						}
						break;
					case "OtherInsST":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherCarrier.State;
						}
						break;
					case "OtherInsZip":
						if(otherPlan.PlanNum!=0) {
							displayStrings[i]=otherCarrier.Zip;
						}
						break;
					case "SubscrLastFirst":
						displayStrings[i]=subsc.LName+", "+subsc.FName+" "+subsc.MiddleI;
						break;
					case "SubscrAddress":
						displayStrings[i]=subsc.Address;
						break;
					case "SubscrAddress2":
						displayStrings[i]=subsc.Address2;
						break;
					case "SubscrAddressComplete":
						displayStrings[i]=subsc.Address+" "+subsc.Address2;
						break;
					case "SubscrCity":
						displayStrings[i]=subsc.City;
						break;
					case "SubscrST":
						displayStrings[i]=subsc.State;
						break;
					case "SubscrZip":
						displayStrings[i]=subsc.Zip;
						break;
					case "SubscrPhone"://needs work.  Only used for 1500
						if(isRenaissance) {
							//Expecting (XXX)XXX-XXXX
							displayStrings[i]=subsc.HmPhone;
							if(subsc.HmPhone.Length>14) {//Might have a note following the number.
								displayStrings[i]=subsc.HmPhone.Substring(0,14);
							}
						}
						else {
							string phone=subsc.HmPhone.Replace("(","");
							phone=phone.Replace(")","    ");
							phone=phone.Replace("-","  ");
							displayStrings[i]=phone;
						}
						break;
					case "SubscrDOB":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=subsc.Birthdate.ToShortDateString();//MM/dd/yyyy
						}
						else {
							displayStrings[i]=subsc.Birthdate.ToString(ClaimFormCur.Items[i].FormatString);
						}
						break;
					case "SubscrIsMale":
						if(subsc.Gender==PatientGender.Male) {
							displayStrings[i]="X";
						}
						break;
					case "SubscrIsFemale":
						if(subsc.Gender==PatientGender.Female) {
							displayStrings[i]="X";
						}
						break;
					case "SubscrGender":
						if(subsc.Gender==PatientGender.Male) {
							displayStrings[i]="M";
						}
						else {
							displayStrings[i]="F";
						}
						break;
					case "SubscrIsMarried":
						if(subsc.Position==PatientPosition.Married) {
							displayStrings[i]="X";
						}
						break;
					case "SubscrIsSingle":
						if(subsc.Position==PatientPosition.Single
							|| subsc.Position==PatientPosition.Child
							|| subsc.Position==PatientPosition.Widowed) {
							displayStrings[i]="X";
						}
						break;
					case "SubscrID":
						patPlans=PatPlans.Refresh(PatNumCur);
						string patID=PatPlans.GetPatID(subCur.InsSubNum,patPlans);
						if(patID=="") {
							displayStrings[i]=subCur.SubscriberID;
						}
						else {
							displayStrings[i]=patID;
						}
						break;
					case "SubscrIDStrict":
						displayStrings[i]=subCur.SubscriberID;
						break;
					case "SubscrIsFTStudent":
						if(subsc.StudentStatus=="F") {
							displayStrings[i]="X";
						}
						break;
					case "SubscrIsPTStudent":
						if(subsc.StudentStatus=="P") {
							displayStrings[i]="X";
						}
						break;
					case "GroupName":
						displayStrings[i]=planCur.GroupName;
						break;
					case "GroupNum":
						displayStrings[i]=planCur.GroupNum;
						break;
					case "DivisionNo":
						displayStrings[i]=planCur.DivisionNo;
						break;
					case "EmployerName":
						displayStrings[i]=Employers.GetEmployer(planCur.EmployerNum).EmpName;;
						break;
					case "RelatIsSelf":
						if(ClaimCur.PatRelat==Relat.Self) {
							displayStrings[i]="X";
						}
						break;
					case "RelatIsSpouse":
						if(ClaimCur.PatRelat==Relat.Spouse) {
							displayStrings[i]="X";
						}
						break;
					case "RelatIsChild":
						if(ClaimCur.PatRelat==Relat.Child) {
							displayStrings[i]="X";
						}
						break;
					case "RelatIsOther":
						if(ClaimCur.PatRelat==Relat.Dependent
							|| ClaimCur.PatRelat==Relat.Employee
							|| ClaimCur.PatRelat==Relat.HandicapDep
							|| ClaimCur.PatRelat==Relat.InjuredPlaintiff
							|| ClaimCur.PatRelat==Relat.LifePartner
							|| ClaimCur.PatRelat==Relat.SignifOther) {
							displayStrings[i]="X";
						}
						break;
					case "Relationship":
						if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
							if(ClaimCur.PatRelat==Relat.Self) {
								displayStrings[i]="Self";
							}
							else if(ClaimCur.PatRelat==Relat.Spouse) {
								displayStrings[i]="Spouse";
							}
							else if(ClaimCur.PatRelat==Relat.Child) {
								displayStrings[i]="Child";
							}
							else if(ClaimCur.PatRelat==Relat.SignifOther || ClaimCur.PatRelat==Relat.LifePartner) {
								displayStrings[i]="Common Law Spouse";
							}
							else {
								displayStrings[i]="Other";
							}
						}
						else {
							displayStrings[i]=ClaimCur.PatRelat.ToString();
						}
						break;
					case "IsFTStudent":
						if(PatCur.StudentStatus=="F") {
							displayStrings[i]="X";
						}
						break;
					case "IsPTStudent":
						if(PatCur.StudentStatus=="P") {
							displayStrings[i]="X";
						}
						break;
					case "IsStudent":
						if(CultureInfo.CurrentCulture.Name.EndsWith("CA")//Canadian. en-CA or fr-CA
							&& (PatCur.CanadianEligibilityCode==1 || PatCur.CanadianEligibilityCode==3))//Patient is a student
						{
							displayStrings[i]="X";
						}
						else if(PatCur.StudentStatus=="P" || PatCur.StudentStatus=="F") {
							displayStrings[i]="X";
						}
						break;
					case "CollegeName":
						displayStrings[i]=PatCur.SchoolName;
						break;
					case "PatientLastFirst":
						displayStrings[i]=PatCur.LName+", "+PatCur.FName+" "+PatCur.MiddleI;
						break;
					case "PatientLastFirstMiCommas"://Medical required format for UB04 printed claims
						displayStrings[i]=PatCur.LName+", "+PatCur.FName+(PatCur.MiddleI==""?"":(", "+PatCur.MiddleI[0]));
						break;
					case "PatientFirstMiddleLast":
						displayStrings[i]=PatCur.FName+" "+PatCur.MiddleI+" "+PatCur.LName;
						break;
					case "PatientFirstName":
						displayStrings[i] = PatCur.FName;
						break;
					case "PatientMiddleName":
						displayStrings[i] = PatCur.MiddleI;
						break;
					case "PatientLastName":
						displayStrings[i] = PatCur.LName;
						break;
					case "PatientAddress":
						displayStrings[i]=PatCur.Address;
						break;
					case "PatientAddress2":
						displayStrings[i]=PatCur.Address2;
						break;
					case "PatientAddressComplete":
						displayStrings[i]=PatCur.Address+" "+PatCur.Address2;
						break;
					case "PatientCity":
						displayStrings[i]=PatCur.City;
						break;
					case "PatientST":
						displayStrings[i]=PatCur.State;
						break;
					case "PatientZip":
						displayStrings[i]=PatCur.Zip;
						break;
					case "PatientPhone"://needs work.  Only used for 1500
						if(isRenaissance) {
							//Expecting (XXX)XXX-XXXX
							displayStrings[i]=PatCur.HmPhone;
							if(PatCur.HmPhone.Length>14) {//Might have a note following the number.
								displayStrings[i]=PatCur.HmPhone.Substring(0,14);
							}
						}
						else {
							string phonep=PatCur.HmPhone.Replace("(","");
							phonep=phonep.Replace(")","    ");
							phonep=phonep.Replace("-","  ");
							displayStrings[i]=phonep;
						}
						break;
					case "PatientDOB":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=PatCur.Birthdate.ToShortDateString();//MM/dd/yyyy
						}
						else {
							displayStrings[i]=PatCur.Birthdate.ToString
								(ClaimFormCur.Items[i].FormatString);
						}
						break;
					case "PatientIsMale":
						if(PatCur.Gender==PatientGender.Male) {
							displayStrings[i]="X";
						}
						break;
					case "PatientIsFemale":
						if(PatCur.Gender==PatientGender.Female) {
							displayStrings[i]="X";
						}
						break;
					case "PatientGender":
						if(PatCur.Gender==PatientGender.Male) {
							displayStrings[i]="Male";
						}
						else if(PatCur.Gender==PatientGender.Female) {
							displayStrings[i]="Female";
						}
						break;
					case "PatientGenderLetter":
						if(subsc.Gender==PatientGender.Male) {
							displayStrings[i]="M";
						}
						else {
							displayStrings[i]="F";
						}
						break;
					case "PatientIsMarried":
						if(PatCur.Position==PatientPosition.Married) {
							displayStrings[i]="X";
						}
						break;
					case "PatientIsSingle":
						if(PatCur.Position==PatientPosition.Single
							|| PatCur.Position==PatientPosition.Child
							|| PatCur.Position==PatientPosition.Widowed) {
							displayStrings[i]="X";
						}
						break;
					case "PatIDFromPatPlan": //Dependant Code for Canada
						patPlans=PatPlans.Refresh(PatNumCur);
						if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
							if(carrier.ElectID=="000064") { //Pacific Blue Cross (PBC)
								displayStrings[i]=subCur.SubscriberID+"-"+PatPlans.GetPatID(subCur.InsSubNum,patPlans);
							}
						}
						else {
							displayStrings[i]=PatPlans.GetPatID(subCur.InsSubNum,patPlans);
						}
						break;
					case "PatientSSN":
						if(PatCur.SSN.Length==9) {
							displayStrings[i]=PatCur.SSN.Substring(0,3)
								+"-"+PatCur.SSN.Substring(3,2)
								+"-"+PatCur.SSN.Substring(5);
						}
						else {
							displayStrings[i]=PatCur.SSN;
						}
						break;
					case "PatientMedicaidID":
						displayStrings[i]=PatCur.MedicaidID;
						break;
					case "PatientID-MedicaidOrSSN":
						if(PatCur.MedicaidID!="") {
							displayStrings[i]=PatCur.MedicaidID;
						}
						else {
							displayStrings[i]=PatCur.SSN;
						}
						break;
					case "PatientChartNum":
						displayStrings[i]=PatCur.ChartNumber;
						break;
					case "PatientPatNum":
						displayStrings[i]=PatCur.PatNum.ToString();
						break;
					case "Diagnosis1":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=diagnoses[0];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=diagnoses[0].Replace(".","");
						}
						break;
					case "Diagnosis2":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=diagnoses[1];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=diagnoses[1].Replace(".","");
						}
						break;
					case "Diagnosis3":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=diagnoses[2];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=diagnoses[2].Replace(".","");
						}
						break;
					case "Diagnosis4":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=diagnoses[3];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=diagnoses[3].Replace(".","");
						}
						break;
					case "DiagnosisA":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[0];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[0].Replace(".","");
						}
						break;
					case "DiagnosisB":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[1];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[1].Replace(".","");
						}
						break;
					case "DiagnosisC":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[2];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[2].Replace(".","");
						}
						break;
					case "DiagnosisD":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[3];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[3].Replace(".","");
						}
						break;
					case "DiagnosisE":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[4];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[4].Replace(".","");
						}
						break;
					case "DiagnosisF":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[5];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[5].Replace(".","");
						}
						break;
					case "DiagnosisG":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[6];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[6].Replace(".","");
						}
						break;
					case "DiagnosisH":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[7];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[7].Replace(".","");
						}
						break;
					case "DiagnosisI":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[8];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[8].Replace(".","");
						}
						break;
					case "DiagnosisJ":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[9];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[9].Replace(".","");
						}
						break;
					case "DiagnosisK":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[10];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[10].Replace(".","");
						}
						break;
					case "DiagnosisL":
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=arrayDiagnoses[11];
						}
						else if(ClaimFormCur.Items[i].FormatString=="NoDec") {
							displayStrings[i]=arrayDiagnoses[11].Replace(".","");
						}
						break;
			//this is where the procedures used to be
					case "Miss1":
						if(missingTeeth.Contains("1")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss2":
						if(missingTeeth.Contains("2")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss3":
						if(missingTeeth.Contains("3")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss4":
						if(missingTeeth.Contains("4")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss5":
						if(missingTeeth.Contains("5")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss6":
						if(missingTeeth.Contains("6")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss7":
						if(missingTeeth.Contains("7")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss8":
						if(missingTeeth.Contains("8")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss9":
						if(missingTeeth.Contains("9")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss10":
						if(missingTeeth.Contains("10")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss11":
						if(missingTeeth.Contains("11")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss12":
						if(missingTeeth.Contains("12")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss13":
						if(missingTeeth.Contains("13")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss14":
						if(missingTeeth.Contains("14")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss15":
						if(missingTeeth.Contains("15")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss16":
						if(missingTeeth.Contains("16")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss17":
						if(missingTeeth.Contains("17")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss18":
						if(missingTeeth.Contains("18")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss19":
						if(missingTeeth.Contains("19")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss20":
						if(missingTeeth.Contains("20")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss21":
						if(missingTeeth.Contains("21")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss22":
						if(missingTeeth.Contains("22")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss23":
						if(missingTeeth.Contains("23")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss24":
						if(missingTeeth.Contains("24")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss25":
						if(missingTeeth.Contains("25")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss26":
						if(missingTeeth.Contains("26")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss27":
						if(missingTeeth.Contains("27")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss28":
						if(missingTeeth.Contains("28")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss29":
						if(missingTeeth.Contains("29")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss30":
						if(missingTeeth.Contains("30")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss31":
						if(missingTeeth.Contains("31")) {
							displayStrings[i]="X";
						}
						break;
					case "Miss32":
						if(missingTeeth.Contains("32")) {
							displayStrings[i]="X";
						}
						break;
					case "Remarks":
						displayStrings[i]="";
						if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
							if(carrier.ElectID=="000064") { //Pacific Blue Cross (PBC)
								if(ClaimCur.ClaimType=="PreAuth") {
									displayStrings[i]+="Predetermination only."+Environment.NewLine;
								}
								else {
									if(subCur.AssignBen) {
										displayStrings[i]+="Please pay provider."+Environment.NewLine;
									}
									else {
										displayStrings[i]+="Please pay patient."+Environment.NewLine;
									}
								}
							}
						}
						if(ClaimCur.AttachmentID!="" && !ClaimCur.ClaimNote.StartsWith(ClaimCur.AttachmentID)){
							displayStrings[i]=ClaimCur.AttachmentID+" ";
						}
						displayStrings[i]+=ClaimCur.ClaimNote;
						break;
					case "PatientRelease":
						if(subCur.ReleaseInfo) {
							displayStrings[i]="Signature on File";
						}
						break;
					case "PatientReleaseDate":
						if(subCur.ReleaseInfo && ClaimCur.DateSent.Year > 1860) {
							if(ClaimFormCur.Items[i].FormatString=="") {
								displayStrings[i]=ClaimCur.DateSent.ToShortDateString();
							}
							else {
								displayStrings[i]=ClaimCur.DateSent.ToString(ClaimFormCur.Items[i].FormatString);
							}
						} 
						break;
					case "PatientAssignment":
						if(subCur.AssignBen) {
							displayStrings[i]="Signature on File";
						}
						break;
					case "PatientAssignmentDate":
						if(subCur.AssignBen && ClaimCur.DateSent.Year > 1860) {
							if(ClaimFormCur.Items[i].FormatString=="") {
								displayStrings[i]=ClaimCur.DateSent.ToShortDateString();
							}
							else {
								displayStrings[i]=ClaimCur.DateSent.ToString(ClaimFormCur.Items[i].FormatString);
							}
						}
						break;
					case "PlaceIsOffice":
						if(ClaimCur.PlaceService==PlaceOfService.Office) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsHospADA2002":
						if(ClaimCur.PlaceService==PlaceOfService.InpatHospital
							|| ClaimCur.PlaceService==PlaceOfService.OutpatHospital) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsExtCareFacilityADA2002":
						if(ClaimCur.PlaceService==PlaceOfService.CustodialCareFacility
							|| ClaimCur.PlaceService==PlaceOfService.SkilledNursFac) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsOtherADA2002":
						if(ClaimCur.PlaceService==PlaceOfService.PatientsHome
							|| ClaimCur.PlaceService==PlaceOfService.OtherLocation) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsInpatHosp":
						if(ClaimCur.PlaceService==PlaceOfService.InpatHospital) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsOutpatHosp":
						if(ClaimCur.PlaceService==PlaceOfService.OutpatHospital) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsAdultLivCareFac":
						if(ClaimCur.PlaceService==PlaceOfService.CustodialCareFacility) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsSkilledNursFac":
						if(ClaimCur.PlaceService==PlaceOfService.SkilledNursFac) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsPatientsHome":
						if(ClaimCur.PlaceService==PlaceOfService.PatientsHome) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceIsOtherLocation":
						if(ClaimCur.PlaceService==PlaceOfService.OtherLocation) {
							displayStrings[i]="X";
						}
						break;
					case "PlaceNumericCode":
						displayStrings[i]=GetPlaceOfServiceNum(ClaimCur.PlaceService);
						break;
					case "IsRadiographsAttached":
						if(ClaimCur.Radiographs>0) {
							displayStrings[i]="X";
						}
						break;
					case "RadiographsNumAttached":
						displayStrings[i]=ClaimCur.Radiographs.ToString();
						break;
					case "RadiographsNotAttached":
						if(ClaimCur.Radiographs==0) {
							displayStrings[i]="X";
						}
						break;
					case "IsEnclosuresAttached":
						if(ClaimCur.Radiographs>0 || ClaimCur.AttachedImages>0 || ClaimCur.AttachedModels>0) {
							displayStrings[i]="X";
						}
						break;
					case "AttachedImagesNum":
						displayStrings[i]=ClaimCur.AttachedImages.ToString();
						break;
					case "AttachedModelsNum":
						displayStrings[i]=ClaimCur.AttachedModels.ToString();
						break;
					case "IsNotOrtho":
						if(!ClaimCur.IsOrtho) {
							displayStrings[i]="X";
						}
						break;
					case "IsOrtho":
						if(ClaimCur.IsOrtho) {
							displayStrings[i]="X";
						}
						break;
					case "DateOrthoPlaced":
						if(ClaimCur.OrthoDate.Year > 1880){
							if(ClaimFormCur.Items[i].FormatString=="") {
								displayStrings[i]=ClaimCur.OrthoDate.ToShortDateString();
							}
							else {
								displayStrings[i]=ClaimCur.OrthoDate.ToString(ClaimFormCur.Items[i].FormatString);
							}
						}
						break;
					case "MonthsOrthoRemaining":
						if(ClaimCur.OrthoRemainM > 0) {
							displayStrings[i]=ClaimCur.OrthoRemainM.ToString();
						}
						break;
					case "IsNotProsth":
						if(ClaimCur.IsProsthesis=="N") {
							displayStrings[i]="X";
						}
						break;
					case "IsInitialProsth":
						if(ClaimCur.IsProsthesis=="I") {
							displayStrings[i]="X";
						}
						break;
					case "IsNotReplacementProsth":
						if(ClaimCur.IsProsthesis!="R") {//=='I'nitial or 'N'o
							displayStrings[i]="X";
						}
						break;
					case "IsReplacementProsth":
						if(ClaimCur.IsProsthesis=="R") {
							displayStrings[i]="X";
						}
						break;
					case "DatePriorProsthPlaced":
						if(ClaimCur.PriorDate.Year > 1860){
							if(ClaimFormCur.Items[i].FormatString=="") {
								displayStrings[i]=ClaimCur.PriorDate.ToShortDateString();
							}
							else {
								displayStrings[i]=ClaimCur.PriorDate.ToString(ClaimFormCur.Items[i].FormatString);
							}
						}
						break;
					case "IsOccupational":
						if(ClaimCur.AccidentRelated=="E") {
							displayStrings[i]="X";
						}
						break;
					case "IsNotOccupational":
						if(ClaimCur.AccidentRelated!="E") {
							displayStrings[i]="X";
						}
						break;
					case "IsAutoAccident":
						if(ClaimCur.AccidentRelated=="A") {
							displayStrings[i]="X";
						}
						break;
					case "IsNotAutoAccident":
						if(ClaimCur.AccidentRelated!="A") {
							displayStrings[i]="X";
						}
						break;
					case "IsOtherAccident":
						if(ClaimCur.AccidentRelated=="O") {
							displayStrings[i]="X";
						}
						break;
					case "IsNotOtherAccident":
						if(ClaimCur.AccidentRelated!="O") {
							displayStrings[i]="X";
						}
						break;
					case "IsNotAccident":
						if(ClaimCur.AccidentRelated!="O" && ClaimCur.AccidentRelated!="A") {
							displayStrings[i]="X";
						}
						break;
					case "IsAccident":
						if(ClaimCur.AccidentRelated!="") {
							displayStrings[i]="X";
						}
						break;
					case "AccidentDate":
						if(ClaimCur.AccidentDate.Year > 1860){
							if(ClaimFormCur.Items[i].FormatString=="") {
								displayStrings[i]=ClaimCur.AccidentDate.ToShortDateString();
							}
							else {
								displayStrings[i]=ClaimCur.AccidentDate.ToString(ClaimFormCur.Items[i].FormatString);
							}
						}
						break;
					case "AccidentST":
						displayStrings[i]=ClaimCur.AccidentST;
						break;
					case "BillingDentist":
						Provider P=ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)];
						displayStrings[i]=P.FName+" "+P.MI+" "+P.LName+" "+P.Suffix;
						break;
					//case "BillingDentistAddress":
					//  if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)){
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingAddress);
					//  }
					//  else if(clinic==null) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeAddress);
					//  }
					//  else {
					//    displayStrings[i]=clinic.Address;
					//  }
					//  break;
					//case "BillingDentistAddress2":
					//  if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingAddress2);
					//  }
					//  else if(clinic==null) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeAddress2);
					//  }
					//  else {
					//    displayStrings[i]=clinic.Address2;
					//  }
					//  break;
					//case "BillingDentistCity":
					//  if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingCity);
					//  }
					//  else if(clinic==null) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeCity);
					//  }
					//  else {
					//    displayStrings[i]=clinic.City;
					//  }
					//  break;
					//case "BillingDentistST":
					//  if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingST);
					//  }
					//  else if(clinic==null) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeST);
					//  }
					//  else {
					//    displayStrings[i]=clinic.State;
					//  }
					//  break;
					//case "BillingDentistZip":
					//  if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingZip);
					//  }
					//  else if(clinic==null) {
					//    displayStrings[i]=PrefC.GetString(PrefName.PracticeZip);
					//  }
					//  else {
					//    displayStrings[i]=clinic.Zip;
					//  }
					//  break;
					case "BillingDentistMedicaidID":
						displayStrings[i]=ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)].MedicaidID;
						break;
					case "BillingDentistProviderID":
						ProviderIdent[] provIdents=ProviderIdents.GetForPayor(ClaimCur.ProvBill,carrier.ElectID);
						if(provIdents.Length>0){
							displayStrings[i]=provIdents[0].IDNumber;//just use the first one we find
						}
						break;
					case "BillingDentistNPI":
						displayStrings[i]=ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)].NationalProvID;
						if(CultureInfo.CurrentCulture.Name.EndsWith("CA") && //Canadian. en-CA or fr-CA
							carrier.ElectID=="000064" && //Pacific Blue Cross (PBC)
							ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)].NationalProvID!= ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvTreat)].NationalProvID && //Billing and treating providers are different
							displayStrings[i].Length==9) { //Only for provider numbers which have been entered correctly (to prevent and indexing exception).
							displayStrings[i]="00"+displayStrings[i].Substring(2,5)+"00";
						}
						break;
					case "BillingDentistLicenseNum":
						displayStrings[i]=ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)].StateLicense;
						break;
					case "BillingDentistSSNorTIN":
						displayStrings[i]=ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)].SSN;
						break;
					case "BillingDentistNumIsSSN":
						if(!ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)].UsingTIN) {
							displayStrings[i]="X";
						}
						break;
					case "BillingDentistNumIsTIN":
						if(ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)].UsingTIN) {
							displayStrings[i]="X";
						}
						break;
					case "BillingDentistPh123":
						if(clinic==null){
							if(PrefC.GetString(PrefName.PracticePhone).Length==10){
								displayStrings[i]=PrefC.GetString(PrefName.PracticePhone).Substring(0,3);
							}
						}
						else{
							if(clinic.Phone.Length==10){
								displayStrings[i]=clinic.Phone.Substring(0,3);
							}
						}
						break;
					case "BillingDentistPh456":
						if(clinic==null){
							if(PrefC.GetString(PrefName.PracticePhone).Length==10){
								displayStrings[i]=PrefC.GetString(PrefName.PracticePhone).Substring(3,3);
							}
						}
						else{
							if(clinic.Phone.Length==10){
								displayStrings[i]=clinic.Phone.Substring(3,3);
							}
						}
						break;
					case "BillingDentistPh78910":
						if(clinic==null){
							if(PrefC.GetString(PrefName.PracticePhone).Length==10){
								displayStrings[i]=PrefC.GetString(PrefName.PracticePhone).Substring(6);
							}
						}
						else{
							if(clinic.Phone.Length==10){
								displayStrings[i]=clinic.Phone.Substring(6);
							}
						}
						break;
					case "BillingDentistPhoneFormatted":
						if(clinic==null){
							if(PrefC.GetString(PrefName.PracticePhone).Length==10){
								displayStrings[i]="("+PrefC.GetString(PrefName.PracticePhone).Substring(0,3)
									+")"+PrefC.GetString(PrefName.PracticePhone).Substring(3,3)
									+"-"+PrefC.GetString(PrefName.PracticePhone).Substring(6);
							}
						}
						else{
							if(clinic.Phone.Length==10){
								displayStrings[i]="("+clinic.Phone.Substring(0,3)
									+")"+clinic.Phone.Substring(3,3)
									+"-"+clinic.Phone.Substring(6);
							}
						}
						break;
					case "BillingDentistPhoneRaw":
						if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticePhone);
						}
						else {
							displayStrings[i]=clinic.Phone;
						}
						break;
					case "PayToDentistAddress": //Behaves just like the old BillingDentistAddress field, but is overridden by the Pay-To address if the Pay-To address has been specified.
						if(clinic!=null && clinic.PayToAddress!="") {
							displayStrings[i]=clinic.PayToAddress;
						}
						else if(PrefC.GetString(PrefName.PracticePayToAddress)!="") { //All Pay-To address fields are used in 5010 eclaims when Pay-To address line 1 is not blank.
						  displayStrings[i]=PrefC.GetString(PrefName.PracticePayToAddress);
						}
						else if(clinic!=null && clinic.UseBillAddrOnClaims) {
							displayStrings[i]=clinic.BillingAddress;
						}
						else if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)){
						  displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingAddress);
						}
						else if(clinic==null) {
						  displayStrings[i]=PrefC.GetString(PrefName.PracticeAddress);
						}
						else {
							displayStrings[i]=clinic.Address;
						}
						break;
					case "PayToDentistAddress2": //Behaves just like the old BillingDentistAddress2 field, but is overridden by the Pay-To address if the Pay-To address has been specified.
						if(clinic!=null && clinic.PayToAddress!="") {
							displayStrings[i]=clinic.PayToAddress2;
						}
						else if(PrefC.GetString(PrefName.PracticePayToAddress)!="") { //All Pay-To address fields are used in 5010 eclaims when Pay-To address line 1 is not blank.
						  displayStrings[i]=PrefC.GetString(PrefName.PracticePayToAddress2);
						}
						else if(clinic!=null && clinic.UseBillAddrOnClaims) {
							displayStrings[i]=clinic.BillingAddress2;
						}
						else if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)){
						  displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingAddress2);
						}
						else if(clinic==null) {
						  displayStrings[i]=PrefC.GetString(PrefName.PracticeAddress2);
						}
						else {
							displayStrings[i]=clinic.Address2;
						}
						break;
					case "PayToDentistCity": //Behaves just like the old BillingDentistCity field, but is overridden by the Pay-To address if the Pay-To address has been specified.
						if(clinic!=null && clinic.PayToAddress!="") {
							displayStrings[i]=clinic.PayToCity;
						}
						else if(PrefC.GetString(PrefName.PracticePayToAddress)!="") { //All Pay-To address fields are used in 5010 eclaims when Pay-To address line 1 is not blank.
							displayStrings[i]=PrefC.GetString(PrefName.PracticePayToCity);
						}
						else if(clinic!=null && clinic.UseBillAddrOnClaims) {
							displayStrings[i]=clinic.BillingCity;
						}
						else if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingCity);
						}
						else if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeCity);
						}
						else {
							displayStrings[i]=clinic.City;
						}
						break;
					case "PayToDentistST": //Behaves just like the old BillingDentistST field, but is overridden by the Pay-To address if the Pay-To address has been specified.
						if(clinic!=null && clinic.PayToAddress!="") {
							displayStrings[i]=clinic.PayToState;
						}
						else if(PrefC.GetString(PrefName.PracticePayToAddress)!="") { //All Pay-To address fields are used in 5010 eclaims when Pay-To address line 1 is not blank.
							displayStrings[i]=PrefC.GetString(PrefName.PracticePayToST);
						}
						else if(clinic!=null && clinic.UseBillAddrOnClaims) {
							displayStrings[i]=clinic.BillingState;
						}
						else if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingST);
						}
						else if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeST);
						}
						else {
							displayStrings[i]=clinic.State;
						}
						break;
					case "PayToDentistZip": //Behaves just like the old BillingDentistZip field, but is overridden by the Pay-To address if the Pay-To address has been specified.
						if(clinic!=null && clinic.PayToAddress!="") {
							displayStrings[i]=clinic.PayToZip;
						}
						else if(PrefC.GetString(PrefName.PracticePayToAddress)!="") { //All Pay-To address fields are used in 5010 eclaims when Pay-To address line 1 is not blank.
							displayStrings[i]=PrefC.GetString(PrefName.PracticePayToZip);
						}
						else if(clinic!=null && clinic.UseBillAddrOnClaims) {
							displayStrings[i]=clinic.BillingZip;
						}
						else if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeBillingZip);
						}
						else if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeZip);
						}
						else {
							displayStrings[i]=clinic.Zip;
						}
						break;
					case "TreatingDentistFName":
						displayStrings[i]=treatDent.FName;
						break;
					case "TreatingDentistLName":
						displayStrings[i]=treatDent.LName;
						break;
					case "TreatingDentistSignature":
						if(treatDent.SigOnFile){
							if(PrefC.GetBool(PrefName.ClaimFormTreatDentSaysSigOnFile)){
								displayStrings[i]="Signature on File";
							}
							else{
								displayStrings[i]=treatDent.FName+" "+treatDent.MI+" "+treatDent.LName+" "+treatDent.Suffix;
							}
						}
						break;
					case "TreatingDentistSigDate":
						if(treatDent.SigOnFile && ClaimCur.DateSent.Year > 1860){
							if(ClaimFormCur.Items[i].FormatString=="") {
								displayStrings[i]=ClaimCur.DateSent.ToShortDateString();
							}
							else {
								displayStrings[i]=ClaimCur.DateSent.ToString(ClaimFormCur.Items[i].FormatString);
							}
						}
						break;
					case "TreatingDentistMedicaidID":
						displayStrings[i]=treatDent.MedicaidID;
						break;
					case "TreatingDentistProviderID":
						provIdents=ProviderIdents.GetForPayor(ClaimCur.ProvTreat,carrier.ElectID);
						if(provIdents.Length>0) {
							displayStrings[i]=provIdents[0].IDNumber;//just use the first one we find
						}
						break;
					case "TreatingDentistNPI":
						displayStrings[i]=treatDent.NationalProvID;
						break;
					case "TreatingDentistLicense":
						displayStrings[i]=treatDent.StateLicense;
						break;
					case "TreatingDentistAddress":
						if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeAddress);
						}
						else {
							displayStrings[i]=clinic.Address;
						}
						break;
					case "TreatingDentistCity":
						if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeCity);
						}
						else {
							displayStrings[i]=clinic.City;
						}
						break;
					case "TreatingDentistST":
						if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeST);
						}
						else {
							displayStrings[i]=clinic.State;
						}
						break;
					case "TreatingDentistZip":
						if(clinic==null) {
							displayStrings[i]=PrefC.GetString(PrefName.PracticeZip);
						}
						else {
							displayStrings[i]=clinic.Zip;
						}
						break;
					case "TreatingDentistPh123":
						if(clinic==null){
							if(PrefC.GetString(PrefName.PracticePhone).Length==10){
								displayStrings[i]=PrefC.GetString(PrefName.PracticePhone).Substring(0,3);
							}
						}
						else{
							if(clinic.Phone.Length==10){
								displayStrings[i]=clinic.Phone.Substring(0,3);
							}
						}
						break;
					case "TreatingDentistPh456":
						if(clinic==null){
							if(PrefC.GetString(PrefName.PracticePhone).Length==10){
								displayStrings[i]=PrefC.GetString(PrefName.PracticePhone).Substring(3,3);
							}
						}
						else{
							if(clinic.Phone.Length==10){
								displayStrings[i]=clinic.Phone.Substring(3,3);
							}
						}
						break;
					case "TreatingDentistPh78910":
						if(clinic==null){
							if(PrefC.GetString(PrefName.PracticePhone).Length==10){
								displayStrings[i]=PrefC.GetString(PrefName.PracticePhone).Substring(6);
							}
						}
						else{
							if(clinic.Phone.Length==10){
								displayStrings[i]=clinic.Phone.Substring(6);
							}
						}
						break;
					case "TreatingProviderSpecialty":
						displayStrings[i]=X12Generator.GetTaxonomy
							(ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvTreat)]);
						break;
					case "TotalPages":
						displayStrings[i]="";//totalPages.ToString();//bugs with this field that we can't fix since we didn't write that code.
						break;
					case "ReferringProvNPI":
						if(ClaimReferral==null){
							displayStrings[i]="";
						}
						else{
							displayStrings[i]=ClaimReferral.NationalProvID;
						}
						break;
					case "ReferringProvNameFL":
						if(ClaimReferral==null){
							displayStrings[i]="";
						}
						else{
							displayStrings[i]=ClaimReferral.GetNameFL();
						}
						break;
					case "MedUniformBillType":
						displayStrings[i]=ClaimCur.UniformBillType;
						break;
					case "MedAdmissionTypeCode":
						displayStrings[i]=ClaimCur.AdmissionTypeCode;
						break;
					case "MedAdmissionSourceCode":
						displayStrings[i]=ClaimCur.AdmissionSourceCode;
						break;
					case "MedPatientStatusCode":
						displayStrings[i]=ClaimCur.PatientStatusCode;
						break;
					case "MedAccidentCode": //For UB04.
						if(ClaimCur.AccidentRelated=="A") { //Auto accident
							displayStrings[i]="01";
						}
						else if(ClaimCur.AccidentRelated=="E") { //Employment related accident
							displayStrings[i]="04";
						}
						break;
					case "ICDindicator"://For the 1500_02_12 claim form.
						byte icdVersion=0;
						List<byte> listDxVersions=new List<byte>();
						Procedures.GetUniqueDiagnosticCodes(Procedures.GetProcsFromClaimProcs(ListClaimProcs),false,listDxVersions);
						if(listDxVersions.Count>0) {
							icdVersion=listDxVersions[0];
						}
						if(icdVersion==9) {
							displayStrings[i]="9";
						}
						else if(icdVersion==10) {
							displayStrings[i]="0";
						}
						break;
					case "ICDindicatorAB"://For the ADA 2012 claim form.
						icdVersion=0;
						listDxVersions=new List<byte>();
						Procedures.GetUniqueDiagnosticCodes(Procedures.GetProcsFromClaimProcs(ListClaimProcs),false,listDxVersions);
						if(listDxVersions.Count>0) {
							icdVersion=listDxVersions[0];
						}
						if(icdVersion==9) {
							displayStrings[i]="B";
						}
						else if(icdVersion==10) {
							displayStrings[i]="AB";
						}
						break;
				}//switch
				if(CultureInfo.CurrentCulture.Name=="nl-BE"	&& displayStrings[i]==""){//Dutch Belgium
					displayStrings[i]="*   *   *";
				}
				//Renaissance eclaims only: Remove newlines from display strings to prevent formatting issues, because the .rss file format requires each field on a single line.
				if(isRenaissance && displayStrings[i]!=null) {
					displayStrings[i]=displayStrings[i].Replace("\r","").Replace("\n","");
				}
			}//for
		}
	
		/// <summary></summary>
		private string GetPlaceOfServiceNum(PlaceOfService place){
			switch(place){
				default:
					return "";
				case PlaceOfService.AmbulatorySurgicalCenter:
					return "24";
				case PlaceOfService.CustodialCareFacility:
					return "33";
				case PlaceOfService.EmergencyRoomHospital:
					return "23";
				case PlaceOfService.InpatHospital:
					return "21";
				case PlaceOfService.Office:
					return "11";
				case PlaceOfService.OutpatHospital:
					return "22";
				case PlaceOfService.PatientsHome:
					return "12";
				case PlaceOfService.SkilledNursFac:
					return "31";
				case PlaceOfService.MobileUnit:
					return "15";
				case PlaceOfService.School:
					return "03";
				case PlaceOfService.MilitaryTreatFac:
					return "26";
				case PlaceOfService.FederalHealthCenter:
					return "50";
				case PlaceOfService.PublicHealthClinic:
					return "71";
				case PlaceOfService.RuralHealthClinic:
					return "72";
			}
		}

		/// <summary></summary>
		/// <param name="startProc">For page 1, this will be 0, otherwise it might be 10, 8, 20, or whatever.  It is the 0-based index of the first proc. Depends on how many procedures this claim format can display and which page we are on.</param>
		/// <param name="totProcs">The number of procedures that can be displayed or printed per claim form.  Depends on the individual claim format. For example, 10 on the ADA2002</param>
		private void FillProcStrings(int startProc,int totProcs){
			int qty;
			for(int i=0;i<ClaimFormCur.Items.Length;i++){
				if(ClaimFormCur.Items[i]==null){//Renaissance does not use [0]
					continue;
				}
				InsPlan planCur = InsPlans.GetPlan(ClaimCur.PlanNum, ListInsPlan);
				qty = 0;
				switch(ClaimFormCur.Items[i].FieldName){
					//there is no default, because any non-matches will remain as ""
					case "P1Date":
						displayStrings[i]=GetProcInfo("Date",1+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P1Area":
						displayStrings[i]=GetProcInfo("Area",1+startProc);
						break;
					case "P1System":
						displayStrings[i]=GetProcInfo("System",1+startProc);
						break;
					case "P1ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",1+startProc);
						break;
					case "P1Surface":
						displayStrings[i]=GetProcInfo("Surface",1+startProc);
						break;
					case "P1Code":
						displayStrings[i]=GetProcInfo("Code",1+startProc);
						break;
					case "P1Description":
						displayStrings[i]=GetProcInfo("Desc",1+startProc);
						break;
					case "P1Fee":
						displayStrings[i]=GetProcInfo("Fee",1+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P1TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",1+startProc);
						break;
					case "P1PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",1+startProc);
						break;
					case "P1Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",1+startProc);
						break;
					case "P1DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",1+startProc);
						break;
					case "P1Lab":
						displayStrings[i]=GetProcInfo("Lab",1+startProc);
						break;
					case "P1FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",1+startProc);
						break;
					case "P1ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",1+startProc);
						break;
					case "P1TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",1+startProc);
						break;
					case "P1RevCode":
						displayStrings[i]=GetProcInfo("RevCode",1+startProc);
						break;
					case "P1CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",1+startProc);
						break;
					case "P1CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",1+startProc);
						break;
					case "P1CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",1+startProc);
						break;
					case "P1CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",1+startProc);
						break;
					//case "P1UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",1+startProc);
					//	break;
					case "P1UnitQty":
						if(planCur.ShowBaseUnits) {
							short bunit;
							System.Int16.TryParse(GetProcInfo("BaseUnits",1 + startProc),out bunit);
							short uqty;
							System.Int16.TryParse(GetProcInfo("UnitQty",1 + startProc),out uqty);
							qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",1+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",1+startProc));
						}
						else {
							qty = 0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P1CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",1+startProc) + GetProcInfo("CodeMod1",1+startProc) + GetProcInfo("CodeMod2",1+startProc) + GetProcInfo("CodeMod3",1+startProc) + GetProcInfo("CodeMod4",1+startProc);
						break;
					case "P2Date":
						displayStrings[i]=GetProcInfo("Date",2+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P2Area":
						displayStrings[i]=GetProcInfo("Area",2+startProc);
						break;
					case "P2System":
						displayStrings[i]=GetProcInfo("System",2+startProc);
						break;
					case "P2ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",2+startProc);
						break;
					case "P2Surface":
						displayStrings[i]=GetProcInfo("Surface",2+startProc);
						break;
					case "P2Code":
						displayStrings[i]=GetProcInfo("Code",2+startProc);
						break;
					case "P2Description":
						displayStrings[i]=GetProcInfo("Desc",2+startProc);
						break;
					case "P2Fee":
						displayStrings[i]=GetProcInfo("Fee",2+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P2TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",2+startProc);
						break;
					case "P2PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",2+startProc);
						break;
					case "P2Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",2+startProc);
						break;
					case "P2DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",2+startProc);
						break;
					case "P2Lab":
						displayStrings[i]=GetProcInfo("Lab",2+startProc);
						break;
					case "P2FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",2+startProc);
						break;
					case "P2ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",2+startProc);
						break;
					case "P2TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",2+startProc);
						break;
					case "P2RevCode":
						displayStrings[i]=GetProcInfo("RevCode",2+startProc);
						break;
					case "P2CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",2+startProc);
						break;
					case "P2CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",2+startProc);
						break;
					case "P2CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",2+startProc);
						break;
					case "P2CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",2+startProc);
						break;
					//case "P2UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",2+startProc);
					//	break;
					case "P2UnitQty":
						if(planCur.ShowBaseUnits){
              short bunit;
              System.Int16.TryParse(GetProcInfo("BaseUnits", 2 + startProc), out bunit);
              short uqty;
              System.Int16.TryParse(GetProcInfo("UnitQty", 2 + startProc), out uqty);
              qty = bunit + uqty;
						} 
						else if(GetProcInfo("UnitQty",2+startProc)!=""){
							qty=Int16.Parse(GetProcInfo("UnitQty",2+startProc));
						} 
						else {
							qty=0;
						}
            if(qty==0){
              displayStrings[i]="";
            } else {
              displayStrings[i]=qty.ToString();
            }
						break;
					case "P2CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",2+startProc) 
							+ GetProcInfo("CodeMod1",2+startProc) 
							+ GetProcInfo("CodeMod2",2+startProc) 
							+ GetProcInfo("CodeMod3",2+startProc) 
							+ GetProcInfo("CodeMod4",2+startProc);
						break;
					case "P3Date":
						displayStrings[i]=GetProcInfo("Date",3+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P3Area":
						displayStrings[i]=GetProcInfo("Area",3+startProc);
						break;
					case "P3System":
						displayStrings[i]=GetProcInfo("System",3+startProc);
						break;
					case "P3ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",3+startProc);
						break;
					case "P3Surface":
						displayStrings[i]=GetProcInfo("Surface",3+startProc);
						break;
					case "P3Code":
						displayStrings[i]=GetProcInfo("Code",3+startProc);
						break;
					case "P3Description":
						displayStrings[i]=GetProcInfo("Desc",3+startProc);
						break;
					case "P3Fee":
						displayStrings[i]=GetProcInfo("Fee",3+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P3TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",3+startProc);
						break;
					case "P3PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",3+startProc);
						break;
					case "P3Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",3+startProc);
						break;
					case "P3DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",3+startProc);
						break;
					case "P3Lab":
						displayStrings[i]=GetProcInfo("Lab",3+startProc);
						break;
					case "P3FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",3+startProc);
						break;
					case "P3ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",3+startProc);
						break;
					case "P3TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",3+startProc);
						break;
					case "P3RevCode":
						displayStrings[i]=GetProcInfo("RevCode",3+startProc);
						break;
					case "P3CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",3+startProc);
						break;
					case "P3CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",3+startProc);
						break;
					case "P3CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",3+startProc);
						break;
					case "P3CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",3+startProc);
						break;
					//case "P3UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",3+startProc);
					//	break;
					case "P3UnitQty":
						if(planCur.ShowBaseUnits){
              short bunit;
              System.Int16.TryParse(GetProcInfo("BaseUnits", 3 + startProc), out bunit);
              short uqty;
              System.Int16.TryParse(GetProcInfo("UnitQty", 3 + startProc), out uqty);
              qty = bunit + uqty;
						} 
						else if(GetProcInfo("UnitQty",3+startProc)!=""){
							qty=Int16.Parse(GetProcInfo("UnitQty",3+startProc));
						} 
						else {
							qty=0;
						}
            if(qty==0){
                displayStrings[i]="";
            } 
						else {
                displayStrings[i]=qty.ToString();
            }
						break;
					case "P3CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",3+startProc) 
							+ GetProcInfo("CodeMod1",3+startProc) 
							+ GetProcInfo("CodeMod2",3+startProc) 
							+ GetProcInfo("CodeMod3",3+startProc) 
							+ GetProcInfo("CodeMod4",3+startProc);
						break;
					case "P4Date":
						displayStrings[i]=GetProcInfo("Date",4+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P4Area":
						displayStrings[i]=GetProcInfo("Area",4+startProc);
						break;
					case "P4System":
						displayStrings[i]=GetProcInfo("System",4+startProc);
						break;
					case "P4ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",4+startProc);
						break;
					case "P4Surface":
						displayStrings[i]=GetProcInfo("Surface",4+startProc);
						break;
					case "P4Code":
						displayStrings[i]=GetProcInfo("Code",4+startProc);
						break;
					case "P4Description":
						displayStrings[i]=GetProcInfo("Desc",4+startProc);
						break;
					case "P4Fee":
						displayStrings[i]=GetProcInfo("Fee",4+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P4TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",4+startProc);
						break;
					case "P4PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",4+startProc);
						break;
					case "P4Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",4+startProc);
						break;
					case "P4DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",4+startProc);
						break;
					case "P4Lab":
						displayStrings[i]=GetProcInfo("Lab",4+startProc);
						break;
					case "P4FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",4+startProc);
						break;
					case "P4ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",4+startProc);
						break;
					case "P4TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",4+startProc);
						break;
					case "P4RevCode":
						displayStrings[i]=GetProcInfo("RevCode",4+startProc);
						break;
					case "P4CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",4+startProc);
						break;
					case "P4CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",4+startProc);
						break;
					case "P4CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",4+startProc);
						break;
					case "P4CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",4+startProc);
						break;
					//case "P4UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",4+startProc);
					//	break;
					case "P4UnitQty":
						if(planCur.ShowBaseUnits){
              short bunit;
              System.Int16.TryParse(GetProcInfo("BaseUnits", 4 + startProc), out bunit);
              short uqty;
              System.Int16.TryParse(GetProcInfo("UnitQty", 4 + startProc), out uqty);
              qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",4+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",4+startProc));
						}
						else {
							qty=0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P4CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",4+startProc) 
							+ GetProcInfo("CodeMod1",4+startProc) 
							+ GetProcInfo("CodeMod2",4+startProc) 
							+ GetProcInfo("CodeMod3",4+startProc) 
							+ GetProcInfo("CodeMod4",4+startProc);
						break;
					case "P5Date":
						displayStrings[i]=GetProcInfo("Date",5+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P5Area":
						displayStrings[i]=GetProcInfo("Area",5+startProc);
						break;
					case "P5System":
						displayStrings[i]=GetProcInfo("System",5+startProc);
						break;
					case "P5ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",5+startProc);
						break;
					case "P5Surface":
						displayStrings[i]=GetProcInfo("Surface",5+startProc);
						break;
					case "P5Code":
						displayStrings[i]=GetProcInfo("Code",5+startProc);
						break;
					case "P5Description":
						displayStrings[i]=GetProcInfo("Desc",5+startProc);
						break;
					case "P5Fee":
						displayStrings[i]=GetProcInfo("Fee",5+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P5TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",5+startProc);
						break;
					case "P5PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",5+startProc);
						break;
					case "P5Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",5+startProc);
						break;
					case "P5DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",5+startProc);
						break;
					case "P5Lab":
						displayStrings[i]=GetProcInfo("Lab",5+startProc);
						break;
					case "P5FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",5+startProc);
						break;
					case "P5ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",5+startProc);
						break;
					case "P5TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",5+startProc);
						break;
					case "P5RevCode":
						displayStrings[i]=GetProcInfo("RevCode",5+startProc);
						break;
					case "P5CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",5+startProc);
						break;
					case "P5CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",5+startProc);
						break;
					case "P5CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",5+startProc);
						break;
					case "P5CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",5+startProc);
						break;
					//case "P5UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",5+startProc);
					//	break;
					case "P5UnitQty":
						if(planCur.ShowBaseUnits) {
							short bunit;
							System.Int16.TryParse(GetProcInfo("BaseUnits",5 + startProc),out bunit);
							short uqty;
							System.Int16.TryParse(GetProcInfo("UnitQty",5 + startProc),out uqty);
							qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",5+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",5+startProc));
						}
						else {
							qty=0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P5CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",5+startProc) 
							+ GetProcInfo("CodeMod1",5+startProc) 
							+ GetProcInfo("CodeMod2",5+startProc) 
							+ GetProcInfo("CodeMod3",5+startProc) 
							+ GetProcInfo("CodeMod4",5+startProc);
						break;
					case "P6Date":
						displayStrings[i]=GetProcInfo("Date",6+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P6Area":
						displayStrings[i]=GetProcInfo("Area",6+startProc);
						break;
					case "P6System":
						displayStrings[i]=GetProcInfo("System",6+startProc);
						break;
					case "P6ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",6+startProc);
						break;
					case "P6Surface":
						displayStrings[i]=GetProcInfo("Surface",6+startProc);
						break;
					case "P6Code":
						displayStrings[i]=GetProcInfo("Code",6+startProc);
						break;
					case "P6Description":
						displayStrings[i]=GetProcInfo("Desc",6+startProc);
						break;
					case "P6Fee":
						displayStrings[i]=GetProcInfo("Fee",6+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P6TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",6+startProc);
						break;
					case "P6PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",6+startProc);
						break;
					case "P6Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",6+startProc);
						break;
					case "P6DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",6+startProc);
						break;
					case "P6Lab":
						displayStrings[i]=GetProcInfo("Lab",6+startProc);
						break;
					case "P6FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",6+startProc);
						break;
					case "P6ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",6+startProc);
						break;
					case "P6TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",6+startProc);
						break;
					case "P6RevCode":
						displayStrings[i]=GetProcInfo("RevCode",6+startProc);
						break;
					case "P6CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",6+startProc);
						break;
					case "P6CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",6+startProc);
						break;
					case "P6CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",6+startProc);
						break;
					case "P6CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",6+startProc);
						break;
					//case "P6UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",6+startProc);
					//	break;
					case "P6UnitQty":
						if(planCur.ShowBaseUnits) {
							short bunit;
							System.Int16.TryParse(GetProcInfo("BaseUnits",6 + startProc),out bunit);
							short uqty;
							System.Int16.TryParse(GetProcInfo("UnitQty",6 + startProc),out uqty);
							qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",6+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",6+startProc));
						}
						else {
							qty=0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P6CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",6+startProc) 
							+ GetProcInfo("CodeMod1",6+startProc) 
							+ GetProcInfo("CodeMod2",6+startProc) 
							+ GetProcInfo("CodeMod3",6+startProc) 
							+ GetProcInfo("CodeMod4",6+startProc);
						break;
					case "P7Date":
						displayStrings[i]=GetProcInfo("Date",7+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P7Area":
						displayStrings[i]=GetProcInfo("Area",7+startProc);
						break;
					case "P7System":
						displayStrings[i]=GetProcInfo("System",7+startProc);
						break;
					case "P7ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",7+startProc);
						break;
					case "P7Surface":
						displayStrings[i]=GetProcInfo("Surface",7+startProc);
						break;
					case "P7Code":
						displayStrings[i]=GetProcInfo("Code",7+startProc);
						break;
					case "P7Description":
						displayStrings[i]=GetProcInfo("Desc",7+startProc);
						break;
					case "P7Fee":
						displayStrings[i]=GetProcInfo("Fee",7+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P7TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",7+startProc);
						break;
					case "P7PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",7+startProc);
						break;
					case "P7Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",7+startProc);
						break;
					case "P7DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",7+startProc);
						break;
					case "P7Lab":
						displayStrings[i]=GetProcInfo("Lab",7+startProc);
						break;
					case "P7FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",7+startProc);
						break;
					case "P7ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",7+startProc);
						break;
					case "P7TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",7+startProc);
						break;
					case "P7RevCode":
						displayStrings[i]=GetProcInfo("RevCode",7+startProc);
						break;
					case "P7CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",7+startProc);
						break;
					case "P7CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",7+startProc);
						break;
					case "P7CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",7+startProc);
						break;
					case "P7CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",7+startProc);
						break;
					//case "P7UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",7+startProc);
					//	break;
					case "P7UnitQty":
						if(planCur.ShowBaseUnits) {
							short bunit;
							System.Int16.TryParse(GetProcInfo("BaseUnits",7 + startProc),out bunit);
							short uqty;
							System.Int16.TryParse(GetProcInfo("UnitQty",7 + startProc),out uqty);
							qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",7+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",7+startProc));
						}
						else {
							qty=0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P7CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",7+startProc) 
							+ GetProcInfo("CodeMod1",7+startProc) 
							+ GetProcInfo("CodeMod2",7+startProc) 
							+ GetProcInfo("CodeMod3",7+startProc) 
							+ GetProcInfo("CodeMod4",7+startProc);
						break;
					case "P8Date":
						displayStrings[i]=GetProcInfo("Date",8+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P8Area":
						displayStrings[i]=GetProcInfo("Area",8+startProc);
						break;
					case "P8System":
						displayStrings[i]=GetProcInfo("System",8+startProc);
						break;
					case "P8ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",8+startProc);
						break;
					case "P8Surface":
						displayStrings[i]=GetProcInfo("Surface",8+startProc);
						break;
					case "P8Code":
						displayStrings[i]=GetProcInfo("Code",8+startProc);
						break;
					case "P8Description":
						displayStrings[i]=GetProcInfo("Desc",8+startProc);
						break;
					case "P8Fee":
						displayStrings[i]=GetProcInfo("Fee",8+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P8TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",8+startProc);
						break;
					case "P8PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",8+startProc);
						break;
					case "P8Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",8+startProc);
						break;
					case "P8DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",8+startProc);
						break;
					case "P8Lab":
						displayStrings[i]=GetProcInfo("Lab",8+startProc);
						break;
					case "P8FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",8+startProc);
						break;
					case "P8ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",8+startProc);
						break;
					case "P8TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",8+startProc);
						break;
					case "P8RevCode":
						displayStrings[i]=GetProcInfo("RevCode",8+startProc);
						break;
					case "P8CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",8+startProc);
						break;
					case "P8CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",8+startProc);
						break;
					case "P8CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",8+startProc);
						break;
					case "P8CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",8+startProc);
						break;
					//case "P8UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",8+startProc);
					//	break;
					case "P8UnitQty":
						if(planCur.ShowBaseUnits) {
							short bunit;
							System.Int16.TryParse(GetProcInfo("BaseUnits",8 + startProc),out bunit);
							short uqty;
							System.Int16.TryParse(GetProcInfo("UnitQty",8 + startProc),out uqty);
							qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",8+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",8+startProc));
						}
						else {
							qty=0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P8CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",8+startProc) 
							+ GetProcInfo("CodeMod1",8+startProc) 
							+ GetProcInfo("CodeMod2",8+startProc) 
							+ GetProcInfo("CodeMod3",8+startProc) 
							+ GetProcInfo("CodeMod4",8+startProc);
						break;
					case "P9Date":
						displayStrings[i]=GetProcInfo("Date",9+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P9Area":
						displayStrings[i]=GetProcInfo("Area",9+startProc);
						break;
					case "P9System":
						displayStrings[i]=GetProcInfo("System",9+startProc);
						break;
					case "P9ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",9+startProc);
						break;
					case "P9Surface":
						displayStrings[i]=GetProcInfo("Surface",9+startProc);
						break;
					case "P9Code":
						displayStrings[i]=GetProcInfo("Code",9+startProc);
						break;
					case "P9Description":
						displayStrings[i]=GetProcInfo("Desc",9+startProc);
						break;
					case "P9Fee":
						displayStrings[i]=GetProcInfo("Fee",9+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P9TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",9+startProc);
						break;
					case "P9PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",9+startProc);
						break;
					case "P9Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",9+startProc);
						break;
					case "P9DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",9+startProc);
						break;
					case "P9Lab":
						displayStrings[i]=GetProcInfo("Lab",9+startProc);
						break;
					case "P9FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",9+startProc);
						break;
					case "P9ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",9+startProc);
						break;
					case "P9TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",9+startProc);
						break;
					case "P9RevCode":
						displayStrings[i]=GetProcInfo("RevCode",9+startProc);
						break;
					case "P9CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",9+startProc);
						break;
					case "P9CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",9+startProc);
						break;
					case "P9CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",9+startProc);
						break;
					case "P9CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",9+startProc);
						break;
					//case "P9UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",9+startProc);
					//	break;
					case "P9UnitQty":
						if(planCur.ShowBaseUnits) {
							short bunit;
							System.Int16.TryParse(GetProcInfo("BaseUnits",9 + startProc),out bunit);
							short uqty;
							System.Int16.TryParse(GetProcInfo("UnitQty",9 + startProc),out uqty);
							qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",9+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",9+startProc));
						}
						else {
							qty=0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P9CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",9+startProc) 
							+ GetProcInfo("CodeMod1",9+startProc) 
							+ GetProcInfo("CodeMod2",9+startProc) 
							+ GetProcInfo("CodeMod3",9+startProc) 
							+ GetProcInfo("CodeMod4",9+startProc);
						break;
					case "P10Date":
						displayStrings[i]=GetProcInfo("Date",10+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P10Area":
						displayStrings[i]=GetProcInfo("Area",10+startProc);
						break;
					case "P10System":
						displayStrings[i]=GetProcInfo("System",10+startProc);
						break;
					case "P10ToothNumber":
						displayStrings[i]=GetProcInfo("ToothNum",10+startProc);
						break;
					case "P10Surface":
						displayStrings[i]=GetProcInfo("Surface",10+startProc);
						break;
					case "P10Code":
						displayStrings[i]=GetProcInfo("Code",10+startProc);
						break;
					case "P10Description":
						displayStrings[i]=GetProcInfo("Desc",10+startProc);
						break;
					case "P10Fee":
						displayStrings[i]=GetProcInfo("Fee",10+startProc,ClaimFormCur.Items[i].FormatString);
						break;
					case "P10TreatDentMedicaidID":
						displayStrings[i]=GetProcInfo("TreatDentMedicaidID",10+startProc);
						break;
					case "P10PlaceNumericCode":
						displayStrings[i]=GetProcInfo("PlaceNumericCode",10+startProc);
						break;
					case "P10Diagnosis":
						displayStrings[i]=GetProcInfo("Diagnosis",10+startProc);
						break;
					case "P10DiagnosisPoint":
						displayStrings[i]=GetProcInfo("DiagnosisPoint",10+startProc);
						break;
					case "P10Lab":
						displayStrings[i]=GetProcInfo("Lab",10+startProc);
						break;
					case "P10FeeMinusLab":
						displayStrings[i]=GetProcInfo("FeeMinusLab",10+startProc);
						break;
					case "P10ToothNumOrArea":
						displayStrings[i]=GetProcInfo("ToothNumOrArea",10+startProc);
						break;
					case "P10TreatProvNPI":
						displayStrings[i]=GetProcInfo("TreatProvNPI",10+startProc);
						break;
					case "P10RevCode":
						displayStrings[i]=GetProcInfo("RevCode",10+startProc);
						break;
					case "P10CodeMod1":
						displayStrings[i]=GetProcInfo("CodeMod1",10+startProc);
						break;
					case "P10CodeMod2":
						displayStrings[i]=GetProcInfo("CodeMod2",10+startProc);
						break;
					case "P10CodeMod3":
						displayStrings[i]=GetProcInfo("CodeMod3",10+startProc);
						break;
					case "P10CodeMod4":
						displayStrings[i]=GetProcInfo("CodeMod4",10+startProc);
						break;
					//case "P10UnitCode":
					//	displayStrings[i]=GetProcInfo("UnitCode",10+startProc);
					//	break;
					case "P10UnitQty":
						if(planCur.ShowBaseUnits) {
							short bunit;
							System.Int16.TryParse(GetProcInfo("BaseUnits",10 + startProc),out bunit);
							short uqty;
							System.Int16.TryParse(GetProcInfo("UnitQty",10 + startProc),out uqty);
							qty = bunit + uqty;
						}
						else if(GetProcInfo("UnitQty",10+startProc)!="") {
							qty=Int16.Parse(GetProcInfo("UnitQty",10+startProc));
						}
						else {
							qty=0;
						}
						if(qty==0) {
							displayStrings[i]="";
						}
						else {
							displayStrings[i]=qty.ToString();
						}
						break;
					case "P10CodeAndMods":
						displayStrings[i]=GetProcInfo("Code",10+startProc) 
							+ GetProcInfo("CodeMod1",10+startProc) 
							+ GetProcInfo("CodeMod2",10+startProc) 
							+ GetProcInfo("CodeMod3",10+startProc) 
							+ GetProcInfo("CodeMod4",10+startProc);
						break;
					case "TotalFee":
						decimal fee=0;//fee only for this page. Each page is treated like a separate claim.
						for(int f=startProc;f<startProc+totProcs;f++) {//eg f=0;f<10;f++
							if(f < ListClaimProcs.Count) {
								fee+=(decimal)((ClaimProc)ListClaimProcs[f]).FeeBilled;
								if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
									List<Procedure> labProcs=Procedures.GetCanadianLabFees(ListClaimProcs[f].ProcNum,ListProc);
									for(int j=0;j<labProcs.Count;j++) {
										fee+=(decimal)labProcs[j].ProcFee;
									}
								}
							}
						}
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=fee.ToString("F");
						}
						else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
							displayStrings[i] = fee.ToString("F").Replace("."," ");
						}
						else {
							displayStrings[i]=fee.ToString(ClaimFormCur.Items[i].FormatString);
						}
						break;
					case "DateService"://only for this page, Earliest proc date.
						DateTime dateService=((ClaimProc)ListClaimProcs[0]).ProcDate;
						for(int f=startProc;f<startProc+totProcs;f++){//eg f=0;f<10;f++
							if(f < ListClaimProcs.Count && ((ClaimProc)ListClaimProcs[f]).ProcDate < dateService)
								dateService=((ClaimProc)ListClaimProcs[f]).ProcDate;
						}
						if(ClaimFormCur.Items[i].FormatString=="") {
							displayStrings[i]=dateService.ToShortDateString();
						}
						else {
							displayStrings[i]=dateService.ToString(ClaimFormCur.Items[i].FormatString);
						}
						break;
				}//switch
				if(CultureInfo.CurrentCulture.Name=="nl-BE" && displayStrings[i]==""){//Dutch Belgium
					displayStrings[i]="*   *   *";
				}
			}//for i
		}

		private void FillMedValueCodes(){
			ListClaimValCodeLog = ClaimValCodeLogs.GetForClaim(ClaimCur.ClaimNum);
			if(ListClaimValCodeLog.Count>0){
				ClaimValCodeLog[] vcA;
				vcA = new ClaimValCodeLog[12];
				for(int i=0;i<ListClaimValCodeLog.Count;i++){
					vcA[i]=(ClaimValCodeLog)ListClaimValCodeLog[i];
				}
				for(int i=ListClaimValCodeLog.Count;i<12;i++){
					vcA[i]= new ClaimValCodeLog();
				}
				for(int i=0;i<ClaimFormCur.Items.Length;i++){
					switch(ClaimFormCur.Items[i].FieldName){
						case "MedValCode39a":
							displayStrings[i]=vcA[0].ValCode;
							break;
						case "MedValAmount39a":
							if(vcA[0].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i]=vcA[0].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[0].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode39b":
							if(vcA[3]!=null)
								displayStrings[i]=vcA[3].ValCode;
							break;
						case "MedValAmount39b":
							if(vcA[3].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[3].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[3].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode39c":
							if(vcA[6]!=null)
								displayStrings[i]=vcA[6].ValCode;
							break;
						case "MedValAmount39c":
							if(vcA[6].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[6].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[6].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode39d":
							if(vcA[9]!=null)
								displayStrings[i]=vcA[9].ValCode;
							break;
						case "MedValAmount39d":
							if(vcA[9].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[9].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[9].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode40a":
							if(vcA[1]!=null) {
								displayStrings[i]=vcA[1].ValCode;
							}
							break;
						case "MedValAmount40a":
							if(vcA[1].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[1].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[1].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode40b":
							if(vcA[4]!=null) {
								displayStrings[i]=vcA[4].ValCode;
							}
							break;
						case "MedValAmount40b":
							if(vcA[4].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[4].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[4].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode40c":
							if(vcA[7]!=null) {
								displayStrings[i]=vcA[7].ValCode;
							}
							break;
						case "MedValAmount40c":
							if(vcA[7].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[7].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[7].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode40d":
							if(vcA[10]!=null)
								displayStrings[i]=vcA[10].ValCode;
							break;
						case "MedValAmount40d":
							if(vcA[10].ValAmount==0){
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[10].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[10].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode41a":
							if(vcA[2]!=null)
								displayStrings[i]=vcA[2].ValCode;
							break;
						case "MedValAmount41a":
							if(vcA[2].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[2].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[2].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode41b":
							if(vcA[5]!=null) {
								displayStrings[i]=vcA[5].ValCode;
							}
							break;
						case "MedValAmount41b":
							if(vcA[5].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[5].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[5].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode41c":
							if(vcA[8]!=null) {
								displayStrings[i]=vcA[8].ValCode;
							}
							break;
						case "MedValAmount41c":
							if(vcA[8].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[8].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[8].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
						case "MedValCode41d":
							if(vcA[11]!=null)
								displayStrings[i]=vcA[11].ValCode;
							break;
						case "MedValAmount41d":
							if(vcA[11].ValAmount==0) {
								displayStrings[i]="";
							}
							else if(ClaimFormCur.Items[i].FormatString == "NoDec") {
								displayStrings[i] = vcA[11].ValAmount.ToString("F").Replace("."," ");
							}
							else {
								displayStrings[i]=vcA[11].ValAmount.ToString(ClaimFormCur.Items[i].FormatString);
							}
							break;
					}
				}
			}
		}

		private void FillMedCondCodes(){
			ClaimCondCodeLog claimCondCodeLog=ClaimCondCodeLogs.GetByClaimNum(ClaimCur.ClaimNum);
			if(claimCondCodeLog==null) {
				return;
			}
			for(int i=0;i<ClaimFormCur.Items.Length;i++) {
				switch(ClaimFormCur.Items[i].FieldName) {
					case "MedConditionCode18":
						displayStrings[i]=claimCondCodeLog.Code0;
						break;
					case "MedConditionCode19":
						displayStrings[i]=claimCondCodeLog.Code1;
						break;
					case "MedConditionCode20":
						displayStrings[i]=claimCondCodeLog.Code2;
						break;
					case "MedConditionCode21":
						displayStrings[i]=claimCondCodeLog.Code3;
						break;
					case "MedConditionCode22":
						displayStrings[i]=claimCondCodeLog.Code4;
						break;
					case "MedConditionCode23":
						displayStrings[i]=claimCondCodeLog.Code5;
						break;
					case "MedConditionCode24":
						displayStrings[i]=claimCondCodeLog.Code6;
						break;
					case "MedConditionCode25":
						displayStrings[i]=claimCondCodeLog.Code7;
						break;
					case "MedConditionCode26":
						displayStrings[i]=claimCondCodeLog.Code8;
						break;
					case "MedConditionCode27":
						displayStrings[i]=claimCondCodeLog.Code9;
						break;
					case "MedConditionCode28":
						displayStrings[i]=claimCondCodeLog.Code10;
						break;
				}
			}
		}

		///<summary>These fields are used for the UB04.</summary>
		private void FillMedInsStrings(){
			PatPlan patPlan=null;
			for(int i=0;i<ListPatPlans.Count;i++) {
				if(ListPatPlans[i].InsSubNum==ClaimCur.InsSubNum) {
					patPlan=ListPatPlans[i];
					break;
				}
			}
			string insFilingCodeStr=InsFilingCodes.GetEclaimCode(planCur.FilingCode);
			//Determine the slot (A, B or C) where the medical insurance information belongs.
			string insLine="A";
			if(insFilingCodeStr=="MC") { //Medicaid
				insLine="C";
			}
			else if(patPlan==null) {//Plan was dropped.
				//We only support one medical plan right now so defaulting to primary should be fine. 
			}
			else {
				//If not Medicaid, then primary is on line A, secondary is on line B, and Tertiary is on line C.
				if(patPlan.Ordinal==2) {
					insLine="B";
				}
				else if(patPlan.Ordinal==3) {
					insLine="C";
				}
			}
			//Determine the prior payments or total payments from other insurance companies.
			decimal priorPaymentsA=0;
			decimal priorPaymentsB=0;
			for(int i=0;i<ClaimProcsForClaim.Count;i++) {
				for(int j=0;j<ClaimProcsForPat.Count;j++) {
					if(!ClaimProcs.IsValidClaimAdj(ClaimProcsForPat[j],ClaimProcsForClaim[i].ProcNum,ClaimProcsForClaim[i].InsSubNum)) {
						continue;
					}
					if(insFilingCodeStr=="MC") { //Medicaid
						string insFilingCodeClaimProcStr="";
						for(int k=0;k<ListInsPlan.Count;k++) {
							if(ListInsPlan[k].PlanNum==ClaimProcsForPat[j].PlanNum) {
								insFilingCodeClaimProcStr=InsFilingCodes.GetEclaimCode(ListInsPlan[k].FilingCode);
								break;
							}
						}
						if(insFilingCodeClaimProcStr=="16" || insFilingCodeClaimProcStr=="MB") {//HMO_MedicareRisk and MedicarePartB
							priorPaymentsA+=(decimal)ClaimProcsForPat[j].InsPayAmt;
						}
						else {
							priorPaymentsB+=(decimal)ClaimProcsForPat[j].InsPayAmt;
						}
					}
					else {
						for(int k=0;k<ListPatPlans.Count;k++) {
							if(ListPatPlans[k].InsSubNum==ClaimProcsForPat[j].InsSubNum) {
								if(ListPatPlans[k].Ordinal==1) {
									priorPaymentsA+=(decimal)ClaimProcsForPat[j].InsPayAmt;
								}
								else if(ListPatPlans[k].Ordinal==2) {
									priorPaymentsB+=(decimal)ClaimProcsForPat[j].InsPayAmt;
								}
								break;
							}
						}
					}
				}
			}
			for(int i=0;i<ClaimFormCur.Items.Length;i++) {
				string stringFormat=ClaimFormCur.Items[i].FormatString;
				if(ClaimFormCur.Items[i].FieldName=="MedInsCrossoverIndicator") {
					if(insFilingCodeStr=="MB") { //Medicare Part B
						displayStrings[i]="XOVR";
					}
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"Name") { //MedInsAName, MedInsBName, MedInsCName
					displayStrings[i]=Carriers.GetName(planCur.CarrierNum);
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"PlanID") { //MedInsAPlanID, MedInsBPlanID, MedInsCPlanID
					//Not used. Leave blank.
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"RelInfo") { //MedInsARelInfo, MedInsBRelInfo, MedInsCRelInfo
					displayStrings[i]=subCur.ReleaseInfo?"X":"";
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"AssignBen") { //MedInsAAssignBen, MedInsBAssignBen, MedInsCAssignBen
					displayStrings[i]=subCur.AssignBen?"X":"";
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedInsAPriorPmt") {
					if(priorPaymentsA==0) {
						continue;
					}
					if(stringFormat=="") {
						displayStrings[i]=priorPaymentsA.ToString("F");
					}
					else if(stringFormat=="NoDec") {
						displayStrings[i]=priorPaymentsA.ToString("F").Replace("."," ");
					}
					else {
						displayStrings[i]=priorPaymentsA.ToString(stringFormat);
					}
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedInsBPriorPmt") {
					if(priorPaymentsB==0) {
						continue;
					}
					if(stringFormat=="") {
						displayStrings[i]=priorPaymentsB.ToString("F");
					}
					else if(stringFormat=="NoDec") {
						displayStrings[i]=priorPaymentsB.ToString("F").Replace("."," ");
					}
					else {
						displayStrings[i]=priorPaymentsB.ToString(stringFormat);
					}
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"AmtDue") { //MedInsAAmtDue, MedInsBAmtDue, MedInsCAmtDue
					decimal totalValAmount=(decimal)ClaimValCodeLogs.GetValAmountTotal(ClaimCur.ClaimNum,"23");
					decimal amtDue=((decimal)ClaimCur.ClaimFee-priorPaymentsA-priorPaymentsB-totalValAmount);
					if(stringFormat=="") {
						displayStrings[i]=amtDue.ToString("F");
					}
					else if(stringFormat=="NoDec") {
						displayStrings[i]=amtDue.ToString("F").Replace("."," ");
					}
					else {
						displayStrings[i]=amtDue.ToString(stringFormat);
					}
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"OtherProvID") { //MedInsAOtherProvID, MedInsBOtherProvID, MedInsCOtherProvID
					string CarrierElectID=carrier.ElectID.ToString();
					Provider prov=ProviderC.ListLong[Providers.GetIndexLong(ClaimCur.ProvBill)];
					if(prov.ProvNum>0 && CarrierElectID!="" && ProviderIdents.GetForPayor(prov.ProvNum,CarrierElectID).Length>0) {
						ProviderIdent provID=ProviderIdents.GetForPayor(prov.ProvNum,CarrierElectID)[0];
						if(provID.IDNumber != "") {
							displayStrings[i]=provID.IDNumber.ToString();
						}
						else {
							displayStrings[i] = "";
						}
					}
					else {
						displayStrings[i]="";
					}
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"InsuredName") { //MedInsAInsuredName, MedInsBInsuredName, MedInsCInsuredName
					displayStrings[i]=Patients.GetPat(subCur.Subscriber).GetNameFLFormal();
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"Relation") { //MedInsARelation, MedInsBRelation, MedInsCRelation
					if(ClaimCur.PatRelat==Relat.Spouse) {
						displayStrings[i]="01";
					}
					else if(ClaimCur.PatRelat==Relat.Self) {
						displayStrings[i]="18";
					}
					else if(ClaimCur.PatRelat==Relat.Child) {
						displayStrings[i]="19";
					}
					else if(ClaimCur.PatRelat==Relat.Employee) {
						displayStrings[i]="20";
					}
					else if(ClaimCur.PatRelat==Relat.LifePartner) {
						displayStrings[i]="53";
					}
					else {
						displayStrings[i]="G8";
					}
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"InsuredID") { //MedInsAInsuredID, MedInsBInsuredID, MedInsCInsuredID
					displayStrings[i]=subCur.SubscriberID;
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"GroupName") { //MedInsAGroupName, MedInsBGroupName, MedInsCGroupName
					displayStrings[i]=planCur.GroupName;
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"GroupNum") { //MedInsAGroupNum, MedInsBGroupNum, MedInsCGroupNum
					displayStrings[i]=planCur.GroupNum;
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"AuthCode") { //MedInsAAuthCode, MedInsBAuthCode, MedInsCAuthCode
					displayStrings[i]=ClaimCur.PreAuthString;
				}
				else if(ClaimFormCur.Items[i].FieldName=="MedIns"+insLine+"Employer") { //MedInsAEmployer, MedInsBEmployer, MedInsCEmployer
					displayStrings[i]=Employers.GetName(planCur.EmployerNum);
				}
			}
		}

		/// <summary>Uses the fee field to determine how many procedures this claim will print.</summary>
		/// <returns></returns>
		private int ProcLimitForFormat(){
			int retVal=0;
			//loop until a match is not found.  The max of 10 is built in because of course it will never match to 11 since there is no such fieldName.
			for(int i=0;i<15;i++){
				for(int j=0;j<ClaimFormCur.Items.Length;j++){
					if(ClaimFormCur.Items[j].FieldName=="P"+i.ToString()+"Fee"){
						retVal=i;
					}
				}//for j
			}
			if(retVal==0){//if claimform doesn't use fees, use procedurecode
				for(int i=0;i<15;i++){
					for(int j=0;j<ClaimFormCur.Items.Length;j++){
						if(ClaimFormCur.Items[j].FieldName=="P"+i.ToString()+"Code"){
							retVal=i;
						}
					}//for j
				}
			}
			if(retVal==0){//if STILL zero
				retVal=10;
			}
			return retVal;
		}

		/// <summary>Overload that does not need a stringFormat</summary>
		/// <param name="field"></param>
		/// <param name="procIndex"></param>
		/// <returns></returns>
		private string GetProcInfo(string field,int procIndex) {
			return GetProcInfo(field,procIndex,"");
		}

		/// <summary>Gets the string to be used for this field and index.</summary>
		/// <param name="field"></param>
		/// <param name="procIndex"></param>
		/// <param name="stringFormat"></param>
		/// <returns></returns>
		private string GetProcInfo(string field,int procIndex, string stringFormat) {
			//remember that procIndex is 1 based, not 0 based, 
			procIndex--;//so convert to 0 based
			if(ListClaimProcs.Count <= procIndex){
				//if(CultureInfo.CurrentCulture.Name=="nl-BE"){//Dutch Belgium
				//	return"*   *   *";
				//}
				//else{
				return "";
				//}
			}
			if(field=="System") {
				return "JP";
			}
			if(field=="Code") {
				return ListClaimProcs[procIndex].CodeSent;
			}
			if(field=="System") {
				return "JP";
			}
			if(field=="Fee") {
				decimal totalProcFees=(decimal)ListClaimProcs[procIndex].FeeBilled;
				if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
					List<Procedure> labProcs=Procedures.GetCanadianLabFees(ListClaimProcs[procIndex].ProcNum,ListProc);
					for(int i=0;i<labProcs.Count;i++) {
						totalProcFees+=(decimal)labProcs[i].ProcFee;
					}
				}
				if(stringFormat=="") {
					return totalProcFees.ToString("F");
				}
				else if(stringFormat=="NoDec") {
					return totalProcFees.ToString("F").Replace("."," ");
				}
				return totalProcFees.ToString(stringFormat);
			}
			Procedure ProcCur=Procedures.GetProcFromList(ListProc,ListClaimProcs[procIndex].ProcNum);
			ProcedureCode procCode=ProcedureCodes.GetProcCode(ProcCur.CodeNum);
			if(field=="RevCode"){
				return ProcCur.RevCode;
			}
			if(field=="CodeMod1"){
				return ProcCur.CodeMod1;
			}
			if(field=="CodeMod2"){
				return ProcCur.CodeMod2;
			}
			if(field=="CodeMod3"){
				return ProcCur.CodeMod3;
			}
			if(field=="CodeMod4"){
				return ProcCur.CodeMod4;
			}
			//if(field=="UnitCode"){
			//	return ProcCur.UnitCode;
			//}
			if(field=="UnitQty"){
				return ProcCur.UnitQty.ToString();
			}
			if(field=="BaseUnits"){
				return ProcCur.BaseUnits.ToString();
			}
			if(field=="Desc") {
				if(procCode.DrugNDC!="") {
					//For UB04, we must show the procedure description as a standard drug format so that the drug can be easily recognized.
					//The DrugNDC field is only used when medical features are turned on so this behavior won't take effect in many circumstances.
					string drugUnit="UN";//Unit
					float drugQty=ProcCur.DrugQty;
					switch(ProcCur.DrugUnit) {
						case EnumProcDrugUnit.Gram:
							drugUnit="GR";
							break;
						case EnumProcDrugUnit.InternationalUnit:
							drugUnit="F2";
							break;
						case EnumProcDrugUnit.Milligram:
							drugUnit="GR";
							drugQty=drugQty/1000;
							break;
						case EnumProcDrugUnit.Milliliter:
							drugUnit="ML";
							break;
					}
					return "N4"+procCode.DrugNDC+drugUnit+drugQty.ToString("f3");
				}
				else {
					ProcedureCode procCodeSent=ProcedureCodes.GetProcCode(ListClaimProcs[procIndex].CodeSent);
					if(procCodeSent.TreatArea==TreatmentArea.Quad) {
						return ProcCur.Surf+" "+procCodeSent.Descript;
					}
					else {
						return procCodeSent.Descript;
					}
				}
			}
			if(field=="Date"){
				if(ClaimCur.ClaimType=="PreAuth") {//no date on preauth procedures
					return "";
				}
				if(stringFormat=="") {
					return ListClaimProcs[procIndex].ProcDate.ToShortDateString();
				}
				return ListClaimProcs[procIndex].ProcDate.ToString(stringFormat);
			}
			if(field=="TreatDentMedicaidID"){
				if(ListClaimProcs[procIndex].ProvNum==0){
					return "";
				}
				else return ProviderC.ListLong[Providers.GetIndexLong(ListClaimProcs[procIndex].ProvNum)].MedicaidID;
			}
			if(field=="TreatProvNPI"){
				if(ListClaimProcs[procIndex].ProvNum==0) {
					return "";
				}
				else {
					return ProviderC.ListLong[Providers.GetIndexLong(ListClaimProcs[procIndex].ProvNum)].NationalProvID;
				}
			}
			if(field=="PlaceNumericCode"){
				return GetPlaceOfServiceNum(ClaimCur.PlaceService);
			}
			//(Procedure)Procedures.HList[ClaimProcsForClaim[procIndex].ProcNum];
			//Procedure ProcOld=ProcCur.Clone();
			if(field=="Diagnosis"){
				if(ProcCur.DiagnosticCode==""){
					return "";
				}
				//string diagstr="";//would concat them together, but OD only allows one diagnosis per code anyway.
				for(int d=0;d<diagnoses.Length;d++){
					if(diagnoses[d]==ProcCur.DiagnosticCode){
						return (d+1).ToString();
					}
				}
				return ProcCur.DiagnosticCode;
			}
			if(field=="DiagnosisPoint") {
				if(ProcCur.DiagnosticCode=="") {
					return "";//No diagnosis codes present on procedure.
				}
				string pointer="";//Output will be in alphabetical order.
				for(int d=0;d<arrayDiagnoses.Length;d++) {
					if(arrayDiagnoses[d]=="") {
						continue;
					}
					if(arrayDiagnoses[d]==ProcCur.DiagnosticCode || arrayDiagnoses[d]==ProcCur.DiagnosticCode2 ||
						arrayDiagnoses[d]==ProcCur.DiagnosticCode3 || arrayDiagnoses[d]==ProcCur.DiagnosticCode4) 
					{
						pointer+=(Char)(d+(int)('A'));//Characters A through L.
					}
				}
				return pointer;
			}
			if(field=="Lab") {// && ProcCur.LabFee>0) {
				if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
					List<Procedure> labProcs=Procedures.GetCanadianLabFees(ListClaimProcs[procIndex].ProcNum,ListProc);
					decimal totalLabFees=0;
					for(int i=0;i<labProcs.Count;i++) {
						totalLabFees+=(decimal)labProcs[i].ProcFee;
					}
					if(stringFormat=="") {
						return totalLabFees.ToString("F");
					}
					else if(stringFormat=="NoDec") {
						return totalLabFees.ToString("F").Replace("."," ");
					}
					return totalLabFees.ToString(stringFormat);
				}
				return "";//ProcCur.LabFee.ToString("n");
			}
			if(field=="FeeMinusLab") {
				if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
					if(stringFormat=="") {
						return ListClaimProcs[procIndex].FeeBilled.ToString("F");
					}
					else if(stringFormat=="NoDec") {
						double amt = ListClaimProcs[procIndex].FeeBilled * 100;
						return amt.ToString();
					}
					else {
						return ListClaimProcs[procIndex].FeeBilled.ToString(stringFormat);
					}
				}
				return "";//(((ClaimProc)claimprocs[procIndex]).FeeBilled-ProcCur.LabFee).ToString("n");
			}
			string area="";
			string toothNum="";
			string surf="";
			switch(ProcedureCodes.GetProcCode(ProcCur.CodeNum).TreatArea){
				case TreatmentArea.Surf:
					//area blank
					toothNum=Tooth.ToInternat(ProcCur.ToothNum);
					surf=Tooth.SurfTidyForClaims(ProcCur.Surf,ProcCur.ToothNum);
					break;
				case TreatmentArea.Tooth:
					//area blank
					toothNum=Tooth.ToInternat(ProcCur.ToothNum);
					//surf blank
					break;
				case TreatmentArea.Quad:
					area=AreaToCode(ProcCur.Surf);//"UL" etc -> 20 etc
					//num blank
					//surf blank
					break;
				case TreatmentArea.Sextant:
					if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
						//United States Sextant 1 is Canadian sextant 03.
						//United States Sextant 2 is Canadian sextant 04.
						//United States Sextant 3 is Canadian sextant 05.
						//United States Sextant 4 is Canadian sextant 06.
						//United States Sextant 5 is Canadian sextant 07.
						//United States Sextant 6 is Canadian sextant 08.
						//The sextant goes into the "International Tooth Code" column on the claim form, according to the Nova Scotia NIHB fee guide page VII.
						toothNum=(PIn.Int(ProcCur.Surf)+2).ToString().PadLeft(2,'0');//Add 2 to US sextant, then prepend a '0'.
					}
					else {//United States
						area="";//leave it blank.  Never used anyway.
						//area="S"+ProcCur.Surf;//area
						//num blank
						//surf blank
					}
					break;
				case TreatmentArea.Arch:
					area=AreaToCode(ProcCur.Surf);//area "U", etc
					//num blank
					//surf blank
					break;
				case TreatmentArea.ToothRange:
					//area blank
					toothNum=Tooth.FormatRangeForDisplay(ProcCur.ToothRange);
					/*for(int i=0;i<ProcCur.ToothRange.Split(',').Length;i++){
						if(!Tooth.IsValidDB(ProcCur.ToothRange.Split(',')[i])){
							continue;
						}
						if(i>0){
							toothNum+=",";
						}
						toothNum+=Tooth.ToInternat(ProcCur.ToothRange.Split(',')[i]);
					}*/
					//surf blank
					break;
				default://mouth
					//area?
					break;
			}//switch treatarea
      switch(field){
				case "Area":
					return area;
				case "ToothNum":
					return toothNum;
				case "Surface":
					return surf;
				case "ToothNumOrArea":
					if(toothNum!=""){
						return toothNum;
					}
					else{
						return area;
					}
			}
			MessageBox.Show("error in getprocinfo");
			return "";//should never get to here
		}

		private string AreaToCode(string area){
			switch(area){
				case "U":
					return "01";
				case "L":
					return "02";
				case "UR":
					return "10";
				case "UL":
					return "20";
				case "LL":
					return "30";
				case "LR":
					return "40";
			}
			return "";
		}

		private void butBack_Click(object sender, System.EventArgs e){
			if(Preview2.StartPage==0) { 
				return; 
			}
			Preview2.StartPage--;
			labelTotPages.Text=(Preview2.StartPage+1).ToString() + " / " + totalPages.ToString();
		}

		private void butFwd_Click(object sender, System.EventArgs e){
			if(Preview2.StartPage==totalPages-1) {
				return;
			}
			Preview2.StartPage++;
			labelTotPages.Text=(Preview2.StartPage+1).ToString() + " / " + totalPages.ToString();
		}

		private void butPrint_Click(object sender, System.EventArgs e){
			if(PrintClaim()){
				Etranss.SetClaimSentOrPrinted(ClaimNumCur,ClaimCur.PatNum,0,EtransType.ClaimPrinted,0);
				//Claims.UpdateStatus(ThisClaimNum,"P");
				SecurityLogs.MakeLogEntry(Permissions.ClaimSend,ClaimCur.PatNum,Lan.g(this,"Claim printed from Claim Preview window."));
				DialogResult=DialogResult.OK;
			}
			else{
				DialogResult=DialogResult.Cancel;
			}
			//Close();
		}

		private void butClose_Click(object sender, System.EventArgs e) {
			DialogResult=DialogResult.OK;
		}


	}

}
















