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 barcodescanner extends Activity implements B4AActivity{
	public static barcodescanner 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 BA(this.getApplicationContext(), null, null, "shub.dpm", "shub.dpm.barcodescanner");
			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 (barcodescanner).");
				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.barcodescanner");
        
        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.barcodescanner", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (barcodescanner) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (barcodescanner) 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 barcodescanner.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 (barcodescanner) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        else
            BA.LogInfo("** Activity (barcodescanner) 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() {
            barcodescanner mc = mostCurrent;
			if (mc == null || mc != activity.get())
				return;
			processBA.setActivityPaused(false);
            BA.LogInfo("** Activity (barcodescanner) 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 anywheresoftware.b4a.keywords.Common __c = null;
public billwrapper.billWrapper _bs1 = null;
public anywheresoftware.b4a.objects.Timer _pattimer = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblpatient = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlenterpatid = null;
public anywheresoftware.b4a.objects.EditTextWrapper _txtpatnr = null;
public shub.dpm.main _main = null;
public shub.dpm.parameter _parameter = null;
public shub.dpm.about _about = null;
public shub.dpm.allgfnkt _allgfnkt = null;
public shub.dpm.listdata _listdata = null;
public shub.dpm.starter _starter = null;
public shub.dpm.listpat _listpat = null;
public shub.dpm.b4xpages _b4xpages = null;
public shub.dpm.b4xcollections _b4xcollections = null;
public shub.dpm.httputils2service _httputils2service = null;

public static void initializeProcessGlobals() {
             try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
}
public static String  _activity_create(boolean _firsttime) throws Exception{
 //BA.debugLineNum = 22;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
 //BA.debugLineNum = 24;BA.debugLine="Activity.LoadLayout(\"BarcodeScanner\")";
mostCurrent._activity.LoadLayout("BarcodeScanner",mostCurrent.activityBA);
 //BA.debugLineNum = 25;BA.debugLine="Activity.Title=\"Charge-Scanner\"";
mostCurrent._activity.setTitle(BA.ObjectToCharSequence("Charge-Scanner"));
 //BA.debugLineNum = 28;BA.debugLine="bs1.ScanMode = bs1.FORMAT_ONE_D";
mostCurrent._bs1.setScanMode(mostCurrent._bs1.FORMAT_ONE_D);
 //BA.debugLineNum = 29;BA.debugLine="AllgFnkt.PatID=0";
mostCurrent._allgfnkt._patid /*String*/  = BA.NumberToString(0);
 //BA.debugLineNum = 30;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) { 
 //BA.debugLineNum = 31;BA.debugLine="AllgFnkt.sURL=AllgFnkt.Get_Params(\"URL\")";
mostCurrent._allgfnkt._surl /*String*/  = mostCurrent._allgfnkt._get_params /*String*/ (mostCurrent.activityBA,"URL");
 //BA.debugLineNum = 32;BA.debugLine="AllgFnkt.ResettimerInterval=AllgFnkt.Get_Params(";
mostCurrent._allgfnkt._resettimerinterval /*int*/  = (int)(Double.parseDouble(mostCurrent._allgfnkt._get_params /*String*/ (mostCurrent.activityBA,"TIMER")));
 }else {
 };
 //BA.debugLineNum = 35;BA.debugLine="lblpatient.Text=\"Bitte Patient auswählen\"";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence("Bitte Patient auswählen"));
 //BA.debugLineNum = 36;BA.debugLine="pattimer.Initialize(\"timer\",AllgFnkt.ResettimerIn";
mostCurrent._pattimer.Initialize(processBA,"timer",(long) (mostCurrent._allgfnkt._resettimerinterval /*int*/ ));
 //BA.debugLineNum = 37;BA.debugLine="End Sub";
return "";
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
 //BA.debugLineNum = 52;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 53;BA.debugLine="Try";
try { //BA.debugLineNum = 54;BA.debugLine="bs1.stopScanning";
mostCurrent._bs1.stopScanning();
 } 
       catch (Exception e4) {
			processBA.setLastException(e4); };
 //BA.debugLineNum = 58;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 39;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 41;BA.debugLine="If AllgFnkt.pid<>\"\" Then AllgFnkt.PatID=AllgFnkt.";
if ((mostCurrent._allgfnkt._pid /*String*/ ).equals("") == false) { 
mostCurrent._allgfnkt._patid /*String*/  = mostCurrent._allgfnkt._pid /*String*/ ;};
 //BA.debugLineNum = 43;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) { 
 //BA.debugLineNum = 44;BA.debugLine="AllgFnkt.Get_Params(\"TIMER\")";
mostCurrent._allgfnkt._get_params /*String*/ (mostCurrent.activityBA,"TIMER");
 //BA.debugLineNum = 45;BA.debugLine="pattimer.Enabled=False";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 46;BA.debugLine="pattimer.Initialize(\"timer\",AllgFnkt.ResettimerI";
mostCurrent._pattimer.Initialize(processBA,"timer",(long) (mostCurrent._allgfnkt._resettimerinterval /*int*/ ));
 //BA.debugLineNum = 47;BA.debugLine="pattimer.Enabled=True";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 };
 //BA.debugLineNum = 49;BA.debugLine="If AllgFnkt.PID<>\"\" Then get_Pat(AllgFnkt.PID)";
if ((mostCurrent._allgfnkt._pid /*String*/ ).equals("") == false) { 
_get_pat(mostCurrent._allgfnkt._pid /*String*/ );};
 //BA.debugLineNum = 50;BA.debugLine="End Sub";
return "";
}
public static String  _bs1_scan_value(String _val,byte[] _rawbyte,int _barcodetype) throws Exception{
shub.dpm.httpjob _job = null;
anywheresoftware.b4a.audio.Beeper _b = null;
 //BA.debugLineNum = 88;BA.debugLine="Sub bs1_scan_value(val As String, rawbyte() As Byt";
 //BA.debugLineNum = 89;BA.debugLine="If AllgFnkt.JobEnabled=False Then Return";
if (mostCurrent._allgfnkt._jobenabled /*boolean*/ ==anywheresoftware.b4a.keywords.Common.False) { 
if (true) return "";};
 //BA.debugLineNum = 90;BA.debugLine="AllgFnkt.JobEnabled=False";
mostCurrent._allgfnkt._jobenabled /*boolean*/  = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 91;BA.debugLine="Try";
try { //BA.debugLineNum = 92;BA.debugLine="bs1.stopScanning";
mostCurrent._bs1.stopScanning();
 } 
       catch (Exception e6) {
			processBA.setLastException(e6); };
 //BA.debugLineNum = 96;BA.debugLine="Dim job As HttpJob";
_job = new shub.dpm.httpjob();
 //BA.debugLineNum = 97;BA.debugLine="AllgFnkt.JobName=\"PostCharche\"";
mostCurrent._allgfnkt._jobname /*String*/  = "PostCharche";
 //BA.debugLineNum = 98;BA.debugLine="job.Initialize(AllgFnkt.JobName, Me)";
_job._initialize /*String*/ (processBA,mostCurrent._allgfnkt._jobname /*String*/ ,barcodescanner.getObject());
 //BA.debugLineNum = 100;BA.debugLine="job.PostString(AllgFnkt.sURL&\"/DPMService/api/Pat";
_job._poststring /*String*/ (mostCurrent._allgfnkt._surl /*String*/ +"/DPMService/api/PatCharge/"+mostCurrent._allgfnkt._patid /*String*/ +"/"+_val,"");
 //BA.debugLineNum = 102;BA.debugLine="Dim b As Beeper";
_b = new anywheresoftware.b4a.audio.Beeper();
 //BA.debugLineNum = 103;BA.debugLine="b.Initialize(300, 500) '300 milliseconds, 500 hz";
_b.Initialize((int) (300),(int) (500));
 //BA.debugLineNum = 104;BA.debugLine="b.Beep";
_b.Beep();
 //BA.debugLineNum = 105;BA.debugLine="pattimer.Enabled=True";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 106;BA.debugLine="End Sub";
return "";
}
public static String  _btnenterpatid_click() throws Exception{
anywheresoftware.b4a.agraham.dialogs.InputDialog _inppat = null;
 //BA.debugLineNum = 189;BA.debugLine="Private Sub btnEnterPatID_Click";
 //BA.debugLineNum = 190;BA.debugLine="Dim inppat As InputDialog";
_inppat = new anywheresoftware.b4a.agraham.dialogs.InputDialog();
 //BA.debugLineNum = 191;BA.debugLine="inppat.InputType=inppat.INPUT_TYPE_NUMBERS";
_inppat.setInputType(_inppat.INPUT_TYPE_NUMBERS);
 //BA.debugLineNum = 192;BA.debugLine="If inppat.Show(\"\",\"Patient Nummer eingeben\",\"OK\",";
if (_inppat.Show("","Patient Nummer eingeben","OK","","",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null))==anywheresoftware.b4a.keywords.Common.DialogResponse.CANCEL) { 
if (true) return "";};
 //BA.debugLineNum = 193;BA.debugLine="get_Pat(inppat.Input)";
_get_pat(_inppat.getInput());
 //BA.debugLineNum = 194;BA.debugLine="lblpatient.RequestFocus";
mostCurrent._lblpatient.RequestFocus();
 //BA.debugLineNum = 195;BA.debugLine="End Sub";
return "";
}
public static String  _btnenterpatid_longclick() throws Exception{
anywheresoftware.b4a.agraham.dialogs.InputDialog _inppat = null;
 //BA.debugLineNum = 226;BA.debugLine="Private Sub btnEnterPatID_LongClick";
 //BA.debugLineNum = 227;BA.debugLine="Dim inppat As InputDialog";
_inppat = new anywheresoftware.b4a.agraham.dialogs.InputDialog();
 //BA.debugLineNum = 228;BA.debugLine="inppat.InputType=inppat.INPUT_TYPE_TEXT";
_inppat.setInputType(_inppat.INPUT_TYPE_TEXT);
 //BA.debugLineNum = 229;BA.debugLine="If inppat.Show(\"\",\"Patient Name eingeben\",\"OK\",\"\"";
if (_inppat.Show("","Patient Name eingeben","OK","","",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null))==anywheresoftware.b4a.keywords.Common.DialogResponse.CANCEL) { 
if (true) return "";};
 //BA.debugLineNum = 230;BA.debugLine="get_Pat_Name(inppat.Input)";
_get_pat_name(_inppat.getInput());
 //BA.debugLineNum = 231;BA.debugLine="lblpatient.RequestFocus";
mostCurrent._lblpatient.RequestFocus();
 //BA.debugLineNum = 232;BA.debugLine="End Sub";
return "";
}
public static String  _btnlistdata_click() throws Exception{
 //BA.debugLineNum = 215;BA.debugLine="Private Sub btnListdata_Click";
 //BA.debugLineNum = 216;BA.debugLine="If AllgFnkt.PatID=0 Then";
if ((mostCurrent._allgfnkt._patid /*String*/ ).equals(BA.NumberToString(0))) { 
 //BA.debugLineNum = 217;BA.debugLine="ToastMessageShow(\"Bitte zuerst Patient auswählen";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Bitte zuerst Patient auswählen."),anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 218;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 220;BA.debugLine="AllgFnkt.pid=AllgFnkt.PatID";
mostCurrent._allgfnkt._pid /*String*/  = mostCurrent._allgfnkt._patid /*String*/ ;
 //BA.debugLineNum = 221;BA.debugLine="AllgFnkt.PatName=lblpatient.Text";
mostCurrent._allgfnkt._patname /*String*/  = mostCurrent._lblpatient.getText();
 //BA.debugLineNum = 222;BA.debugLine="StartActivity(\"ListData\")";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)("ListData"));
 //BA.debugLineNum = 224;BA.debugLine="End Sub";
return "";
}
public static String  _btnsearchpat_click() throws Exception{
anywheresoftware.b4a.agraham.dialogs.InputDialog _inppat = null;
 //BA.debugLineNum = 176;BA.debugLine="Private Sub btnSearchPat_Click";
 //BA.debugLineNum = 177;BA.debugLine="Dim inppat As InputDialog";
_inppat = new anywheresoftware.b4a.agraham.dialogs.InputDialog();
 //BA.debugLineNum = 178;BA.debugLine="If inppat.Show(\"Patient-Nr\",\"Patient Nummer einge";
if (_inppat.Show("Patient-Nr","Patient Nummer eingeben","OK","","",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null))==anywheresoftware.b4a.keywords.Common.DialogResponse.CANCEL) { 
if (true) return "";};
 //BA.debugLineNum = 179;BA.debugLine="get_Pat(inppat.Input)";
_get_pat(_inppat.getInput());
 //BA.debugLineNum = 180;BA.debugLine="pattimer.Enabled=False";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 181;BA.debugLine="get_Pat(txtPatNr.Text)";
_get_pat(mostCurrent._txtpatnr.getText());
 //BA.debugLineNum = 184;BA.debugLine="pattimer.Enabled=True";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 185;BA.debugLine="End Sub";
return "";
}
public static String  _btnstartscan_click() throws Exception{
 //BA.debugLineNum = 197;BA.debugLine="Private Sub BtnStartScan_Click";
 //BA.debugLineNum = 198;BA.debugLine="If AllgFnkt.PatID=0 Then";
if ((mostCurrent._allgfnkt._patid /*String*/ ).equals(BA.NumberToString(0))) { 
 //BA.debugLineNum = 199;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);
 //BA.debugLineNum = 200;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 202;BA.debugLine="AllgFnkt.JobEnabled=True";
mostCurrent._allgfnkt._jobenabled /*boolean*/  = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 203;BA.debugLine="bs1.startScanning";
mostCurrent._bs1.startScanning();
 //BA.debugLineNum = 204;BA.debugLine="pattimer.Enabled=False";
mostCurrent._pattimer.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 205;BA.debugLine="End Sub";
return "";
}
public static String  _btnstopscan_click() throws Exception{
 //BA.debugLineNum = 207;BA.debugLine="Private Sub BtnStopScan_Click";
 //BA.debugLineNum = 208;BA.debugLine="Try";
try { //BA.debugLineNum = 209;BA.debugLine="bs1.stopScanning";
mostCurrent._bs1.stopScanning();
 } 
       catch (Exception e4) {
			processBA.setLastException(e4); };
 //BA.debugLineNum = 212;BA.debugLine="Activity.Finish";
mostCurrent._activity.Finish();
 //BA.debugLineNum = 213;BA.debugLine="End Sub";
return "";
}
public static String  _get_pat(String _id) throws Exception{
shub.dpm.httpjob _job = null;
String _callurl = "";
 //BA.debugLineNum = 67;BA.debugLine="Sub get_Pat(id As String)";
 //BA.debugLineNum = 68;BA.debugLine="Dim job As HttpJob";
_job = new shub.dpm.httpjob();
 //BA.debugLineNum = 69;BA.debugLine="AllgFnkt.JobName=\"GetPat\"";
mostCurrent._allgfnkt._jobname /*String*/  = "GetPat";
 //BA.debugLineNum = 70;BA.debugLine="job.Initialize(AllgFnkt.JobName, Me)";
_job._initialize /*String*/ (processBA,mostCurrent._allgfnkt._jobname /*String*/ ,barcodescanner.getObject());
 //BA.debugLineNum = 72;BA.debugLine="Dim callurl As String";
_callurl = "";
 //BA.debugLineNum = 73;BA.debugLine="callurl=AllgFnkt.sURL&\"/DPMService/api/Service_Vi";
_callurl = mostCurrent._allgfnkt._surl /*String*/ +"/DPMService/api/Service_View_Pat/"+_id;
 //BA.debugLineNum = 74;BA.debugLine="job.Download(callurl)";
_job._download /*String*/ (_callurl);
 //BA.debugLineNum = 75;BA.debugLine="End Sub";
return "";
}
public static String  _get_pat_name(String _searchstring) throws Exception{
shub.dpm.httpjob _job = null;
String _callurl = "";
 //BA.debugLineNum = 77;BA.debugLine="Sub get_Pat_Name(searchstring As String)";
 //BA.debugLineNum = 78;BA.debugLine="Dim job As HttpJob";
_job = new shub.dpm.httpjob();
 //BA.debugLineNum = 79;BA.debugLine="AllgFnkt.Searchstring=searchstring";
mostCurrent._allgfnkt._searchstring /*String*/  = _searchstring;
 //BA.debugLineNum = 80;BA.debugLine="AllgFnkt.JobName=\"GetPatName\"";
mostCurrent._allgfnkt._jobname /*String*/  = "GetPatName";
 //BA.debugLineNum = 81;BA.debugLine="job.Initialize(AllgFnkt.JobName, Me)";
_job._initialize /*String*/ (processBA,mostCurrent._allgfnkt._jobname /*String*/ ,barcodescanner.getObject());
 //BA.debugLineNum = 83;BA.debugLine="Dim callurl As String";
_callurl = "";
 //BA.debugLineNum = 84;BA.debugLine="callurl=AllgFnkt.sURL&\"/DPMService/api/Service_Vi";
_callurl = mostCurrent._allgfnkt._surl /*String*/ +"/DPMService/api/Service_View_Pat/search/"+_searchstring;
 //BA.debugLineNum = 85;BA.debugLine="job.Download(callurl)";
_job._download /*String*/ (_callurl);
 //BA.debugLineNum = 86;BA.debugLine="End Sub";
return "";
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 12;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 15;BA.debugLine="Private bs1 As BillScanner";
mostCurrent._bs1 = new billwrapper.billWrapper();
 //BA.debugLineNum = 16;BA.debugLine="Private pattimer As Timer";
mostCurrent._pattimer = new anywheresoftware.b4a.objects.Timer();
 //BA.debugLineNum = 17;BA.debugLine="Dim lblpatient As Label";
mostCurrent._lblpatient = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 18;BA.debugLine="Dim pnlEnterPatID As Panel";
mostCurrent._pnlenterpatid = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 19;BA.debugLine="Dim txtPatNr As EditText";
mostCurrent._txtpatnr = new anywheresoftware.b4a.objects.EditTextWrapper();
 //BA.debugLineNum = 20;BA.debugLine="End Sub";
return "";
}
public static String  _jobdone(shub.dpm.httpjob _job) throws Exception{
String _res = "";
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
anywheresoftware.b4a.objects.collections.List _list1 = null;
anywheresoftware.b4a.objects.collections.Map _map1 = null;
 //BA.debugLineNum = 108;BA.debugLine="Sub JobDone(Job As HttpJob)";
 //BA.debugLineNum = 109;BA.debugLine="ProgressDialogHide";
anywheresoftware.b4a.keywords.Common.ProgressDialogHide();
 //BA.debugLineNum = 110;BA.debugLine="If Job.Success Then";
if (_job._success /*boolean*/ ) { 
 //BA.debugLineNum = 111;BA.debugLine="Dim res As String";
_res = "";
 //BA.debugLineNum = 112;BA.debugLine="res = Job.GetString";
_res = _job._getstring /*String*/ ();
 //BA.debugLineNum = 113;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 114;BA.debugLine="parser.Initialize(res)";
_parser.Initialize(_res);
 //BA.debugLineNum = 116;BA.debugLine="Log(\"Response from server: \" & res)";
anywheresoftware.b4a.keywords.Common.LogImpl("72424840","Response from server: "+_res,0);
 //BA.debugLineNum = 118;BA.debugLine="Select Job.JobName";
switch (BA.switchObjectToInt(_job._jobname /*String*/ ,"GetPat","GetPatName","PostCharche")) {
case 0: {
 //BA.debugLineNum = 121;BA.debugLine="Dim list1 As List";
_list1 = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 122;BA.debugLine="list1 = parser.NextArray";
_list1 = _parser.NextArray();
 //BA.debugLineNum = 123;BA.debugLine="If list1.Size<1 Then";
if (_list1.getSize()<1) { 
 //BA.debugLineNum = 124;BA.debugLine="ToastMessageShow(\"Patient nicht vorhanden.\",T";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Patient nicht vorhanden."),anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 126;BA.debugLine="AllgFnkt.PatID=0";
mostCurrent._allgfnkt._patid /*String*/  = BA.NumberToString(0);
 //BA.debugLineNum = 127;BA.debugLine="lblpatient.Text=\"Patient nicht vorhanden.\"";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence("Patient nicht vorhanden."));
 //BA.debugLineNum = 128;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 130;BA.debugLine="Dim map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 131;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))));
 //BA.debugLineNum = 132;BA.debugLine="Log(map1)";
anywheresoftware.b4a.keywords.Common.LogImpl("72424856",BA.ObjectToString(_map1),0);
 //BA.debugLineNum = 134;BA.debugLine="AllgFnkt.PatID = map1.Get(\"id\")";
mostCurrent._allgfnkt._patid /*String*/  = BA.ObjectToString(_map1.Get((Object)("id")));
 //BA.debugLineNum = 135;BA.debugLine="AllgFnkt.PatName=map1.Get(\"pat\")";
mostCurrent._allgfnkt._patname /*String*/  = BA.ObjectToString(_map1.Get((Object)("pat")));
 //BA.debugLineNum = 136;BA.debugLine="lblpatient.Text=AllgFnkt.PatName";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence(mostCurrent._allgfnkt._patname /*String*/ ));
 break; }
case 1: {
 //BA.debugLineNum = 139;BA.debugLine="Dim list1 As List";
_list1 = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 140;BA.debugLine="list1 = parser.NextArray";
_list1 = _parser.NextArray();
 //BA.debugLineNum = 141;BA.debugLine="If list1.Size<1 Then";
if (_list1.getSize()<1) { 
 //BA.debugLineNum = 142;BA.debugLine="ToastMessageShow(\"Keine Daten gefunden\",True)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Keine Daten gefunden"),anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 143;BA.debugLine="AllgFnkt.PatID=0";
mostCurrent._allgfnkt._patid /*String*/  = BA.NumberToString(0);
 //BA.debugLineNum = 144;BA.debugLine="lblpatient.Text=\"Patient nicht vorhanden.\"";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence("Patient nicht vorhanden."));
 //BA.debugLineNum = 145;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 147;BA.debugLine="If list1.Size=1 Then";
if (_list1.getSize()==1) { 
 //BA.debugLineNum = 148;BA.debugLine="Dim map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 149;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))));
 //BA.debugLineNum = 150;BA.debugLine="AllgFnkt.PatID = map1.Get(\"id\")";
mostCurrent._allgfnkt._patid /*String*/  = BA.ObjectToString(_map1.Get((Object)("id")));
 //BA.debugLineNum = 151;BA.debugLine="AllgFnkt.PatName=map1.Get(\"pat\")";
mostCurrent._allgfnkt._patname /*String*/  = BA.ObjectToString(_map1.Get((Object)("pat")));
 //BA.debugLineNum = 152;BA.debugLine="lblpatient.Text=AllgFnkt.PatName";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence(mostCurrent._allgfnkt._patname /*String*/ ));
 //BA.debugLineNum = 153;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 155;BA.debugLine="StartActivity(\"ListPat\")";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)("ListPat"));
 break; }
case 2: {
 //BA.debugLineNum = 166;BA.debugLine="ToastMessageShow(\"Barcode erfolgreich gespeich";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Barcode erfolgreich gespeichert"),anywheresoftware.b4a.keywords.Common.False);
 break; }
}
;
 }else {
 //BA.debugLineNum = 169;BA.debugLine="ToastMessageShow(\"Funktionsaufruf fehlgeschlagen";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Funktionsaufruf fehlgeschlagen."),anywheresoftware.b4a.keywords.Common.True);
 };
 //BA.debugLineNum = 171;BA.debugLine="Job.Release";
_job._release /*String*/ ();
 //BA.debugLineNum = 172;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 10;BA.debugLine="End Sub";
return "";
}
public static String  _timer_tick() throws Exception{
 //BA.debugLineNum = 60;BA.debugLine="Sub Timer_Tick";
 //BA.debugLineNum = 61;BA.debugLine="AllgFnkt.PatID=0";
mostCurrent._allgfnkt._patid /*String*/  = BA.NumberToString(0);
 //BA.debugLineNum = 62;BA.debugLine="lblpatient.Text=\"Bitte Patient auswählen\"";
mostCurrent._lblpatient.setText(BA.ObjectToCharSequence("Bitte Patient auswählen"));
 //BA.debugLineNum = 63;BA.debugLine="End Sub";
return "";
}
}
