forked from andymckay/malawi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
load.py
99 lines (84 loc) · 2.91 KB
/
load.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
import sys, os
sys.path.append(os.path.join(os.getcwd(),'lib'))
# override the standard method for running this
# so that we can include settings.py and our own
# settings
from rapidsms.config import Config
from rapidsms.manager import Manager
from django.core.management import execute_manager, setup_environ
# we know it will be rapidsms.ini in this projects
os.environ["RAPIDSMS_INI"] = "rapidsms.ini"
os.environ["DJANGO_SETTINGS_MODULE"] = "settings.py"
conf = Config(os.environ["RAPIDSMS_INI"])
import settings
setup_environ(settings)
from datetime import datetime, timedelta
from apps.sms.models.base import ReportMalnutrition, Case, Zone, Facility
from apps.sms.views.reporting import MalawiReport
from apps.sms.views.adding import NewPatient
from apps.sms.views.joining import MalawiJoin
from random import choice
class FakeMessage:
def __init__(self, number):
self.peer = self.sender = number
def respond(self, *args, **kw):
print args[0]
now = datetime.now()
fm = FakeMessage("1234567")
# this is Kaigwazanga, a GMC in the North Region > Rumphi Zone
MalawiJoin(fm, "15 Andy McKay")()
NewPatient(fm, "50 15 M 19102008 123124124")()
muac = 130
height = 100
for x in range(0, 100):
muac -= 1
height -= 0.5
MalawiReport(fm, "50 28.2 %s %s N Y" % (height, muac))()
res = ReportMalnutrition.objects.filter(case=1).latest("entered_at")
res.entered_at = now - timedelta(days=x)
res.save()
fm = FakeMessage("1234560")
# Mkanda > Kaigwazanga
MalawiJoin(fm, "16 Andy McKay")()
NewPatient(fm, "51 16 M 19102008 123124124")()
muac = 12
height = 90
for x in range(0, 100):
muac -= 0.1
height -= 0.5
MalawiReport(fm, "51 21.2 %s %s N Y" % (height, muac))()
res = ReportMalnutrition.objects.filter(case=2).latest("entered_at")
res.entered_at = now - timedelta(days=x)
res.save()
fm = FakeMessage("999999")
# this is Changata, a GMC in the Southeern Region > Thyolo
MalawiJoin(fm, "126 Coulibaly Mariam")()
NewPatient(fm, "70 1201 M 19102008 123124124")()
muac = 15
height = 10
for x in range(0, 100):
muac -= 0.1
height += 0.5
MalawiReport(fm, "70 24.2 9.5 %s N Y" % muac)()
res = ReportMalnutrition.objects.filter(case=3).latest("entered_at")
res.entered_at = now - timedelta(days=x * 2)
res.save()
fm = FakeMessage("999299")
# this is Changata, a GMC in the Southeern Region > Thyolo
MalawiJoin(fm, "127 Coulibaly Mariam")()
NewPatient(fm, "71 1201 M 19102008 123124124")()
muac = 15
height = 30
for x in range(0, 100):
muac -= 0.11
height += 0.5
MalawiReport(fm, "71 25.2 95.5 %s N Y" % muac)()
res = ReportMalnutrition.objects.filter(case=4).latest("entered_at")
res.entered_at = now - timedelta(days=x * 2)
res.save()
print
print Facility.objects.get(codename=126).name
print Facility.objects.get(codename=127).name
print Facility.objects.get(codename=15).name
print Facility.objects.get(codename=16).name