package shub.dpm;


import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;

public class appmain extends Activity implements B4AActivity{
	public static appmain mostCurrent;
	static boolean afterFirstLayout;
	static boolean isFirst = true;
    private static boolean processGlobalsRun = false;
	BALayout layout;
	public static BA processBA;
	BA activityBA;
    ActivityWrapper _activity;
    java.util.ArrayList<B4AMenuItem> menuItems;
	public static final boolean fullScreen = false;
	public static final boolean includeTitle = true;
    public static WeakReference<Activity> previousOne;
    public static boolean dontPause;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        mostCurrent = this;
		if (processBA == null) {
			processBA = new anywheresoftware.b4a.ShellBA(this.getApplicationContext(), null, null, "shub.dpm", "shub.dpm.appmain");
			processBA.loadHtSubs(this.getClass());
	        float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
	        BALayout.setDeviceScale(deviceScale);
            
		}
		else if (previousOne != null) {
			Activity p = previousOne.get();
			if (p != null && p != this) {
                BA.LogInfo("Killing previous instance (appmain).");
				p.finish();
			}
		}
        processBA.setActivityPaused(true);
        processBA.runHook("oncreate", this, null);
		if (!includeTitle) {
        	this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
        }
        if (fullScreen) {
        	getWindow().setFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,   
        			android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
		
        processBA.sharedProcessBA.activityBA = null;
		layout = new BALayout(this);
		setContentView(layout);
		afterFirstLayout = false;
        WaitForLayout wl = new WaitForLayout();
        if (anywheresoftware.b4a.objects.ServiceHelper.StarterHelper.startFromActivity(this, processBA, wl, false))
		    BA.handler.postDelayed(wl, 5);

	}
	static class WaitForLayout implements Runnable {
		public void run() {
			if (afterFirstLayout)
				return;
			if (mostCurrent == null)
				return;
            
			if (mostCurrent.layout.getWidth() == 0) {
				BA.handler.postDelayed(this, 5);
				return;
			}
			mostCurrent.layout.getLayoutParams().height = mostCurrent.layout.getHeight();
			mostCurrent.layout.getLayoutParams().width = mostCurrent.layout.getWidth();
			afterFirstLayout = true;
			mostCurrent.afterFirstLayout();
		}
	}
	private void afterFirstLayout() {
        if (this != mostCurrent)
			return;
		activityBA = new BA(this, layout, processBA, "shub.dpm", "shub.dpm.appmain");
        
        processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
        anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
        _activity = new ActivityWrapper(activityBA, "activity");
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (BA.isShellModeRuntimeCheck(processBA)) {
			if (isFirst)
				processBA.raiseEvent2(null, true, "SHELL", false);
			processBA.raiseEvent2(null, true, "CREATE", true, "shub.dpm.appmain", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (appmain) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (appmain) Resume **");
        processBA.raiseEvent(null, "activity_resume");
        if (android.os.Build.VERSION.SDK_INT >= 11) {
			try {
				android.app.Activity.class.getMethod("invalidateOptionsMenu").invoke(this,(Object[]) null);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}
	public void addMenuItem(B4AMenuItem item) {
		if (menuItems == null)
			menuItems = new java.util.ArrayList<B4AMenuItem>();
		menuItems.add(item);
	}
	@Override
	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		super.onCreateOptionsMenu(menu);
        try {
            if (processBA.subExists("activity_actionbarhomeclick")) {
                Class.forName("android.app.ActionBar").getMethod("setHomeButtonEnabled", boolean.class).invoke(
                    getClass().getMethod("getActionBar").invoke(this), true);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (processBA.runHook("oncreateoptionsmenu", this, new Object[] {menu}))
            return true;
		if (menuItems == null)
			return false;
		for (B4AMenuItem bmi : menuItems) {
			android.view.MenuItem mi = menu.add(bmi.title);
			if (bmi.drawable != null)
				mi.setIcon(bmi.drawable);
            if (android.os.Build.VERSION.SDK_INT >= 11) {
				try {
                    if (bmi.addToBar) {
				        android.view.MenuItem.class.getMethod("setShowAsAction", int.class).invoke(mi, 1);
                    }
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			mi.setOnMenuItemClickListener(new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
		}
        
		return true;
	}   
 @Override
 public boolean onOptionsItemSelected(android.view.MenuItem item) {
    if (item.getItemId() == 16908332) {
        processBA.raiseEvent(null, "activity_actionbarhomeclick");
        return true;
    }
    else
        return super.onOptionsItemSelected(item); 
}
@Override
 public boolean onPrepareOptionsMenu(android.view.Menu menu) {
    super.onPrepareOptionsMenu(menu);
    processBA.runHook("onprepareoptionsmenu", this, new Object[] {menu});
    return true;
    
 }
 protected void onStart() {
    super.onStart();
    processBA.runHook("onstart", this, null);
}
 protected void onStop() {
    super.onStop();
    processBA.runHook("onstop", this, null);
}
    public void onWindowFocusChanged(boolean hasFocus) {
       super.onWindowFocusChanged(hasFocus);
       if (processBA.subExists("activity_windowfocuschanged"))
           processBA.raiseEvent2(null, true, "activity_windowfocuschanged", false, hasFocus);
    }
	private class B4AMenuItemsClickListener implements android.view.MenuItem.OnMenuItemClickListener {
		private final String eventName;
		public B4AMenuItemsClickListener(String eventName) {
			this.eventName = eventName;
		}
		public boolean onMenuItemClick(android.view.MenuItem item) {
			processBA.raiseEventFromUI(item.getTitle(), eventName + "_click");
			return true;
		}
	}
    public static Class<?> getObject() {
		return appmain.class;
	}
    private Boolean onKeySubExist = null;
    private Boolean onKeyUpSubExist = null;
	@Override
	public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeydown", this, new Object[] {keyCode, event}))
            return true;
		if (onKeySubExist == null)
			onKeySubExist = processBA.subExists("activity_keypress");
		if (onKeySubExist) {
			if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK &&
					android.os.Build.VERSION.SDK_INT >= 18) {
				HandleKeyDelayed hk = new HandleKeyDelayed();
				hk.kc = keyCode;
				BA.handler.post(hk);
				return true;
			}
			else {
				boolean res = new HandleKeyDelayed().runDirectly(keyCode);
				if (res)
					return true;
			}
		}
		return super.onKeyDown(keyCode, event);
	}
	private class HandleKeyDelayed implements Runnable {
		int kc;
		public void run() {
			runDirectly(kc);
		}
		public boolean runDirectly(int keyCode) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keypress", false, keyCode);
			if (res == null || res == true) {
                return true;
            }
            else if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK) {
				finish();
				return true;
			}
            return false;
		}
		
	}
    @Override
	public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeyup", this, new Object[] {keyCode, event}))
            return true;
		if (onKeyUpSubExist == null)
			onKeyUpSubExist = processBA.subExists("activity_keyup");
		if (onKeyUpSubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyUp(keyCode, event);
	}
	@Override
	public void onNewIntent(android.content.Intent intent) {
        super.onNewIntent(intent);
		this.setIntent(intent);
        processBA.runHook("onnewintent", this, new Object[] {intent});
	}
    @Override 
	public void onPause() {
		super.onPause();
        if (_activity == null)
            return;
        if (this != mostCurrent)
			return;
		anywheresoftware.b4a.Msgbox.dismiss(true);
        if (!dontPause)
            BA.LogInfo("** Activity (appmain) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        else
            BA.LogInfo("** Activity (appmain) Pause event (activity is not paused). **");
        if (mostCurrent != null)
            processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());		
        if (!dontPause) {
            processBA.setActivityPaused(true);
            mostCurrent = null;
        }

        if (!activityBA.activity.isFinishing())
			previousOne = new WeakReference<Activity>(this);
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        processBA.runHook("onpause", this, null);
	}

	@Override
	public void onDestroy() {
        super.onDestroy();
		previousOne = null;
        processBA.runHook("ondestroy", this, null);
	}
    @Override 
	public void onResume() {
		super.onResume();
        mostCurrent = this;
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (activityBA != null) { //will be null during activity create (which waits for AfterLayout).
        	ResumeMessage rm = new ResumeMessage(mostCurrent);
        	BA.handler.post(rm);
        }
        processBA.runHook("onresume", this, null);
	}
    private static class ResumeMessage implements Runnable {
    	private final WeakReference<Activity> activity;
    	public ResumeMessage(Activity activity) {
    		this.activity = new WeakReference<Activity>(activity);
    	}
		public void run() {
            appmain mc = mostCurrent;
			if (mc == null || mc != activity.get())
				return;
			processBA.setActivityPaused(false);
            BA.LogInfo("** Activity (appmain) Resume **");
            if (mc != mostCurrent)
                return;
		    processBA.raiseEvent(mc._activity, "activity_resume", (Object[])null);
		}
    }
	@Override
	protected void onActivityResult(int requestCode, int resultCode,
	      android.content.Intent data) {
		processBA.onActivityResult(requestCode, resultCode, data);
        processBA.runHook("onactivityresult", this, new Object[] {requestCode, resultCode});
	}
	private static void initializeGlobals() {
		processBA.raiseEvent2(null, true, "globals", false, (Object[])null);
	}
    public void onRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
        for (int i = 0;i < permissions.length;i++) {
            Object[] o = new Object[] {permissions[i], grantResults[i] == 0};
            processBA.raiseEventFromDifferentThread(null,null, 0, "activity_permissionresult", true, o);
        }
            
    }



public static void initializeProcessGlobals() {
             try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
}
public anywheresoftware.b4a.keywords.Common __c = null;
public static String _patid = "";
public static String _surl = "";
public billwrapper.billWrapper _bs1 = null;
public anywheresoftware.b4a.objects.ButtonWrapper _button1 = null;
public anywheresoftware.b4a.objects.ButtonWrapper _button2 = null;
public static String _jobname = "";
public static String _patname = "";
public anywheresoftware.b4a.objects.EditTextWrapper _txtpatnr = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlenterpatid = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblpatient = null;
public static long _timeout = 0L;
public static long _dtnow = 0L;
public anywheresoftware.b4a.objects.ButtonWrapper _btnsearchpat = null;
public anywheresoftware.b4a.objects.Timer _pattimer = null;
public anywheresoftware.b4a.objects.Timer _starttimer = null;
public b4a.example.dateutils _dateutils = null;
public shub.dpm.main _main = null;
public shub.dpm.listdata _listdata = null;
public shub.dpm.param _param = null;
public shub.dpm.starter _starter = null;
public shub.dpm.tempdata _tempdata = null;
public shub.dpm.about _about = null;
public shub.dpm.httputils2service _httputils2service = null;
public shub.dpm.xuiviewsutils _xuiviewsutils = null;
public static String  _activity_create(boolean _firsttime) throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_create", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "activity_create", new Object[] {_firsttime}));}
RDebugUtils.currentLine=3080192;
 //BA.debugLineNum = 3080192;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
RDebugUtils.currentLine=3080194;
 //BA.debugLineNum = 3080194;BA.debugLine="Activity.AddMenuItem(\"Parameter\",\"bt1\")";
mostCurrent._activity.AddMenuItem(BA.ObjectToCharSequence("Parameter"),"bt1");
RDebugUtils.currentLine=3080195;
 //BA.debugLineNum = 3080195;BA.debugLine="Activity.AddMenuItem(\"Über...\",\"bt2\")";
mostCurrent._activity.AddMenuItem(BA.ObjectToCharSequence("Über..."),"bt2");
RDebugUtils.currentLine=3080197;
 //BA.debugLineNum = 3080197;BA.debugLine="Activity.LoadLayout(\"main\")";
mostCurrent._activity.LoadLayout("main",mostCurrent.activityBA);
RDebugUtils.currentLine=3080198;
 //BA.debugLineNum = 3080198;BA.debugLine="Activity.Title=\"DPM - Charge Scanner\"";
mostCurrent._activity.setTitle(BA.ObjectToCharSequence("DPM - Charge Scanner"));
RDebugUtils.currentLine=3080199;
 //BA.debugLineNum = 3080199;BA.debugLine="bs1.ScanMode = bs1.FORMAT_ONE_D";
mostCurrent._bs1.setScanMode(mostCurrent._bs1.FORMAT_ONE_D);
RDebugUtils.currentLine=3080200;
 //BA.debugLineNum = 3080200;BA.debugLine="PatID=0";
_patid = BA.NumberToString(0);
RDebugUtils.currentLine=3080201;
 //BA.debugLineNum = 3080201;BA.debugLine="If File.Exists(File.DirInternal ,\"DPM.ini\") = Tru";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"DPM.ini")==anywheresoftware.b4a.keywords.Common.True) { 
RDebugUtils.currentLine=3080202;
 //BA.debugLineNum = 3080202;BA.debugLine="Get_Params";
_get_params();
 }else {
 };
RDebugUtils.currentLine=3080206;
 //BA.debugLineNum = 3080206;BA.debugLine="PatTimer.Initialize(\"timer\",timeout)";
mostCurrent._pattimer.Initialize(processBA,"timer",_timeout);
RDebugUtils.currentLine=3080207;
 //BA.debugLineNum = 3080207;BA.debugLine="If TempData.pid<>\"\" Then";
if ((mostCurrent._tempdata._pid /*String*/ ).equals("") == false) { 
RDebugUtils.currentLine=3080208;
 //BA.debugLineNum = 3080208;BA.debugLine="get_Pat(TempData.pid)";
_get_pat(mostCurrent._tempdata._pid /*String*/ );
RDebugUtils.currentLine=3080209;
 //BA.debugLineNum = 3080209;BA.debugLine="TempData.pid=\"\"";
mostCurrent._tempdata._pid /*String*/  = "";
 };
RDebugUtils.currentLine=3080211;
 //BA.debugLineNum = 3080211;BA.debugLine="End Sub";
return "";
}
public static String  _get_params() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "get_params", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "get_params", null));}
anywheresoftware.b4a.objects.streams.File.TextReaderWrapper _tr = null;
anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _inp = null;
RDebugUtils.currentLine=3342336;
 //BA.debugLineNum = 3342336;BA.debugLine="Sub Get_Params";
