on mouseUp
/* search Mysql query into OSCAR By Dr. Ian Pun August 2, 2013 */
/* This is the preferences file. put it into /Library/Application Support/MedLogix/OHN kiosk preferences
ssh -pPORT OSCARUSER@OSCARSERVERIP "
mysql -uroot -pSQLPASSWORD OSCAR_DB_NAME <<QUERY_INPUT
%SQLQUERYSTRING%
QUERY_INPUT
";
*/
/* load the preferences from the textfile into */
put "/home/maveric19841/OHN kiosk preferences" into preffile
open file preffile
read from file preffile until EOF
put it into field "SQLqueryExecute"
close file preffile
if it is empty then
answer "Preference file not present"
exit mouseUp
end if
put "Status" & return into field "statusdisplay"
repeat
ask "Please Slide your Health Card"
if it is empty then exit mouseUp
put it into wholesearchstring
put word 1 of it into searchstring
if length(searchstring) = 10 and luhncheck(searchstring) = 0 then exit repeat
if char 1 to 8 of it is "%B610054" then
put it into readmagline
set itemdelimiter to "^"
put char 17 to 18 of item 3 of readmagline into magVC
put char 9 to 18 of item 1 of readmagline into magOHN
put magOHN && magVC into wholesearchstring
put magOHN into searchstring
set itemdelimiter to comma
if luhncheck (searchstring) = 0 then
exit repeat
end if
end if
end repeat
put field "SQLqueryExecute" into SQLquery
replace "%SQLQUERYSTRING%" with " select * from demographic where hin = \""e&"%SEARCHSTRING%\""e&";" in SQLquery
replace "%SEARCHSTRING%" with searchstring in SQLquery
get shell(SQLquery)
if it contains "not resolved" then exit mouseUp
if it is empty then
answer "No result found"
exit mouseUp
end if
put it after last char of field "statusdisplay"
put field "SQLqueryExecute" into SQLquery
replace "%SQLQUERYSTRING%" with " select ver, demographic_no from demographic where hin = \""e&"%SEARCHSTRING%\""e&";" in SQLquery
replace "%SEARCHSTRING%" with searchstring in SQLquery
get shell(SQLquery)
if it contains "not resolved" then exit mouseUp
put word 2 of line 2 of it into demographic_no
put return & it after last char of field "statusdisplay"
if word 1 of line 2 of it <> toupper(word 2 of wholesearchstring) and toupper(word 2 of wholesearchstring) <> empty then
put field "SQLqueryExecute" into SQLquery
replace "%SQLQUERYSTRING%" with " update demographic set ver = \"& quote & toupper(word 2 of wholesearchstring) & "\" & quote & " where hin = \" & quote & searchstring & "\" "e&";" in SQLquery
get shell(SQLquery)
if it contains "not resolved" then exit mouseUp
put "version code updated " & magOHN && magVC & return after last char of field "statusdisplay"
end if
/**/
put field "SQLqueryExecute" into SQLquery
replace "%SQLQUERYSTRING%" with " select appointment_no , status from appointment where demographic_no = \" & quote & demographic_no & "\" & quote & " and appointment_date = \" & quote & sqbDate() & "\" & quote & ";" in SQLquery
get shell(SQLquery)
if it contains "not resolved" then exit mouseUp
if it is empty then
put return & "Please See the Receptionist" & return before first char of field "statusdisplay"
exit mouseUp
else
put return & "Please Be Seated and Wait for your Name" & return before first char of field "statusdisplay"
end if
put it after last char of field "statusdisplay"
/* get appointment number */
put word 1 of line 2 of it into appointment_no
put word 1 of line 3 of it into status
/* if status of patient is not billed BS */
if char 1 of status <> "B" then
/* update the appointment status */
put field "SQLqueryExecute" into SQLquery
replace "%SQLQUERYSTRING%" with " update appointment set status = \"& quote & "P" & "\" & quote & " where appointment_no = " & appointment_no & ";" in SQLquery
get shell(SQLquery)
put it after last char of field "statusdisplay"
if it contains "not resolved" then exit mouseUp
end if
end mouseUp
function luhncheck OHN
/* Luhn OHN check routine by Ian Pun 1991, 2013 returns zero if checks out */
if isNumber(OHN) then
repeat with n = 1 to (length(OHN) - 1)
if n mod 2 = 1 then
add char (char n of OHN) + 1 of "0246813579" to total
else
add char n of OHN to total
end if
end repeat
return (10 - total mod 10 - char(length(OHN)) of OHN) mod 10
else
return 1
end if
end luhncheck
function sqbDate
get the long time
convert it to dateitems
set the numberformat to "00"
return¬
(item 1 of it)+0 & "-" & (item 2 of it)+0 & "-" & (item 3 of it)+0
end sqbDate