Perspectives on Physical Therapy

I went to physical therapy today for an evaluation after my car accident. While I was there, I noticed a young, healthy, athletic looking woman who came in on crutches, with fresh surgical scars on her knees take…her first steps.

“I can walk!” she said.

I have no idea what her injury or surgery was, but the therapist was teaching her movement by movement … heel first, then the foot. Let your knee bend a little, now step forward. She was relearning how to walk, step by step.

The JavaScript Event loop for Emergency Physicians

If you’re a reader of my blog past or present you’ll know that I’ve long been interested in programming and am also an Emergency Medicine physician.  While studying javacript callback functions I was referred to this talk which explains them well, but it didn’t really “click” until I saw the visual “event loop” waiting for it’s opportunity to let the main stack know there were results to dealt with from prior callback functions.

What’s a callback function? This is one I’m still wrapping my head around, but it allows for a task to be worked on while the main program continues to function.  This way the main program is not held up waiting for results that may be dependent on some 3rd party, such as downloading a file or communicating with an API, or any other calculation or processing that needs to be done.

A callback function seemed confusing to me because I was trying to understand the literal terms of what was being “called back”.  While I’m still not certain I get that, let me explain it in terms of how the emergency room functions.  If you’ve ever been a patient in the ER or in a hospital and had a health care worker stop into your room to keep you updated on results or what exactly you’re waiting for, this should make a lot of sense to you.

And if you happen to also be an Emergency Physician or Practitioner managing complex care for many patients, you’ll also recognize YOUR role in the “event loop”.

The physician’s physical location is the main stack

In order to diagnose & treat a patient. The physician has a role in evaluating the patient’s primary complaint, including a history, a physical exam, objective testing data, and then a clinical summary of what it all means.

Some of this can only be done by the physician being present, in the room, talking with the patient and doing a hands on physical exam. The physican may be caring for many patients at once, but can only be in one place at a time. The physician’s physical location combined with what stage of evaluation they are in is kind of like the main call stack.

  • Pick up a New Chart
  • Read the chief complaint, note allergies, prior medical issues, and nursing notes that may be pertinent
  • Go to the patient room and talk with the patient, get further history
  • Perform a physical exam on the patient
  • Return to the desk or order entry area and order appropriate blood tests, x rays, other diagnostic tests, or place a phone call to a specialist.

All of these things ideally happen in an uninterrupted sequence. Bear with me here, interruptions are common, but the above set allows for full focus on ONE patient at a time and minimizes early errors in thinking, or forgetting something like an out of the ordinary lab test for your patient that seems appropriate (for example, a TSH is not a routine test, but in some cases it may be valuable to the ER physician).

So the call stack, the main flow of the ER, involves the physician reviewing charts, seeing patients and ordering tests. She does this twenty times a day, but must find time inbetween these “stacks” to review all that data she’s ordered.

Each test ordered is a callback function

When the physician or practitioner orders blood tests, several things happen automatically that creates a new work routine for one or more people. Stickers are printed for the blood tubes, a technician sees the order and grabs the supplies to draw the blood. The technician or nurse physically goes to the room to draw blood on the patient. Blood tubes are labeled and sent to the lab with care.

The lab receives them and begins processing them and eventually results are returned, either on a printer, via telephone or most often, in a computerized record system. The lab runs the blood tests on several different machines and they results come back at different times, to be reviewed by the nurse & physician when they are available to synthesize that information and make a decision on it.

Clearly if the physician had to wait for all of this to happen, or even part of it, before moving to the next patient, the flow of the ER would creep to a complete halt. Physicians would be limited to 1 to 3 patients per day rather than 2 to 3 per hour. Only because these ancillary tests are “callbacks” can the physician move on to the next patient in the queue to being their evaluation.

The event loop allows the physician to process the results
At some point the physician has a brief mental & physical break beteween seeing two patients, or between a phone call and the next patient and can turn to the computer to see what’s resulted on a waiting patient. This is analgous to the call stack (the physicians workload) finally being open again to pay attention to a new piece of information.

The results of the testing (the callbacks) are available to review

An experienced physician understands the flow of effort 7 energy between picking up a new chart (filling the call stack again) and reviewing prior results on older patients ( the call backs) This is the “event loop”. The event loop waits until the call stack is empty, until the main program flow has returned from other tasks, and can manage the results of functions, whether it is a set of calculations, a file, or information from a web site.

The event loop analogy applies to not only test results but any other type of interruption to the physicians call stack. Interruptions create a mistake prone environment, so it’s vital that both physician and other staff recognize the ideal moments in which to have new information processed.

Asynchronous Patient Flow

Only because of the asynchronous nature of the “Physician Stack”, “Callback Testing”, and “Event Loop Interruptions” can today’s healthcare environment support the massive volume of patients needing to be seen. We are always looking for ways to become more efficient while maintaining good patient care, satisfaction, reducing mistakes or injuries, and maintaining work satisfaction for all involved.

I would imagine in the same way during my exploration as a javascript full stack developer, I’ll continue to seek out ways to maintain efficiency, improve program flow and keep myself happy along the way while getting a good product for any client I work with.

