Skip to content

Commit 7b310b2

Browse files
committed
Merge pull request #1063 from medic/testing
v0.4.8 release
2 parents 92d5117 + f99c9d9 commit 7b310b2

File tree

14 files changed

+95
-19
lines changed

14 files changed

+95
-19
lines changed

Changes.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Medic Mobile Release Notes
22

3+
## 0.4.8
4+
5+
### Jul 14, 2015
6+
7+
- Added SMS parser fixes from dev branch:
8+
9+
- parse string fields with exlamation marks
10+
- compact textforms format handles quotes in quotes
11+
12+
- Fixed export bug when using lowercase form codes. Please re-upload your forms
13+
so they are formatted correctly. #998
14+
15+
- Fixed bug where exporting yields same result with or without date
16+
filter. #1059, #1031
17+
318
## 0.4.7
419

520
### Jun 16, 2015

Gruntfile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ module.exports = function(grunt) {
125125
'outline-none': false,
126126
'qualified-headings': false,
127127
'unique-headings': false,
128+
'selector-max-approaching': false
128129
}
129130
}
130131
},
@@ -402,4 +403,4 @@ module.exports = function(grunt) {
402403
];
403404
};
404405

405-
};
406+
};

kanso.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "medic",
33
"display_name": "Medic Mobile",
4-
"version": "0.4.7",
4+
"version": "0.4.8",
55
"description": "SMS data collection designed for rural environments.",
66
"long_description" : "Medic Mobile is a web based SMS data collection and analytics tool focused on community health care workers in rural environments. We help large health organizations collect and analyze data sent from health care workers using ordinary mobile phones.",
77
"url": "https://github.com/medic/medic-webapp",

lib/show-includes/configuration.js

