Mobile Medic
December 10, 2007
Mobile Medic
In Short: An application designed to improve the effectiveness of medical personnel in developing nations.
Why: The growing expansion of mobile phones into poor areas is far outpacing that of any other communications technology; that fact together with the numerous problems facing overworked, understaffed, and undertrained medical personnel present a very important and exciting opportunity.
Background:
- Design for the other 90%
- Cell phone counseling in the Congo
- Blue Trunk Libraries (WHO)
- The global Health Library
The technical part (How it works):
- Asterisk (open-source telephony program)
- PHP (server – side programming language)
- MySQL (data base program)
Asterisk Code
Calling a PHP script using the Asterisk Gateway Interface (AGI)
[redial_blm272]
exten => s,1,Answer();
exten => s,n,AGI(/home/blm272/asterisk_agi/mobileMedic.php);
exten => t,1,Hangup();
The PHP script (AKA the Heavy Lifting)
#!/usr/local/bin/php -q
require('/var/lib/asterisk/agi-bin/phpagi.php');
//set time limit
set_time_limit(60);
// SQL Query Helper Function
function sqlQuery($query)
{
global $mySql;
$data = null;
$result = mysql_query($query, $mySql);
# This set's up an associative array (key->value pair) for all of the data returned
if (sizeof($result) > 0)
{
$num_fields = mysql_num_fields($result);
$row_cnt = 0;
while ($row_data = mysql_fetch_array($result)) {
for ($cnt = 0; $cnt < $num_fields; $cnt++) {
$field_name = mysql_field_name($result, $cnt);
$data[$row_cnt][$field_name] = $row_data[$cnt];
}
$row_cnt++;
}
}
return $data;
}
//Audio Files turned into variables for convenience
$welcomeAudio = "/home/blm272/asterisk_sounds/welcomeAudio"; //welcome, please enter PIN
$mainMenuAudio = "/home/blm272/asterisk_sounds/mainMenuAudio"; //say main menu options
$extensionAudio = "/home/blm272/asterisk_sounds/extensionAudio"; //ask for extension
// Create an AGI Object
$agi = new AGI();
// Predefined AGI Variables, send them to the Asterisk console for debugging
$agi->conlog($agi->request["agi_request"]);
$agi->conlog($agi->request["agi_channel"]);
$agi->conlog($agi->request["agi_language"]);
$agi->conlog($agi->request["agi_uniqueid"]);
$agi->conlog($agi->request["agi_callerid"]);
$agi->conlog($agi->request["agi_dnid"]);
$agi->conlog($agi->request["agi_rdnis"]);
$agi->conlog($agi->request["agi_context"]);
$agi->conlog($agi->request["agi_extension"]);
$agi->conlog($agi->request["agi_priority"]);
$agi->conlog($agi->request["agi_enhanced"]);
$agi->conlog($agi->request["agi_accountcode"]);
$agi->conlog($agi->request["agi_network"]);
$agi->conlog($agi->request["agi_network_script"]);
// Database connection variables
$hostname = "itp.nyu.edu";
$dbname = "blm272";
$username = "blm272";
$password = "kvibn+6";
// Connect to the database
$mySql = mysql_connect($hostname, $username, $password) or die (mysql_error());
mysql_select_db($dbname, $mySql) or die(mysql_error());
//start dialplan
$agi->answer();
//$agi->wait(1);
//$agi->text2wav('Welcome to mobile medic. Please Enter Your PIN Number');
//$agi->stream_file($welcomeAudio); //answer and ask for pin (need to put in add new pin?)
//$agi->get_data($welcomeAudio);
$return = $agi->get_data($welcomeAudio);
$callerID = $agi->request["agi_callerid"];
if ($return['result'] > 0)
{
//$agi->get_data($welcomeAudio);
$extension = chr($return['result']);
$query ="INSERT INTO Voicemail (callerID, extension, time) VALUES ('" . $agi->request["agi_callerid"] ."', '" . $return['result'] . "', NOW())";
$insert_result = mysql_query($query, $mySql);
//$insert_result[2] = $extension;
//echo ($extension);
// Query the database to see if this caller has called before
$query = "SELECT id, extension, FROM Voicemail WHERE extension = '" . $return['result'] . "'";
$result = mysql_query($query, $mySql);
//$agi->say_number($ascii);
//$agi->text2wav('Thank you. Proceeding to Main Menu for'.' '.$agi->say_number($ascii));
echo ($result);
//$result = sqlQuery($query, $mySql);
if (sizeof($result) > 0)
{
//we got a result from the DB
$agi->conlog("Database ID: " . $result[0]['id']);
//play options menu and listen for response (get data = background)
$whereto = $agi->get_data($mainMenuAudio, 5000, 1);
if (is_numeric($whereto['result']))
{
$agi->conlog("Result: " . $whereto['result']);
$agi->say_number($whereto['result']);
//menu options start here
if ($whereto['result'] == 1) //emergency call to doctor
{
//ask for extension to call
$extension= $agi->get_data($extensionAudio); //max digits for extensions is 4
if(is_numeric($extension['result']))
{
$query = "SELECT doctorNumber, extension FROM Doctors WHERE extension = '". $extension['result'] . "'";
//Query DB to find doctor's number based on extension
//$query = "SELECT doctorNumber, extension FROM Doctors WHERE extension = '" . $extension['result'] . "'";
$result = SQLquery($query, $mySql);
//if (sizeof($result >0))
if (sizeof ($result > 0));
{
$agi->say_number($extension['result']);
//$docNum = 18312959612;
$docNum = $result[0]['doctorNumber'];
//$agi->say_number($result[0]['doctorNumber']);
$agi->exec('Dial', trim("SIP/itp_jnctn/" . $docNum . "|30|r"));
if (!$result)
{
die("Error " . mysql_errno() . " : " . mysql_error());
}
//$agi->goto("redial_blm272_sip","s",1);
}
}
}
elseif ($whereto['result'] == 2) //leave message in Doctor's VM, who then gets a text notification
{
//ask for extension to call
$extension= $agi->get_data($extensionAudio, 10000, 4); //max digits for extensions is 4
if(is_numeric($extension['result']))
{
$voicemail_location = "/home/blm272/asterisk_sounds/voicemail";
$callerID = $agi->request["agi_callerid"];
$record_file = $voicemail_location . time() . "vm" . $agi->request["agi_callerid"];
$agi->record_file($record_file, "WAV", "0123456789", 10000, 0, true, 5);
$query ="INSERT INTO Voicemail (callerID, record_file, time) VALUES ('" . $agi->request["agi_callerid"] . "', '" . $record_file . "', NOW())";
//$query = "insert into callers (caller_id, name_audio) values ('" . $agi->request["agi_callerid"] . "', '" . $record_file . "')";
$insert_result = mysql_query($query, $mySql);
$agi->stream_file($record_file);
if (!$result)
{
die("Error " . mysql_errno() . " : " . mysql_error());
}
}
else
{
//Timout
$agi->goto("redial_blm272","t",1);
}
}
elseif ($whereto['result'] == 3) //check messages from doctor
{
$testFile = "/home/blm272/asterisk_sounds/voicemail1197263266vm_blm272.wav";
$agi->stream_file($testFile);
$callerID = $agi->request["agi_callerid"];
$query = "SELECT callerID, record_file, time FROM Voicemail WHERE callerID = '". $agi->request["agi_callerid"] . "' ORDER BY time DESC";
$result = sqlQuery($query, $mySql);
if (sizeof($result) >0)
{
$agi->stream_file($result[0]['record_file']);
}
if (!$result)
{
die("Error " . mysql_errno() . " : " . mysql_error());
}
}
elseif ($whereto['result'] == 4) //exit (go back to PIN prompt via the dialplan)
{
function agi_goto($con='redial_blm272',$ext='s',$pri=1)
{
$this->goto($con, $ext, $pri);
}
}
else
{
// Timeout.. Probably (or send them back to the ask for PIN section...)
mysql_close ($mySql);
$agi->goto("redial_blm272","t",1);
}
}
}
}
?>
The PHP script sets up a gateway for asterisk and mysql to work together, forming a framework of user options based on dtmf input from any standard telephone. This includes calling out directly to a doctor based on extension, directly leaving a voice mail in a specific directory, and listening to your own voice messages, with more options to come soon.
This code is not quite fully functional, but its most of the way there. Any tips or questions are also welcome.
Ultimate Man-Purse : Results
November 26, 2007
So after much sewing and cutting, here’s what Hatti and I came up with for our re-design of the man-purse:
I’m particularly happy with the ID card holder on the strap and the waterproof umbrella holder pocket. I could see myself being really happy with these features in my bag, and almost everyone we talked to seemed equally positive about these changes.
Iteration Project – The Ultimate Man-Purse
October 22, 2007
Hatti Lim and I are working on a male version of Hatti’s urban purse for our iterative assignment in design workshop. The idea is to create some sort of mechanism that eases the gesture that men (typically living in a city) have to endure, by reaching around into the back pocket to take out their wallet (presumably to show an ID//for NYU??) while carrying a any sort of messenger style bag that could potentially be making the gesture more difficult. [Assuming you need a messenger bag to fit all the things you would need if you were carrying a backpack].
First of all, we looked at why the messeger bag was preferrable to the classic bookbag. What we noticed is that the ‘bookbag’ has many flaws for the urban dweller. First of all, it is not optimal for riding in subways- it makes up a good deal of space and is situated in the chest-level area; where people have the greatest girth (as far as body mass) and provides much discomfort for those in the train if the owner does not have the forethought to take off his bag and bring it down to his/her feet (where there are typically gaps between people for it to fit). Furthermore, if they do have the forethought to do so, it usually smacks a few bystanders along its way down, since the movement for taking off a backpack lends itself to those sort of incidents. Also, accessing items in a backpack is rather awkward and uncomfortable, having either to engage in the wrap-around gumby arm only to feel around blindly for what you are looking for..or even worse, the swing around and bringing it to the front (again, probably smacking a few poor neighbors in the process). Lastly, there are cultural stigmas that we associate with backpacks as being adolescant or unprofessional, etc. (I.E, you probably would not wear your backpack to a job interview or a bar for drinks after work). All of these reasons have led us to re-adapt the sling bag instead of the bookbag.
The first idea and main focus of our bag is to make use of the strap that run diagonally along your chest, since it is the portion of the bag the user would have easiest access to. We think that by adapting an elastic mechanism inside a pocket (a feature I actually stole from the arm portion of one of my snowboarding jackets) will be a good appropriation for the wallet. Also, Roger Tsai mentioned in class that he can never listen to an ipod in his backpack bc the headphones are too short, so it should be easy to fabricate another pocket along the front of the strap for an ipod as well.
Another feature we wish to add is the ability to make it slightly modular. While Hatti focused a lot on the pocket mechanisms, I was more concerned with the safety of his laptop and how a lot of uneccessary space is wasted on days that he decides not to carry it. So, we have decided to attempt a compartmentalization process where you can attach and detach portions (just 2 for now) of your bag to give the wearble a more modular approach. Wish us luck!
Project 2 Documentation
October 17, 2007
Here’s the link to my presentation and documentation for my observation and response assignment. I was reasonably happy with the concept, although I wish my prototyping skills were a bit better, especially since I spent so long working on this one, reworking it from scratch at least three times. Oh well. Practice always helps. Enjoy.
Ritual, Vice, or Fetish – Observations and Thoughts
October 6, 2007
While observing the interaction between books and people, I realized quickly that my design ideas would focus down to one of three general options: changing the human, changing the book, or some combination of both.
What I mean by this is pretty simple.
Changing the human involves design solutions centered around the perspective of allowing the user (humans) to interact more comfortably with the books by designing something centered around the body. Essentially, by changing the form in which the user interacts with the book. Harnesses, gloves, stands, and the like.
Changing the book, then, involves looking at the design possibilities generated from changing the actual form of the book itself. Is the current rectanglular shape really the most human-centered form? How can the text be displayed efficiently while still improving the ease of use? Is it a technological solution, or simply a form solution? Changing materials and information technologies all come into play here.
And finally, perhaps the answer lies in both worlds; the marriage of a human component and a book component creating the ultimate reading experience. Some kind of modular systemic design solution seems like a very interesting and challenging possibility.
This final design possibility seems the most promising – both the book and the human have been in their current forms for so long that it would seem a whole new interface would be necessary to affect serious change. So I am currently researching what has been done in this and closely related areas, as well as advances in relevant material and information technology, to see if an elegant solution presents itself.
Ritual, Vice, or Fetish (Design Workshop Project 2)
September 29, 2007
For this assignment we have to do some observation and needfinding surrounding a group or activity, analyze it, and offer some design solutions.
I have decided to pursue the book as my subject of scrutiny. The basic design, use, and function of books has not significantly changed since the invention of modern typesetting and binding practices. Yet people are reading less and less, and reading can still be an unwieldy process. Ever try reading lying down? Clearly something can be done besides insisting that everyone read on their computer 100% of the time.
This shall be my challenge.
Next Design Icon (pt.2)
September 29, 2007
The prototype and final presentation are finished for my re-imagining of the Swiss Army Knife as the next design icon.
Link to the presentation: Design Icon
The Next Design Icon
September 19, 2007
For Design Workshop I have to decide upon and add to what I think should be the next design icon. (The chair is the current one). I have decided to pick the Swiss Army Knife as the new icon. Check back soon for a link to the presentation I gave on Monday regarding my choice.
For this week, I need to design the next iteration of the swiss army knife. I have some great ideas, so stay tuned for some sketches and whatnot.


