You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
4.8 KiB

B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=11
@EndOfDesignText@
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public PatID As String
Public sURL As String=""
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private bs1 As BillScanner
Private Button1 As Button
Private Button2 As Button
Dim JobName As String
Dim PatName As String
Private txtPatNr As EditText
Private pnlEnterPatID As Panel
Private lblPatient As Label
Private timeout As Long
Private dtnow As Long
Private btnSearchPat As Button
Dim PatTimer As Timer
Dim StartTimer As Timer
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.AddMenuItem("Parameter","bt1")
Activity.AddMenuItem("Über...","bt2")
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
Activity.Title="DPM - Charge Scanner"
bs1.ScanMode = bs1.FORMAT_ONE_D
PatID=0
If File.Exists(File.DirInternal ,"DPM.ini") = True Then
Get_Params
Else
'StartActivity("Param")
End If
PatTimer.Initialize("timer",timeout)
If TempData.pid<>"" Then
get_Pat(TempData.pid)
TempData.pid=""
End If
End Sub
Sub Activity_Resume
If TempData.pid<>"" Then PatID=TempData.pid
If File.Exists(File.DirInternal ,"DPM.ini") = True Then
Get_Params
PatTimer.Enabled=False
PatTimer.Initialize("timer",timeout)
PatTimer.Enabled=True
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Try
bs1.stopScanning
Catch
End Try
PatID=0
End Sub
Sub Timer_Tick
PatID=0
lblPatient.Text="Bitte Patient auswählen"
End Sub
Sub Get_Params
Dim TR As TextReader
Dim inp As InputStream
inp=File.OpenInput(File.DirInternal , "DPM.ini")
TR.Initialize(inp)
Try
sURL=TR.Readline
Catch
sURL=""
End Try
Try
timeout = TR.ReadLine
Catch
timeout=30000
End Try
TR.Close
End Sub
'tEST 1328
Sub DateDiff (units, date1, date2)
Try
Dim x As Long
Dim y As Long
Dim z As Long
x=DateTime.DateParse(date1)
y=DateTime.DateParse(date2)
Select units
Case "ss"
z=60
End Select
Return (y-x) / z
Catch
Return 10
End Try
End Sub
Sub bs1_scan_value(val As String, rawbyte() As Byte, barcodetype As Int)
'bs1.stopScanning
'Log("Value = " & val)
'Log("type = " & barcodetype)
'Log(" ")
If DateDiff("ss",dtnow,DateTime.Now)<2 Then Return
Dim job As HttpJob
JobName="PostCharche"
job.Initialize(JobName, Me)
dtnow=DateTime.Now
job.PostString(sURL&"/DPMService/api/PatCharge/"&PatID&"/"&val,"")
Dim b As Beeper
b.Initialize(300, 500) '300 milliseconds, 500 hz
'b.Beep
PatTimer.Enabled=True
End Sub
Sub Button1_Click
If PatID=0 Then
ToastMessageShow("Bitte zuerst Patient wählen",True)
End If
bs1.startScanning
PatTimer.Enabled=False
End Sub
Private Sub Button2_Click
Try
bs1.stopScanning
Catch
End Try
End Sub
Sub get_Pat(id As String)
Dim job As HttpJob
JobName="GetPat"
job.Initialize(JobName, Me)
Dim callurl As String
callurl=sURL&"/DPMService/api/Service_View_Pat/"&id
job.Download(callurl)
'job.Download("http://192.168.111.67/DPMService/api/Service_View_Pat/"&id)
End Sub
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
Dim parser As JSONParser
parser.Initialize(res)
Log("Response from server: " & res)
Select Job.JobName
Case "GetPat"
Dim list1 As List
list1 = parser.NextArray
If list1.Size<1 Then
ToastMessageShow("Patient nicht vorhanden.",True)
pnlEnterPatID.Visible=True
Return
End If
Dim map1 As Map
map1 = list1.Get(0)
Log(map1)
PatID = map1.Get("id")
PatName=map1.Get("pat")
lblPatient.Text=PatName
Case "PostCharche"
ToastMessageShow("Barcode erfolgreich gespeichert",False)
End Select
Else
ToastMessageShow("Funktionsaufruf fehlgeschlagen.",True)
End If
Job.Release
End Sub
Private Sub btnSearchPat_Click
PatTimer.Enabled=False
get_Pat(txtPatNr.Text)
pnlEnterPatID.Visible=False
btnSearchPat.RequestFocus
PatTimer.Enabled=True
End Sub
Private Sub btnEnterPatID_Click
txtPatNr.ForceDoneButton=True
pnlEnterPatID.Visible=True
txtPatNr.Text=""
txtPatNr.RequestFocus
End Sub
Private Sub lblPatient_LongClick
StartActivity("Param")
End Sub
Sub bt1_Click
StartActivity("Param")
End Sub
Sub bt2_click
StartActivity("About")
End Sub
Private Sub btnListdata_Click
'StartActivity(ListData)
'CallSubDelayed3(ListData,"get_data",txtPatNr.text,sURL)
ListData.PatID=PatID
TempData.pid=PatID
TempData.pname=lblPatient.Text
ListData.sURL=sURL
'CallSubDelayed(ListData,"")
StartActivity("ListData")
End Sub