Skip to content

Commit

Permalink
avniproject/avni-webapp#1203 - methods to support standardReportCardI…
Browse files Browse the repository at this point in the history
…nput fields
  • Loading branch information
petmongrels committed May 21, 2024
1 parent 2a00eea commit 93bcd6e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
34 changes: 30 additions & 4 deletions src/ReportCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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"}
},
};

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 93bcd6e

Please sign in to comment.