RDebugUtils.currentLine=3342337;
 //BA.debugLineNum = 3342337;BA.debugLine="Dim TR As TextReader";
_tr = new anywheresoftware.b4a.objects.streams.File.TextReaderWrapper();
RDebugUtils.currentLine=3342338;
 //BA.debugLineNum = 3342338;BA.debugLine="Dim inp As InputStream";
_inp = new anywheresoftware.b4a.objects.streams.File.InputStreamWrapper();
RDebugUtils.currentLine=3342339;
 //BA.debugLineNum = 3342339;BA.debugLine="inp=File.OpenInput(File.DirInternal , \"DPM.ini\")";
_inp = anywheresoftware.b4a.keywords.Common.File.OpenInput(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"DPM.ini");
RDebugUtils.currentLine=3342340;
 //BA.debugLineNum = 3342340;BA.debugLine="TR.Initialize(inp)";
_tr.Initialize((java.io.InputStream)(_inp.getObject()));
RDebugUtils.currentLine=3342341;
 //BA.debugLineNum = 3342341;BA.debugLine="Try";
try {RDebugUtils.currentLine=3342342;
 //BA.debugLineNum = 3342342;BA.debugLine="sURL=TR.Readline";
_surl = _tr.ReadLine();
 } 
       catch (Exception e8) {
			processBA.setLastException(e8);RDebugUtils.currentLine=3342344;
 //BA.debugLineNum = 3342344;BA.debugLine="sURL=\"\"";
_surl = "";
 };
