public List<CodePickerModel> SetDataSource(out int uvWidth,ProcedureDiagnosticMaster procDiagObj)
		{
			uvWidth=280;
			int pcharcount = 0;
			CodePickerModel item;
			int cnt = 1;
			List<CodePickerModel> dlist = new List<CodePickerModel> ();
			foreach (DataResults procItem in procDiagObj.results) {
				item = new CodePickerModel ();
				item.ItemID = procItem.ProcCodeID;
				item.ItemText = procItem.Name;
				item.ItemCode = procItem.Code;
				dlist.Add (item);
				if (pcharcount < item.ItemText.Length) {
					pcharcount = item.ItemText.Length;
					uvWidth = MeasureTextSize (item.ItemText);
				}
				item = null;
				cnt++;
			}
			return dlist;
		}
		public void SaveJsonToFile(DataResults selectedObj,string fileName)
		{
			string json = string.Empty;

			string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			string filePath = Path.Combine(path, fileName);

			List<DataResults> lstOfSelectedProcs = new List<DataResults>();
			lstOfSelectedProcs.Add(selectedObj);

			if (!File.Exists (filePath)) {
				ProcedureDiagnosticMaster lastSelectProcs = new ProcedureDiagnosticMaster ();
				lastSelectProcs.results = lstOfSelectedProcs;
				json = JsonConvert.SerializeObject (lastSelectProcs);
			} else {
				string lastContents = ReadFile (filePath);
				File.Delete (filePath);
				ProcedureDiagnosticMaster lastSelectedProceduresObj = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject(lastContents,typeof(ProcedureDiagnosticMaster));
				lastSelectedProceduresObj.results.Add (selectedObj);
				json = JsonConvert.SerializeObject (lastSelectedProceduresObj);
			}


			using (var file = File.Open(filePath, FileMode.Append, FileAccess.Write))
			using (var strm = new StreamWriter(file))
			{
				strm.Write(json);

			}
		}
Exemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            View.Layer.Frame = new CoreGraphics.CGRect (0, 0, uvWidth, uvheight);
            NavBar=new UINavigationBar(new CoreGraphics.CGRect (0, 0, uvWidth, 44));
            utListView = new UITableView (new CoreGraphics.CGRect (0, 44, uvWidth, uvheight));
            //			UIBarButtonItem TrashBtn = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, TrashBtnClicked);

            UIButton btnCancel = new UIButton (new CGRect (0, 0, 80, 30));
            btnCancel.SetTitleColor (UIColor.Blue, UIControlState.Normal);
            btnCancel.SetTitle ("Cancel", UIControlState.Normal);
            btnCancel.TouchUpInside += (object sender, EventArgs e) => {
                if(popover!=null)
                    popover.Dismiss(false);
            };
            UIBarButtonItem TrashBtn = new UIBarButtonItem (btnCancel);

            UINavigationItem navgitem = new UINavigationItem ("Select");
            navgitem.SetLeftBarButtonItem (TrashBtn, true);
            NavBar.PushNavigationItem(navgitem,true);
            searchBar=new UISearchBar(new CoreGraphics.CGRect (100, 0, uvWidth-100, 44));
            this.View.Add (NavBar);
            this.View.AddSubview(utListView);
            this.View.AddSubview(searchBar);
            this.utListView.Source =new CodePickerSource(this);
            searchBar.BecomeFirstResponder ();
            searchBar.Text = searchkey;
            searchBar.TextChanged+= async (object sender, UISearchBarTextChangedEventArgs e) => {
                if(!string.IsNullOrEmpty(searchBar.Text))
                {
                    AppDelegate.pb.Start(this.View,"Searching...");
                    var webClient = new WebClient();
                    string url =  "http://reference.iprocedures.com/"+type+"/"+searchBar.Text.Trim()+"/20";
                    string procData = webClient.DownloadString (url);
                    procedureItems = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject (procData, typeof(ProcedureDiagnosticMaster));
                    int uwidth = 0;
                    DataSource = SetProcedureDataSource(out uwidth);
                    this.utListView.Source =new CodePickerSource(this);
                    this.utListView.ReloadData();
                    AppDelegate.pb.Stop();
                }

                    //RectangleF fillrect = new RectangleF(0,0,uwidth,uvheight);
                    //this.View.Frame=fillrect;

            };

            // Perform any additional setup after loading the view, typically from a nib.
        }
		public async void DownloadData(string type,string searchParam,UITextField codeField,UITextField descriptionField)
		{
			var webClient = new WebClient();
			string url =  "http://reference.iprocedures.com/"+type+"/"+searchParam.Trim()+"/40";
			string procData = webClient.DownloadString (url);
			procedureItems = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject (procData, typeof(ProcedureDiagnosticMaster));

			float x = (float)descriptionField.Frame.X;
			float y = (float)descriptionField.Frame.Y;
			int uvwidth = 0;
			List<CodePickerModel> list = SetProcedureDataSource (out uvwidth);
    		cp	= new CodePicker (this,uvwidth,searchParam.Trim(),type);

			if(searchParam.Trim().Length > 0)
				cp.PresentFromPopover (descriptionField, x, y,uvwidth);

			cp.DataSource = list;
			cp._ValueChanged += async delegate {
				DataResults selectedObj = new DataResults{Name = cp.SelectedText,Code=cp.SelectedCodeValue,ProcCodeID = cp.SelectedValue};
				string fileName = string.Empty;
				if(type == "CPT")
					fileName = "lastSelectedProcedures.txt";
				else
					fileName = "lastSelectedDiagnosis.txt";

				SaveJsonToFile(selectedObj,fileName);

				codeField.Text = cp.SelectedCodeValue;
				descriptionField.Text = cp.SelectedText;
				int ProcCodeType;
				if(type == "CPT")
					ProcCodeType = 1 ;
				else
				{
					selectedDiagnosisCodeid.Add(cp.SelectedValue);
					ProcCodeType = 2 ;
				}

				UpdateProcedureDiagnostic(cp.SelectedValue,cp.SelectedCodeValue,cp.SelectedText,ProcCodeType);
			};
		}
		public void AddProcedure(string code,string description)
		{
			CoreGraphics.CGRect descriptionFrame = new CoreGraphics.CGRect(14,baseYProcDescriptionValue,377,30);
			CoreGraphics.CGRect codeFrame = new CoreGraphics.CGRect(405,baseYProcCodeValue,70,30);

			UITextField codeText = new UITextField(codeFrame);
			UITextField descriptionText = new UITextField(descriptionFrame);
			codeText.Text=code;
			codeText.BorderStyle = UITextBorderStyle.RoundedRect;
			codeText.Tag = 2;
			codeText.EditingDidBegin += (object sender, EventArgs e) => {
				showKeyBoard = true;
			};

			codeText.EditingDidEnd += (object sender, EventArgs e) => {
				showKeyBoard = false;
			};

			descriptionText.BorderStyle = UITextBorderStyle.RoundedRect;
			descriptionText.Tag = 1;
			descriptionText.Text=description;
			descriptionText.EditingDidBegin += (object sender, EventArgs e) => {
				showKeyBoard = true;
			};

			descriptionText.EditingDidEnd += (object sender, EventArgs e) => {
				showKeyBoard = false;
			};

			descriptionText.EditingDidEnd += (senderDesc, e) => {


				bool itemPreviouslySearched = false;

				string lastSelectedProcedures = ReadFile("lastSelectedProcedures.txt");
				if(lastSelectedProcedures != string.Empty){
					lastSelectedProceduresObj = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject(lastSelectedProcedures,typeof(ProcedureDiagnosticMaster));
					foreach (DataResults item in lastSelectedProceduresObj.results) {
						if(item.Name != null){
							if(item.Name.ToLower().Contains(descriptionText.Text.Trim().ToLower())){
								itemPreviouslySearched = true;
								break;
							}
						}
					}
				}

				if(itemPreviouslySearched){
					int uvWidth=280;
					List<CodePickerModel> list=SetDataSource(out uvWidth,lastSelectedProceduresObj);
					float x = (float)descriptionText.Frame.X;
					float y = (float)descriptionText.Frame.Y;

					cp	=new CodePicker(this,uvWidth,descriptionText.Text,"CPT");
					cp.PresentFromPopover(descriptionText,x,y,uvWidth);
					cp.DataSource=list;
					cp._ValueChanged += delegate {		
						codeText.Text = cp.SelectedCodeValue;
						descriptionText.Text = cp.SelectedText;
					}; 
				}else{
					if(descriptionText.Text.Trim().Length > 0)
						DownloadData("CPT",descriptionText.Text,codeText,descriptionText);
				}

			};


			procedureScrollView.AddSubview(codeText);
			baseYProcCodeValue += 44;

			procedureScrollView.AddSubview(descriptionText);
			baseYProcDescriptionValue += 44;
		}
		public async void DownloadData(string type,string searchParam,UITextField codeField,UITextView descriptionField)
		{
			var webClient = new WebClient();
			string url =  "http://reference.iprocedures.com/"+type+"/"+searchParam.Trim()+"/40";
			string procData = webClient.DownloadString (url);
			procedureItems = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject (procData, typeof(ProcedureDiagnosticMaster));

			float x = (float)descriptionField.Frame.X;
			float y = (float)descriptionField.Frame.Y;
			int uvwidth = 0;
			List<CodePickerModel> list=SetProcedureDataSource (out uvwidth);
			cp	= new CodePicker (this,uvwidth,searchParam.Trim(),type);

			if(searchParam.Trim().Length > 0)
				cp.PresentFromPopover (descriptionField, x, y,uvwidth);

			cp.DataSource = list;
			cp._ValueChanged += async delegate {
				if(cp.SelectedText!=null)
				{
					DataResults selectedObj = new DataResults{Name = cp.SelectedText,Code=cp.SelectedCodeValue,ProcCodeID = cp.SelectedValue};
					string fileName = string.Empty;
					if(type == "CPT")
						fileName = "lastSelectedProcedures.txt";
					else
						fileName = "lastSelectedDiagnosis.txt";

					SaveJsonToFile(selectedObj,fileName);

					codeField.Text = cp.SelectedCodeValue;
					descriptionField.Text = cp.SelectedText;
					int ProcCodeType;
					if(type == "CPT")
						ProcCodeType = 1 ;
					else
					{
						selectedDiagnosisCodeid.Add(cp.SelectedValue);
						ProcCodeType = 2 ;
					}

					UpdateProcedureDiagnostic(cp.SelectedValue,cp.SelectedCodeValue,cp.SelectedText,ProcCodeType);

					int nl=MeasureTextLine(cp.SelectedText);
					nfloat th=30;
					if (nl == 280) {

						baseYDiagnosisDescriptionValue += 0;
						baseYDiagnosisCodeValue += 0;	
						nl=30;
					}
					else if(nl>600 && nl < 899){	
						if(ProcCodeType==2)
						{
							baseYProcDescriptionValue += 10;
							baseYProcCodeValue += 10;	
						}
						else
						{
							baseYDiagnosisDescriptionValue += 10;
							baseYDiagnosisCodeValue += 10;	
						}
						th=50;
					}
					else if(nl>900){
						if(ProcCodeType==2)
						{
							baseYProcDescriptionValue += 20;
							baseYProcCodeValue += 20;	
						}
						else
						{
							baseYDiagnosisDescriptionValue += 20;
							baseYDiagnosisCodeValue += 20;	
						}
						th=60;
					}
					else if(nl>1200){
						if(ProcCodeType==2)
						{
							baseYProcDescriptionValue += 20;
							baseYProcCodeValue += 20;	
						}
						else
						{
							baseYDiagnosisDescriptionValue += 20;
							baseYDiagnosisCodeValue += 20;	
						}
						th=77;
					}
					descriptionField.Layer.Frame=new CoreGraphics.CGRect(descriptionField.Frame.X,descriptionField.Frame.Y,descriptionField.Frame.Width,th);


				}
			};
		}
		public void AddProcedure(string code,string description)
		{
			
			UITextView txtdesc;
			UIView view = procedureScrollView.ViewWithTag(procedurewithTag);
			if (view != null) {
				txtdesc = view as UITextView;
				if (string.IsNullOrEmpty (txtdesc.Text)) {
					return;
				}
			}

			CoreGraphics.CGRect descriptionFrame = new CoreGraphics.CGRect(14,baseYProcDescriptionValue,377,30);
			CoreGraphics.CGRect codeFrame = new CoreGraphics.CGRect(405,baseYProcCodeValue,70,30);

			UITextField codeText = new UITextField(codeFrame);
			MultilineTextView descriptionText = new MultilineTextView(descriptionFrame);
			codeText.Text=code;
			codeText.BorderStyle = UITextBorderStyle.RoundedRect;

			procedurecodewithTag = procedurecodewithTag + 1;
			codeText.Tag = procedurecodewithTag;
			codeText.ShouldBeginEditing += delegate {
				if(this.procedureDetails == null){
					showKeyBoard = false;
					return false;
				}else{
					showKeyBoard = true;
					return true;
				}
			};

			codeText.EditingDidEnd += (object sender, EventArgs e) => {
				showKeyBoard = false;
			};

			descriptionText.ShouldBeginEditing += delegate {
				if(this.procedureDetails == null){
					return false;
				}else{
					showKeyBoard = true;
					return true;
				}
			};

			descriptionText.ShouldEndEditing += delegate {
				showKeyBoard = false;
				return true;
			};


			procedurewithTag = procedurewithTag+1 ;
			descriptionText.Tag =procedurewithTag;

			int mh=MeasureTextLine(description);
			nfloat fh=30;
			if (mh == 280) {

				baseYProcDescriptionValue += 10;
				baseYProcCodeValue += 10;	
				mh=30;
			}
			else if(mh>600 && mh < 899){								
				baseYProcDescriptionValue += 20;
				baseYProcCodeValue += 20;	
				fh=50;
			}
			else if (mh > 900) {
				baseYProcDescriptionValue += 30;
				baseYProcCodeValue += 30;	
				fh = 60;
			} else if (mh > 1200) {
				baseYProcDescriptionValue += 40;
				baseYProcCodeValue += 40;	
				fh = 77;
			}
			descriptionText.Layer.Frame=new CoreGraphics.CGRect(descriptionText.Frame.X,descriptionText.Frame.Y,descriptionText.Frame.Width,fh);	
			descriptionText.Text=description;


			descriptionText.Changed += (senderDesc, e) => {

				if(descriptionText.Text.Length > 1)
				{	
					bool itemPreviouslySearched = false;

					string lastSelectedProcedures = ReadFile("lastSelectedProcedures.txt");
					if(lastSelectedProcedures != string.Empty){
						lastSelectedProceduresObj = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject(lastSelectedProcedures,typeof(ProcedureDiagnosticMaster));
						foreach (DataResults item in lastSelectedProceduresObj.results) {
							if(item.Name != null){
								if(item.Name.ToLower().Contains(descriptionText.Text.Trim().ToLower())){
									itemPreviouslySearched = true;
									break;
								}
							}
						}
					}

					if(itemPreviouslySearched){
						int uvWidth=280;
						List<CodePickerModel> list=SetDataSource(out uvWidth,lastSelectedProceduresObj);
						float x = (float)descriptionText.Frame.X;
						float y = (float)descriptionText.Frame.Y;

						cp	=new CodePicker(this,uvWidth,descriptionText.Text,"CPT");
						cp.PresentFromPopover(descriptionText,x,y,uvWidth);
						cp.DataSource=list;
						cp._ValueChanged +=  async delegate {		
							int ProcCodeID = cp.SelectedValue;
							codeText.Text = cp.SelectedCodeValue;
							int nl=MeasureTextLine(cp.SelectedText);
							nfloat th=30;
							if (nl == 280) {

								baseYProcDescriptionValue += 0;
								baseYProcCodeValue += 0;	
								mh=30;
							}
							else if(nl>600 && nl < 899){								
								baseYProcDescriptionValue += 10;
								baseYProcCodeValue += 10;	
								th=50;
							}
							else if(nl>900){
								
								baseYProcDescriptionValue += 20;
									baseYProcCodeValue += 20;	
								th=60;
							}
							else if(nl>1200){
								baseYProcDescriptionValue += 30;
								baseYProcCodeValue += 30;	
								th=77;
							}
							descriptionText.Layer.Frame=new CoreGraphics.CGRect(descriptionText.Frame.X,descriptionText.Frame.Y,descriptionText.Frame.Width,th);	
							descriptionText.Text = cp.SelectedText;

							UpdateProcedureDiagnostic(ProcCodeID,cp.SelectedCodeValue,cp.SelectedText,1);
							selectedprocedureCodeid.Add(ProcCodeID);
						}; 
					}else{
						if(descriptionText.Text.Trim().Length > 0)
						{
							DownloadData("CPT",descriptionText.Text,codeText,descriptionText);

						}
					}
				}

			};


			procedureScrollView.AddSubview(codeText);
			baseYProcCodeValue += 44;

			procedureScrollView.AddSubview(descriptionText);
			baseYProcDescriptionValue += 44;

			procedureScrollView.SizeToFit ();
			procedureScrollView.ContentSize = new SizeF (float.Parse (procedureScrollView.Frame.Width.ToString ()), float.Parse (procedureScrollView.Frame.Height.ToString ())+55
			);
		}
		public async void DownloadData(string type,string[] searchParam,string codeID)
		{
			var webClient = new WebClient();
			string url =  "http://reference.iprocedures.com/"+type+"/"+searchParam[4].Trim().Replace("%20"," ")+"/40";
			string procData = webClient.DownloadString (url);
			procedureItems = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject (procData, typeof(ProcedureDiagnosticMaster));

			string mCurrentTextBoxID = searchParam [0];
			float x = float.Parse (searchParam [1]);
			float y = float.Parse (searchParam [2]);
			int uvwidth = 0;
			List<CodePickerModel> list=SetProcedureDataSource (out uvwidth);
			cp	= new CodePicker (this,uvwidth);

			if(searchParam[4].Trim().Length > 0)
				cp.PresentFromPopover (wvpatient, x, y,uvwidth);
	
			cp.DataSource = list;
			cp._ValueChanged += delegate {
				DataResults selectedObj = new DataResults{Name = cp.SelectedText,Code=cp.SelectedCodeValue};
				string fileName = string.Empty;
				if(type == "CPT")
					fileName = "lastSelectedProcedures.txt";
				else
					fileName = "lastSelectedDiagnosis.txt";

				SaveJsonToFile(selectedObj,fileName);

				SetTextboxValue (mCurrentTextBoxID, cp.SelectedText);
				SetTextboxValue(codeID,cp.SelectedCodeValue);
				//Nahid Ahmed My Test method
//				UpdatePatientObject(codeID);
			};
		}
		public override void ViewDidLoad ()
		{
			
			base.ViewDidLoad ();
			wvpatient.EndEditing (true);
			BackBtn.TouchUpInside+= (object sender, EventArgs e) => {
				this.NavigationController.PopViewController(true);
			};
			mMenu.ValueChanged+= (object sender, EventArgs e) => {

				wvpatient.EvaluateJavascript("bindPanel("+mMenu.SelectedSegment+")");
			};
			BtnSubmit.TouchUpInside+=async (object sender, EventArgs e) => {
				AppDelegate.pb.Start(this.View,"Please wait...");
				string str=wvpatient.EvaluateJavascript("GetTextboxValue()");
				XmlSerializer xs = new XmlSerializer(typeof(ProfileInfo));
				ProfileInfo objpi = (ProfileInfo)xs.Deserialize(new StringReader(str));

				PQRSServices services=new PQRSServices();
				Patient Profile=new Patient();

				if(patientProcedureDetails!=null)
					Profile.ID=patientProcedureDetails.PatientID;
				else
					Profile.ID=0;				
				Profile.cbEmergency=objpi.cbEmergency;

				if(mPatient!=null)
					Profile.CreatedOn = mPatient.OperationDate;
				else
					Profile.CreatedOn = DateTime.Now.ToShortDateString();
			
				Profile.ddlASAType=objpi.ddlASAType;
				Profile.ddlEncounterType=objpi.ddlEncounterType;
				Profile.LastModifiedDate=DateTime.Now.ToShortDateString();
				Profile.FacilityID=iProPQRSPortableLib.Consts.SelectedFacilityID;
				Profile.FirstName=objpi.Firstname;
				Profile.LastName=objpi.Lastname;
				Profile.DOB=objpi.DOB;	
				Profile.MRN=objpi.MRN;
				ReceiveContext result1 = await AppDelegate.Current.pqrsMgr.AddUpdatePatintInfo (Profile);
				Patient piResult=null;
				if(string.IsNullOrEmpty(result1.message))
				{
					piResult = (Patient)JsonConvert.DeserializeObject(result1.result.ToString() , typeof(Patient));
					//new UIAlertView("Patient Info", "Successfully Saved."
					//	, null, "ok", null).Show();
				}
				else
				{
					new UIAlertView("Patient eroor", result1.message
						, null, "ok", null).Show();
				}
				PatientProcedureFullDetails PDetails=new PatientProcedureFullDetails();
				if(patientProcedureDetails!=null)
				{
					PDetails.ID=patientProcedureDetails.ProcID;
					PDetails.PatientID=patientProcedureDetails.PatientID.ToString();
					PDetails.StatusID=patientProcedureDetails.StatusID.ToString();
				}
				else
				{
					if(piResult==null)
					{
						PDetails.ID=0;
						PDetails.PatientID="0";
					}
					else
					{

						PDetails.ID=0;
						PDetails.PatientID=piResult.ID.ToString();
					}	
				}


				PDetails.Mrn=objpi.MRN;
				PDetails.OperationDate=objpi.OperationDate;
				//PDetails.PatientID=objpi.PatientID;
				//PDetails.Location=objpi.Location;
				//PDetails.ORNumber=objpi.;
				PDetails.Anesthesiologist=objpi.Anesthesiologist1_label;
				PDetails.Anesthesiologist1=objpi.Anesthesiologist2_label;
				PDetails.Anesthesiologist2=objpi.Anesthesiologist2_label;
				PDetails.Anesthesiologist3=objpi.Anesthesiologist2_label;
				PDetails.Crna=objpi.CRNA1_label;
				PDetails.Crna1=objpi.CRNA1_label;
				PDetails.Crna2=objpi.CRNA2_label;
				PDetails.Crna3=objpi.CRNA3_label;
				//PDetails.RlfTime1=objpi.tim;
				//PDetails.RlfTime2
				//PDetails.RlfTime3
				//PDetails.RlfTime4
				PDetails.CrnaRlfTime1=objpi.CrnaStrtTime1;
				PDetails.CrnaRlfTime2=objpi.CrnaStrtTime2;
				PDetails.Surgeon=objpi.Surgeon;
				PDetails.Surgeon2=objpi.Surgeon2;

				PDetails.Surgeon3=objpi.Surgeon3;
			    //PDetails.Procedures=objpi.Procedures1;
				//PDetails.Diagnosis=objpi.CRNA4_label;
				//PDetails.ScheduleStartTime=objpi.;
				//PDetails.StatusID=objpi.CRNA4_label;
				//PDetails.RoomIn=objpi.CRNA4_label;
				PDetails.AnesStart=objpi.AnesStrtTime1;
				//PDetails.SurgeryStart=objpi.OperationDate;
				//PDetails.IncisionTime=objpi.time;
				//PDetails.SurgeryEnd=objpi.CRNA4_label;
				PDetails.AnesEnd=objpi.AnesEndTime1;
				PDetails.LastUpdatedTime=DateTime.Now.ToString();
				//PDetails.tbPreIndBP=objpi.CRNA4_label;
				//PDetails.tbPreIndP=objpi.CRNA4_label;
				//PDetails.tbPreIndSPO2=objpi.CRNA4_label;
				//PDetails.tbPreIndResp=objpi.CRNA4_label;
				PDetails.Procedure1=objpi.Procedures1;
				PDetails.Procedure2=objpi.Procedures2;
				PDetails.Procedure3=objpi.Procedures3;
				PDetails.Procedure4=objpi.Procedures4;
				PDetails.ProcedureCode1=objpi.ProcedureCode1;
				PDetails.ProcedureCode2=objpi.ProcedureCode2;
				PDetails.ProcedureCode3=objpi.ProcedureCode3;
				PDetails.ProcedureCode4=objpi.ProcedureCode4;
				//PDetails.ProcedureUnit1
				//PDetails.ProcedureUnit2
				//PDetails.ProcedureUnit3
				//PDetails.ProcedureUnit4
				PDetails.Diagnosis1=objpi.Diagnosis1;
				PDetails.Diagnosis2=objpi.Diagnosis2;
				PDetails.Diagnosis3=objpi.Diagnosis3;
				PDetails.Diagnosis4=objpi.Diagnosis4;

				PDetails.DiagnosisCode1=objpi.DiagnosisCode1;
				PDetails.DiagnosisCode2=objpi.DiagnosisCode2;
				PDetails.DiagnosisCode3=objpi.DiagnosisCode3;
				PDetails.DiagnosisCode4=objpi.DiagnosisCode4;
				//DiagnosisUnit1
				//DiagnosisUnit2
				//DiagnosisUnit3
				//DiagnosisUnit4
				//Modifier1
				//Modifier2
				//Modifier3
				//Modifier4
				PDetails.Duration=objpi.delayedDuration;
				//SurveyComplete
				//BillingInfo
				//PDFStatus
				//PatientClass
				//CancellationReason
				PDetails.CancellationReasonID=objpi.ddlCancellationReasons;
				//OrderNumber
				PDetails.ddlEncounterType=objpi.ddlEncounterType;
				PDetails.ddlASAType=objpi.ddlASAType;
				PDetails.cbEmergency=objpi.cbEmergency;
				PDetails.Anesthesiologist4=objpi.Anesthesiologist4;
				//RlfTime3
				PDetails.Crna4=objpi.CRNA4_label;
				//CrnaRlfTime3
				//Srna1
				//Srna2
				//SrnaRlfTime1
				//Source
				//Induction
				PDetails.AnesStrtTime1=objpi.AnesStrtTime1;
				PDetails.AnesEndTime1=objpi.AnesEndTime1;
				PDetails.AnesStrtTime2=objpi.AnesStrtTime2;
				PDetails.AnesEndTime2=objpi.AnesEndTime2;
				PDetails.AnesStrtTime3=objpi.AnesStrtTime3;
				PDetails.AnesEndTime3=objpi.AnesEndTime3;
				PDetails.AnesStrtTime4=objpi.AnesStrtTime4;
				PDetails.AnesEndTime4=objpi.AnesEndTime4;
				PDetails.CrnaStrtTime1=objpi.CrnaStrtTime1;
				PDetails.CrnaEndTime1=objpi.CrnaEndTime1;
				PDetails.CrnaStrtTime2=objpi.CrnaStrtTime2;
				PDetails.CrnaEndTime2=objpi.CrnaEndTime2;
				PDetails.CrnaStrtTime3=objpi.CrnaStrtTime3;
				PDetails.CrnaEndTime3=objpi.CrnaEndTime3;
				PDetails.CrnaStrtTime4=objpi.CrnaStrtTime4;
				PDetails.CrnaEndTime4=objpi.CrnaEndTime4;
				//SrnaStrtTime1
				//SrnaEndTime1
				//ListType
				ReceiveContext result2=await services.UpdatePatintProcedureInfo(PDetails);
				if(string.IsNullOrEmpty(result2.message))
				{
					BtnSubmit.Enabled=false;
					AppDelegate.pb.Stop();
					new UIAlertView("Patient Procedure Info", "Successfully Saved."
						, null, "ok", null).Show();
				}
				else
				{
					AppDelegate.pb.Stop();
					new UIAlertView("Patient eroor", result2.message
						, null, "ok", null).Show();
				}


				//Nahid Ahmed Testing patient upload
//				Patient pat = new Patient();
//				pat.ID = 17517;
//				pat.MRN = "54576576876";
//				pat.FirstName = "John6";
//				pat.LastName = "DoelMansuri";
//				pat.Sex = "M";
//				pat.Height = "5)6";
//				pat.Weight = "67";
//				pat.Allergies = "Tablet";
//				pat.PersonProvidingInfo = "Patient";
//				pat.DOB = "1962-02-02T00:00:00";
//				pat.AccountNo = "3564546466";
//				AppDelegate.Current.pqrsMgr.UploadPatientData(pat);

			};
			this.NavigationController.NavigationBarHidden = true;		
			if (mPatient != null && mPatient.PatientID != null) {
				lblPatientName.Text = mPatient.PatientName;
				lblhmrn.Text = "MRN :" + mPatient.MRN;
				lblAccount.Text = "ACCT :" + mPatient.AccountNo;
			} else {
				lblPatientName.Text = "";
				lblhmrn.Text = "";
				lblAccount.Text = "";
			}
			LoadWevView ();
			wvpatient.LoadFinished+= WvPatientProcedure_LoadFinished;
			#region ShouldStartLoad
			wvpatient.ShouldStartLoad = (webView, request, navType) => {
				string requestString=request.Url.Description;
				string param=string.Empty;
				if(requestString.Contains("pro://showAlert/"))
				{
					string message=requestString.Remove(0,15);
					AlertMsg(message);
				}
				else if(requestString.Contains("pro://openDatePicker/"))
				{
					param=requestString.Remove(0,22);
					string[] pary=param.Split(',');
					string mCurrentTextBoxID=pary[0];
					float x=float.Parse(pary[1]);
					float y=float.Parse(pary[2]);
					if(mCurrentTextBoxID=="OperationDate" || mCurrentTextBoxID=="DOB")
					{
						DatePicker  dp=new DatePicker();
						dp.PresentFromPopover(wvpatient,x,y);
						dp._ValueChanged += delegate {	
							int age = DateTime.Now.Year - dp.SelectedDateValue.Year;
							//this.mPatient.DOB = dp.SelectedDate;
							SetTextboxValue(mCurrentTextBoxID,dp.SelectedDate);
							SetTextboxValue("Age",age.ToString());
						};
					}
					else
					{
						TimePicker  tp=new TimePicker();
						tp.PresentFromPopover(wvpatient,x,y);
						tp._ValueChanged += delegate {						
							SetTextboxValue(mCurrentTextBoxID,tp.SelectedTime);
						};
					}

				}
				else if(requestString.Contains("pro://openCodePicker/Diagnosis"))
				{
					param=requestString.Remove(0,22);
					string[] pary=param.Split(',');
					string currentDiagnosticCodeTextID = string.Empty;

					if(requestString.Contains("Diagnosis1"))
						currentDiagnosticCodeTextID = "DiagnosisCode1";
					else if(requestString.Contains("Diagnosis2"))
						currentDiagnosticCodeTextID = "DiagnosisCode2";
					else if(requestString.Contains("Diagnosis3"))
						currentDiagnosticCodeTextID = "DiagnosisCode3";
					else if(requestString.Contains("Diagnosis4"))
						currentDiagnosticCodeTextID = "DiagnosisCode4";

					bool itemPreviouslySearched = false;

					string lastSelectedProcedures = ReadFile("lastSelectedDiagnosis.txt");
					if(lastSelectedProcedures != string.Empty){
						lastSelectedProceduresObj = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject(lastSelectedProcedures,typeof(ProcedureDiagnosticMaster));
						foreach (DataResults item in lastSelectedProceduresObj.results) {
							if(item.Name != null){
								if(item.Name.ToLower().Contains(pary[4].ToLower())){
									itemPreviouslySearched = true;
									break;
								}
							}
						}
					}

					if(cp != null){
						if(cp.popover != null)
							cp.popover.Dismiss(false);
					}


					if(itemPreviouslySearched){
						int uvWidth=280;
						List<CodePickerModel> list=SetDataSource(out uvWidth);
						string mCurrentTextBoxID=pary[0];
						float x=float.Parse(pary[1]);
						float y=float.Parse(pary[2]);
						cp	=new CodePicker(this,uvWidth);
						cp.PresentFromPopover(wvpatient,x,y,uvWidth);
						cp.DataSource=list;
						cp._ValueChanged += delegate {						
							SetTextboxValue(mCurrentTextBoxID,cp.SelectedText);
							SetTextboxValue(currentDiagnosticCodeTextID,cp.SelectedCodeValue);
						}; 
					}else{
						if(pary[4].Replace("%20"," ").Trim().Length > 0)
							DownloadData("ICD9",pary,currentDiagnosticCodeTextID);
					}
				}
				else if(requestString.Contains("pro://openCodePicker/Procedures"))
				{
					param=requestString.Remove(0,22);
					string[] pary=param.Split(',');

					string currentProceduresCodeTextID = string.Empty;

					if(requestString.Contains("Procedures1"))
						currentProceduresCodeTextID = "ProcedureCode1";
					else if(requestString.Contains("Procedures2"))
						currentProceduresCodeTextID = "ProcedureCode2";
					else if(requestString.Contains("Procedures3"))
						currentProceduresCodeTextID = "ProcedureCode3";
					else if(requestString.Contains("Procedures4"))
						currentProceduresCodeTextID = "ProcedureCode4";
					
					bool itemPreviouslySearched = false;

					string lastSelectedProcedures = ReadFile("lastSelectedProcedures.txt");
					if(lastSelectedProcedures != string.Empty){
						lastSelectedProceduresObj = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject(lastSelectedProcedures,typeof(ProcedureDiagnosticMaster));
						foreach (DataResults item in lastSelectedProceduresObj.results) {
							if(item.Name != null){
								if(item.Name.ToLower().Contains(pary[4].ToLower())){
									itemPreviouslySearched = true;
									break;
								}
							}
						}
					}
						
 					if(cp != null){
						if(cp.popover != null)
							cp.popover.Dismiss(false);
					}
					
					if(itemPreviouslySearched){
						int uvWidth=280;
						List<CodePickerModel> list=SetDataSource(out uvWidth);
						string mCurrentTextBoxID=pary[0];
						float x=float.Parse(pary[1]);
						float y=float.Parse(pary[2]);
						cp	=new CodePicker(this,uvWidth);

						if(pary[4].Trim().Length > 0)
							cp.PresentFromPopover(wvpatient,x,y,uvWidth);
						
						cp.DataSource=list;
						cp._ValueChanged += delegate {	
							SetTextboxValue(mCurrentTextBoxID,cp.SelectedText);
							SetTextboxValue(currentProceduresCodeTextID,cp.SelectedCodeValue);
						}; 
					}else{
						if(pary[4].Replace("%20"," ").Trim().Length > 0)
							DownloadData("CPT",pary,currentProceduresCodeTextID);
					}
				}
				else if(requestString.Contains("ipro://Checkmrncode/"))
				{

					param = requestString.Remove(0, 23);
					string[] pary = param.Split(',');
					string mCurrentTextBoxID = pary[3];
					float x = float.Parse(pary[1]);
					float y = float.Parse(pary[2]);
					string mrn=wvpatient.EvaluateJavascript("GetVal('"+mCurrentTextBoxID+"')");
					PQRSServices serv=new PQRSServices();
					ReceiveContext context=new ReceiveContext();
					if(!string.IsNullOrEmpty(mrn))
					{
						AppDelegate.pb.Start(this.View,"Checking MRN number");

						InvokeOnMainThread ( async () =>  {
							context=await serv.CheckExistingPatintInfo(mrn,"1");
							string strtemp=context.result.ToString();
							List<Patient> objpi = (List<Patient>)JsonConvert.DeserializeObject(context.result.ToString() , typeof(List<Patient>));
							//"MRN", "Firstname", "Lastname","DOB","Age","ddlEncounterType","ddlASAType","cbEmergency"
							Patient tempProfil;
							if(objpi.Count>0)
							{
								if(objpi.Count>1)
								{

									int maxval=FindMaxID(objpi);
									tempProfil=objpi.Find(u=>u.ID==maxval);
								}
								else
								{								
									tempProfil=objpi[0];
								}
								SetTextboxValue("Firstname",tempProfil.FirstName);
								SetTextboxValue("Lastname",tempProfil.LastName);
								if(!string.IsNullOrEmpty(tempProfil.DOB))
								{
									SetTextboxValue("DOB",tempProfil.DOB);
									var now = float.Parse(DateTime.Now.ToString("yyyy.MMdd"));
									var dob = float.Parse(Convert.ToDateTime(tempProfil.DOB).ToString("yyyy.MMdd"));
									var age = (int)(now - dob);
									SetTextboxValue("Age", age.ToString());
								}							
								lblhmrn.Text = "MRN :" + tempProfil.MRN;
								lblAccount.Text = "ACCT :" + tempProfil.AccountNo;
								lblPatientName.Text = tempProfil.FirstName+" , "+tempProfil.LastName;
								SetTextboxValue("ddlEncounterType",tempProfil.ddlEncounterType);
								SetTextboxValue("ddlASAType",tempProfil.ddlASAType);
								SetTextboxValue("cbEmergency",tempProfil.cbEmergency);
								AppDelegate.pb.Stop();
							}
							else
							{
								SetTextboxValue("Firstname","");
								SetTextboxValue("Lastname","");
								SetTextboxValue("DOB","");
								SetTextboxValue("Age", "");
								lblhmrn.Text = "";
								lblAccount.Text = "";
								lblPatientName.Text = "";
								SetTextboxValue("ddlEncounterType","");
								SetTextboxValue("ddlASAType","");
								SetTextboxValue("cbEmergency","");
								AppDelegate.pb.Stop();
							}

						});
					}


				}
                else if (requestString.Contains("ipro://mopenCodePicker/"))
                {
					wvpatient.KeyboardDisplayRequiresUserAction = false;
					UIView ruv=wvpatient.InputAccessoryView;
					if(ruv!=null)
						ruv.Hidden=true;
					
                    mCodePicker mcp;

                    param = requestString.Remove(0, 23);
                    string[] pary = param.Split(',');
                    string mCurrentTextBoxID = pary[0];
                    float x = float.Parse(pary[1]);
                    float y = float.Parse(pary[2]);
                    if (mCurrentTextBoxID == "AnesthesiaTech")
                    {
						int uvwidth;
						List<CodePickerModel> alist=mSetDataSource(AnesthesiaTech.Split(','), out  uvwidth);
						mcp = new mCodePicker(this,uvwidth);
                        // need to set Selected Items
                        if (ATlist.Count > 0)
                            mcp.SelectedItems = ATlist;
                        //
						mcp.PresentFromPopover(wvpatient, x, y,uvwidth);
						mcp.mDataSource(alist);
                        mcp._ValueChanged += delegate
                        {
                            ATlist = mcp.SelectedItems;
                            string finalText = string.Empty;
                            foreach (var item in ATlist)
                            {
                                finalText = finalText + ", " + item.ItemText;
                            }
                            SetTextboxValue(mCurrentTextBoxID, finalText.TrimStart(','));
                        };
                    }
                    else if (mCurrentTextBoxID == "Lines")
                    {
						int uvwidth;
						List<CodePickerModel> list=mSetDataSource(Lines.Split(','), out  uvwidth);
                        mcp = new mCodePicker(this);
                        // need to set Selected Items
                        if (Linelist.Count > 0)
                            mcp.SelectedItems = Linelist;
                        //
						mcp.PresentFromPopover(wvpatient, x, y,uvwidth);
						mcp.mDataSource(list);
                        mcp._ValueChanged += delegate
                        {
                            Linelist = mcp.SelectedItems;
                            string finalText = string.Empty;
                            foreach (var item in Linelist)
                            {
                                finalText = finalText + ", " + item.ItemText;
                            }
                            SetTextboxValue(mCurrentTextBoxID, finalText.TrimStart(','));
                        };
                    }
                    else if (mCurrentTextBoxID == "CVCSterileTec")
                    {
						int uvwidth;
						List<CodePickerModel> list=mSetDataSource(CVCSterileTec.Split(','), out  uvwidth);
						mcp = new mCodePicker(this,uvwidth);
                        mcp.Setwidth();
                        // need to set Selected Items
                        if (CVCTlist.Count > 0)
                            mcp.SelectedItems = CVCTlist;
                        //
						mcp.PresentFromPopover(wvpatient, x, y,uvwidth);

						mcp.mDataSource(list);
                        mcp._ValueChanged += delegate
                        {
                            CVCTlist = mcp.SelectedItems;
                            string finalText = string.Empty;
                            foreach (var item in CVCTlist)
                            {
                                finalText = finalText + ", " + item.ItemText;
                            }
                            SetTextboxValue(mCurrentTextBoxID, finalText.TrimStart(','));
                        };
                    }
                    else if (mCurrentTextBoxID == "NerveBlack")
                    {
						int uvwidth;
						List<CodePickerModel> list=mSetDataSource(NerveBlack.Split(','), out uvwidth);
						mcp = new mCodePicker(this,uvwidth);
                        // need to set Selected Items
                        if (NBlist.Count > 0)
                            mcp.SelectedItems = NBlist;
                        //
						mcp.PresentFromPopover(wvpatient, x, y,uvwidth);
						mcp.mDataSource(list);
                        mcp._ValueChanged += delegate
                        {
                            NBlist = mcp.SelectedItems;
                            string finalText = string.Empty;
                            foreach (var item in NBlist)
                            {
                                finalText = finalText + ", " + item.ItemText;
                            }
                            SetTextboxValue(mCurrentTextBoxID, finalText.TrimStart(','));
                        };
                    }
                    else if (mCurrentTextBoxID == "SterileTec")
                    {
						int uvwidth;
						List<CodePickerModel> list=mSetDataSource(SterileTec.Split(','), out uvwidth);
						mcp = new mCodePicker(this,uvwidth);
                        // need to set Selected Items
                        if (STlist.Count > 0)
                            mcp.SelectedItems = STlist;
                        //
						mcp.PresentFromPopover(wvpatient, x, y,uvwidth);
						mcp.mDataSource(list);
                        mcp._ValueChanged += delegate
                        {
                            STlist = mcp.SelectedItems;
                            string finalText = string.Empty;
                            foreach (var item in STlist)
                            {
                                finalText = finalText + ", " + item.ItemText;
                            }
                            SetTextboxValue(mCurrentTextBoxID, finalText.TrimStart(','));
                        };
                    }
                    else if (mCurrentTextBoxID == "SpecialTech")
                    {
						int uvwidth;
						List<CodePickerModel> list=mSetDataSource(SpecialTech.Split(','), out uvwidth);
						mcp = new mCodePicker(this,uvwidth);
                        // need to set Selected Items
                        if (SPTlist.Count > 0)
                            mcp.SelectedItems = SPTlist;
                        //
						mcp.PresentFromPopover(wvpatient, x, y,uvwidth);
						mcp.mDataSource(list);
                        mcp._ValueChanged += delegate
                        {
                            SPTlist = mcp.SelectedItems;
                            string finalText = string.Empty;
                            foreach (var item in SPTlist)
                            {
                                finalText = finalText + ", " + item.ItemText;
                            }
                            SetTextboxValue(mCurrentTextBoxID, finalText.TrimStart(','));
                        };
                    }
                    wvpatient.ResignFirstResponder();
                }
				return true;
			};
			#endregion
			// Perform any additional setup after loading the view, typically from a nib.
		}