コード例 #1
0
ファイル: PQRSServices.cs プロジェクト: Nahidahmed/iProPQRS
		public async Task<ReceiveContext> UpdatePatintProcedureInfo(PatientProcedureFullDetails Profile)
		{
			Stream requestWriter;
			string received=string.Empty;
			ReceiveContext responseObj;
			try
			{
				HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Consts.BaseServerURL + "/anesservices/procs");


				request.ContentType = "application/json; charset=utf-8";

				// Set the Method property to 'POST' to post data to the URI.
				request.Method = "PUT";
				request.Headers ["Token"] =Consts.AuthenticationToken;

				requestWriter = await request.GetRequestStreamAsync();
				string postData=JsonConvert.SerializeObject(Profile,Formatting.Indented);
				//string postData = "{\n      \"ID\": "+Profile.ID+",\n      \"Mrn\": \"54576576876\",\n      \"FirstName\": \"Johnkumar\",\n      \"LastName\": \"Doe1\",\n      \"Sex\": \"M\",\n      \"Height\": \"5)6\",\n      \"Weight\": \"67\",\n      \"Allergies\": \"Tablet\",\n      \"PersonProvidingInfo\": \"Patient\",\n      \"DOB\": \"1962-02-02T00:00:00\",\n      \"AccountNo\": \"3564546466\",\n      \"HNENumber\": null,\n      \"ddlEncounterType\": null,\n      \"ddlASAType\": null,\n      \"cbEmergency\": null,\n      \"Race\": null,\n      \"DeathDate\": null,\n      \"DeathIndicator\": null,\n      \"CreatedOn\": null,\n      \"LastModifiedDate\": \"2015-07-15T06:12:11.52\",\n      \"LastModifiedBy\": \"admin\",\n      \"RecordType\": null,\n      \"FacilityID\": null,\n      \"SSN\": null,\n      \"PrimaryLanguage\": null,\n      \"Ethnicity\": null,\n      \"HomePhone\": null,\n      \"CellPhone\": null,\n      \"MaritalStatus\": null,\n      \"QuickAdd\": \"N\",\n      \"AptID\": null,\n      \"isDFTExported\": null,\n      \"ddlHghtType\": null,\n      \"ddlWghtType\": null,\n      \"tbBMI\": null,\n      \"cbNKDA\": null,\n      \"cbIVDye\": null\n    }\n";
				//string postData = "{\n      \"ID\": 17517,\n      \"Mrn\": \"54576576876\",\n      \"FirstName\": \"Johnkumar\",\n      \"LastName\": \"Doe1\",\n      \"Sex\": \"M\",\n      \"Height\": \"5)6\",\n      \"Weight\": \"67\",\n      \"Allergies\": \"Tablet\",\n      \"PersonProvidingInfo\": \"Patient\",\n      \"DOB\": \"1962-02-02T00:00:00\",\n      \"AccountNo\": \"3564546466\",\n      \"HNENumber\": null,\n      \"ddlEncounterType\": null,\n      \"ddlASAType\": null,\n      \"cbEmergency\": null,\n      \"Race\": null,\n      \"DeathDate\": null,\n      \"DeathIndicator\": null,\n      \"CreatedOn\": null,\n      \"LastModifiedDate\": \"2015-07-15T06:12:11.52\",\n      \"LastModifiedBy\": \"admin\",\n      \"RecordType\": null,\n      \"FacilityID\": null,\n      \"SSN\": null,\n      \"PrimaryLanguage\": null,\n      \"Ethnicity\": null,\n      \"HomePhone\": null,\n      \"CellPhone\": null,\n      \"MaritalStatus\": null,\n      \"QuickAdd\": \"N\",\n      \"AptID\": null,\n      \"isDFTExported\": null,\n      \"ddlHghtType\": null,\n      \"ddlWghtType\": null,\n      \"tbBMI\": null,\n      \"cbNKDA\": null,\n      \"cbIVDye\": null\n    }\n";
				byte[] data = Encoding.UTF8.GetBytes(postData);
				requestWriter.Write(data,0,data.Length);
				WebResponse resp = await request.GetResponseAsync();
				using (var responseStream = resp.GetResponseStream())
				{
					using (var sr = new StreamReader(responseStream))
					{
						received = await sr.ReadToEndAsync();
					}
				}
			}
			catch {

			}
			responseObj = (ReceiveContext)JsonConvert.DeserializeObject(received , typeof(ReceiveContext));
			return responseObj;
		}
コード例 #2
0
		public async void UpdateProcedureDiagnostic(int ProcCodeID,string Code,string Name, int ProcCodeTypeID)
		{
			string msgtitle = string.Empty;
			if (ProcCodeTypeID == 1)
				msgtitle = "Procedure";
			else if (ProcCodeTypeID == 418)
				msgtitle = "MAC CODE is " + Code;
			else
				msgtitle = "Diagnostic";
			
			if (ProcCodeTypeID != 418)
			   AppDelegate.pb.Start(this.View,msgtitle+" Updating...");

			DataResults procedureitem = new DataResults();

			int ProcID;
			string Mrn;
			string PatientID;
			if (procedureDetails == null) {
				procedureDetails = new PatientProcedureFullDetails ();
				ProcID = 0;
				Mrn = patientProfile.MRN;
				PatientID = patientProfile.ID.ToString ();	

				procedureDetails.ID=ProcID;
				procedureDetails.Mrn = patientProfile.MRN;
				procedureDetails.PatientID = patientProfile.ID.ToString();		
				procedureDetails.ListType = "MAIN";
				procedureDetails.Location =  iProPQRSPortableLib.Consts.SelectedFacilityID;

				ReceiveContext result = await AppDelegate.Current.pqrsMgr.UpdatePatintProcedureInfo (procedureDetails);
				if (ProcID == 0) {
					if(result != null && result.result != null &&  result.status != null && result.status.ToUpper () == "OK")
						procedureDetails= (PatientProcedureFullDetails)JsonConvert.DeserializeObject (result.result.ToString (), typeof(PatientProcedureFullDetails));
					else
						NavigationController.PopToRootViewController(true);
					

					lblProcID.Text = "Proc ID: " + procedureDetails.ID;
				}
			}

			procedureitem.ProcID = procedureDetails.ID.ToString();
			procedureitem.ProcCodeID = ProcCodeID;
			procedureitem.Code = Code;
			procedureitem.Name = Name;
			procedureitem.ProcCodeTypeID = ProcCodeTypeID;
			ReceiveContext context=	await AppDelegate.Current.pqrsMgr.UpdateProcedureDiagnostic(procedureitem);
			if (context != null && context.status != null && context.status.ToUpper () == "OK") {				
				AppDelegate.pb.Stop ();
				sCtab.SetEnabled (true, 1);
				sCtab.SetEnabled (true, 2);
				//new UIAlertView (msgtitle, "Successfully Saved", null, "ok", null).Show ();
			} else {

				AppDelegate.pb.Stop ();
				new UIAlertView (msgtitle, context.message, null, "ok", null).Show ();
			}

		}
