Skip to content

Commit

Permalink
default anonymization config for entities
Browse files Browse the repository at this point in the history
  • Loading branch information
sleidig committed Oct 18, 2023
1 parent 86deed3 commit cffad0a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class RecurringActivity extends Entity {
validators: {
required: true,
},
anonymize: "retain",
})
title: string = "";

Expand All @@ -67,6 +68,7 @@ export class RecurringActivity extends Entity {
label: $localize`:Label for the interaction type of a recurring activity:Type`,
dataType: "configurable-enum",
innerDataType: INTERACTION_TYPE_CONFIG_ID,
anonymize: "retain",
})
type: InteractionType;

Expand All @@ -75,6 +77,7 @@ export class RecurringActivity extends Entity {
label: $localize`:Label for the participants of a recurring activity:Participants`,
dataType: "entity-array",
additional: Child.ENTITY_TYPE,
anonymize: "retain",
})
participants: string[] = [];

Expand All @@ -83,6 +86,7 @@ export class RecurringActivity extends Entity {
label: $localize`:Label for the linked schools of a recurring activity:Groups`,
dataType: "entity-array",
additional: School.ENTITY_TYPE,
anonymize: "retain",
})
linkedGroups: string[] = [];

Expand All @@ -91,6 +95,7 @@ export class RecurringActivity extends Entity {
label: $localize`:Label for excluded participants of a recurring activity:Excluded Participants`,
dataType: "entity-array",
additional: Child.ENTITY_TYPE,
anonymize: "retain",
})
excludedParticipants: string[] = [];

Expand All @@ -99,6 +104,7 @@ export class RecurringActivity extends Entity {
label: $localize`:Label for the assigned user(s) of a recurring activity:Assigned user(s)`,
dataType: "entity-array",
additional: User.ENTITY_TYPE,
anonymize: "retain",
})
assignedTo: string[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ export class HealthCheck extends Entity {
return Object.assign(new HealthCheck(), contents);
}

@DatabaseField() child: string;
@DatabaseField({ label: $localize`:Label for date of a health check:Date` })
@DatabaseField({
anonymize: "retain",
})
child: string;

@DatabaseField({
label: $localize`:Label for date of a health check:Date`,
anonymize: "retain-anonymized",
})
date: Date;

/** height measurement in cm **/
Expand Down
4 changes: 4 additions & 0 deletions src/app/child-dev-project/children/model/child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ export class Child extends Entity {
dataType: "configurable-enum",
innerDataType: "center",
label: $localize`:Label for the center of a child:Center`,
anonymize: "retain",
})
center: Center;

@DatabaseField({
label: $localize`:Label for the admission date of a child:Admission`,
anonymize: "retain-anonymized",
})
admissionDate: Date;

Expand All @@ -92,11 +94,13 @@ export class Child extends Entity {

@DatabaseField({
label: $localize`:Label for the dropout date of a child:Dropout Date`,
anonymize: "retain-anonymized",
})
dropoutDate: Date;

@DatabaseField({
label: $localize`:Label for the type of dropout of a child:Dropout Type`,
anonymize: "retain",
})
dropoutType: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class ChildSchoolRelation extends TimePeriod {
validators: {
required: true,
},
anonymize: "retain",
})
childId: string;

Expand All @@ -26,6 +27,7 @@ export class ChildSchoolRelation extends TimePeriod {
validators: {
required: true,
},
anonymize: "retain",
})
schoolId: string;

Expand Down
21 changes: 19 additions & 2 deletions src/app/child-dev-project/notes/model/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class Note extends Entity {
dataType: "entity-array",
additional: Child.ENTITY_TYPE,
editComponent: "EditAttendance",
anonymize: "retain",
})
children: string[] = [];

Expand All @@ -85,42 +86,55 @@ export class Note extends Entity {
*
* No direct access to change this property. Use the `.getAttendance()` method to have safe access.
*/
@DatabaseField({ innerDataType: "schema-embed", additional: EventAttendance })
@DatabaseField({
innerDataType: "schema-embed",
additional: EventAttendance,
anonymize: "retain",
})
private childrenAttendance: Map<string, EventAttendance> = new Map();

@DatabaseField({
label: $localize`:Label for the date of a note:Date`,
dataType: "date-only",
defaultValue: PLACEHOLDERS.NOW,
anonymize: "retain",
})
date: Date;

@DatabaseField({ label: $localize`:Label for the subject of a note:Subject` })
subject: string;

@DatabaseField({
label: $localize`:Label for the actual notes of a note:Notes`,
editComponent: "EditLongText",
})
text: string;

/** IDs of users that authored this note */
@DatabaseField({
label: $localize`:Label for the social worker(s) who created the note:SW`,
dataType: "entity-array",
additional: User.ENTITY_TYPE,
defaultValue: PLACEHOLDERS.CURRENT_USER,
anonymize: "retain",
})
authors: string[] = [];

@DatabaseField({
label: $localize`:Label for the category of a note:Category`,
dataType: "configurable-enum",
innerDataType: INTERACTION_TYPE_CONFIG_ID,
anonymize: "retain",
})
category: InteractionType;

/**
* id referencing a different entity (e.g. a recurring activity) this note is related to
*/
@DatabaseField() relatesTo: string;
@DatabaseField({
anonymize: "retain",
})
relatesTo: string;

/**
* other records (e.g. a recurring activity, group membership, ...) to which this note is related in some way,
Expand All @@ -134,6 +148,7 @@ export class Note extends Entity {
editComponent: "EditEntityArray",
// by default no additional relatedEntities can be linked apart from children and schools, overwrite this in config to display (e.g. additional: "ChildSchoolRelation")
additional: undefined,
anonymize: "retain",
})
relatedEntities: string[] = [];

Expand All @@ -144,13 +159,15 @@ export class Note extends Entity {
label: $localize`:label for the linked schools:Groups`,
dataType: "entity-array",
additional: School.ENTITY_TYPE,
anonymize: "retain",
})
schools: string[] = [];

@DatabaseField({
label: $localize`:Status of a note:Status`,
dataType: "configurable-enum",
innerDataType: "warning-levels",
anonymize: "retain",
})
warningLevel: Ordering.EnumValue;

Expand Down
7 changes: 2 additions & 5 deletions src/app/core/entity/model/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,13 @@ export class Entity {
})
updated: UpdateMetadata;

@DatabaseField({
label: $localize`:Label of checkbox:Inactive`,
description: $localize`:Description of checkbox:Ticking this box will archive the record. No data will be lost but the record will be hidden.`,
})
@DatabaseField({ anonymize: "retain" })
inactive: boolean;

/**
* Whether this entity has been anonymized and therefore cannot be re-activated.
*/
@DatabaseField()
@DatabaseField({ anonymize: "retain" })
anonymized: boolean;

/** whether this entity object is newly created and not yet saved to database */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export class HistoricalEntityData extends Entity {
@DatabaseField({
label: $localize`:Label for date of historical data:Date`,
defaultValue: PLACEHOLDERS.NOW,
anonymize: "retain-anonymized",
})
date: Date;
@DatabaseField() relatedEntity: string;

@DatabaseField({
anonymize: "retain",
})
relatedEntity: string;
}
6 changes: 6 additions & 0 deletions src/app/features/todos/model/todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class Todo extends Entity {
dataType: "date-only",
label: $localize`:Label:Deadline`,
showInDetailsView: true,
anonymize: "retain",
})
deadline: Date;

Expand All @@ -54,6 +55,7 @@ export class Todo extends Entity {
label: $localize`:Label:Start date`,
description: $localize`:Description:When you are planning to start work so that you keep enough time before the actual hard deadline.`,
showInDetailsView: true,
anonymize: "retain",
})
startDate: Date;

Expand All @@ -70,6 +72,7 @@ export class Todo extends Entity {
additional: User.ENTITY_TYPE,
showInDetailsView: true,
defaultValue: PLACEHOLDERS.CURRENT_USER,
anonymize: "retain",
})
assignedTo: string[] = [];

Expand All @@ -87,6 +90,7 @@ export class Todo extends Entity {
RecurringActivity.ENTITY_TYPE,
],
showInDetailsView: true,
anonymize: "retain",
})
relatedEntities: string[] = [];

Expand All @@ -103,12 +107,14 @@ export class Todo extends Entity {
},
] as { label: string; interval: TimeInterval }[],
showInDetailsView: true,
anonymize: "retain",
})
repetitionInterval: TimeInterval;

@DatabaseField({
label: $localize`:label for Todo entity property:completed`,
viewComponent: "DisplayTodoCompletion",
anonymize: "retain",
})
completed?: TodoCompletion;

Expand Down

0 comments on commit cffad0a

Please sign in to comment.