RDebugUtils.currentLine=3342346;
 //BA.debugLineNum = 3342346;BA.debugLine="Try";
try {RDebugUtils.currentLine=3342347;
 //BA.debugLineNum = 3342347;BA.debugLine="timeout = TR.ReadLine";
_timeout = (long)(Double.parseDouble(_tr.ReadLine()));
 } 
       catch (Exception e13) {
			processBA.setLastException(e13);RDebugUtils.currentLine=3342350;
 //BA.debugLineNum = 3342350;BA.debugLine="timeout=30000";
_timeout = (long) (30000);
 };
RDebugUtils.currentLine=3342353;
 //BA.debugLineNum = 3342353;BA.debugLine="TR.Close";
_tr.Close();
RDebugUtils.currentLine=3342354;
 //BA.debugLineNum = 3342354;BA.debugLine="End Sub";
return "";
}
public static String  _get_pat(String _id) throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "get_pat", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "get_pat", new Object[] {_id}));}
shub.dpm.httpjob _job = null;
String _callurl = "";
RDebugUtils.currentLine=3604480;
 //BA.debugLineNum = 3604480;BA.debugLine="Sub get_Pat(id As String)";
RDebugUtils.currentLine=3604481;
 //BA.debugLineNum = 3604481;BA.debugLine="Dim job As HttpJob";