Resources:
https://www.youtube.com/watch?v=8aGhZQkoFbQ

Loupe: A visualization of the JS CallStack/Callback/Event Loop

Free Code Camp – A Full stack JavaScript development education platform

Converting a Javascript object to a readable JSON file

While working through the final challenges at FCC (Free Code Camp) I coded a live working Angular.js project alongside the hand-holding tutorials that are entirely done in side the browser.

The tutorials at CodeSchool are excellent as they prompt you step by step through what initially seem like very complex tasks.  As a I worked through the tutorial and watched the videos, I recreated the project (a fun little gemstore) on my own computer.

This was really important to me to convince myself that I understood the technology.

However in the final final step of the angular.js course, and thus the final challenge of Free Code Camp, they introduced a cool trick to import data from an external file in a format called JSON.  JSON is very similar in appearance to how a Javascript object appears…it’s human readable in the same way, however the syntax is slightly different.

 

It was going to be a daunting task to convert the entire object from Javascript to JSON just to get this last step working.  A little googling led me to two pieces of advice that solved my problem instantly.

 

First was this gem at Stackoverflow:

  1. Launch Firefox/Chrome/Safari
  2. Open Firebug/developer tools
  3. Copy/paste your code into the console.
  4. Then type console.log(JSON.stringify(object)) and voila!

So I tried it, and got back a minified version of the JSON object. This actually worked fine, but I couldn’t read it, so I used this nifty site to simply format it with line breaks and tabs:

https://www.jsoneditoronline.org/

Just click the icon of the little outline after pasting in the results from your console and presto…there is your JSON file.

 

WorkFlowy to Keynote Presentation Steps

Frustrating, but I finally figured out a way to go from WorkFlowy to a powerpoint or keynote presentation.  It’s not obvious and requires a “middle man” program.   This works on my Mac, and is untested on other platforms.

 

  • First, using Workflowy to export the outline you want to make into a presentation.
  • Then, copy all the text and open TextEdit on your mac.   TextEdit actually creates RTF files, not just plain text.  Paste your Workflowy document into Text Edit.   The outlining should all still be intact.
  • Save this file to your harddrive.

Now open Keynote and do these steps

  • Start a new presentation
  • View->Outline Mode
  • Click next to slide 1 in the outline and…
  • Edit ->Match Destination Formatting.

 

That should do it! Good luck.

Split Decision

Split Decision

These days I divide my time between clinical and consulting work.   in my consulting job I work as a medical command physician for ambulances, helicopters and airlines needing advice and direction on all sorts of medical emergencies.

For the past several months I have been fielding several calls a day regarding screening for *possible* Ebola patients wanting to board a plane or currently in the air and suddenly developing symptoms.

Of all of those phone calls…only one of them had recent travel in Liberia and originated from a West African airport.  All of the rest were from random passengers that vomited, or had diarrhea…but had no travel history, no fevers, no exposure to anyone who had an recent travel history, exposure to the virus, etc, etc.

Part of my job is to reassure and clear those patients who have absolutely zero risk of carrying this particular virus.   But there is so much fear and paranoia that we are fielding calls about nearly anyone who vomits.

God forbid a passenger on Coumadin develops a nose bleed!  That’s a sure call to screen for Ebola even if the passenger is a little old lady from Pasadena who always gets a nosebleed on a plane.

 

A Gift to Remember Me By

A Gift to Remember Me By

Last night at dinner, this girl, Virginia, said, I’ll see you tomorrow! It old her that I was leaving in the morning. She asked for a gift to remember her by. I told her I didn’t have much (which was true, I packed ultra light, and brought no gifts) she asked if I could give her my necklace (I said no). I told her I would draw her a photo instead.

So I brought out this sketchbook that Kwin Krisadaphong sent me, and she asked for that as a gift. I showed her Kwin’s inscription and told her I couldn’t give away a gift to me.

I quickly sketched out this picture with a nice sketch pen I carry with the book. (She asked for the pen as well. )

I tore out the page and handed it to her after writing a message in both English and Spanish, then reached around to hug her and slipped the pen I to her back pocket. She pulled her shirt down over the pen so no one else would see.

It’s hard to want to be able to give everything to every child, but some of them somehow seem to make a bigger mark than others.10333385_10203949741775539_5831120630524831564_o 1601955_10203949741655536_2200180618000528146_o 10410722_10203949738815465_648259956400244290_n

Extracting Riches from Time

Extracting Riches from Time

In Houston waiting for the flight to Pittsburgh now 4 minutes late. Plane pulls up to the gate. Me: “oh good, the plan is here!” Everyone around me: ” grumble grumble late grumble grumble”

Perspective people, perspective. You are all blessed with the freedom and income to travel. Unfortunately complaining and bad attitudes seem to be included.

I have learned so much from those who have fewer material goods than I do, but whom are far richer in extracting the most from each moment in life.

 

995647_10203950531875291_4238924936704141142_n

Lights, Stethoscope, Action!

Lights, Stethoscope, Action!

Safely arrived in Honduras, met our transportation to the village, saw many old friends already, it almost feels like home.

The Sun is setting, the breeze is cool, the kids at everywhere, the meal was great, the parrots are chirping and the strangest thing is there are lights coming on in the village.