コード例 #3
0
		private async void SavePatientInfo()
		{
			try
			{
			if (validatedata ()) {
				Patient profile = new Patient ();

				if (patientProfile != null)
					profile.ID = patientProfile.ID;
				else
					profile.ID = 0;		

//			if(uSEmergency.On)
//				profile.cbEmergency = "on";
//			else
//				profile.cbEmergency = string.Empty;

				profile.CreatedOn = DateTime.Now.ToShortDateString ();
//			profile.ddlEncounterType=EncounterBtn.TitleLabel.Text;
				profile.LastModifiedDate = DateTime.Now.ToShortDateString ();
				profile.FacilityID = iProPQRSPortableLib.Consts.SelectedFacilityID;
				profile.FirstName = txtpFirstName.Text;
				profile.LastName = txtpLastName.Text;
				profile.DOB = txtpDOB.Text;	
				profile.MRN = txtpmrn.Text;
			    if(!string.IsNullOrEmpty(btnPatientGender.CurrentTitle))
				   profile.Sex = btnPatientGender.CurrentTitle.Substring(0,1);

//			switch (PhysicalStatusBtn.TitleLabel.Text) {
//			case "ASA 1":
//				profile.ddlASAType = "1";
//				break;
//			case "ASA 2":
//				profile.ddlASAType = "2";
//				break;
//			case "ASA 3":
//				profile.ddlASAType = "3";
//				break;
//			case "ASA 4":
//				profile.ddlASAType = "4";
//				break;
//			case "ASA 5":
//				profile.ddlASAType = "5";
//				break;
//			case "ASA 6":
//				profile.ddlASAType = "6";
//				break;
//			}

				ReceiveContext result1 = await AppDelegate.Current.pqrsMgr.AddUpdatePatintInfo (profile);
					if(result1 != null && result1.result != null && result1.status !=null && result1.status.ToUpper() =="OK" ) 
					{
						Patient patientDetails = (Patient)JsonConvert.DeserializeObject(result1.result.ToString() , typeof(Patient));
						patientProfile = patientDetails;
						Patient piResult = null;
						if (string.IsNullOrEmpty (result1.message)) {
							Console.WriteLine ("Patient Info. Successfully Saved.");	
		//					new UIAlertView ("Patient Info", "Successfully Saved."
		//					, null, "ok", null).Show ();

							EncounterBtn.Enabled = true;
							PhysicalStatusBtn.Enabled = true;
							uSEmergency.Enabled = true;
							addNewDiagnosis.Enabled = true;
							deleteDiagnosis.Enabled = true;
							removeProc.Enabled = true;
							addNewProc.Enabled = true;

								lblFullName.Text = patientDetails.LastName.Trim() + ", " + patientDetails.FirstName.Trim();
								mrnLbl.Text = "MRN: " + patientDetails.MRN.Trim();
								lblFullName.Hidden=false;
								mrnLbl.Hidden=false;
							#region Procedure Creation
							if (procedureDetails == null) {
								procedureDetails = new PatientProcedureFullDetails ();
								procedureDetails.ID = 0;
								procedureDetails.Mrn = patientProfile.MRN;
								procedureDetails.PatientID = patientProfile.ID.ToString();						
								procedureDetails.StatusID = "1";
								
								procedureDetails.OperationDate = tctSurgeryDate.Text;
								procedureDetails.ListType = "MAIN";
								procedureDetails.Location =  iProPQRSPortableLib.Consts.SelectedFacilityID;


								ReceiveContext result = await AppDelegate.Current.pqrsMgr.UpdatePatintProcedureInfo (procedureDetails);
								if (result != null && result.result != null) 
									procedureDetails = (PatientProcedureFullDetails)JsonConvert.DeserializeObject (result.result.ToString (), typeof(PatientProcedureFullDetails));

								lblProcID.Text = "Proc ID: " + procedureDetails.ID;
									btnSubmit.Hidden=false;
								if (this.procedureDetails.StatusID == "1" || this.procedureDetails.StatusID == "2")
										btnSubmit.SetTitle (" Finalize", UIControlState.Normal);
									
								if(string.IsNullOrEmpty(result.message) &&  result.status!=null && result.status.ToUpper().Trim() == "OK" ){
									Console.WriteLine("Procedure Info. Successfully Saved.");	
								}
							}
							#endregion Procedure Creation
						} else {
							new UIAlertView ("Patient eroor", result1.message
							, null, "ok", null).Show ();
						}
					}
					else
						NavigationController.PopToRootViewController(true);
					
			}
			}
			catch {
				string str = "";
			}
		}
