Skip to content

Commit

Permalink
Always return some form definition
Browse files Browse the repository at this point in the history
#7933

(cherry picked from commit a0bcf5b)
  • Loading branch information
dianabarsan authored Nov 29, 2022
1 parent 74b6798 commit f09396d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 3 additions & 4 deletions api/src/services/report/smsparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,11 @@ exports.parse = (def, doc) => {
}
}

if(!bsYear) {
if (bsYear) {
formData[aggregateBSDateField] = bsToEpoch(bsYear, bsMonth, bsDay);
} else {
logger.error('Can not aggregate bsAggreDate without bsYear');
return;
}

formData[aggregateBSDateField] = bsToEpoch(bsYear, bsMonth, bsDay);
}

// pass along some system generated fields
Expand Down
14 changes: 12 additions & 2 deletions api/tests/mocha/services/report/smsparser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ describe('sms parser', () => {
lmp_date: moment('2012-03-12').valueOf()
});
});


it('BS date parts with invalid bsYear yyys: compact textforms', () => {
const doc = { message: 'YYYS 12345 123 11 29' };
Expand All @@ -647,6 +647,16 @@ describe('sms parser', () => {
});
});

it('BS date parts with missing bsYear yyys: compact textforms', () => {
const doc = { message: 'YYYS 12345' };
const def = definitions.forms.YYYS;
const data = smsparser.parse(def, doc);
chai.expect(data).to.deep.equal({
patient_id: '12345',
});
});


it('BS date parts without bsMonth & bsDay yyyr: compact textforms', () => {
const doc = { message: 'YYYR 12345 2068' };
const def = definitions.forms.YYYR;
Expand Down Expand Up @@ -1474,7 +1484,7 @@ describe('sms parser', () => {
type: 'string',
labels: {
tiny: 'ch'
}
}
}
}
};
Expand Down

0 comments on commit f09396d

Please sign in to comment.