diff --git a/src/Duration.js b/src/Duration.js index 7418458..d148cfe 100644 --- a/src/Duration.js +++ b/src/Duration.js @@ -4,7 +4,7 @@ import moment from "moment"; class Duration { constructor(durationValue, durationUnit) { this._durationValue = durationValue; - this.durationUnit = durationUnit; + this.durationUnit = durationUnit || Duration.Day; } static inDay(value) { diff --git a/src/ReportCard.js b/src/ReportCard.js index 337290e..dee298b 100644 --- a/src/ReportCard.js +++ b/src/ReportCard.js @@ -136,6 +136,9 @@ class ReportCard extends BaseEntity { } getStandardReportCardInputRecentDuration() { + if (_.isEmpty(this.that.standardReportCardInputRecentDurationJSON)) { + return new Duration(1, Duration.Day); + } const duration = JSON.parse(this.that.standardReportCardInputRecentDurationJSON); return new Duration(duration.value, duration.unit); } diff --git a/src/Schema.js b/src/Schema.js index 4e81bcc..0a67c2e 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -935,6 +935,12 @@ function createRealmConfig() { standardReportCardType.type = _.replace(_.startCase(standardReportCardType.description), new RegExp(' ', 'g'), ''); }); + _.forEach(newDB.objects(ReportCard.schema.name), (card) => { + card.standardReportCardInputSubjectTypes = []; + card.standardReportCardInputPrograms = []; + card.standardReportCardInputEncounterTypes = []; + }); + //Reset MyDashboard cache because shape of filterJSON in cache has changed const dashboardCache = newDB.objects("DashboardCache"); newDB.delete(dashboardCache);