コード例 #4
0
		public async void ValidateAndUpdateProcedure(string paramname, string paramvalue)
		{
			if (patientProfile != null && patientProfile.ID != 0) {
//				AppDelegate.pb.Start(this.View,"Updating ...");
//				procedureDetails.ID = 0;
//				procedureDetails.Mrn = patientProfile.MRN;
//				procedureDetails.PatientID = patientProfile.ID.ToString();						
//				procedureDetails.StatusID = "1";
//
//				procedureDetails.OperationDate = tctSurgeryDate.Text;
//				procedureDetails.ListType = "MAIN";
//				procedureDetails.Location =  iProPQRSPortableLib.Consts.SelectedFacilityID;


				int ProcID;
				string Mrn;
				string PatientID;
				int StatusID;

				if (procedureDetails == null) {
					procedureDetails = new PatientProcedureFullDetails ();
					ProcID = 0;
					Mrn = patientProfile.MRN;
					PatientID = patientProfile.ID.ToString ();	
					StatusID = 1;
				} else {
					ProcID = procedureDetails.ID;
					Mrn = procedureDetails.Mrn;
					PatientID = procedureDetails.PatientID;	
					if (procedureDetails.StatusID != null)
						StatusID = Convert.ToInt16 (procedureDetails.StatusID);
					else
						StatusID = 1;
				}
				procedureDetails.ID = ProcID;
				procedureDetails.Mrn = patientProfile.MRN;
				procedureDetails.PatientID = patientProfile.ID.ToString ();		
				procedureDetails.StatusID = StatusID.ToString ();
				if (paramname == "EncounterType")
					procedureDetails.ddlEncounterType = paramvalue;
				else if (paramname == "PhysicalStatus")
					procedureDetails.ddlASAType = paramvalue;
				else if (paramname == "Emergency")
					procedureDetails.cbEmergency = paramvalue;

				procedureDetails.ListType = "MAIN";
				procedureDetails.Location = iProPQRSPortableLib.Consts.SelectedFacilityID;
				ReceiveContext result = await AppDelegate.Current.pqrsMgr.UpdatePatintProcedureInfo (procedureDetails);
				if (result != null && result.result != null && result.status != null && result.status.ToUpper () == "OK") {
					if (ProcID == 0) {
						if (result != null && result.result != null && result.status != null && result.status.ToUpper () == "OK")
							procedureDetails = (PatientProcedureFullDetails)JsonConvert.DeserializeObject (result.result.ToString (), typeof(PatientProcedureFullDetails));
						else
							NavigationController.PopToRootViewController (true);
						
						lblProcID.Text = "Proc ID: " + procedureDetails.ID;
					}

					if (string.IsNullOrEmpty (result.message) && result.status != null && result.status.ToUpper ().Trim () == "OK") {
//					AppDelegate.pb.Stop();
						Console.WriteLine ("Patient Procedure Info. Successfully Saved.");	
//					new UIAlertView("Patient Procedure Info", "Successfully Saved."
//						, null, "ok", null).Show();

						if (this.procedureDetails.StatusID == "0" || this.procedureDetails.StatusID == "1")
							tctSurgeryDate.Enabled = true;

						if (this.procedureDetails.StatusID == "2" || this.procedureDetails.StatusID == "3")
							tctSurgeryDate.Enabled = false;
					

						if (this.procedureDetails.StatusID == "3") {
							btnSubmit.SetTitle ("Unlock", UIControlState.Normal);
							uvPatientInfo.UserInteractionEnabled = false;
							uvBillingInfo.UserInteractionEnabled = false;
							uvQualityMetrics.UserInteractionEnabled = false;
						}
						
						btnSubmit.Hidden = false;
						if (this.procedureDetails.StatusID == "1" || this.procedureDetails.StatusID == "2")
							btnSubmit.SetTitle (" Finalize", UIControlState.Normal);
					
						if (this.procedureDetails.StatusID == "2" || this.procedureDetails.StatusID == "1") {
							//btnSubmit.SetTitle ("Finalize", UIControlState.Normal);
							uvPatientInfo.UserInteractionEnabled = true;
							string format = "MM/dd/yyyy"; 
							DateTime dt = DateTime.ParseExact (tctSurgeryDate.Text, format, System.Globalization.CultureInfo.CurrentCulture);
							if (DateTime.Now.Date < dt) {
								uvBillingInfo.UserInteractionEnabled = false;
								uvQualityMetrics.UserInteractionEnabled = false;
							} else {
								uvBillingInfo.UserInteractionEnabled = true;
								uvQualityMetrics.UserInteractionEnabled = true;
							}
						}
						//If the Billing Info and Quality Metrics are disabled, enable them after procedure creation
						sCtab.SetEnabled (true, 1);
						sCtab.SetEnabled (true, 2);
					} else {
//					AppDelegate.pb.Stop();
						Console.WriteLine ("Patient Procedure Info. Save failed.");	
//					new UIAlertView("Procedure eroor", result.message
//						, null, "ok", null).Show();
					}
				} else {
					NavigationController.PopToRootViewController(true);
					//new UIAlertView ("Patient Info", "Please Update Patient Info"
					//, null, "ok", null).Show ();
				}
			}
		}
