From 93bcd6ea22bbc1e9605282136e941acc231d3c76 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Tue, 21 May 2024 16:32:45 +0530 Subject: [PATCH] avniproject/avni-webapp#1203 - methods to support standardReportCardInput fields --- src/ReportCard.js | 34 ++++++++++++++++++++++++++++++---- src/Schema.js | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/ReportCard.js b/src/ReportCard.js index c442128..e49add6 100644 --- a/src/ReportCard.js +++ b/src/ReportCard.js @@ -3,10 +3,9 @@ import General from "./utility/General"; import ResourceUtil from "./utility/ResourceUtil"; import StandardReportCardType from "./StandardReportCardType"; import _ from 'lodash'; - -function throwInvalidIndexError(index, reportCardsLength) { - throw new Error(`Invalid index ${index} specified for reportCard with length ${reportCardsLength}`); -} +import SubjectType from "./SubjectType"; +import Program from "./Program"; +import EncounterType from "./EncounterType"; class ReportCard extends BaseEntity { static schema = { @@ -22,6 +21,9 @@ class ReportCard extends BaseEntity { voided: {type: "bool", default: false}, nested: {type: "bool", default: false, optional: true}, countOfCards: {type: "int", default: 1, optional: true}, //Used only by nested ReportCards + standardReportCardInputSubjectTypes: {type: "list", objectType: "SubjectType"}, + standardReportCardInputPrograms: {type: "list", objectType: "Program"}, + standardReportCardInputEncounterTypes: {type: "list", objectType: "EncounterType"} }, }; @@ -98,6 +100,30 @@ class ReportCard extends BaseEntity { return _.isNil(this.standardReportCardType) ? '#ffffff' : this.standardReportCardType.textColor; } + get standardReportCardInputSubjectTypes() { + return this.toEntityList("standardReportCardInputSubjectTypes", SubjectType); + } + + set standardReportCardInputSubjectTypes(x) { + this.that.standardReportCardInputSubjectTypes = this.fromEntityList(x); + } + + get standardReportCardInputPrograms() { + return this.toEntityList("standardReportCardInputPrograms", Program); + } + + set standardReportCardInputPrograms(x) { + this.that.standardReportCardInputPrograms = this.fromEntityList(x); + } + + get standardReportCardInputEncounterTypes() { + return this.toEntityList("standardReportCardInputEncounterTypes", EncounterType); + } + + set standardReportCardInputEncounterTypes(x) { + this.that.standardReportCardInputEncounterTypes = this.fromEntityList(x); + } + /** * Helper method used to generate unique key value for Nested Report Cards using UUID and Index of the Report Card. * The Nested Report Card's query responses would be mapped to the corresponding Dashboard Report cards using the UUID and Index. diff --git a/src/Schema.js b/src/Schema.js index d319806..73462c5 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -252,7 +252,7 @@ function createRealmConfig() { return doCompact; }, //order is important, should be arranged according to the dependency - schemaVersion: 189, + schemaVersion: 190, onMigration: function (oldDB, newDB) { console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`); if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem)