Skip to content

Commit

Permalink
Merge pull request #2 from EyeSeeTea/feature/domain
Browse files Browse the repository at this point in the history
feat: Domain entities for zebra
  • Loading branch information
bhavananarayanan authored Jul 8, 2024
2 parents cd8eeb5 + 4213c07 commit 7581407
Show file tree
Hide file tree
Showing 20 changed files with 560 additions and 17 deletions.
52 changes: 50 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,56 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-07-04T13:31:07.802Z\n"
"PO-Revision-Date: 2024-07-04T13:31:07.802Z\n"
"POT-Creation-Date: 2024-07-01T02:04:44.570Z\n"
"PO-Revision-Date: 2024-07-01T02:04:44.570Z\n"

msgid "Low"
msgstr ""

msgid "Medium"
msgstr ""

msgid "High"
msgstr ""

msgid "Less than 0.1%"
msgstr ""

msgid "Between 0.1% to 0.25%"
msgstr ""

msgid "Above 0.25%"
msgstr ""

msgid "Within a district"
msgstr ""

msgid "Within a province with more than one district affected"
msgstr ""

msgid "More than one province affected with high threat of spread locally and internationally"
msgstr ""

msgid "Available within the district with support from provincial and national level"
msgstr ""

msgid "Available within the province with minimal support from national level"
msgstr ""

msgid "Available at national with support required from international"
msgstr ""

msgid "Grade 1"
msgstr ""

msgid "Grade 2"
msgstr ""

msgid "Grade 3"
msgstr ""

msgid "Invalid grade"
msgstr ""

msgid "Add new option"
msgstr ""
Expand Down
68 changes: 67 additions & 1 deletion i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,13 +1,64 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-07-04T13:31:07.802Z\n"
"POT-Creation-Date: 2024-07-01T02:04:44.570Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"

msgid "Low"
msgstr ""

msgid "Medium"
msgstr ""

msgid "High"
msgstr ""

msgid "Less than 0.1%"
msgstr ""

msgid "Between 0.1% to 0.25%"
msgstr ""

msgid "Above 0.25%"
msgstr ""

msgid "Within a district"
msgstr ""

msgid "Within a province with more than one district affected"
msgstr ""

msgid ""
"More than one province affected with high threat of spread locally and "
"internationally"
msgstr ""

msgid ""
"Available within the district with support from provincial and national level"
msgstr ""

msgid "Available within the province with minimal support from national level"
msgstr ""

msgid "Available at national with support required from international"
msgstr ""

msgid "Grade 1"
msgstr ""

msgid "Grade 2"
msgstr ""

msgid "Grade 3"
msgstr ""

msgid "Invalid grade"
msgstr ""

msgid "Add new option"
msgstr ""

Expand Down Expand Up @@ -52,3 +103,18 @@ msgstr ""

msgid "Resources"
msgstr ""

#~ msgid "Add"
#~ msgstr "Añadir"

#~ msgid "List"
#~ msgstr "Listar"

#~ msgid "Back"
#~ msgstr "Volver"

#~ msgid "Help"
#~ msgstr "Ayuda"

#~ msgid "Hello {{name}}"
#~ msgstr "Hola {{name}}"
13 changes: 10 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />

<link type="text/css" rel="stylesheet" href="/includes/material-design-icons/material-icons.css" />
<link
type="text/css"
rel="stylesheet"
href="/includes/material-design-icons/material-icons.css"
/>
<link type="text/css" rel="stylesheet" href="/includes/roboto-font.css" />
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" />
<link
href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css"
rel="stylesheet"
/>

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#000000" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>Zebra</title>
</head>

<body>
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "dhis2-app-skeleton",
"description": "DHIS2 Skeleton App",
"name": "zebra",
"description": "Zambia Emergency Bridge for Response Application",
"version": "0.0.1",
"license": "GPL-3.0",
"author": "EyeSeeTea team",
"homepage": ".",
"repository": {
"type": "git",
"url": "git+https://github.com/eyeseetea/dhis2-app-skeleton.git"
"url": "git+https://github.com/eyeseetea/zebra-dev.git"
},
"dependencies": {
"@dhis2/app-runtime": "2.8.0",
Expand Down Expand Up @@ -112,8 +112,8 @@
"script-example": "npx ts-node src/scripts/example.ts"
},
"manifest.webapp": {
"name": "DHIS2 Skeleton App",
"description": "DHIS2 Skeleton App",
"name": "zebra",
"description": "Zambia Emergency Bridge for Response Application",
"icons": {
"48": "icon.png"
},
Expand Down
60 changes: 60 additions & 0 deletions src/domain/entities/DiseaseOutbreakEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Struct } from "./generic/Struct";
import { IncidentActionPlan } from "./incident-action-plan/IncidentActionPlan";
import { IncidentManagementTeam } from "./incident-management-team/IncidentManagementTeam";
import { TeamMember } from "./incident-management-team/TeamMember";
import { OrgUnit } from "./OrgUnit";
import { CodedNamedRef, NamedRef } from "./Ref";
import { RiskAssessment } from "./risk-assessment/RiskAssessment";
import { Maybe } from "../../utils/ts-utils";

type HazardType =
| "Biological:Human"
| "Biological:Animal"
| "Chemical"
| "Environmental"
| "Unknown";

type IncidentStatusType = "Watch" | "Alert" | "Respond" | "Closed" | "Discarded";

type DateWithNarrative = {
date: Date;
narrative: string;
};