コード例 #5
0
		public async  Task<bool> submitFinalizecase()
		{
			bool boolresult=false;
			if (ValidatefiledsFinalizecase ()) {
				string alrtmsg = "Are you sure you want to " + btnSubmit.CurrentTitle.ToLower() + " the case?";
				var finalizeConfirm = new UIAlertView ("Confirmation", alrtmsg, null, "Cancel", "Yes");
				finalizeConfirm.Show ();
				finalizeConfirm.Clicked += async (object senders, UIButtonEventArgs es) => {
					if (es.ButtonIndex == 0) {
						boolresult = false;
					}
					else
					{
						boolresult=true;
					if (patientProfile != null && patientProfile.ID != 0) {
						//				AppDelegate.pb.Start(this.View,"Updating ...");
						int ProcID;
						string Mrn;
						string PatientID;
						if (procedureDetails == null) {
							procedureDetails = new PatientProcedureFullDetails ();
							ProcID = 0;
							Mrn = patientProfile.MRN;
							PatientID = patientProfile.ID.ToString ();	
						} else {
							ProcID = procedureDetails.ID;
							Mrn = procedureDetails.Mrn;
							PatientID = procedureDetails.PatientID;	
						}
						procedureDetails.ID = ProcID;
						procedureDetails.Mrn = patientProfile.MRN;
						procedureDetails.PatientID = patientProfile.ID.ToString ();		


						procedureDetails.ddlEncounterType = EncounterBtn.TitleLabel.Text;

						procedureDetails.ddlASAType = physicalStatus.ToString();


						procedureDetails.ListType = "MAIN";
						procedureDetails.Location = iProPQRSPortableLib.Consts.SelectedFacilityID;
						if(btnSubmit.CurrentTitle.Trim() == "Finalize")							
							this.procedureDetails.StatusID = "3";

						if(btnSubmit.CurrentTitle == "Unlock")
							this.procedureDetails.StatusID = "2";


						ReceiveContext result =await AppDelegate.Current.pqrsMgr.UpdatePatintProcedureInfo (procedureDetails);
						if (result != null && result.result != null && result.status != null && result.status.ToUpper () == "OK") {	
							if (ProcID == 0) {
								if (result != null && result.result != null && result.status != null && result.status.ToUpper () == "OK")
									procedureDetails = (PatientProcedureFullDetails)JsonConvert.DeserializeObject (result.result.ToString (), typeof(PatientProcedureFullDetails));


								lblProcID.Text = "Proc ID: " + procedureDetails.ID;
							}
						}
						else
							NavigationController.PopToRootViewController(true);

						if (string.IsNullOrEmpty (result.message) && result.status != null && result.status.ToUpper ().Trim () == "OK") {
							//					AppDelegate.pb.Stop();
							Console.WriteLine ("Patient Procedure Info. Successfully Saved.");	
							//					new UIAlertView("Patient Procedure Info", "Successfully Saved."
							//						, null, "ok", null).Show();


							if (this.procedureDetails.StatusID == "0" || this.procedureDetails.StatusID == "1")
								tctSurgeryDate.Enabled = true;

							if (this.procedureDetails.StatusID == "2" || this.procedureDetails.StatusID == "3")
								tctSurgeryDate.Enabled = false;


							if (this.procedureDetails.StatusID == "3") {
								btnSubmit.SetTitle ("Unlock", UIControlState.Normal);
								btnSubmit.BackgroundColor = UIColor.Gray;
								uvPatientInfo.UserInteractionEnabled = false;
								uvBillingInfo.UserInteractionEnabled = false;
								//uvDynamicQualityMetrics.UserInteractionEnabled = false;
								//svQualityMetrics.UserInteractionEnabled = false;
								Setenableanddiablelbl(false);
							}


							if (this.procedureDetails.StatusID == "2" || this.procedureDetails.StatusID == "1") {
								btnSubmit.SetTitle (" Finalize", UIControlState.Normal);

								uvPatientInfo.UserInteractionEnabled = true;
								string format = "MM/dd/yyyy"; 
								DateTime dt = DateTime.ParseExact(tctSurgeryDate.Text, format,System.Globalization.CultureInfo.CurrentCulture);
								if (DateTime.Now.Date < dt) {
									uvBillingInfo.UserInteractionEnabled = false;
									uvQualityMetrics.UserInteractionEnabled = false;
								} else {
									uvBillingInfo.UserInteractionEnabled = true;
									uvQualityMetrics.UserInteractionEnabled = true;
								}
							}

							//If the Billing Info and Quality Metrics are disabled, enable them after procedure creation
							sCtab.SetEnabled (true, 1);
							sCtab.SetEnabled (true, 2);
						} else {
							NavigationController.PopToRootViewController(true);
							//					AppDelegate.pb.Stop();
							Console.WriteLine ("Patient Procedure Info. Save failed.");	
							//					new UIAlertView("Procedure eroor", result.message
							//						, null, "ok", null).Show();
						}
					} else {
						new UIAlertView ("Patient Info", "Please Update Patient Info"
							, null, "ok", null).Show ();
					}
					if (this.procedureDetails.StatusID == "3") {
						NavigationController.PopViewController(true);
					}
					boolresult= true;
					}
				};
			}
			return boolresult;
			
		}