_job = new shub.dpm.httpjob();
RDebugUtils.currentLine=3604482;
 //BA.debugLineNum = 3604482;BA.debugLine="JobName=\"GetPat\"";
mostCurrent._jobname = "GetPat";
RDebugUtils.currentLine=3604483;
 //BA.debugLineNum = 3604483;BA.debugLine="job.Initialize(JobName, Me)";
_job._initialize /*String*/ (null,processBA,mostCurrent._jobname,appmain.getObject());
RDebugUtils.currentLine=3604485;
 //BA.debugLineNum = 3604485;BA.debugLine="Dim callurl As String";
_callurl = "";
RDebugUtils.currentLine=3604486;
 //BA.debugLineNum = 3604486;BA.debugLine="callurl=sURL&\"/DPMService/api/Service_View_Pat/\"&";
_callurl = _surl+"/DPMService/api/Service_View_Pat/"+_id;
RDebugUtils.currentLine=3604487;
 //BA.debugLineNum = 3604487;BA.debugLine="job.Download(callurl)";
_job._download /*String*/ (null,_callurl);
RDebugUtils.currentLine=3604490;
 //BA.debugLineNum = 3604490;BA.debugLine="End Sub";
return "";
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
RDebugUtils.currentModule="appmain";
RDebugUtils.currentLine=3211264;
 //BA.debugLineNum = 3211264;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
RDebugUtils.currentLine=3211266;
 //BA.debugLineNum = 3211266;BA.debugLine="Try";
try {RDebugUtils.currentLine=3211267;
 //BA.debugLineNum = 3211267;BA.debugLine="bs1.stopScanning";
mostCurrent._bs1.stopScanning();
 } 
       catch (Exception e4) {
			processBA.setLastException(e4); };
RDebugUtils.currentLine=3211270;
 //BA.debugLineNum = 3211270;BA.debugLine="PatID=0";
_patid = BA.NumberToString(0);
RDebugUtils.currentLine=3211271;
 //BA.debugLineNum = 3211271;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_resume", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "activity_resume", null));}
RDebugUtils.currentLine=3145728;
 //BA.debugLineNum = 3145728;BA.debugLine="Sub Activity_Resume";
RDebugUtils.currentLine=3145729;
 //BA.debugLineNum = 3145729;BA.debugLine="If TempData.pid<>\"\" Then PatID=TempData.pid";