type Syndrome = CodedNamedRef;
type Disease = CodedNamedRef;
type NotificationSource = CodedNamedRef;

type DiseaseOutbreakEventAttrs = NamedRef & {
created: Date;
lastUpdated: Date;
createdBy: TeamMember;
hazardType: HazardType;
mainSyndrome: Syndrome;
suspectedDisease: Disease;
notificationSource: NotificationSource;
areasAffected: {
provinces: OrgUnit[];
districts: OrgUnit[];
};
incidentStatus: IncidentStatusType;
emerged: DateWithNarrative;
detected: DateWithNarrative;
notified: DateWithNarrative;
responseNarrative: string;
incidentManager: TeamMember;
notes: Maybe<string>;
riskAssessments: RiskAssessment[];
IncidentActionPlan: IncidentActionPlan;
IncidentManagementTeam: IncidentManagementTeam;
};
/**
* Note: DiseaseOutbreakEvent represents Event in the Figma.
* Not using event as it is a keyword and can also be confused with dhis event
**/

export class DiseaseOutbreakEvent extends Struct<DiseaseOutbreakEventAttrs>() {
static validateEventName() {
//TO DO : Ensure event name is unique on event creation.
}
}
7 changes: 7 additions & 0 deletions src/domain/entities/OrgUnit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { CodedNamedRef } from "./Ref";

type OrgUnitLevelType = "Province" | "District";

export type OrgUnit = CodedNamedRef & {
level: OrgUnitLevelType;
};
29 changes: 29 additions & 0 deletions src/domain/entities/Properties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CodedNamedRef } from "./Ref";

type PropertTypes = "string" | "date" | "number" | "boolean";

type BaseProperty = CodedNamedRef & {
type: PropertTypes;
};

type StringProperty = BaseProperty & {
type: "string";
value: string;
};

type DateProperty = BaseProperty & {
type: "date";
value: Date;
};

type NumberProperty = BaseProperty & {
type: "number";
value: number;
};

type BooleanProperty = BaseProperty & {
type: "boolean";
value: boolean;
};

export type Property = StringProperty | DateProperty | NumberProperty | BooleanProperty;
4 changes: 4 additions & 0 deletions src/domain/entities/Ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export interface Ref {
export interface NamedRef extends Ref {
name: string;
}

export interface CodedNamedRef extends NamedRef {
code: string;
}
5 changes: 5 additions & 0 deletions src/domain/entities/generic/Either.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
export class Either<Error, Data> {
constructor(public value: EitherValue<Error, Data>) {}

getOrThrow(): Data {
if (this.value.data) return this.value.data;
else throw this.value.error;
}

match<Res>(matchObj: MatchObject<Error, Data, Res>): Res {
switch (this.value.type) {
case "success":
Expand Down
7 changes: 1 addition & 6 deletions src/domain/entities/generic/Struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

export function Struct<Attrs>() {
abstract class Base {
constructor(_attributes: Attrs) {
protected constructor(_attributes: Attrs) {
Object.assign(this, _attributes);
}

Expand All @@ -28,15 +28,10 @@ export function Struct<Attrs>() {
const ParentClass = this.constructor as new (values: Attrs) => typeof this;
return new ParentClass({ ...this._getAttributes(), ...partialAttrs });
}

static create<U extends Base>(this: new (attrs: Attrs) => U, attrs: Attrs): U {
return new this(attrs);
}
}

return Base as {
new (values: Attrs): Attrs & Base;
create: (typeof Base)["create"];
};
}

Expand Down
8 changes: 8 additions & 0 deletions src/domain/entities/incident-action-plan/ActionPlan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Property } from "../Properties";
import { Struct } from "../generic/Struct";

interface ActionPlanAttrs {
properties: Property[];
}

export class ActionPlan extends Struct<ActionPlanAttrs>() {}
12 changes: 12 additions & 0 deletions src/domain/entities/incident-action-plan/IncidentActionPlan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ActionPlan } from "./ActionPlan";
import { Ref } from "../Ref";
import { Struct } from "../generic/Struct";
import { ResponseAction } from "./ResponseAction";

interface IncidentActionPlanAttrs extends Ref {
lastUpdated: Date;
actionPlan: ActionPlan;
responseActions: ResponseAction[];
}

export class IncidentActionPlan extends Struct<IncidentActionPlanAttrs>() {}
22 changes: 22 additions & 0 deletions src/domain/entities/incident-action-plan/ResponseAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CodedNamedRef } from "../Ref";
import { Struct } from "../generic/Struct";
import { TeamMember } from "../incident-management-team/TeamMember";

type ResponseActionStatusType = "NotDone" | "Pending" | "InProgress" | "Complete";
type ResponseActionVerificationType = "Verified" | "Unverified";
type MainTask = CodedNamedRef;
type SubPillar = CodedNamedRef;
type TimeLine = CodedNamedRef;

interface ResponseActionAttrs {
mainTask: MainTask;
subActivities: string;
subPillar: SubPillar;
responsibleOfficer: TeamMember;
dueDate: Date;
timeLine: TimeLine;
status: ResponseActionStatusType;
verification: ResponseActionVerificationType;
}

export class ResponseAction extends Struct<ResponseActionAttrs>() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Struct } from "../generic/Struct";
import { TeamMember } from "./TeamMember";

interface IncidentManagementTeamAttrs {
teamHierarchy: TeamMember[];
}

export class IncidentManagementTeam extends Struct<IncidentManagementTeamAttrs>() {}
Loading

0 comments on commit 7581407

Please sign in to comment.