2 years ago there was no electricity here at all, then all of a sudden electric poles went up, now lines and lights.

We have seen one patient already, a boy with a leg infection from a motorcycle accident.
1015434_10203914586416677_1879935061682213035_o

1557255_10203914585096644_1744898627202999460_o

10553831_10203914583536605_7873463023821558553_o

10482262_10203914581056543_5940667337934937247_o

10341971_10203914573816362_4280732148331900710_n

10002912_10203914572736335_3569399091455749085_n

10429280_10203914572096319_3390134230347889828_n

7576_10203914571736310_4302241043697883218_n

Getting Oauth2 to work with Python on a Mac

I am ataking a coursera course in Data Science and having trouble getting the prelim check for the first assignment to run without errors.  Here are the details  any help is appreciated!

Using Mac OS 10.8.5
Which Python returns:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

Running the first assignment script after updating teh API calls results in this:

$ python twitterstream.py > output.txt
Traceback (most recent call last):
  File “twitterstream.py”, line 1, in <module>
    import oauth2 as oauth
ImportError: No module named oauth2
So I go back double check my oauth2 installation

$ pip install oauth2
Traceback (most recent call last):
  File “/usr/local/bin/pip”, line 5, in
    from pkg_resources import load_entry_point
  File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py”, line 2603, in
    working_set.require(__requires__)
  File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py”, line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py”, line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.5.2

So now I investigate PIP:

$ which pip
/usr/local/bin/pip
Not even sure what that means, but it’s there.

I investigate the pip file and see this, the version looks consistent internally with the error I am seeing above.

#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: ‘pip==1.5.2′,’console_scripts’,’pip’
__requires__ = ‘pip==1.5.2’
import sys
from pkg_resources import load_entry_point
sys.exit(
   load_entry_point(‘pip==1.5.2’, ‘console_scripts’, ‘pip’)()
)
I try easy install and get this result:

$ easy_install oauth2
error: can’t create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
    [Errno 13] Permission denied: ‘/Users/suzanne/Library/Python/2.7/site-packages/test-easy-install-8879.write-test’
The installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:
    /Users/suzanne/Library/Python/2.7/site-packages/

SO I try with SUDO

$ sudo easy_install oauth2
Searching for oauth2
Best match: oauth2 1.5.211
Processing oauth2-1.5.211-py2.7.egg
oauth2 1.5.211 is already the active version in easy-install.pth
Using /Users/suzanne/Library/Python/2.7/site-packages/oauth2-1.5.211-py2.7.egg
Processing dependencies for oauth2
Finished processing dependencies for oauth2

This seems to have worked?  But I still get the ORIGINAL error above when running the twitterstream.py file.

Do I have more than one python installed? THis command shows basically one (I think??)
$ type -a python

python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python
python is /usr/local/bin/python
python is /usr/bin/python
python is /usr/local/bin/python

When I look using my finder I do see folders for Python 2.3, 2.5, 2.6 and 2.7
I recall playing with Python installs awhile ago so I’m not sure if I added 2.7 myself and if that broke anything.

Here is my $PATH

$ echo $PATH
/Users/suzanne/.rvm/gems/ruby-2.1.0/bin:/Users/suzanne/.rvm/gems/ruby-2.1.0@global/bin:/Users/suzanne/.rvm/rubies/ruby-2.1.0/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/heroku/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/suzanne/.rvm/bin

I am stuck.  I have googled/stackoverflowe searched everything I can think of and I can’t get the pre-assignment one command to work.

Any help? PLEASE??

Local WordPress Installation using MAMP

This is as much for my own records as to help anyone out, but this is the collection of softwares I used while considering using Genesis as a new framework for custom wordpress installations. I should probabaly outsource this, but seeing as the costs tend to range from $500 to $25oo for a PSD -> WordPress framework conversion, I think it’s worth tackling myself.  I’ve done minor custom codes for wordpress but not straight from PSD files, just from other design ideas and havn’t done too shabby. If I can up my game a bit perhaps I can code for others as well?

Anyway here’s the softwares:

MAMP

WordPress.org

 

Troubleshooting guide for My SQL Server not starting

http://eliteeternity.com/mysql-server-wont-start-mamp-red-light-mac/

 

Installing WP Manually

http://codex.wordpress.org/Installing_WordPress

 

How to fix PHPMy Admin after making the same mistake everyone else makes with changing the root password:

Using Terminal, type: /Applications/MAMP/Library/bin/mysqladmin -u root -p password <NEWPASSWORD>

At the next prompt type the same password

Then Tools->Clear Cache (on your browser) and restart

 

Random key generator for wp-config:

https://api.wordpress.org/secret-key/1.1/salt/

 

And a couple of tutorials I’m browsing:

http://eliteeternity.com/mysql-server-wont-start-mamp-red-light-mac/

http://www.1stwebdesigner.com/tutorials/stylish-design-agency-landing-page-photoshop-tutorial/

http://www.1stwebdesigner.com/wordpress/psd-to-html-tutorial-code-photoshop/

 

I hope someone else finds this helpful, please leave a comment if you do!