コード例 #6
0
		public AddPatientViewController (Patient patientProfile,PatientProcedureFullDetails procedureDetails) : base ("AddPatientViewController", null)
		{
			this.procedureDetails = procedureDetails;
			this.patientProfile=patientProfile;
		}
コード例 #7
0
		public async void ValidateAndUpdateProcedure(string paramname, string paramvalue)
		{
			if (patientProfile != null && patientProfile.ID != 0) {
//				AppDelegate.pb.Start(this.View,"Updating ...");
				int ProcID;
				string Mrn;
				string PatientID;
				if (procedureDetails == null) {
					procedureDetails = new PatientProcedureFullDetails ();
					ProcID = 0;
					Mrn = patientProfile.MRN;
					PatientID = patientProfile.ID.ToString ();	
				} else {
					ProcID = procedureDetails.ID;
					Mrn = procedureDetails.Mrn;
					PatientID = procedureDetails.PatientID;	
				}
				procedureDetails.ID = ProcID;
				procedureDetails.Mrn = patientProfile.MRN;
				procedureDetails.PatientID = patientProfile.ID.ToString();						
				if (paramname == "EncounterType")
					procedureDetails.ddlEncounterType = paramvalue;
				else if (paramname == "PhysicalStatus")
					procedureDetails.ddlASAType = paramvalue;
				else if (paramname == "Emergency")
					procedureDetails.cbEmergency = paramvalue;

				ReceiveContext result = await AppDelegate.Current.pqrsMgr.UpdatePatintProcedureInfo (procedureDetails);
				if (ProcID == 0) {
					if(result != null && result.result != null )
						procedureDetails = (PatientProcedureFullDetails)JsonConvert.DeserializeObject (result.result.ToString (), typeof(PatientProcedureFullDetails));
					
					lblProcID.Text = "Proc ID: " + procedureDetails.ID;
				}

				if(string.IsNullOrEmpty(result.message) &&  result.status!=null && result.status.ToUpper().Trim() == "OK" ){
//					AppDelegate.pb.Stop();
					Console.WriteLine("Patient Procedure Info. Successfully Saved.");	
//					new UIAlertView("Patient Procedure Info", "Successfully Saved."
//						, null, "ok", null).Show();

					if (this.procedureDetails.StatusID == "3") {
						btnSubmit.SetTitle ("UnSubmit", UIControlState.Normal);
						uvPatientInfo.UserInteractionEnabled = false;
						uvBillingInfo.UserInteractionEnabled = false;
						uvQualityMetrics.UserInteractionEnabled = false;
					}
						

					if (this.procedureDetails.StatusID == "2" || this.procedureDetails.StatusID == "1") {
						btnSubmit.SetTitle ("Submit", UIControlState.Normal);
						uvPatientInfo.UserInteractionEnabled = true;
						uvBillingInfo.UserInteractionEnabled = true;
						uvQualityMetrics.UserInteractionEnabled = true;
					}

				}else
				{
//					AppDelegate.pb.Stop();
					Console.WriteLine("Patient Procedure Info. Save failed.");	
//					new UIAlertView("Procedure eroor", result.message
//						, null, "ok", null).Show();
				}
			} else {
				new UIAlertView("Patient Info", "Please Update Patient Info"
					, null, "ok", null).Show();
			}
		}
コード例 #8
0
		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.
		}