if ((mostCurrent._tempdata._pid /*String*/ ).equals("") == false) { 
_patid = mostCurrent._tempdata._pid /*String*/ ;};
RDebugUtils.currentLine=3145730;
 //BA.debugLineNum = 3145730;BA.debugLine="If File.Exists(File.DirInternal ,\"DPM.ini\") = Tru";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"DPM.ini")==anywheresoftware.b4a.keywords.Common.True) { 
RDebugUtils.currentLine=3145731;
 //BA.debugLineNum = 3145731;BA.debugLine="Get_Params";
_get_params();
RDebugUtils.currentLine=3145732;
 //BA.debugLineNum = 3145732;BA.debugLine="PatTimer.Enabled=False";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=3145733;
 //BA.debugLineNum = 3145733;BA.debugLine="PatTimer.Initialize(\"timer\",timeout)";
mostCurrent._pattimer.Initialize(processBA,"timer",_timeout);
RDebugUtils.currentLine=3145734;
 //BA.debugLineNum = 3145734;BA.debugLine="PatTimer.Enabled=True";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 };
RDebugUtils.currentLine=3145736;
 //BA.debugLineNum = 3145736;BA.debugLine="End Sub";
return "";
}
public static String  _bs1_scan_value(String _val,byte[] _rawbyte,int _barcodetype) throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "bs1_scan_value", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "bs1_scan_value", new Object[] {_val,_rawbyte,_barcodetype}));}
shub.dpm.httpjob _job = null;
anywheresoftware.b4a.audio.Beeper _b = null;
RDebugUtils.currentLine=3407872;
 //BA.debugLineNum = 3407872;BA.debugLine="Sub bs1_scan_value(val As String, rawbyte() As Byt";
RDebugUtils.currentLine=3407877;
 //BA.debugLineNum = 3407877;BA.debugLine="If DateDiff(\"ss\",dtnow,DateTime.Now)<2 Then Retur";
if ((double)(Double.parseDouble(_datediff("ss",BA.NumberToString(_dtnow),BA.NumberToString(anywheresoftware.b4a.keywords.Common.DateTime.getNow()))))<2) { 
if (true) return "";};
RDebugUtils.currentLine=3407878;
 //BA.debugLineNum = 3407878;BA.debugLine="Dim job As HttpJob";
_job = new shub.dpm.httpjob();
RDebugUtils.currentLine=3407879;
 //BA.debugLineNum = 3407879;BA.debugLine="JobName=\"PostCharche\"";
mostCurrent._jobname = "PostCharche";
RDebugUtils.currentLine=3407880;
 //BA.debugLineNum = 3407880;BA.debugLine="job.Initialize(JobName, Me)";
_job._initialize /*String*/ (null,processBA,mostCurrent._jobname,appmain.getObject());
RDebugUtils.currentLine=3407882;
 //BA.debugLineNum = 3407882;BA.debugLine="dtnow=DateTime.Now";
_dtnow = anywheresoftware.b4a.keywords.Common.DateTime.getNow();
RDebugUtils.currentLine=3407883;
 //BA.debugLineNum = 3407883;BA.debugLine="job.PostString(sURL&\"/DPMService/api/PatCharge/\"&";
_job._poststring /*String*/ (null,_surl+"/DPMService/api/PatCharge/"+_patid+"/"+_val,"");
RDebugUtils.currentLine=3407885;
 //BA.debugLineNum = 3407885;BA.debugLine="Dim b As Beeper";
_b = new anywheresoftware.b4a.audio.Beeper();
RDebugUtils.currentLine=3407886;
 //BA.debugLineNum = 3407886;BA.debugLine="b.Initialize(300, 500) '300 milliseconds, 500 hz";
_b.Initialize((int) (300),(int) (500));
RDebugUtils.currentLine=3407888;
 //BA.debugLineNum = 3407888;BA.debugLine="PatTimer.Enabled=True";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=3407890;
 //BA.debugLineNum = 3407890;BA.debugLine="End Sub";
return "";
}
public static String  _datediff(String _units,String _date1,String _date2) throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "datediff", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "datediff", new Object[] {_units,_date1,_date2}));}
long _x = 0L;
long _y = 0L;
long _z = 0L;
RDebugUtils.currentLine=27721728;
 //BA.debugLineNum = 27721728;BA.debugLine="Sub DateDiff (units, date1, date2)";
RDebugUtils.currentLine=27721729;
 //BA.debugLineNum = 27721729;BA.debugLine="Try";
