Download - Fighting Malnutrition with SMS and Django
![Page 1: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/1.jpg)
Fighting Malnutrition with SMS and Django
Andy McKayclearwind consulting
[email protected]@clearwind
![Page 2: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/2.jpg)
clearwind consulting
Lots of Plone sitesWrote book
![Page 3: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/3.jpg)
clearwind consulting
Prinicpal of ClearwindBeen doing Python for about 9 yearsco-founder of Enfold Systems
![Page 4: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/4.jpg)
clearwind consulting
![Page 5: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/5.jpg)
clearwind consulting
existing project
![Page 6: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/6.jpg)
clearwind consulting
rapidsms
![Page 7: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/7.jpg)
clearwind consulting
Schuyler ErleMatt Berg
Adam McKaigand others...
![Page 8: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/8.jpg)
clearwind consulting
deployment help?
![Page 9: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/9.jpg)
clearwind consulting
4 days, 32 hours flight...
![Page 10: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/10.jpg)
clearwind consulting
![Page 11: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/11.jpg)
clearwind consulting
and yes this area is home to a certain famous family....
![Page 12: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/12.jpg)
clearwind consulting
health care workers
for community health care workers in the field
large number of children to look after
in village (not in clinics)
![Page 13: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/13.jpg)
clearwind consulting
![Page 14: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/14.jpg)
clearwind consulting
identify and helpsometimes not easy to spot malnurished kids
maybe no records
let other people know the kid needs help
parents sometimes have enough trouble feeding rest of the family
![Page 15: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/15.jpg)
clearwind consulting
disclaimerI am not a health careworked or related to development
i know the techy bits
can't speak about efficiency of the program
![Page 16: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/16.jpg)
clearwind consulting
Robbed of vital nutrients as children, they grow up stunted and sickly, weaklings in a land that still runs on manual labor.
http://www.nytimes.com/2006/12/28/world/africa/28malnutrition.html
![Page 17: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/17.jpg)
clearwind consulting
muacmid upper arm circumfrence
Matt Berg
![Page 18: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/18.jpg)
children
muac
clearwind consulting
worker
![Page 19: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/19.jpg)
django
sms
clearwind consulting
children worker
muac
![Page 20: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/20.jpg)
clinic
sms
clearwind consulting
django
sms
children worker
muac
![Page 21: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/21.jpg)
![Page 22: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/22.jpg)
clearwind consulting
spomskyd
serial
![Page 23: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/23.jpg)
clearwind consulting
spomskyd
django route
http
serial
![Page 24: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/24.jpg)
clearwind consulting
![Page 25: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/25.jpg)
clearwind consulting
since then spomskyd has been replaced by pygsm
pygsm do a lot of work sorting out all those sms quirks
pygsm
django route
http
serial
![Page 26: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/26.jpg)
clearwind consulting
custom ui
pygsm
django route
http
serialworkers
django runserver
![Page 27: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/27.jpg)
clearwind consulting
Note: test data
![Page 28: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/28.jpg)
clearwind consulting
Note: test data
![Page 29: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/29.jpg)
clearwind consulting
Note: test data
![Page 30: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/30.jpg)
clearwind consulting
admins
admincustom ui
workers
django runserver
pygsm
django route
http
serial
![Page 31: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/31.jpg)
clearwind consulting
7654321 > +26 105 d v f
child 26 MUAC 105diarrheoavomitingfever
![Page 32: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/32.jpg)
clearwind consulting
7654321 > +26 105 d v f
7654321 < MUAC> SAM+ Patient requires IMMEDIATE inpatient care. +26 MADISON, M, F/4 (Sally). MUAC 105 mm, Diarrhea, Fever, Vomiting
![Page 33: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/33.jpg)
clearwind consulting
7654321 > +26 105 d v f
7654321 < MUAC> SAM+ Patient requires IMMEDIATE inpatient care. +26 MADISON, M, F/4 (Sally). MUAC 105 mm, Diarrhea, Fever, Vomiting
7654322 < @jdoe reports +26: SAM+, MUAC 105 mm, Diarrhea, Fever, Vomiting
![Page 34: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/34.jpg)
clearwind consulting
malaria
![Page 35: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/35.jpg)
clearwind consulting
7654321 > mrdt +34 y n f
malaria rapid diagnosis
child 34y has malarin has no bednetf has a fever
![Page 36: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/36.jpg)
clearwind consulting
7654321 > mrdt +34 y n f
7654321 < MRDT> Child +34, MADISON, Molly, F/12m has MALARIA. Child is less than 3. Please provide 1 tab of Coartem (ACT) twice a day for 3 days
![Page 37: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/37.jpg)
clearwind consulting
Matt Berg
![Page 38: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/38.jpg)
clearwind consulting
flew back
![Page 39: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/39.jpg)
clearwind consulting
sleptmoved houseslept, slept
http://www.flickr.com/photos/chris_gin/2388032929/sizes/l/
![Page 40: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/40.jpg)
clearwind consulting
technical details
some of these are based on later work for Malawi
talk about a few of the bits i worked on
interesting
![Page 41: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/41.jpg)
clearwind consulting
rapidsms
![Page 42: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/42.jpg)
clearwind consulting
from rapidsms.message import Message
message.text
message.person
message.send()
message.respond(text)
message.forward(identity, text=None)
rapidsms api
![Page 43: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/43.jpg)
clearwind consulting
decorator for routing
![Page 44: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/44.jpg)
clearwind consulting
# Register a new patient
@keyword(r'new (\S+) (\S+) ([MF]) ([\d\-]+)( \D+)?( \d+)?( z\d+)?')
@authenticated
def new_case (self, message,...[snip]):
# Do something with the new patient
![Page 45: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/45.jpg)
clearwind consulting
i like urls.py
![Page 46: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/46.jpg)
clearwind consulting
1. see what's going where2. route to different
its a django standard, more friendly for other users
easier to change sms without having to change the code
![Page 47: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/47.jpg)
clearwind consulting
urlpatterns = patterns('',
(r'^new (.*)', "apps.mctc.views.joining.new_case"),
)despite the name, url patterns can be used for more than just urls
![Page 48: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/48.jpg)
clearwind consulting
try:
callback, args, kwargs = resolver.resolve(message.text.lower())
except Resolver404:
message.respond(_("Unknown command: %(msg)s...) % {"msg":message.text[:10]})
![Page 49: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/49.jpg)
clearwind consulting
form handling
![Page 50: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/50.jpg)
clearwind consulting
full of checkingcode, views were full of checking and validation
in django this is done by forms
![Page 51: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/51.jpg)
clearwind consulting
parse string into form
![Page 52: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/52.jpg)
clearwind consulting
# NEW 70 1201 M 19102008 123124124
class NewForm(Form):
child = StringField(valid="(\d+)")
gmc = StringField(valid="(\d+)")
sex = GenderField()
dob = DateField(format="%m%d%Y")
contact = StringField(valid="(\d+)", required=False)
![Page 53: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/53.jpg)
clearwind consulting
class based viewshttp://www.slideshare.net/simon/classbased-views-with-django
![Page 54: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/54.jpg)
clearwind consulting
class based view that does repetitive work→ validate form→ process form→ what to do if it goes wrongsubclassed for different country (eg. Malawi)
![Page 55: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/55.jpg)
clearwind consulting
class MalawiNew(New): @authenticated def post_init(self): self.form = NewForm def pre_process(self): # malawi specific request years, months = years_months(self.form.clean.dob.data.strftime.data) if years > 5: raise FormFailed, "You have attempted to register child #%s. However, "\ "the date of birth entered is %s. The age of this "\ "child is above 5 years. Please resend SMS with corrected "\ "age." % (self.form.clean.child.data, self.form.clean.dob.data.strftime("%m.%d.%Y")) def post_process(self): if self.form.clean.contact.data: self.data.case.mobile = self.form.clean.contact def error_already_exists(self): # malawi specific code return "You have attempted to register child #%s in %s GMC. However, this child already exists. If this is an error, please resend SMS with correct information. If this patient is new or a replacement, please use the EXIT command first, then re-register." % (self.form.clean.child.data, self.data.provider.clinic.name)
![Page 56: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/56.jpg)
clearwind consulting
testing
![Page 57: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/57.jpg)
clearwind consulting
tests really matter
![Page 58: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/58.jpg)
clearwind consulting
test_05_cancelling = """
1234567 > REPORT 70 25.2 95.5 13.5 N Y
1234567 < Thank you Mariam Coulibaly for reporting child #70, weight = 25.2 kg, height = 95.5 cm, MUAC = 13.5 cm, no oedema, yes diarrhea...[snip]
1234567 > CANCEL 70
1234567 < Report for 70 cancelcel...[snip]"""
brillianty done format
allows easy reading bynon technical users
![Page 59: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/59.jpg)
clearwind consulting
reusable tablehttp://github.com/andymckay/django-reusable-tables/tree/master
![Page 60: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/60.jpg)
clearwind consulting
Note: test data
![Page 61: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/61.jpg)
clearwind consulting
liking it less
![Page 62: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/62.jpg)
clearwind consulting
register("case", Case, [ ["Id", "ref_id", "{{object.ref_id}}"], ["Name", "last_name", "{{object.first_name}} {{object.last_name}}"],...[snip]
])
![Page 63: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/63.jpg)
clearwind consulting
what challenges?
![Page 64: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/64.jpg)
clearwind consulting
another framework?
designed for a non-technical audience
as a techy that can be annoying, eg settings.py
if you just want to speak to SMS and nothing else, maybe better way to go
![Page 65: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/65.jpg)
clearwind consulting
not enough timeschuyler, adam, matt
![Page 66: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/66.jpg)
clearwind consulting
infrastructure
this is the pavement in the main street
![Page 67: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/67.jpg)
clearwind consulting
We have over 5000 kids in the system now and counting. It's been used to catch over 100 kids with malnutrition and about 400 with malaria.
Matt Berg
![Page 68: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/68.jpg)
clearwind consulting
thank you, django
![Page 69: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/69.jpg)
clearwind consulting
volunteers wanted
5-10Hour projects we would love volunteer help with
![Page 70: Fighting Malnutrition with SMS and Django](https://reader034.vdocuments.us/reader034/viewer/2022052619/555a2e4bd8b42ab3088b5008/html5/thumbnails/70.jpg)
clearwind consulting
more infowww.rapidsms.org/rapidresponse