From 98afbda7ab4a3c4ee772bb00de14a13b4b32feaf Mon Sep 17 00:00:00 2001 From: Joy A Date: Thu, 5 Sep 2024 11:16:17 +0530 Subject: [PATCH 01/10] avniproject/avni-server#781 | Add type to StandardReportCardType --- src/Schema.js | 2 +- src/StandardReportCardType.js | 111 ++++++++++++---------- test/ReportCardTest.js | 4 +- test/ref/StandardReportCardTypeFactory.js | 3 +- 4 files changed, 65 insertions(+), 55 deletions(-) diff --git a/src/Schema.js b/src/Schema.js index 7305575..b190c2e 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -256,7 +256,7 @@ function createRealmConfig() { return doCompact; }, //order is important, should be arranged according to the dependency - schemaVersion: 196, + schemaVersion: 197, 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) diff --git a/src/StandardReportCardType.js b/src/StandardReportCardType.js index 7c68e3e..5b2f3c4 100644 --- a/src/StandardReportCardType.js +++ b/src/StandardReportCardType.js @@ -13,6 +13,7 @@ class StandardReportCardType extends BaseEntity { uuid: "string", name: "string", description: {type: "string", optional: true}, + type: {type: "string", optional: true}, voided: {type: "bool", default: false}, }, }; @@ -37,20 +38,28 @@ class StandardReportCardType extends BaseEntity { this.that.description = x; } - static type = { - PendingApproval: "Pending approval", + get type() { + return this.that.type; + } + + set type(x) { + this.that.type = x; + } + + static types = { + PendingApproval: "PendingApproval", Approved: "Approved", Rejected: "Rejected", - ScheduledVisits: "Scheduled visits", - OverdueVisits: "Overdue visits", - RecentRegistrations: "Recent registrations", - RecentEnrolments: "Recent enrolments", - RecentVisits: "Recent visits", + ScheduledVisits: "ScheduledVisits", + OverdueVisits: "OverdueVisits", + RecentRegistrations: "RecentRegistrations", + RecentEnrolments: "RecentEnrolments", + RecentVisits: "RecentVisits", Total: "Total", Comments: "Comments", - CallTasks: "Call tasks", - OpenSubjectTasks: "Open subject tasks", - DueChecklist: "Due checklist" + CallTasks: "CallTasks", + OpenSubjectTasks: "OpenSubjectTasks", + DueChecklist: "DueChecklist" }; static recentCardDurationUnits = [ @@ -61,26 +70,26 @@ class StandardReportCardType extends BaseEntity { get iconName() { const typeIcon = { - [StandardReportCardType.type.Approved]: 'check-circle', - [StandardReportCardType.type.Rejected]: 'cancel', - [StandardReportCardType.type.PendingApproval]: 'av-timer', - [StandardReportCardType.type.Comments]: 'message', - [StandardReportCardType.type.CallTasks]: 'call', - [StandardReportCardType.type.OpenSubjectTasks]: 'sticky-note-2', + [StandardReportCardType.types.Approved]: 'check-circle', + [StandardReportCardType.types.Rejected]: 'cancel', + [StandardReportCardType.types.PendingApproval]: 'av-timer', + [StandardReportCardType.types.Comments]: 'message', + [StandardReportCardType.types.CallTasks]: 'call', + [StandardReportCardType.types.OpenSubjectTasks]: 'sticky-note-2', }; - return typeIcon[this.name]; + return typeIcon[this.type]; } get cardColor() { const typeCardColor = { - [StandardReportCardType.type.Approved]: '#00897b', - [StandardReportCardType.type.Rejected]: '#bf360c', - [StandardReportCardType.type.PendingApproval]: '#6a1b9a', - [StandardReportCardType.type.Comments]: '#3949ab', - [StandardReportCardType.type.CallTasks]: '#69a672', - [StandardReportCardType.type.OpenSubjectTasks]: '#717cac', + [StandardReportCardType.types.Approved]: '#00897b', + [StandardReportCardType.types.Rejected]: '#bf360c', + [StandardReportCardType.types.PendingApproval]: '#6a1b9a', + [StandardReportCardType.types.Comments]: '#3949ab', + [StandardReportCardType.types.CallTasks]: '#69a672', + [StandardReportCardType.types.OpenSubjectTasks]: '#717cac', }; - return typeCardColor[this.name]; + return typeCardColor[this.type]; } get textColor() { @@ -89,78 +98,78 @@ class StandardReportCardType extends BaseEntity { static fromResource(resource) { return General.assignFields(resource, new StandardReportCardType(), - ["uuid", "name", "description", "voided"]); + ["uuid", "name", "description", "voided", "type"]); } isStandardCard() { - return _.includes([...this.approvalTypes(), StandardReportCardType.type.Comments, StandardReportCardType.type.CallTasks, StandardReportCardType.type.OpenSubjectTasks], this.name); + return _.includes([...this.approvalTypes(), StandardReportCardType.types.Comments, StandardReportCardType.types.CallTasks, StandardReportCardType.types.OpenSubjectTasks], this.type); } approvalTypes() { - return [StandardReportCardType.type.PendingApproval, StandardReportCardType.type.Approved, StandardReportCardType.type.Rejected] + return [StandardReportCardType.types.PendingApproval, StandardReportCardType.types.Approved, StandardReportCardType.types.Rejected] } defaultTypes() { - return [StandardReportCardType.type.ScheduledVisits, StandardReportCardType.type.OverdueVisits, StandardReportCardType.type.RecentRegistrations, StandardReportCardType.type.RecentEnrolments, StandardReportCardType.type.RecentVisits, StandardReportCardType.type.Total] + return [StandardReportCardType.types.ScheduledVisits, StandardReportCardType.types.OverdueVisits, StandardReportCardType.types.RecentRegistrations, StandardReportCardType.types.RecentEnrolments, StandardReportCardType.types.RecentVisits, StandardReportCardType.types.Total] } isApprovalType() { - return _.includes(this.approvalTypes(), this.name); + return _.includes(this.approvalTypes(), this.type); } isCommentType() { - return this.name === StandardReportCardType.type.Comments; + return this.type === StandardReportCardType.types.Comments; } isTaskType() { - return _.includes([StandardReportCardType.type.CallTasks, StandardReportCardType.type.OpenSubjectTasks], this.name); + return _.includes([StandardReportCardType.types.CallTasks, StandardReportCardType.types.OpenSubjectTasks], this.type); } isChecklistType() { - return this.name === StandardReportCardType.type.DueChecklist; + return this.type === StandardReportCardType.types.DueChecklist; } getTaskTypeType() { - switch (this.name) { - case StandardReportCardType.type.CallTasks: + switch (this.type) { + case StandardReportCardType.types.CallTasks: return TaskType.TaskTypeName.Call; - case StandardReportCardType.type.OpenSubjectTasks: + case StandardReportCardType.types.OpenSubjectTasks: return TaskType.TaskTypeName.OpenSubject; } } isDefaultType() { - return _.includes(this.defaultTypes(), this.name); + return _.includes(this.defaultTypes(), this.type); } getApprovalStatusForType() { - return typeToStatusMap[this.name]; + return typeToStatusMap[this.type]; } isSubjectTypeFilterSupported() { return [ - StandardReportCardType.type.ScheduledVisits, - StandardReportCardType.type.OverdueVisits, - StandardReportCardType.type.RecentRegistrations, - StandardReportCardType.type.RecentEnrolments, - StandardReportCardType.type.RecentVisits, - StandardReportCardType.type.Total, - ].includes(this.name); + StandardReportCardType.types.ScheduledVisits, + StandardReportCardType.types.OverdueVisits, + StandardReportCardType.types.RecentRegistrations, + StandardReportCardType.types.RecentEnrolments, + StandardReportCardType.types.RecentVisits, + StandardReportCardType.types.Total, + ].includes(this.type); } isRecentType() { return [ - StandardReportCardType.type.RecentRegistrations, - StandardReportCardType.type.RecentEnrolments, - StandardReportCardType.type.RecentVisits, - ].includes(this.name); + StandardReportCardType.types.RecentRegistrations, + StandardReportCardType.types.RecentEnrolments, + StandardReportCardType.types.RecentVisits, + ].includes(this.type); } } const typeToStatusMap = { - [StandardReportCardType.type.PendingApproval]: ApprovalStatus.statuses.Pending, - [StandardReportCardType.type.Approved]: ApprovalStatus.statuses.Approved, - [StandardReportCardType.type.Rejected]: ApprovalStatus.statuses.Rejected, + [StandardReportCardType.types.PendingApproval]: ApprovalStatus.statuses.Pending, + [StandardReportCardType.types.Approved]: ApprovalStatus.statuses.Approved, + [StandardReportCardType.types.Rejected]: ApprovalStatus.statuses.Rejected, }; export default StandardReportCardType; diff --git a/test/ReportCardTest.js b/test/ReportCardTest.js index d2c789b..c8bb888 100644 --- a/test/ReportCardTest.js +++ b/test/ReportCardTest.js @@ -4,9 +4,9 @@ import StandardReportCardType from "../src/StandardReportCardType"; import {assert} from 'chai'; it('is subject type filter supported', function () { - const approvedType = StandardReportCardTypeFactory.create({name: StandardReportCardType.type.Approved}); + const approvedType = StandardReportCardTypeFactory.create({name: 'Approved', type: StandardReportCardType.types.Approved}); const reportCard = ReportCardFactory.create({standardReportCardType: approvedType}); assert.equal(reportCard.isSubjectTypeFilterSupported(), false); - reportCard.standardReportCardType = StandardReportCardTypeFactory.create({name: StandardReportCardType.type.ScheduledVisits}); + reportCard.standardReportCardType = StandardReportCardTypeFactory.create({name: 'Scheduled visits', type: StandardReportCardType.types.ScheduledVisits}); assert.equal(reportCard.isSubjectTypeFilterSupported(), true); }); diff --git a/test/ref/StandardReportCardTypeFactory.js b/test/ref/StandardReportCardTypeFactory.js index ed5aa86..6afda68 100644 --- a/test/ref/StandardReportCardTypeFactory.js +++ b/test/ref/StandardReportCardTypeFactory.js @@ -1,9 +1,10 @@ import StandardReportCardType from "../../src/StandardReportCardType"; class StandardReportCardTypeFactory { - static create({name}) { + static create({name, type}) { const standardReportCardType = new StandardReportCardType(); standardReportCardType.name = name; + standardReportCardType.type = type; return standardReportCardType; } } From f59ea541719f025e818d646ed1ecd0ebcc39d684 Mon Sep 17 00:00:00 2001 From: Joy A Date: Thu, 5 Sep 2024 11:17:31 +0530 Subject: [PATCH 02/10] v1.32.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 226ee13..225d722 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openchs-models", "description": "OpenCHS data model to be used by front end clients", - "version": "1.32.7", + "version": "1.32.9", "private": false, "repository": { "type": "git", From d026e0ec58779aed2afd8bc2738b382c1c11cf08 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 9 Sep 2024 14:36:32 +0530 Subject: [PATCH 03/10] avniproject/avni-server#782 - use v2 endpoints for report card related entities --- src/EntityMetaData.js | 687 ++++++++++++++++++++++-------------------- 1 file changed, 362 insertions(+), 325 deletions(-) diff --git a/src/EntityMetaData.js b/src/EntityMetaData.js index dfd9f65..8a2224d 100644 --- a/src/EntityMetaData.js +++ b/src/EntityMetaData.js @@ -70,69 +70,71 @@ import UserSubjectAssignment from "./assignment/UserSubjectAssignment"; import DashboardFilter from "./reports/DashboardFilter"; const refData = (clazz, { - res, - filter = "lastModified", - translated, - parent, - syncWeight, - resUrl, - syncPushRequired = true, - syncPullRequired = true + res, + filter = "lastModified", + translated, + parent, + syncWeight, + resUrl, + syncPushRequired = true, + syncPullRequired = true, + apiVersion } = {}) => ({ - schemaName: clazz.schema.name, - entityName: clazz.schema.name, - entityClass: clazz, - resourceName: res || _.camelCase(clazz.schema.name), - type: "reference", - nameTranslated: translated || false, - resourceSearchFilterURL: filter, - parent: parent, - syncWeight: syncWeight, - resourceUrl: resUrl, - syncPushRequired, - syncPullRequired + schemaName: clazz.schema.name, + entityName: clazz.schema.name, + entityClass: clazz, + resourceName: res || _.camelCase(clazz.schema.name), + type: "reference", + nameTranslated: translated || false, + resourceSearchFilterURL: filter, + parent: parent, + syncWeight: syncWeight, + resourceUrl: resUrl, + syncPushRequired, + syncPullRequired, + apiVersion }); const refDataNameTranslated = (clazz, attrs = {}) => refData(clazz, {...attrs, translated: true}); const txData = ( - clazz, - { - entityName, - res, - resUrl, - parent, + clazz, + { + entityName, + res, + resUrl, + parent, + apiVersion, + syncWeight, + privilegeParam, + privilegeEntity, + privilegeName, + queryParam, + hasMoreThanOneAssociation, + apiQueryParams, + apiQueryParamKey, + syncPushRequired = true, + syncPullRequired = true + } = {} +) => ({ + schemaName: clazz.schema.name, + entityName: entityName || clazz.schema.name, + entityClass: clazz, + resourceName: res || _.camelCase(clazz.schema.name), + resourceUrl: resUrl, + type: "tx", + nameTranslated: false, + parent: parent, apiVersion, - syncWeight, + syncWeight: syncWeight, privilegeParam, privilegeEntity, privilegeName, queryParam, - hasMoreThanOneAssociation, + hasMoreThanOneAssociation: !!hasMoreThanOneAssociation, apiQueryParams, apiQueryParamKey, - syncPushRequired = true, - syncPullRequired = true - } = {} -) => ({ - schemaName: clazz.schema.name, - entityName: entityName || clazz.schema.name, - entityClass: clazz, - resourceName: res || _.camelCase(clazz.schema.name), - resourceUrl: resUrl, - type: "tx", - nameTranslated: false, - parent: parent, - apiVersion, - syncWeight: syncWeight, - privilegeParam, - privilegeEntity, - privilegeName, - queryParam, - hasMoreThanOneAssociation: !!hasMoreThanOneAssociation, - apiQueryParams, - apiQueryParamKey, - syncPushRequired, - syncPullRequired + syncPushRequired, + syncPullRequired }); const checklistDetail = refData(ChecklistDetail, {syncWeight: 1}); @@ -141,254 +143,289 @@ const ruleDependency = refData(RuleDependency, {syncWeight: 3}); const form = refData(Form, {syncWeight: 4}); const formMapping = refData(FormMapping, {syncWeight: 1}); const encounterType = refDataNameTranslated(EncounterType, { - res: "operationalEncounterType", - syncWeight: 4, + res: "operationalEncounterType", + syncWeight: 4, }); const program = refDataNameTranslated(Program, { - res: "operationalProgram", - syncWeight: 3, + res: "operationalProgram", + syncWeight: 3, }); const gender = refDataNameTranslated(Gender, {syncWeight: 1}); const individualRelation = refDataNameTranslated(IndividualRelation, { - syncWeight: 3, + syncWeight: 3, }); const individualRelationGenderMapping = refDataNameTranslated(IndividualRelationGenderMapping, { - syncWeight: 3, + syncWeight: 3, }); const individualRelationshipType = refDataNameTranslated(IndividualRelationshipType, { - syncWeight: 3, + syncWeight: 3, }); const concept = refDataNameTranslated(Concept, {syncWeight: 4}); const video = refDataNameTranslated(Video, {syncWeight: 0}); const subjectType = refDataNameTranslated(SubjectType, { - res: "operationalSubjectType", - syncWeight: 1, + res: "operationalSubjectType", + syncWeight: 1, }); const checklistItemDetail = refData(ChecklistItemDetail, { - parent: checklistDetail, - syncWeight: 3, + parent: checklistDetail, + syncWeight: 3, }); const formElementGroup = refDataNameTranslated(FormElementGroup, { - parent: form, - syncWeight: 3, + parent: form, + syncWeight: 3, }); const formElement = refDataNameTranslated(FormElement, { - parent: formElementGroup, - syncWeight: 5, + parent: formElementGroup, + syncWeight: 5, }); const conceptAnswer = refData(ConceptAnswer, { - parent: concept, - syncWeight: 2, + parent: concept, + syncWeight: 2, }); const identifierSource = refData(IdentifierSource, {syncWeight: 0}); const organisationConfig = refData(OrganisationConfig, {syncWeight: 0}); const platformTranslation = refData(PlatformTranslation, {syncWeight: 0}); const translation = refData(Translation, {syncWeight: 0}); const individual = txData(Individual, { - syncWeight: 5, - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, + syncWeight: 5, + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, }); const subjectMigration = txData(SubjectMigration, { - res: "subjectMigrations", - syncWeight: 0, - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, + res: "subjectMigrations", + syncWeight: 0, + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, }); const resetSync = txData(ResetSync, { - res: "resetSyncs", - syncWeight: 0, + res: "resetSyncs", + syncWeight: 0, }); const addressLevel = refDataNameTranslated(AddressLevel, { - res: "locations", - syncWeight: 4, + res: "locations", + syncWeight: 4, }); const locationMapping = refData(LocationMapping, { - parent: addressLevel, - syncWeight: 4, + parent: addressLevel, + syncWeight: 4, }); const encounter = txData(Encounter, { - parent: individual, - syncWeight: 7, - privilegeParam: "encounterTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.encounter, - privilegeName: Privilege.privilegeName.viewVisit, + parent: individual, + syncWeight: 7, + privilegeParam: "encounterTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.encounter, + privilegeName: Privilege.privilegeName.viewVisit, }); const programEnrolment = txData(ProgramEnrolment, { - parent: individual, - syncWeight: 5, - privilegeParam: "programUuid", - privilegeEntity: Privilege.privilegeEntityType.enrolment, - privilegeName: Privilege.privilegeName.viewEnrolmentDetails, + parent: individual, + syncWeight: 5, + privilegeParam: "programUuid", + privilegeEntity: Privilege.privilegeEntityType.enrolment, + privilegeName: Privilege.privilegeName.viewEnrolmentDetails, }); const programEncounter = txData(ProgramEncounter, { - parent: programEnrolment, - syncWeight: 9, - privilegeParam: "programEncounterTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.encounter, - privilegeName: Privilege.privilegeName.viewVisit, + parent: programEnrolment, + syncWeight: 9, + privilegeParam: "programEncounterTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.encounter, + privilegeName: Privilege.privilegeName.viewVisit, }); const checklist = txData(Checklist, { - res: "txNewChecklistEntity", - parent: programEnrolment, - syncWeight: 3, - privilegeParam: "checklistDetailUuid", - privilegeEntity: Privilege.privilegeEntityType.checklist, - privilegeName: Privilege.privilegeName.viewChecklist, + res: "txNewChecklistEntity", + parent: programEnrolment, + syncWeight: 3, + privilegeParam: "checklistDetailUuid", + privilegeEntity: Privilege.privilegeEntityType.checklist, + privilegeName: Privilege.privilegeName.viewChecklist, }); const checklistItem = txData(ChecklistItem, { - res: "txNewChecklistItemEntity", - parent: checklist, - syncWeight: 3, - privilegeParam: "checklistDetailUuid", - privilegeEntity: Privilege.privilegeEntityType.checklist, - privilegeName: Privilege.privilegeName.viewChecklist, + res: "txNewChecklistItemEntity", + parent: checklist, + syncWeight: 3, + privilegeParam: "checklistDetailUuid", + privilegeEntity: Privilege.privilegeEntityType.checklist, + privilegeName: Privilege.privilegeName.viewChecklist, }); const individualRelationship = txData(IndividualRelationship, { - parent: individual, - syncWeight: 2, - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, + parent: individual, + syncWeight: 2, + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, }); const groupSubject = txData(GroupSubject, { - parent: individual, - syncWeight: 0, - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, - hasMoreThanOneAssociation: true, + parent: individual, + syncWeight: 0, + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, + hasMoreThanOneAssociation: true, }); const videoTelemetric = txData(VideoTelemetric, { - res: "videotelemetric", - parent: video, - syncWeight: 0, - syncPullRequired: false + res: "videotelemetric", + parent: video, + syncWeight: 0, + syncPullRequired: false }); const syncTelemetry = txData(SyncTelemetry, { - resUrl: "syncTelemetry", - syncWeight: 1, - syncPullRequired: false + resUrl: "syncTelemetry", + syncWeight: 1, + syncPullRequired: false }); const userInfo = txData(UserInfo, { - resUrl: "me", - apiVersion: "v2", - syncWeight: 1, + resUrl: "me", + apiVersion: "v2", + syncWeight: 1, }); const identifierAssignment = txData(IdentifierAssignment, {syncWeight: 0}); const ruleFailureTelemetry = txData(RuleFailureTelemetry, { - resUrl: "ruleFailureTelemetry", - syncWeight: 0, - syncPullRequired: false + resUrl: "ruleFailureTelemetry", + syncWeight: 0, + syncPullFRequired: false }); const groups = refData(Groups, {res: "groups", syncWeight: 0}); const myGroups = refData(MyGroups, {res: "myGroups", syncWeight: 0}); const groupPrivileges = refData(GroupPrivileges, { - res: "groupPrivilege", - syncWeight: 0, + res: "groupPrivilege", + syncWeight: 0, }); const privilege = refData(Privilege, {res: "privilege", syncWeight: 0}); const extension = refData(Extension, {res: "extensions", syncWeight: 0, filter: ''}); const groupRole = refData(GroupRole, {res: "groupRole", syncWeight: 0}); -const locationHierarchy = refData(LocationHierarchy, { res: "locations", resUrl: "locationHierarchy", syncWeight: 0 }); -const reportCard = refData(ReportCard, {res: "card", syncWeight: 0}); -const dashboard = refData(Dashboard, {res: "dashboard", syncWeight: 0}); -const dashboardFilter = refData(DashboardFilter, {res: 'dashboardFilter', parent: dashboard, syncWeight: 0}); -const dashboardSection = refData(DashboardSection, {res: "dashboardSection", syncWeight: 0}); -const dashboardSectionCardMapping = refData(DashboardSectionCardMapping, { res: "dashboardSectionCardMapping", syncWeight: 0 }); -const standardReportCardType = refData(StandardReportCardType, { res: "standardReportCardType", syncWeight: 0 }); +const locationHierarchy = refData(LocationHierarchy, { + res: "locations", + resUrl: "locationHierarchy", + syncWeight: 0 +}); +const reportCard = refData(ReportCard, + {res: "card", syncWeight: 0, apiVersion: "v2"}); +const dashboard = refData(Dashboard, {res: "dashboard", syncWeight: 0, apiVersion: "v2"}); +const dashboardFilter = refData(DashboardFilter, { + res: 'dashboardFilter', + parent: dashboard, + syncWeight: 0, + apiVersion: "v2" +}); +const dashboardSection = refData(DashboardSection, {res: "dashboardSection", syncWeight: 0, apiVersion: "v2"}); +const dashboardSectionCardMapping = refData(DashboardSectionCardMapping, { + res: "dashboardSectionCardMapping", + syncWeight: 0, + apiVersion: "v2" +}); +const standardReportCardType = refData(StandardReportCardType, { + res: "standardReportCardType", + syncWeight: 0, + apiVersion: "v2" +}); const approvalStatus = refData(ApprovalStatus, {res: "approvalStatus", syncWeight: 0}); const groupDashboard = refData(GroupDashboard, {res: "groupDashboard", syncWeight: 0}); -export const EntityApprovalStatusMetaData = txData(EntityApprovalStatus, { res: "entityApprovalStatus", entityName: "EntityApprovalStatus"}); +export const EntityApprovalStatusMetaData = txData(EntityApprovalStatus, { + res: "entityApprovalStatus", + entityName: "EntityApprovalStatus" +}); const subjectEntityApprovalStatus = txData(EntityApprovalStatus, - { res: "entityApprovalStatus", - resUrl: "entityApprovalStatus", - entityName: 'SubjectEntityApprovalStatus', - apiQueryParams: {"entityType": "Subject"}, - apiQueryParamKey: "entityTypeUuid", - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, - parent: individual, - syncWeight: 2, - syncPushRequired: false }); + { + res: "entityApprovalStatus", + resUrl: "entityApprovalStatus", + entityName: 'SubjectEntityApprovalStatus', + apiQueryParams: {"entityType": "Subject"}, + apiQueryParamKey: "entityTypeUuid", + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, + parent: individual, + syncWeight: 2, + syncPushRequired: false + }); const encounterEntityApprovalStatus = txData(EntityApprovalStatus, - { res: "entityApprovalStatus", - resUrl: "entityApprovalStatus", - entityName: 'EncounterEntityApprovalStatus', - apiQueryParams: {"entityType": "Encounter"}, - apiQueryParamKey: "entityTypeUuid", - privilegeParam: "encounterTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.encounter, - privilegeName: Privilege.privilegeName.viewVisit, - parent: encounter, - syncWeight: 2, - syncPushRequired: false }); + { + res: "entityApprovalStatus", + resUrl: "entityApprovalStatus", + entityName: 'EncounterEntityApprovalStatus', + apiQueryParams: {"entityType": "Encounter"}, + apiQueryParamKey: "entityTypeUuid", + privilegeParam: "encounterTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.encounter, + privilegeName: Privilege.privilegeName.viewVisit, + parent: encounter, + syncWeight: 2, + syncPushRequired: false + }); const programEncounterEntityApprovalStatus = txData(EntityApprovalStatus, - { res: "entityApprovalStatus", - resUrl: "entityApprovalStatus", - entityName: 'ProgramEncounterEntityApprovalStatus', - apiQueryParams: {"entityType": "ProgramEncounter"}, - apiQueryParamKey: "entityTypeUuid", - privilegeParam: "programEncounterTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.encounter, - privilegeName: Privilege.privilegeName.viewVisit, - parent: programEncounter, - syncWeight: 2, - syncPushRequired: false }); + { + res: "entityApprovalStatus", + resUrl: "entityApprovalStatus", + entityName: 'ProgramEncounterEntityApprovalStatus', + apiQueryParams: {"entityType": "ProgramEncounter"}, + apiQueryParamKey: "entityTypeUuid", + privilegeParam: "programEncounterTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.encounter, + privilegeName: Privilege.privilegeName.viewVisit, + parent: programEncounter, + syncWeight: 2, + syncPushRequired: false + }); const programEnrolmentEntityApprovalStatus = txData(EntityApprovalStatus, - { res: "entityApprovalStatus", - resUrl: "entityApprovalStatus", - entityName: 'ProgramEnrolmentEntityApprovalStatus', - apiQueryParams: {"entityType": "ProgramEnrolment"}, - apiQueryParamKey: "entityTypeUuid", - privilegeParam: "programUuid", - privilegeEntity: Privilege.privilegeEntityType.enrolment, - privilegeName: Privilege.privilegeName.viewEnrolmentDetails, - parent: programEnrolment, - syncWeight: 2, - syncPushRequired: false }); + { + res: "entityApprovalStatus", + resUrl: "entityApprovalStatus", + entityName: 'ProgramEnrolmentEntityApprovalStatus', + apiQueryParams: {"entityType": "ProgramEnrolment"}, + apiQueryParamKey: "entityTypeUuid", + privilegeParam: "programUuid", + privilegeEntity: Privilege.privilegeEntityType.enrolment, + privilegeName: Privilege.privilegeName.viewEnrolmentDetails, + parent: programEnrolment, + syncWeight: 2, + syncPushRequired: false + }); const checklistItemEntityApprovalStatus = txData(EntityApprovalStatus, - { res: "entityApprovalStatus", - resUrl: "entityApprovalStatus", - entityName: 'ChecklistItemEntityApprovalStatus', - apiQueryParams: {"entityType": "ChecklistItem"}, - apiQueryParamKey: "entityTypeUuid", - privilegeParam: "checklistDetailUuid", - privilegeEntity: Privilege.privilegeEntityType.checklist, - privilegeName: Privilege.privilegeName.viewChecklist, - parent: checklistItem, - syncWeight: 2, - syncPushRequired: false }); + { + res: "entityApprovalStatus", + resUrl: "entityApprovalStatus", + entityName: 'ChecklistItemEntityApprovalStatus', + apiQueryParams: {"entityType": "ChecklistItem"}, + apiQueryParamKey: "entityTypeUuid", + privilegeParam: "checklistDetailUuid", + privilegeEntity: Privilege.privilegeEntityType.checklist, + privilegeName: Privilege.privilegeName.viewChecklist, + parent: checklistItem, + syncWeight: 2, + syncPushRequired: false + }); const entityApprovalStatus = txData(EntityApprovalStatus, { - res: 'entityApprovalStatus', - syncWeight: 1, - syncPullRequired: false + res: 'entityApprovalStatus', + syncWeight: 1, + syncPullRequired: false }); const news = txData(News, {syncWeight: 0}); const documentation = refData(Documentation, {res: 'documentations', syncWeight: 0}); -const documentationItem = refData(DocumentationItem, {res: 'documentationItems', parent: documentation, syncWeight: 0}); +const documentationItem = refData(DocumentationItem, { + res: 'documentationItems', + parent: documentation, + syncWeight: 0 +}); const comment = txData(Comment, { - parent: individual, - syncWeight: 1, - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, + parent: individual, + syncWeight: 1, + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, }); const commentThread = txData(CommentThread, { - syncWeight: 1, - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, + syncWeight: 1, + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, }); const task = txData(Task, {syncWeight: 0}); const taskType = refData(TaskType, {res: 'taskType', syncWeight: 0}); @@ -397,133 +434,133 @@ const taskUnAssigment = txData(TaskUnAssignment, {res: 'taskUnAssignments', sync const menuItem = refData(MenuItem, {res: 'menuItem', syncWeight: 0}); const subjectProgramEligibility = txData(SubjectProgramEligibility, { - resUrl: "subjectProgramEligibility", - syncWeight: 0, - privilegeParam: "subjectTypeUuid", - privilegeEntity: Privilege.privilegeEntityType.subject, - privilegeName: Privilege.privilegeName.viewSubject, + resUrl: "subjectProgramEligibility", + syncWeight: 0, + privilegeParam: "subjectTypeUuid", + privilegeEntity: Privilege.privilegeEntityType.subject, + privilegeName: Privilege.privilegeName.viewSubject, }); const userSubjectAssignment = txData(UserSubjectAssignment, {syncWeight: 0}); class EntityMetaData { - schemaName; - entityName; - entityClass; - resourceName; - type; - nameTranslated; - resourceSearchFilterURL; - parent; - syncWeight; - resourceUrl; + schemaName; + entityName; + entityClass; + resourceName; + type; + nameTranslated; + resourceSearchFilterURL; + parent; + syncWeight; + resourceUrl; - //order is important. last entity in each (tx and ref) with be executed first. parent should be synced before the child. - static model() { - return [ - groupDashboard, - approvalStatus, - dashboardSectionCardMapping, - dashboardSection, - dashboardFilter, - dashboard, - reportCard, - standardReportCardType, - menuItem, - locationHierarchy, - video, - checklistItemDetail, - checklistDetail, - rule, - ruleDependency, - individualRelationshipType, - individualRelationGenderMapping, - individualRelation, - formMapping, - formElement, - formElementGroup, - form, - documentationItem, - documentation, - identifierSource, - organisationConfig, - platformTranslation, - translation, + //order is important. last entity in each (tx and ref) with be executed first. parent should be synced before the child. + static model() { + return [ + groupDashboard, + approvalStatus, + dashboardSectionCardMapping, + dashboardSection, + dashboardFilter, + dashboard, + reportCard, + standardReportCardType, + menuItem, + locationHierarchy, + video, + checklistItemDetail, + checklistDetail, + rule, + ruleDependency, + individualRelationshipType, + individualRelationGenderMapping, + individualRelation, + formMapping, + formElement, + formElementGroup, + form, + documentationItem, + documentation, + identifierSource, + organisationConfig, + platformTranslation, + translation, - locationMapping, - addressLevel, - taskStatus, - taskType, - encounterType, - program, - gender, - groupRole, - subjectType, - conceptAnswer, - concept, - myGroups, - groupPrivileges, - groups, - privilege, + locationMapping, + addressLevel, + taskStatus, + taskType, + encounterType, + program, + gender, + groupRole, + subjectType, + conceptAnswer, + concept, + myGroups, + groupPrivileges, + groups, + privilege, - resetSync, - subjectMigration, - userSubjectAssignment, - task, - taskUnAssigment, - subjectProgramEligibility, - news, - videoTelemetric, - groupSubject, - comment, - commentThread, - entityApprovalStatus, - subjectEntityApprovalStatus, - encounterEntityApprovalStatus, - programEncounterEntityApprovalStatus, - programEnrolmentEntityApprovalStatus, - checklistItemEntityApprovalStatus, - individualRelationship, - checklistItem, - checklist, - encounter, - identifierAssignment, - programEncounter, - programEnrolment, - individual, - extension, - userInfo, - ruleFailureTelemetry, - syncTelemetry, - ]; - } + resetSync, + subjectMigration, + userSubjectAssignment, + task, + taskUnAssigment, + subjectProgramEligibility, + news, + videoTelemetric, + groupSubject, + comment, + commentThread, + entityApprovalStatus, + subjectEntityApprovalStatus, + encounterEntityApprovalStatus, + programEncounterEntityApprovalStatus, + programEnrolmentEntityApprovalStatus, + checklistItemEntityApprovalStatus, + individualRelationship, + checklistItem, + checklist, + encounter, + identifierAssignment, + programEncounter, + programEnrolment, + individual, + extension, + userInfo, + ruleFailureTelemetry, + syncTelemetry, + ]; + } - static entitiesLoadedFromServer() { - return _.differenceBy(EntityMappingConfig.getInstance().getEntities(), [Settings, LocaleMapping].concat(EntityMetaData.embeddedEntities()), "schema.name"); - } + static entitiesLoadedFromServer() { + return _.differenceBy(EntityMappingConfig.getInstance().getEntities(), [Settings, LocaleMapping].concat(EntityMetaData.embeddedEntities()), "schema.name"); + } - static embeddedEntities() { - return _.filter(EntityMappingConfig.getInstance().getEntities(), entity => entity.schema.embedded); - } + static embeddedEntities() { + return _.filter(EntityMappingConfig.getInstance().getEntities(), entity => entity.schema.embedded); + } - static findByName(entityName) { - return EntityMetaData.findByNameIn(entityName, EntityMetaData.model()); - } + static findByName(entityName) { + return EntityMetaData.findByNameIn(entityName, EntityMetaData.model()); + } - static findByNameIn(entityName, modelCollection) { - return _.find( - modelCollection, - (entityMetadata) => entityMetadata.entityName === entityName - ); - } + static findByNameIn(entityName, modelCollection) { + return _.find( + modelCollection, + (entityMetadata) => entityMetadata.entityName === entityName + ); + } - static getEntitiesToBePulled() { - return _.filter(EntityMetaData.model(), (entityMetadata) => entityMetadata.syncPullRequired) - } + static getEntitiesToBePulled() { + return _.filter(EntityMetaData.model(), (entityMetadata) => entityMetadata.syncPullRequired) + } - static allModels() { - return _.concat(EntityApprovalStatusMetaData, EntityMetaData.model()); - } + static allModels() { + return _.concat(EntityApprovalStatusMetaData, EntityMetaData.model()); + } } export default EntityMetaData; From 44a9a138900c7feec9c6eef246b4168a37a7ac0a Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 9 Sep 2024 14:37:13 +0530 Subject: [PATCH 04/10] v1.32.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 225d722..937dcbd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openchs-models", "description": "OpenCHS data model to be used by front end clients", - "version": "1.32.9", + "version": "1.32.10", "private": false, "repository": { "type": "git", From 1477700ad2183710e6aaa3a281f679480e9062b3 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Tue, 10 Sep 2024 16:48:03 +0530 Subject: [PATCH 05/10] avniproject/avni-server#782 - v2 endpoints changes --- src/EntityMetaData.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/EntityMetaData.js b/src/EntityMetaData.js index 8a2224d..ca263f7 100644 --- a/src/EntityMetaData.js +++ b/src/EntityMetaData.js @@ -313,7 +313,11 @@ const dashboardFilter = refData(DashboardFilter, { syncWeight: 0, apiVersion: "v2" }); -const dashboardSection = refData(DashboardSection, {res: "dashboardSection", syncWeight: 0, apiVersion: "v2"}); +const dashboardSection = refData(DashboardSection, { + res: "dashboardSection", + syncWeight: 0, + apiVersion: "v2" +}); const dashboardSectionCardMapping = refData(DashboardSectionCardMapping, { res: "dashboardSectionCardMapping", syncWeight: 0, @@ -321,11 +325,14 @@ const dashboardSectionCardMapping = refData(DashboardSectionCardMapping, { }); const standardReportCardType = refData(StandardReportCardType, { res: "standardReportCardType", + syncWeight: 0 +}); +const approvalStatus = refData(ApprovalStatus, {res: "approvalStatus", syncWeight: 0}); +const groupDashboard = refData(GroupDashboard, { + res: "groupDashboard", syncWeight: 0, apiVersion: "v2" }); -const approvalStatus = refData(ApprovalStatus, {res: "approvalStatus", syncWeight: 0}); -const groupDashboard = refData(GroupDashboard, {res: "groupDashboard", syncWeight: 0}); export const EntityApprovalStatusMetaData = txData(EntityApprovalStatus, { res: "entityApprovalStatus", From f9ca47dea146430ff61aa8fa1957f2637eb28d82 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Tue, 10 Sep 2024 16:48:38 +0530 Subject: [PATCH 06/10] v1.32.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 937dcbd..c79c20d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openchs-models", "description": "OpenCHS data model to be used by front end clients", - "version": "1.32.10", + "version": "1.32.11", "private": false, "repository": { "type": "git", From 00130eeae318a207023f718816572e89e645b5cb Mon Sep 17 00:00:00 2001 From: Joy A Date: Wed, 11 Sep 2024 14:59:55 +0530 Subject: [PATCH 07/10] #54 | Migration to initialise StandardReportCardType.type values --- src/Schema.js | 14 ++++++++++++++ src/StandardReportCardType.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Schema.js b/src/Schema.js index b190c2e..ff148b8 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -921,6 +921,20 @@ function createRealmConfig() { if (oldDB.schemaVersion < 191) { newDB.delete(newDB.objects("CustomDashboardCache")); } + if (oldDB.schemaVersion < 197) { + _.forEach(newDB.objects("StandardReportCardType"), (standardReportCardType) => { + if (standardReportCardType.name === 'Last 24 hours registrations') { + standardReportCardType.description = 'Recent registrations'; + } + if (standardReportCardType.name === 'Last 24 hours enrolments') { + standardReportCardType.description = 'Recent enrolments'; + } + if (standardReportCardType.name === 'Last 24 hours visits') { + standardReportCardType.description = 'Recent visits'; + } + standardReportCardType.type = _.replace(_.startCase(standardReportCardType.description), new RegExp(' ', 'g'), ''); + }); + } }, }; } diff --git a/src/StandardReportCardType.js b/src/StandardReportCardType.js index 5b2f3c4..ebb9d2e 100644 --- a/src/StandardReportCardType.js +++ b/src/StandardReportCardType.js @@ -13,7 +13,7 @@ class StandardReportCardType extends BaseEntity { uuid: "string", name: "string", description: {type: "string", optional: true}, - type: {type: "string", optional: true}, + type: {type: "string"}, voided: {type: "bool", default: false}, }, }; From 909f9874a9c7ecacfa62f25c425fab3a13746ac6 Mon Sep 17 00:00:00 2001 From: Joy A Date: Wed, 11 Sep 2024 15:00:47 +0530 Subject: [PATCH 08/10] v1.32.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c79c20d..3dfeefd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openchs-models", "description": "OpenCHS data model to be used by front end clients", - "version": "1.32.11", + "version": "1.32.12", "private": false, "repository": { "type": "git", From f0cf363e00fdf878b1f07ebf3f5c81ff98efb100 Mon Sep 17 00:00:00 2001 From: Joy A Date: Wed, 11 Sep 2024 17:38:23 +0530 Subject: [PATCH 09/10] avniproject/avni-client#1495 | Migration to reset MyDashboard cache --- src/Schema.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Schema.js b/src/Schema.js index ff148b8..4e81bcc 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -934,6 +934,10 @@ function createRealmConfig() { } standardReportCardType.type = _.replace(_.startCase(standardReportCardType.description), new RegExp(' ', 'g'), ''); }); + + //Reset MyDashboard cache because shape of filterJSON in cache has changed + const dashboardCache = newDB.objects("DashboardCache"); + newDB.delete(dashboardCache); } }, }; From 079d89b5be300947b2e536646ffd1e492356fb98 Mon Sep 17 00:00:00 2001 From: Joy A Date: Wed, 11 Sep 2024 17:38:52 +0530 Subject: [PATCH 10/10] v1.32.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3dfeefd..a7933cb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openchs-models", "description": "OpenCHS data model to be used by front end clients", - "version": "1.32.12", + "version": "1.32.13", "private": false, "repository": { "type": "git",