try {RDebugUtils.currentLine=27721730;
 //BA.debugLineNum = 27721730;BA.debugLine="Dim x As Long";
_x = 0L;
RDebugUtils.currentLine=27721731;
 //BA.debugLineNum = 27721731;BA.debugLine="Dim y As Long";
_y = 0L;
RDebugUtils.currentLine=27721732;
 //BA.debugLineNum = 27721732;BA.debugLine="Dim z As Long";
_z = 0L;
RDebugUtils.currentLine=27721733;
 //BA.debugLineNum = 27721733;BA.debugLine="x=DateTime.DateParse(date1)";
_x = anywheresoftware.b4a.keywords.Common.DateTime.DateParse(_date1);
RDebugUtils.currentLine=27721734;
 //BA.debugLineNum = 27721734;BA.debugLine="y=DateTime.DateParse(date2)";
_y = anywheresoftware.b4a.keywords.Common.DateTime.DateParse(_date2);
RDebugUtils.currentLine=27721735;
 //BA.debugLineNum = 27721735;BA.debugLine="Select units";
switch (BA.switchObjectToInt(_units,"ss")) {
case 0: {
RDebugUtils.currentLine=27721737;
 //BA.debugLineNum = 27721737;BA.debugLine="z=60";
_z = (long) (60);
 break; }
}
;
RDebugUtils.currentLine=27721740;
 //BA.debugLineNum = 27721740;BA.debugLine="Return (y-x) / z";
if (true) return BA.NumberToString((_y-_x)/(double)_z);
 } 
       catch (Exception e13) {
			processBA.setLastException(e13);RDebugUtils.currentLine=27721742;
 //BA.debugLineNum = 27721742;BA.debugLine="Return 10";
if (true) return BA.NumberToString(10);
 };
RDebugUtils.currentLine=27721746;
 //BA.debugLineNum = 27721746;BA.debugLine="End Sub";
return "";
}
public static String  _bt1_click() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "bt1_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "bt1_click", null));}
RDebugUtils.currentLine=3932160;
 //BA.debugLineNum = 3932160;BA.debugLine="Sub bt1_Click";
RDebugUtils.currentLine=3932161;
 //BA.debugLineNum = 3932161;BA.debugLine="StartActivity(\"Param\")";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)("Param"));
RDebugUtils.currentLine=3932162;
 //BA.debugLineNum = 3932162;BA.debugLine="End Sub";
return "";
}
public static String  _bt2_click() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "bt2_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "bt2_click", null));}
RDebugUtils.currentLine=3997696;
 //BA.debugLineNum = 3997696;BA.debugLine="Sub bt2_click";
RDebugUtils.currentLine=3997697;
 //BA.debugLineNum = 3997697;BA.debugLine="StartActivity(\"About\")";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)("About"));
RDebugUtils.currentLine=3997698;
 //BA.debugLineNum = 3997698;BA.debugLine="End Sub";
return "";
}
public static String  _btnenterpatid_click() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btnenterpatid_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btnenterpatid_click", null));}
RDebugUtils.currentLine=3801088;
 //BA.debugLineNum = 3801088;BA.debugLine="Private Sub btnEnterPatID_Click";
RDebugUtils.currentLine=3801089;
 //BA.debugLineNum = 3801089;BA.debugLine="txtPatNr.ForceDoneButton=True";
mostCurrent._txtpatnr.setForceDoneButton(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=3801090;
 //BA.debugLineNum = 3801090;BA.debugLine="pnlEnterPatID.Visible=True";
mostCurrent._pnlenterpatid.setVisible(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=3801091;
 //BA.debugLineNum = 3801091;BA.debugLine="txtPatNr.Text=\"\"";
mostCurrent._txtpatnr.setText(BA.ObjectToCharSequence(""));
RDebugUtils.currentLine=3801092;
 //BA.debugLineNum = 3801092;BA.debugLine="txtPatNr.RequestFocus";
mostCurrent._txtpatnr.RequestFocus();
RDebugUtils.currentLine=3801093;
 //BA.debugLineNum = 3801093;BA.debugLine="End Sub";
return "";
}
public static String  _btnlistdata_click() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btnlistdata_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btnlistdata_click", null));}
RDebugUtils.currentLine=4063232;
 //BA.debugLineNum = 4063232;BA.debugLine="Private Sub btnListdata_Click";
RDebugUtils.currentLine=4063236;
 //BA.debugLineNum = 4063236;BA.debugLine="ListData.PatID=PatID";
mostCurrent._listdata._patid /*String*/  = _patid;
RDebugUtils.currentLine=4063237;
 //BA.debugLineNum = 4063237;BA.debugLine="TempData.pid=PatID";
mostCurrent._tempdata._pid /*String*/  = _patid;
RDebugUtils.currentLine=4063238;
 //BA.debugLineNum = 4063238;BA.debugLine="TempData.pname=lblPatient.Text";
mostCurrent._tempdata._pname /*String*/  = mostCurrent._lblpatient.getText();
RDebugUtils.currentLine=4063239;
 //BA.debugLineNum = 4063239;BA.debugLine="ListData.sURL=sURL";
mostCurrent._listdata._surl /*String*/  = _surl;
RDebugUtils.currentLine=4063242;
 //BA.debugLineNum = 4063242;BA.debugLine="StartActivity(\"ListData\")";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)("ListData"));
RDebugUtils.currentLine=4063243;
 //BA.debugLineNum = 4063243;BA.debugLine="End Sub";
return "";
}
public static String  _btnsearchpat_click() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btnsearchpat_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btnsearchpat_click", null));}
RDebugUtils.currentLine=3735552;
 //BA.debugLineNum = 3735552;BA.debugLine="Private Sub btnSearchPat_Click";
