public void ViewQualityMetrics(List<iProPQRSPortableLib.Type> Types,List<iProPQRSPortableLib.Option> DropdownOption, string HeaderTitle)
		{
			float hUVB=200;
			UIView finalView=new UIView();
			UIView uvBlock = new UIView ();
			UIImageView titleimg = new UIImageView (new CoreGraphics.CGRect (0, 0, 992, 40));
			titleimg.Image=UIImage.FromFile(@"headerBarTall.png");
			UILabel lbltitle = new UILabel (new CoreGraphics.CGRect (8, 8, 140, 21));
			lbltitle.Text = HeaderTitle;
			uvBlock.Add (titleimg);
			uvBlock.Add (lbltitle);
			float yuvc = 50;
			UIView uvcontrol;
			//mainrootview.RootData.Sort((x,y)=> x.ItemID.CompareTo(y.ItemID));
			Types.Sort((xx,yy)=> xx.Priority.CompareTo(yy.Priority));
			for (int i = 0; i < Types.Count; i++) {

				List<iProPQRSPortableLib.Option> masterMainList = new List<iProPQRSPortableLib.Option>();
				List<iProPQRSPortableLib.Option> masterSubCatList = new List<iProPQRSPortableLib.Option>();


				if (!string.IsNullOrEmpty (Types [i].Label)) {
					uvcontrol = new UIView (new CoreGraphics.CGRect (0, yuvc, 992, 85));				        
					UILabel lblname = new UILabel (new CoreGraphics.CGRect (20, 8, 480, 41));
					lblname.Lines = 3;
					lblname.Text = Types [i].Label;
					string selectedtext = string.Empty;
					string selectedid = string.Empty;
					string selectedsubitemtext = string.Empty;
					string Attriblabel = string.Empty;
					int AttribTypeID=0;

					if (iProPQRSPortableLib.Consts.SelectedProcAttribtslist != null) {						
						var selecteditem = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.Where (u => u.ProcAttribTypeID == Types [i].ProcAttribTypeID ).SingleOrDefault ();
						if (selecteditem != null) {
							AttribTypeID = selecteditem.ProcAttribTypeID;
							Attriblabel = selecteditem.Value;
							string[] arrytxt;
							//var ditem = DropdownOption.Where (u => u.Value == selecteditem.Value && u.ProcAttribTypeID == selecteditem.ProcAttribTypeID).ToList ();
							arrytxt = DropdownOption.Where (u => u.Value == selecteditem.Value && u.ProcAttribTypeID == selecteditem.ProcAttribTypeID).Select (s => s.Description).ToArray ();
							if (arrytxt != null && arrytxt.Length > 0) {
								selectedtext = arrytxt [0];
							}
						}
					}
					int mlpopid = 0;
					int TypeItemID;
					string TypeValue;
					if (Types [i].ProcAttribTypeID == 606) {
						string str = "";
					}
					if (Types [i].ProcAttribTypeID == 605) {
						masterMainList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 686);
						masterSubCatList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 605);
						mlpopid = 686;
						if (masterMainList.Count > 1) {
							TypeItemID=masterMainList[1].ProcAttribTypeID;
							TypeValue=masterMainList[1].Value; 
						}


					} else if (Types [i].ProcAttribTypeID == 607) {
						mlpopid = 685;
						masterMainList = ASA8MasterList;
						masterSubCatList = ASA8SubMasterList;
						if (masterMainList.Count > 1) {
							TypeItemID=masterMainList[1].ProcAttribTypeID;
							TypeValue=masterMainList[1].Value; 
						}

					}
					else if (Types [i].ProcAttribTypeID == 656) {
						mlpopid = 687;
						masterMainList = ASA9MasterList;
						masterSubCatList = ASA9SubMasterList;
						if (masterMainList.Count > 1) {
							TypeItemID=masterMainList[0].ProcAttribTypeID;
							TypeValue=masterMainList[0].Value; 
						}

					}
					else {
						mlpopid = Types [i].ProcAttribTypeID ;
						masterMainList = DropdownOption.FindAll (u => u.ProcAttribTypeID == Types [i].ProcAttribTypeID);
					}
					if (Types [i].ProcAttribTypeID == 605 || Types [i].ProcAttribTypeID == 607 || Types [i].ProcAttribTypeID == 656) {
						//&& Attriblabel=="0582F"
						string str=mlpopid.ToString();
						if (iProPQRSPortableLib.Consts.SelectedProcAttribtslist != null) {
							var	selectedMainListIDs = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (masterMainList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							if (selectedMainListIDs.Count > 0) {
								string[] arrytxt;
								arrytxt = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Where (u => u.Value == selectedMainListIDs [0].Value && u.ProcAttribTypeID == selectedMainListIDs [0].ProcAttribTypeID).Select (s => s.Description).ToArray ();
								if (arrytxt.Length > 0)
									selectedtext = arrytxt [0];
							}
							var selectedSubCatListIDs = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (masterSubCatList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							if (selectedSubCatListIDs.Count > 0) {
								selectedsubitemtext = selectedsubitemtext + "(";
								foreach (var SIT in selectedSubCatListIDs) {
									string[] arrytxt;
									arrytxt = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Where (u => u.Value == SIT.Value && u.ProcAttribTypeID == SIT.ProcAttribTypeID).Select (s => s.Description).ToArray ();
									if (arrytxt.Length > 0)
										selectedsubitemtext = selectedsubitemtext + arrytxt [0] + ",";
								}
								selectedsubitemtext = selectedsubitemtext.TrimEnd (',') + " )";
								//0582F  "0582F"
								if (selectedMainListIDs.Count > 0 && selectedMainListIDs [0].Value == TypeValue)
									selectedtext = selectedtext + selectedsubitemtext;
							}
						}
					}
					if (Types [i].ProcAttribTypeID == 606) {
						string lbltext = string.Empty;
						if (iProPQRSPortableLib.Consts.SelectedProcAttribtslist != null) {
							var	ASA7MasterList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 606);
							var ASA7N1MasterList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 683);
							var ASA7N2MasterList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 684);

							var selectedMasterASA7OptionsIds = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (ASA7MasterList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							var selectedMasterASA7N1OptionsIds = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (ASA7N1MasterList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							var selectedMasterASA7N2OptionsIds = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (ASA7N2MasterList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							foreach (var item in selectedMasterASA7N1OptionsIds) {
								Option opitem = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Find (u => u.ProcAttribTypeID == item.ProcAttribTypeID && u.Value == item.Value);
								if (opitem != null) {
									lbltext = lbltext + opitem.Description + ", ";
								}
							}
							foreach (var item in selectedMasterASA7N2OptionsIds) {
								Option opitem = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Find (u => u.ProcAttribTypeID == item.ProcAttribTypeID && u.Value == item.Value);
								if (opitem != null) {
									lbltext = lbltext + opitem.Description + ", ";
								}
							}
							foreach (var item in selectedMasterASA7OptionsIds) {
								Option opitem = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Find (u => u.ProcAttribTypeID == item.ProcAttribTypeID && u.Value == item.Value);
								if (opitem != null) {
									lbltext = lbltext + opitem.Description + ",";
								}
							}
							selectedtext = lbltext;
						}
					}

					if (Types [i].ProcAttribTypeID == 607) {
						string lbltext = string.Empty;
						if (iProPQRSPortableLib.Consts.SelectedProcAttribtslist != null) {
							var	ASA8MasterList1 = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 685);
							var ASA8MasterList2 = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 1001);
							var ASA8SubList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 607);

							var selectedASA8MasterList1OptionsIds = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (ASA8MasterList1.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							var selectedASA8MasterList2OptionsIds = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (ASA8MasterList2.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							var selectedMasterSubListOptionsIds = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (ASA8SubList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
							foreach (var item in selectedASA8MasterList1OptionsIds) {
								Option opitem = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Find (u => u.ProcAttribTypeID == item.ProcAttribTypeID && u.Value == item.Value);
								if (opitem != null) {
									lbltext = lbltext + opitem.Description + ", ";
								}
							}
							foreach (var item in selectedASA8MasterList2OptionsIds) {
								Option opitem = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Find (u => u.ProcAttribTypeID == item.ProcAttribTypeID && u.Value == item.Value);
								if (opitem != null) {
									lbltext = lbltext + opitem.Description + ", ";
								}
							}
							foreach (var item in selectedMasterSubListOptionsIds) {
								Option opitem = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Find (u => u.ProcAttribTypeID == item.ProcAttribTypeID && u.Value == item.Value);
								if (opitem != null) {
									lbltext = lbltext + opitem.Description + ",";
								}
							}
							selectedtext = lbltext;
						}
					}

					//if (masterMainList.Count > 0)
					//	mlpopid = Types [i].ProcAttribTypeID;//masterMainList [0].ProcAttribTypeID;
					int tempAttribTypeID = Types [i].ProcAttribTypeID;

					UILabel lblDesc = new UILabel ();
					lblDesc.Lines = 3;
					if (AttribTypeID == 608) {
						if (selectedtext.Contains ("NO Serious adverse event"))
							lblDesc.Text = selectedtext;
						else {
							string finaltext = string.Empty;
							foreach (var sitem in selectednonPqrsTypeAS10OptionsIds) {
								//nonPqrsTypeAS10Options
								var itemtype = nonPqrsTypeAS10Options.Where (u => u.ProcAttribTypeID == sitem).ToList ();
								if (itemtype.Count > 0)
									finaltext = finaltext + itemtype [0].Label + ",";
							}
							if (!string.IsNullOrEmpty (finaltext))
								lblDesc.Text = selectedtext + " ( " + finaltext.TrimEnd (',') + " )";
							else
								lblDesc.Text = selectedtext;
						}
					}
					else
						lblDesc.Text = selectedtext;

					int descwidth = 40;
					lblDesc.Lines = 1;
					if (lblDesc.Text != null) {
						int textcount = lblDesc.Text.Length;
						if (textcount < 58) {
							descwidth = 40;
							lblDesc.Lines = 1;
						} else if (textcount > 58 && textcount <= 114) {
							descwidth = 55;
							lblDesc.Lines = 2;
						} else if (textcount > 114) {
							descwidth = 75;
							lblDesc.Lines = 3;
						}
					}

					lblDesc.Frame = new CoreGraphics.CGRect (500, 8, 480, descwidth);
					if (mlpopid == 608 || mlpopid==624 || mlpopid==606 || mlpopid==615 ) {
						uvcontrol.Frame = new CoreGraphics.CGRect (0, yuvc, 992, 100);
						//lblDesc.Frame = new CoreGraphics.CGRect (500, 0, 480, descwidth);
						yuvc = yuvc + 15;
					}
					lblDesc.Layer.BorderColor = UIColor.Gray.CGColor;
					lblDesc.Layer.BorderWidth = (nfloat)0.5;
					lblDesc.Layer.CornerRadius = (nfloat)8.0; 
					UILabel lblhidenmaincatval = new UILabel ();
					lblhidenmaincatval.Hidden = true;
					lblhidenmaincatval.Text = Attriblabel;
					lblhidenmaincatval.Tag = AttribTypeID;

					UILabel lblhidensubcatval = new UILabel ();
					lblhidensubcatval.Hidden = true;
					UITapGestureRecognizer lblDescTap = new UITapGestureRecognizer( async()  => {
						List<Tuple<string, string>>  selectedrootitem=new List<Tuple<string, string>>();
						if(lblhidenmaincatval.Tag != 0)
							selectedrootitem.Add(new Tuple<string,string>(lblhidenmaincatval.Tag.ToString(),lblhidenmaincatval.Text));//,);
						//string name=Types [i].Label;

						if(mlpopid== 608)
						{
							QualityMetricsASA10 qmasafrm=new QualityMetricsASA10(lblDesc);
							qmasafrm.masterMainList=masterMainList;
							qmasafrm.masterSubCatList=nonPqrsTypeAS10Options;
							if(procedureDetails != null && procedureDetails.ID != 0)
								qmasafrm.ProcID=procedureDetails.ID ;

							qmasafrm.PresentFromPopover(lblDesc, (float)lblDesc.Frame.X, (float)lblDesc.Frame.Y);

							//if(masterMainList.Count>0)
							//	BindmultilevelPopupover(masterMainList,selectedrootitem,selectednonPqrsTypeAS10OptionsIds,lblDesc,(int)lblDesc.Frame.Y,lblhidenmaincatval,true);
						}
						else if(mlpopid== 686 || mlpopid== 685 || mlpopid== 687)
						{ //605=686
							QualityMetricsASA qmasafrm=new QualityMetricsASA(lblDesc);
							qmasafrm.masterMainList=masterMainList;
							qmasafrm.masterSubCatList=masterSubCatList;
							qmasafrm._ValueChanged += delegate {
								if (lblDesc.Text.Trim () != string.Empty){
									foreach (QMValidation item in IsRequiredlabels) {
										if(item.proctAttribTypeID == 606){
											item.lbldesc.Layer.BorderColor = UIColor.Gray.CGColor;
											item.lbldesc.Layer.BorderWidth = 1;
										}
									}
									QMValidation itemToRemove = this.IsRequiredlabels.Find(x => x.proctAttribTypeID == 606 && x.lblname.Trim().ToLower() == "non pqrs");
									asa7ItemRemovedPrev = itemToRemove;
									this.IsRequiredlabels.Remove (itemToRemove);
								}else{
									if(asa7ItemRemovedPrev != null){
										QMValidation searchItem = IsRequiredlabels.Find(x => x.proctAttribTypeID == asa7ItemRemovedPrev.proctAttribTypeID);
										if(searchItem == null){
											IsRequiredlabels.Add(asa7ItemRemovedPrev);
											foreach (QMValidation item in IsRequiredlabels) {
												if(item.proctAttribTypeID == 606){
													item.lbldesc.Layer.BorderColor = UIColor.Red.CGColor;
													item.lbldesc.Layer.BorderWidth = 1;
												}
											}
										}
									}else{
										QMValidation searchItem = IsRequiredlabels.Find(x => x.proctAttribTypeID == 606);
										if(searchItem == null){
											IsRequiredlabels.Add(asa8ItemRemovedPrev);
											foreach (QMValidation item in IsRequiredlabels) {
												if(item.proctAttribTypeID == 606){
													item.lbldesc.Layer.BorderColor = UIColor.Red.CGColor;
													item.lbldesc.Layer.BorderWidth = 1;
												}
											}
										}
									}

								}
							};
							if(procedureDetails != null && procedureDetails.ID != 0)
								qmasafrm.ProcID=procedureDetails.ID ;

							qmasafrm.PresentFromPopover(lblDesc, (float)lblDesc.Frame.X, (float)lblDesc.Frame.Y);

							//if(masterMainList.Count>0)
							//	BindmultilevelPopupover(masterMainList,masterSubCatList,lblDesc,(int)lblDesc.Frame.Y,lblhidenmaincatval,lblhidensubcatval,false,TypeItemID,TypeValue);
						}else if(mlpopid == 606){
							QualityMetricsForm qmFrm = new QualityMetricsForm(lblDesc);
							qmFrm._ValueChanged += delegate {
								if (lblDesc.Text.Trim () != string.Empty) {
									foreach (QMValidation item in IsRequiredlabels) {
										if(item.proctAttribTypeID == 607){
											item.lbldesc.Layer.BorderColor = UIColor.Gray.CGColor;
											item.lbldesc.Layer.BorderWidth = 1;
										}
									}
									QMValidation itemToRemove = this.IsRequiredlabels.Find(x => x.proctAttribTypeID == 607 && x.lblname.Trim().ToLower() == "non pqrs");
									asa8ItemRemovedPrev = itemToRemove;
									this.IsRequiredlabels.Remove (itemToRemove);
								}else{
									if(asa8ItemRemovedPrev != null){
										QMValidation searchItem = IsRequiredlabels.Find(x => x.proctAttribTypeID == asa8ItemRemovedPrev.proctAttribTypeID);
										if(searchItem == null){
											IsRequiredlabels.Add(asa8ItemRemovedPrev);
											foreach (QMValidation item in IsRequiredlabels) {
												if(item.proctAttribTypeID == 607){
													item.lbldesc.Layer.BorderColor = UIColor.Red.CGColor;
													item.lbldesc.Layer.BorderWidth = 1;
												}
											}
										}
									}else{
										QMValidation searchItem = IsRequiredlabels.Find(x => x.proctAttribTypeID == 607);
										if(searchItem == null){
											IsRequiredlabels.Add(asa8ItemRemovedPrev);
											foreach (QMValidation item in IsRequiredlabels) {
												if(item.proctAttribTypeID == 607){
													item.lbldesc.Layer.BorderColor = UIColor.Red.CGColor;
													item.lbldesc.Layer.BorderWidth = 1;
												}
											}
										}
									}
								}
							};

							if(procedureDetails != null && procedureDetails.ID != 0)
								qmFrm.ProcID=procedureDetails.ID ;
							qmFrm.PresentFromPopover(lblDesc, (float)lblDesc.Frame.X, (float)lblDesc.Frame.Y);
						}else{
							if(masterMainList.Count>0)
								qmBindPopupover(masterMainList,lblDesc,(int)lblDesc.Frame.Y,tempAttribTypeID);
						}
						int ProcID=0;
						if(procedureDetails != null && procedureDetails.ID != 0)
							ProcID = procedureDetails.ID;
						iProPQRSPortableLib.Consts.SelectedProcAttribtslist  = await AppDelegate.Current.pqrsMgr.GetAllAttribTypesOfAProcedure(ProcID);

						//IsRequiredlabels


						

					});
					lblDesc.UserInteractionEnabled = true;
					lblDesc.AddGestureRecognizer(lblDescTap);


					//UIButton btncontrol = new UIButton (new CoreGraphics.CGRect (550, 8, 319, 30));
					//if(!string.IsNullOrEmpty(selectedtext))
					//	btncontrol.SetTitle (selectedtext, UIControlState.Normal);
					//btncontrol.SetBackgroundImage (UIImage.FromFile (@"textBoxDropDown.png"), UIControlState.Normal);
					//btncontrol.SetTitleColor (UIColor.Black, UIControlState.Normal);

					//btncontrol.TouchUpInside += async (object sender, EventArgs e) => {
					//	List<string>  selectedi=new List<string>{"selected"};
					//string name=Types [i].Label;
					//	if(AttribTypeID== 608)
					//{
					//if(Dropdownlist.Count>0)
					//BindmultilevelPopupover(Dropdownlist,selectedi,btncontrol,(int)btncontrol.Frame.Y,"name");
					//}
					//else
					//{
					//if(Dropdownlist.Count>0)
					//	BindPopupover(Dropdownlist,selectedi,btncontrol,(int)btncontrol.Frame.Y,"name");
					//}
					//};
					//btncontrol.SetTitle (" btn Name " + i, UIControlState.Normal);

					if (Types [i].IsRequired) {
//						lblDesc.Layer.BorderColor = UIColor.FromRGB (255, 102, 102).CGColor;
						lblDesc.Layer.BorderColor = UIColor.Red.CGColor;
						lblDesc.Layer.BorderWidth = 1;
						QMValidation v=new QMValidation();
						v.lbldesc = lblDesc;
						v.lblname = HeaderTitle;
						v.proctAttribTypeID = Types [i].ProcAttribTypeID;
						IsRequiredlabels.Add(v);
					}

					uvcontrol.Add (lblname);
					if (Types [i].IsRequired) {
						CoreGraphics.CGRect frm = lblname.Frame;
						frm.Width= lblname.IntrinsicContentSize.Width;
						lblname.Frame = frm;
						UILabel lblstar = new UILabel (new CoreGraphics.CGRect (lblname.IntrinsicContentSize.Width+20, 8, 10, 41));
						lblstar.Text = "*";
						lblstar.TextColor = UIColor.Red;
						uvcontrol.Add (lblstar);
					}
					uvcontrol.Add (lblname);
					uvcontrol.Add (lblDesc);	

					qmDisablelbl.Add (lblDesc);
					uvcontrol.Add (lblhidenmaincatval);
					uvcontrol.Add (lblhidensubcatval);
					yuvc = yuvc + 65;
					uvBlock.Add (uvcontrol);
					uvcontrol = null;
				}
			}
			uvBlock.Frame = new CoreGraphics.CGRect (0, 0, 992, yuvc + 45);
			uvBlock.Layer.BorderColor = UIColor.Gray.CGColor;
			uvBlock.Layer.BorderWidth = 1;
			//new CoreGraphics.CGRect(xUV,0,992,hUV
			hUV = yuvc + 45;
			finalView.Frame = new CoreGraphics.CGRect (0,yUV,992, hUV);
			finalView.BackgroundColor = UIColor.White;
			yUV = yUV+hUV+5;
			finalView.Add (uvBlock);
			svQualityMetrics.Add(finalView);

			QMValidation asa7Item = IsRequiredlabels.Find(x => x.proctAttribTypeID == 606);
			QMValidation asa8Item = IsRequiredlabels.Find(x => x.proctAttribTypeID == 607);
			QMValidation asa7ItemToRemove = new QMValidation();
			QMValidation asa8ItemToRemove = new QMValidation();
			foreach (QMValidation item in IsRequiredlabels) {
				if (item.proctAttribTypeID != 0 && item.proctAttribTypeID == 606) {
					if (asa8Item != null) {
						if (asa8Item.lbldesc.Text.Trim () != string.Empty) {
							item.lbldesc.Layer.BorderColor = UIColor.Gray.CGColor;
							item.lbldesc.Layer.BorderWidth = 1;
							asa7ItemToRemove = item;
						}
					}
				}
				if (item.proctAttribTypeID != 0 && item.proctAttribTypeID == 607) {
					if (asa7Item != null) {
						if (asa7Item.lbldesc.Text.Trim () != string.Empty) {
							item.lbldesc.Layer.BorderColor = UIColor.Gray.CGColor;
							item.lbldesc.Layer.BorderWidth = 1;
							asa8ItemToRemove = item;
						}
					}
				}
			}
			if (asa7ItemToRemove.lblname != string.Empty) {
				asa7ItemRemovedPrev = asa7ItemToRemove;
				QMValidation itemToRemove = this.IsRequiredlabels.Find(x => x.proctAttribTypeID == asa7ItemRemovedPrev.proctAttribTypeID && x.lblname.Trim().ToLower() == asa7ItemRemovedPrev.lblname.Trim().ToLower());
				if(itemToRemove != null && itemToRemove.proctAttribTypeID != 0)
					IsRequiredlabels.Remove (itemToRemove);
			}

			if (asa8ItemToRemove.lblname != string.Empty) {
				asa8ItemRemovedPrev = asa8ItemToRemove;
				QMValidation itemToRemove = this.IsRequiredlabels.Find(x => x.proctAttribTypeID == asa8ItemRemovedPrev.proctAttribTypeID && x.lblname.Trim().ToLower() == asa8ItemRemovedPrev.lblname.Trim().ToLower());
				if(itemToRemove != null && itemToRemove.proctAttribTypeID != 0)
					IsRequiredlabels.Remove (itemToRemove);
			}

		}
		public void ViewQualityMetrics(List<iProPQRSPortableLib.Type> Types,List<iProPQRSPortableLib.Option> DropdownOption, string HeaderTitle)
		{
			float hUVB=200;
			UIView finalView=new UIView();
			UIView uvBlock = new UIView ();
			UIImageView titleimg = new UIImageView (new CoreGraphics.CGRect (0, 0, 992, 40));
			titleimg.Image=UIImage.FromFile(@"headerBarTall.png");
			UILabel lbltitle = new UILabel (new CoreGraphics.CGRect (8, 8, 140, 21));
			lbltitle.Text = HeaderTitle;
			uvBlock.Add (titleimg);
			uvBlock.Add (lbltitle);
			float yuvc = 50;

			UIView uvcontrol;
			//mainrootview.RootData.Sort((x,y)=> x.ItemID.CompareTo(y.ItemID));
			Types.Sort((xx,yy)=> xx.ProcAttribTypeID.CompareTo(yy.ProcAttribTypeID));
			for (int i = 0; i < Types.Count; i++) {

				List<iProPQRSPortableLib.Option> masterMainList = new List<iProPQRSPortableLib.Option>();
				List<iProPQRSPortableLib.Option> masterSubCatList = new List<iProPQRSPortableLib.Option>();


				if (!string.IsNullOrEmpty (Types [i].Label)) {
					uvcontrol = new UIView (new CoreGraphics.CGRect (0, yuvc, 992, 45));				        
					UILabel lblname = new UILabel (new CoreGraphics.CGRect (20, 8, 500, 21));
					lblname.Text = Types [i].Label;
					string selectedtext = string.Empty;
					string selectedid = string.Empty;
					string selectedsubitemtext = string.Empty;
					string Attriblabel = string.Empty;
					int AttribTypeID=0;

					if (iProPQRSPortableLib.Consts.SelectedProcAttribtslist != null) {						
						var selecteditem = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.Where (u => u.ProcAttribTypeID == Types [i].ProcAttribTypeID ).SingleOrDefault ();
						if (selecteditem != null) {
							AttribTypeID = selecteditem.ProcAttribTypeID;
							Attriblabel = selecteditem.Value;
							string[] arrytxt;
							//var ditem = DropdownOption.Where (u => u.Value == selecteditem.Value && u.ProcAttribTypeID == selecteditem.ProcAttribTypeID).ToList ();
							arrytxt = DropdownOption.Where (u => u.Value == selecteditem.Value && u.ProcAttribTypeID == selecteditem.ProcAttribTypeID).Select (s => s.Description).ToArray ();
							if (arrytxt != null && arrytxt.Length > 0) {
								selectedtext = arrytxt [0];

							}
						}

					}
					int mlpopid = 0;
					int TypeItemID;
					string TypeValue;
					if (Types [i].ProcAttribTypeID == 605) {
						masterMainList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 686);
						masterSubCatList = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.FindAll (x => x.ProcAttribTypeID == 605);
						mlpopid = 686;
						if (masterMainList.Count > 1) {
							TypeItemID=masterMainList[1].ProcAttribTypeID;
							TypeValue=masterMainList[1].Value; 
						}


					} else if (Types [i].ProcAttribTypeID == 607) {
						mlpopid = 685;
						masterMainList = ASA8MasterList;
						masterSubCatList = ASA8SubMasterList;
						if (masterMainList.Count > 1) {
							TypeItemID=masterMainList[1].ProcAttribTypeID;
							TypeValue=masterMainList[1].Value; 
						}

					}
					else if (Types [i].ProcAttribTypeID == 656) {
						mlpopid = 687;
						masterMainList = ASA9MasterList;
						masterSubCatList = ASA9SubMasterList;
						if (masterMainList.Count > 1) {
							TypeItemID=masterMainList[1].ProcAttribTypeID;
							TypeValue=masterMainList[1].Value; 
						}

					}
					else {
						mlpopid = Types [i].ProcAttribTypeID ;
						masterMainList = DropdownOption.FindAll (u => u.ProcAttribTypeID == Types [i].ProcAttribTypeID);
					}
					if (Types [i].ProcAttribTypeID == 605 || Types [i].ProcAttribTypeID == 607 || Types [i].ProcAttribTypeID == 656) {
						//&& Attriblabel=="0582F"
						string str=mlpopid.ToString();
						var	selectedMainListIDs = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll (u => (masterMainList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList ();
						if (selectedMainListIDs.Count > 0)
						{   string[] arrytxt;
							arrytxt = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Where (u => u.Value == selectedMainListIDs[0].Value && u.ProcAttribTypeID == selectedMainListIDs[0].ProcAttribTypeID).Select (s => s.Description).ToArray ();
							if(arrytxt.Length > 0)
							  selectedtext = arrytxt[0];
						}
						var selectedSubCatListIDs = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.FindAll(u => (masterSubCatList.Select (z => z.ProcAttribTypeID)).Contains (u.ProcAttribTypeID)).ToList();
						if (selectedSubCatListIDs.Count > 0) {
							selectedsubitemtext = selectedsubitemtext + "(";
							foreach (var SIT in selectedSubCatListIDs) {
								string[] arrytxt;
								arrytxt = iProPQRSPortableLib.Consts.ProcAttribTypes.result.Options.Where (u => u.Value == SIT.Value && u.ProcAttribTypeID == SIT.ProcAttribTypeID).Select (s => s.Description).ToArray ();
								if(arrytxt.Length > 0)
								  selectedsubitemtext = selectedsubitemtext + arrytxt [0] + ",";
							}
							selectedsubitemtext=selectedsubitemtext.TrimEnd (',') + " )";
							//0582F  "0582F"
							if (selectedMainListIDs.Count > 0 && selectedMainListIDs[0].Value == TypeValue)
							    selectedtext = selectedtext + selectedsubitemtext;
						}
					}

				
					//if (masterMainList.Count > 0)
					//	mlpopid = Types [i].ProcAttribTypeID;//masterMainList [0].ProcAttribTypeID;
					//int AttribTypeID = Types [i].ProcAttribTypeID;
					UILabel lblDesc = new UILabel (new CoreGraphics.CGRect (500, 8, 480, 35));
					if (AttribTypeID == 608) {
						if (selectedtext.Contains ("NO Serious adverse event"))
							lblDesc.Text = selectedtext;
						else {
							string finaltext = "( ";
							foreach (var sitem in selectednonPqrsTypeAS10OptionsIds) {
								//nonPqrsTypeAS10Options
								var itemtype = nonPqrsTypeAS10Options.Where (u => u.ProcAttribTypeID == sitem).ToList ();
								if (itemtype.Count > 0)
									finaltext = finaltext + itemtype [0].Label + ",";
							}
							lblDesc.Text = selectedtext + finaltext.TrimEnd (',') + " )";
						}
					}
					else
						lblDesc.Text = selectedtext;
					
					lblDesc.Layer.BorderColor = UIColor.Gray.CGColor;
					lblDesc.Layer.BorderWidth = (nfloat)0.5;
					lblDesc.Layer.CornerRadius = (nfloat)8.0; 
					UILabel lblhidenmaincatval = new UILabel ();
					lblhidenmaincatval.Hidden = true;
					lblhidenmaincatval.Text = Attriblabel;
					lblhidenmaincatval.Tag = AttribTypeID;

					UILabel lblhidensubcatval = new UILabel ();
					lblhidensubcatval.Hidden = true;
					UITapGestureRecognizer lblDescTap = new UITapGestureRecognizer( async()  => {
						List<Tuple<string, string>>  selectedrootitem=new List<Tuple<string, string>>();
						if(lblhidenmaincatval.Tag != 0)
							selectedrootitem.Add(new Tuple<string,string>(lblhidenmaincatval.Tag.ToString(),lblhidenmaincatval.Text));//,);
						//string name=Types [i].Label;
					
						if(mlpopid== 608)
						{

							if(masterMainList.Count>0)
								BindmultilevelPopupover(masterMainList,selectedrootitem,selectednonPqrsTypeAS10OptionsIds,lblDesc,(int)lblDesc.Frame.Y,lblhidenmaincatval,true);
						}
						else if(mlpopid== 686 || mlpopid== 685 || mlpopid== 687)
						{ //605=686
							QualityMetricsASA qmasafrm=new QualityMetricsASA(lblDesc);
							qmasafrm.masterMainList=masterMainList;
							qmasafrm.masterSubCatList=masterSubCatList;
							if(procedureDetails != null && procedureDetails.ID != 0)
								qmasafrm.ProcID=procedureDetails.ID ;
							
							qmasafrm.PresentFromPopover(lblDesc, (float)lblDesc.Frame.X, (float)lblDesc.Frame.Y);

							//if(masterMainList.Count>0)
							//	BindmultilevelPopupover(masterMainList,masterSubCatList,lblDesc,(int)lblDesc.Frame.Y,lblhidenmaincatval,lblhidensubcatval,false,TypeItemID,TypeValue);
						}else if(mlpopid == 606){
							QualityMetricsForm qmFrm = new QualityMetricsForm();
							if(procedureDetails != null && procedureDetails.ID != 0)
								qmFrm.ProcID=procedureDetails.ID ;
							qmFrm.PresentFromPopover(lblDesc, (float)lblDesc.Frame.X, (float)lblDesc.Frame.Y);
						}else{
							if(masterMainList.Count>0)
								BindPopupover(masterMainList,selectedrootitem,lblDesc,(int)lblDesc.Frame.Y,lblhidenmaincatval);
						}
						int ProcID=0;
						if(procedureDetails != null && procedureDetails.ID != 0)
							ProcID = procedureDetails.ID;
						iProPQRSPortableLib.Consts.SelectedProcAttribtslist  = await AppDelegate.Current.pqrsMgr.GetAllAttribTypesOfAProcedure(ProcID);
					});
					lblDesc.UserInteractionEnabled = true;
					lblDesc.AddGestureRecognizer(lblDescTap);


									//UIButton btncontrol = new UIButton (new CoreGraphics.CGRect (550, 8, 319, 30));
									//if(!string.IsNullOrEmpty(selectedtext))
									//	btncontrol.SetTitle (selectedtext, UIControlState.Normal);
									//btncontrol.SetBackgroundImage (UIImage.FromFile (@"textBoxDropDown.png"), UIControlState.Normal);
									//btncontrol.SetTitleColor (UIColor.Black, UIControlState.Normal);

									//btncontrol.TouchUpInside += async (object sender, EventArgs e) => {
									//	List<string>  selectedi=new List<string>{"selected"};
										//string name=Types [i].Label;
									//	if(AttribTypeID== 608)
										//{
											//if(Dropdownlist.Count>0)
												//BindmultilevelPopupover(Dropdownlist,selectedi,btncontrol,(int)btncontrol.Frame.Y,"name");
										//}
										//else
										//{
										//if(Dropdownlist.Count>0)
										//	BindPopupover(Dropdownlist,selectedi,btncontrol,(int)btncontrol.Frame.Y,"name");
										//}
									//};
									//btncontrol.SetTitle (" btn Name " + i, UIControlState.Normal);


					uvcontrol.Add (lblname);
					uvcontrol.Add (lblDesc);	
					uvcontrol.Add (lblhidenmaincatval);
					uvcontrol.Add (lblhidensubcatval);
					yuvc = yuvc + 45;
					uvBlock.Add (uvcontrol);
					uvcontrol = null;
				}
			}
			uvBlock.Frame = new CoreGraphics.CGRect (0, 0, 992, yuvc + 45);
			uvBlock.Layer.BorderColor = UIColor.Gray.CGColor;
			uvBlock.Layer.BorderWidth = 1;
			//new CoreGraphics.CGRect(xUV,0,992,hUV
			hUV = yuvc + 45;
			finalView.Frame = new CoreGraphics.CGRect (0,yUV,992, hUV);
			finalView.BackgroundColor = UIColor.White;
			yUV = yUV+hUV+5;
			finalView.Add (uvBlock);
			svQualityMetrics.Add(finalView);
		}