+3
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,10 @@ exports.configuration = function (_doc, _req) {
345345
json = JSON.parse(_ev.target.result);
346346
json.forEach(function(form, idx) {
347347
if (form.meta && form.meta.code) {
348+
// form codes are case insensitive and object
349+
// key and a form.meta.code should be the same.
348350
settings.forms[form.meta.code.toUpperCase()] = form;
351+
form.meta.code = form.meta.code.toUpperCase();
349352
}
350353
});
351354
} catch(e) {

lib/shows.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ function onExportFormsSubmit(ev) {
6666
if (startVal !== '') {
6767
// update endkey for startdate as view is descending
6868
endkey.push(startDate.valueOf());
69-
} else {
70-
endkey.push(0);
7169
}
7270
if (endVal !== '') {
7371
// update startkey for enddate as view is descending
@@ -519,7 +517,7 @@ function renderDownloadForms() {
519517
keys = _.keys(titles).sort();
520518

521519
var forms = _.reduce(data.rows, function(memo, row) {
522-
var dh_id = row.key[0],
520+
var dh_id = row.key[0] || 'null_district',
523521
form = row.key[1],
524522
dh_name = row.key[2],
525523
title = '',
@@ -531,6 +529,8 @@ function renderDownloadForms() {
531529
startkey: [true, dh_id, form],
532530
endkey: [true, dh_id, form],
533531
dh_name: dh_name,
532+
include_docs: true,
533+
descending: true,
534534
tz: tz
535535
});
536536

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "medic",
3-
"version": "0.4.7",
3+
"version": "0.4.8",
44
"repository": {
55
"type": "git",
66
"url": "git://github.com/medic/medic-webapp.git"

packages/kujua-sms/kujua-sms/rewrites.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,7 @@ exports.rules = [
5555
},
5656
{
5757
from: '/export/forms/:form',
58-
to: '_list/export_data_records/data_records',
59-
query: {
60-
include_docs: 'true',
61-
descending: 'true',
62-
startkey: [true, ':form', {}],
63-
endkey: [true, ':form'],
64-
form: ':form'
65-
}
58+
to: '_list/export_data_records/data_records'
6659
},
6760
{
6861
from: '/:form/data_record/add/clinic/:phone',

packages/kujua-sms/kujua-sms/views.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports.data_records = {
1010
if (doc.type === 'data_record') {
1111
clinicId = objectpath.get(doc, 'related_entities.clinic._id');
1212
centerId = objectpath.get(doc, 'related_entities.clinic.parent._id');
13-
districtId = objectpath.get(doc, 'related_entities.clinic.parent.parent._id');
13+
districtId = objectpath.get(doc, 'related_entities.clinic.parent.parent._id') || 'null_district';
1414
valid = !doc.errors || doc.errors.length === 0;
1515

1616
emit([doc.reported_date], 1);

packages/kujua-sms/tests/kujua-sms/smsparser.js

+34
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,40 @@ exports['parse string field mixed'] = function(test) {
753753
test.done();
754754
};
755755

756+
exports['parse string field with exlamation mark!'] = function(test) {
757+
test.expect(2);
758+
759+
// textforms
760+
var doc = {
761+
message: "0000 foo 16A!"
762+
};
763+
var def = {
764+
meta: {
765+
code: '0000'
766+
},
767+
fields: {
768+
foo: {
769+
type: 'string',
770+
labels: {
771+
short: 'foo',
772+
tiny: 'foo'
773+
}
774+
}
775+
}
776+
};
777+
var data = smsparser.parse(def, doc);
778+
test.same(data, {foo: "16A!"});
779+
780+
// muvuku
781+
doc = {
782+
message: "1!0000!16A!"
783+
};
784+
data = smsparser.parse(def, doc);
785+
test.same(data, {foo: "16A!"});
786+
787+
test.done();
788+
};
789+
756790
exports['parse string field leading zero'] = function(test) {
757791
test.expect(2);
758792

packages/kujua-sms/tests/kujua-sms/smsparser_compact_textform.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ exports['compact textforms format with hyphen separated form code'] = function(t
9595
test.done();
9696
};
9797

98-
9998
exports['compact textforms format uses quotes for multiple words'] = function(test) {
10099
var doc = {
101100
sent_timestamp: '1-13-12 15:35',
@@ -114,6 +113,25 @@ exports['compact textforms format uses quotes for multiple words'] = function(te
114113
test.done();
115114
};
116115

116+
exports['compact textforms format handles quotes in quotes'] = function(test) {
117+
var doc = {
118+
sent_timestamp: '1-13-12 15:35',
119+
from: '+15551212',
120+
message: 'ANCR "Sarah "killer bee" Connor" 24 2012-03-12'
121+
};
122+
123+
var expectedObj = {
124+
name: 'Sarah \"killer bee\" Connor',
125+
lmp: 24,
126+
somedate: 1331510400000
127+
};
128+
129+
debugger;
130+
var obj = smsparser.parse(def, doc);
131+
test.same(obj, expectedObj);
132+
test.done();
133+
};
134+
117135
exports['compact textforms handles too few fields'] = function(test) {
118136
var doc = {
119137
sent_timestamp: '1-13-12 15:35',

packages/kujua-sms/views/lib/mp_parser.js

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ var parse = exports.parse = function(def, doc) {
2323
name = header[1],
2424
vals = parts.slice(1);
2525

26+
var n = 3;
27+
while (n < header.length) {
28+
header[2] += '!' + header[n++];
29+
}
30+
2631
vals.unshift(header[2]);
2732

2833
if(!def || !def.fields) {

packages/kujua-sms/views/lib/smsparser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ exports.getFormCode = function(msg) {
285285
if (typeof msg !== 'string') { return; }
286286

287287
// muvuku
288-
if (msg.split('!').length === 3) {
288+
if (msg.split('!').length >= 3) {
289289
return msg.split('!')[1].toUpperCase();
290290
}
291291
// textforms

packages/kujua-sms/views/lib/textforms_parser.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ exports.parseCompact = function(def, msg) {
219219
var values = msg.match(/"[^"]+"|[^"\s]+/g);
220220
var keys = _.keys(def.fields);
221221

222+
if (values.length > keys.length) {
223+
values = msg.match(/".+"|[^"\s]+/g);
224+
}
225+
222226
var results = {};
223227
for (var i = 0; i < keys.length; i++) {
224228
if (values.length === 0) {
@@ -231,8 +235,11 @@ exports.parseCompact = function(def, msg) {
231235
} else {
232236
value = values.shift();
233237
}
238+
if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
239+
value = value.substring(1, value.length - 1);
240+
}
234241
if (typeof results[key] === 'undefined') {
235-
results[key] = value.replace(/"/g, '');
242+
results[key] = value;
236243
}
237244
}
238245
return results;

0 commit comments

Comments
 (0)