RDebugUtils.currentLine=3735553;
 //BA.debugLineNum = 3735553;BA.debugLine="PatTimer.Enabled=False";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=3735554;
 //BA.debugLineNum = 3735554;BA.debugLine="get_Pat(txtPatNr.Text)";
_get_pat(mostCurrent._txtpatnr.getText());
RDebugUtils.currentLine=3735555;
 //BA.debugLineNum = 3735555;BA.debugLine="pnlEnterPatID.Visible=False";
mostCurrent._pnlenterpatid.setVisible(anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=3735556;
 //BA.debugLineNum = 3735556;BA.debugLine="btnSearchPat.RequestFocus";
mostCurrent._btnsearchpat.RequestFocus();
RDebugUtils.currentLine=3735557;
 //BA.debugLineNum = 3735557;BA.debugLine="PatTimer.Enabled=True";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=3735558;
 //BA.debugLineNum = 3735558;BA.debugLine="End Sub";
return "";
}
public static String  _button1_click() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "button1_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "button1_click", null));}
RDebugUtils.currentLine=3473408;
 //BA.debugLineNum = 3473408;BA.debugLine="Sub Button1_Click";
RDebugUtils.currentLine=3473409;
 //BA.debugLineNum = 3473409;BA.debugLine="If PatID=0 Then";
if ((_patid).equals(BA.NumberToString(0))) { 
RDebugUtils.currentLine=3473410;
 //BA.debugLineNum = 3473410;BA.debugLine="ToastMessageShow(\"Bitte zuerst Patient wählen\",T";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Bitte zuerst Patient wählen"),anywheresoftware.b4a.keywords.Common.True);
 };
RDebugUtils.currentLine=3473412;
 //BA.debugLineNum = 3473412;BA.debugLine="bs1.startScanning";
mostCurrent._bs1.startScanning();
RDebugUtils.currentLine=3473413;
 //BA.debugLineNum = 3473413;BA.debugLine="PatTimer.Enabled=False";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=3473414;
 //BA.debugLineNum = 3473414;BA.debugLine="End Sub";
return "";
}
public static String  _button2_click() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "button2_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "button2_click", null));}
RDebugUtils.currentLine=3538944;
 //BA.debugLineNum = 3538944;BA.debugLine="Private Sub Button2_Click";
RDebugUtils.currentLine=3538945;
 //BA.debugLineNum = 3538945;BA.debugLine="Try";
try {RDebugUtils.currentLine=3538946;
 //BA.debugLineNum = 3538946;BA.debugLine="bs1.stopScanning";
mostCurrent._bs1.stopScanning();
 } 
       catch (Exception e4) {
			processBA.setLastException(e4); };
RDebugUtils.currentLine=3538949;
 //BA.debugLineNum = 3538949;BA.debugLine="End Sub";
return "";
}
public static String  _jobdone(shub.dpm.httpjob _job) throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "jobdone", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "jobdone", new Object[] {_job}));}
String _res = "";
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
anywheresoftware.b4a.objects.collections.List _list1 = null;
anywheresoftware.b4a.objects.collections.Map _map1 = null;
RDebugUtils.currentLine=3670016;
 //BA.debugLineNum = 3670016;BA.debugLine="Sub JobDone(Job As HttpJob)";
RDebugUtils.currentLine=3670017;
 //BA.debugLineNum = 3670017;BA.debugLine="ProgressDialogHide";
anywheresoftware.b4a.keywords.Common.ProgressDialogHide();
RDebugUtils.currentLine=3670018;
 //BA.debugLineNum = 3670018;BA.debugLine="If Job.Success Then";
if (_job._success /*boolean*/ ) { 
RDebugUtils.currentLine=3670019;
 //BA.debugLineNum = 3670019;BA.debugLine="Dim res As String";
_res = "";
RDebugUtils.currentLine=3670020;
 //BA.debugLineNum = 3670020;BA.debugLine="res = Job.GetString";
_res = _job._getstring /*String*/ (null);
RDebugUtils.currentLine=3670021;
 //BA.debugLineNum = 3670021;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
RDebugUtils.currentLine=3670022;
 //BA.debugLineNum = 3670022;BA.debugLine="parser.Initialize(res)";
_parser.Initialize(_res);
RDebugUtils.currentLine=3670024;
 //BA.debugLineNum = 3670024;BA.debugLine="Log(\"Response from server: \" & res)";
anywheresoftware.b4a.keywords.Common.LogImpl("73670024","Response from server: "+_res,0);
RDebugUtils.currentLine=3670026;
 //BA.debugLineNum = 3670026;BA.debugLine="Select Job.JobName";
switch (BA.switchObjectToInt(_job._jobname /*String*/ ,"GetPat","PostCharche")) {
case 0: {
RDebugUtils.currentLine=3670029;
 //BA.debugLineNum = 3670029;BA.debugLine="Dim list1 As List";
_list1 = new anywheresoftware.b4a.objects.collections.List();
RDebugUtils.currentLine=3670030;
 //BA.debugLineNum = 3670030;BA.debugLine="list1 = parser.NextArray";
_list1 = _parser.NextArray();
RDebugUtils.currentLine=3670031;
 //BA.debugLineNum = 3670031;BA.debugLine="If list1.Size<1 Then";
if (_list1.getSize()<1) { 
RDebugUtils.currentLine=3670032;
 //BA.debugLineNum = 3670032;BA.debugLine="ToastMessageShow(\"Patient nicht vorhanden.\",T";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Patient nicht vorhanden."),anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=3670033;
 //BA.debugLineNum = 3670033;BA.debugLine="pnlEnterPatID.Visible=True";
mostCurrent._pnlenterpatid.setVisible(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=3670034;
 //BA.debugLineNum = 3670034;BA.debugLine="Return";
if (true) return "";
 };
RDebugUtils.currentLine=3670036;
 //BA.debugLineNum = 3670036;BA.debugLine="Dim map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
RDebugUtils.currentLine=3670037;
 //BA.debugLineNum = 3670037;BA.debugLine="map1 = list1.Get(0)";
_map1 = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(_list1.Get((int) (0))));
RDebugUtils.currentLine=3670038;
 //BA.debugLineNum = 3670038;BA.debugLine="Log(map1)";
anywheresoftware.b4a.keywords.Common.LogImpl("73670038",BA.ObjectToString(_map1),0);
RDebugUtils.currentLine=3670040;
 //BA.debugLineNum = 3670040;BA.debugLine="PatID = map1.Get(\"id\")";
_patid = BA.ObjectToString(_map1.Get((Object)("id")));
RDebugUtils.currentLine=3670041;
 //BA.debugLineNum = 3670041;BA.debugLine="PatName=map1.Get(\"pat\")";
mostCurrent._patname = BA.ObjectToString(_map1.Get((Object)("pat")));
RDebugUtils.currentLine=3670042;
 //BA.debugLineNum = 3670042;BA.debugLine="lblPatient.Text=PatName";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence(mostCurrent._patname));
 break; }
case 1: {
RDebugUtils.currentLine=3670044;
 //BA.debugLineNum = 3670044;BA.debugLine="ToastMessageShow(\"Barcode erfolgreich gespeich";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Barcode erfolgreich gespeichert"),anywheresoftware.b4a.keywords.Common.False);
 break; }
}
;
 }else {
RDebugUtils.currentLine=3670047;
 //BA.debugLineNum = 3670047;BA.debugLine="ToastMessageShow(\"Funktionsaufruf fehlgeschlagen";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Funktionsaufruf fehlgeschlagen."),anywheresoftware.b4a.keywords.Common.True);
 };
RDebugUtils.currentLine=3670049;
 //BA.debugLineNum = 3670049;BA.debugLine="Job.Release";
_job._release /*String*/ (null);
RDebugUtils.currentLine=3670050;
 //BA.debugLineNum = 3670050;BA.debugLine="End Sub";
return "";
}
public static String  _lblpatient_longclick() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "lblpatient_longclick", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "lblpatient_longclick", null));}
RDebugUtils.currentLine=3866624;
 //BA.debugLineNum = 3866624;BA.debugLine="Private Sub lblPatient_LongClick";
RDebugUtils.currentLine=3866625;
 //BA.debugLineNum = 3866625;BA.debugLine="StartActivity(\"Param\")";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)("Param"));
RDebugUtils.currentLine=3866626;
 //BA.debugLineNum = 3866626;BA.debugLine="End Sub";
return "";
}
public static String  _timer_tick() throws Exception{
RDebugUtils.currentModule="appmain";
if (Debug.shouldDelegate(mostCurrent.activityBA, "timer_tick", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "timer_tick", null));}
RDebugUtils.currentLine=3276800;
 //BA.debugLineNum = 3276800;BA.debugLine="Sub Timer_Tick";
RDebugUtils.currentLine=3276801;
 //BA.debugLineNum = 3276801;BA.debugLine="PatID=0";
_patid = BA.NumberToString(0);
RDebugUtils.currentLine=3276802;
 //BA.debugLineNum = 3276802;BA.debugLine="lblPatient.Text=\"Bitte Patient auswählen\"";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence("Bitte Patient auswählen"));
RDebugUtils.currentLine=3276803;
 //BA.debugLineNum = 3276803;BA.debugLine="End Sub";
return "";
}
}