generated from EyeSeeTea/dhis2-app-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
434 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//Note: DiseaseOutbreak represents Event in the Figma. | ||
//Not using event as it is a keyword and can also be confused with dhis event | ||
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 { NamedRef, Option } from "./Ref"; | ||
import { RiskAssessment } from "./risk-assessment/RiskAssessment"; | ||
|
||
type HazardType = | ||
| "Biological:Human" | ||
| "Biological:Animal" | ||
| "Chemical" | ||
| "Environmental" | ||
| "Unknown"; | ||
|
||
type IncidentStatusType = "Watch" | "Alert" | "Respond" | "Closed" | "Discarded"; | ||
|
||
type DateWithNarrative = { | ||
date: Date; | ||
narrative: string; | ||
}; | ||
|
||
interface DiseaseOutbreakAttrs extends NamedRef { | ||
created: Date; | ||
lastUpdated: Date; | ||
createdBy: TeamMember; | ||
hazardType: HazardType; | ||
mainSyndrome: Option; | ||
suspectedDisease: Option; | ||
notificationSource: Option; | ||
areasAffected: { | ||
provinces: OrgUnit[]; | ||
districts: OrgUnit[]; | ||
}; | ||
incidentStatus: IncidentStatusType; | ||
dateEmerged: DateWithNarrative; | ||
dateDetected: DateWithNarrative; | ||
dateNotified: DateWithNarrative; | ||
responseNarrative: string; | ||
incidentManager: TeamMember; | ||
notes: string; | ||
//when should risk assessment, IAP,IMT be fetched? Only when the user clicks on the risk assessment tab? | ||
//Can we async get only 1 property in a class? | ||
riskAssessments: RiskAssessment[]; | ||
//we need only response actions property from IncidentActionPlan. How can we map that? | ||
IncidentActionPlan: IncidentActionPlan; | ||
IncidentManagementTeam: IncidentManagementTeam; | ||
} | ||
|
||
export class DiseaseOutbreak extends Struct<DiseaseOutbreakAttrs>() { | ||
static validateEventName() { | ||
//Ensure event name is unique on event creation. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { CodedNamedRef } from "./Ref"; | ||
|
||
type OrgUnitLevelType = "Province" | "District"; | ||
|
||
export interface OrgUnit extends CodedNamedRef { | ||
level: OrgUnitLevelType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//TO DO : Can there be a better name for a generic property? | ||
import { CodedNamedRef } from "./Ref"; | ||
|
||
type PropertTypes = "string" | "date" | "number" | "boolean"; | ||
|
||
//TO DO : what other attributes of a generic domain property? | ||
interface BaseProperty extends CodedNamedRef { | ||
text: string; //or label or key? | ||
type: PropertTypes; | ||
} | ||
|
||
interface StringProperty extends BaseProperty { | ||
type: "string"; | ||
value: string; | ||
} | ||
|
||
interface DateProperty extends BaseProperty { | ||
type: "date"; | ||
value: Date; | ||
} | ||
|
||
interface NumberProperty extends BaseProperty { | ||
type: "number"; | ||
value: number; | ||
} | ||
|
||
interface BooleanProperty extends BaseProperty { | ||
type: "boolean"; | ||
value: boolean; | ||
} | ||
|
||
export type Property = StringProperty | DateProperty | NumberProperty | BooleanProperty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
src/domain/entities/incident-action-plan/IncidentActionPlan.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>() {} |
20 changes: 20 additions & 0 deletions
20
src/domain/entities/incident-action-plan/ResponseAction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Struct } from "../generic/Struct"; | ||
import { TeamMember } from "../incident-management-team/TeamMember"; | ||
import { Option } from "../Ref"; | ||
|
||
//TO DO : Should this be Option? | ||
type ResponseActionStatusType = "Not done" | "Pending" | "In Progress" | "Complete"; | ||
type ResponseActionVerificationType = "Verified" | "Unverified"; | ||
|
||
interface ResponseActionAttrs { | ||
mainTask: Option; | ||
subActivities: string; | ||
subPillar: Option; | ||
responsibleOfficer: TeamMember; | ||
dueDate: Date; | ||
timeLine: Option; | ||
status: ResponseActionStatusType; | ||
verification: ResponseActionVerificationType; | ||
} | ||
|
||
export class ResponseAction extends Struct<ResponseActionAttrs>() {} |
17 changes: 17 additions & 0 deletions
17
src/domain/entities/incident-management-team/IncidentManagementTeam.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Struct } from "../generic/Struct"; | ||
import { TeamMember } from "./TeamMember"; | ||
|
||
interface TeamRole { | ||
role: string; | ||
level: number; | ||
} | ||
|
||
interface RoleTeamMemberMap { | ||
role: TeamRole; | ||
teamMember: TeamMember; | ||
} | ||
interface IncidentManagementTeamAttrs { | ||
teamHeirarchy: RoleTeamMemberMap[]; //Is there a better way to represent heirarchy? Maybe a tree? | ||
} | ||
|
||
export class IncidentManagementTeam extends Struct<IncidentManagementTeamAttrs>() {} |
21 changes: 21 additions & 0 deletions
21
src/domain/entities/incident-management-team/TeamMember.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NamedRef } from "../Ref"; | ||
import { Struct } from "../generic/Struct"; | ||
|
||
type PhoneNumber = string; | ||
type Email = string; | ||
type IncidentManagerStatus = "Available" | "Unavailable"; | ||
|
||
interface TeamMemberAttrs extends NamedRef { | ||
position: string; | ||
phone: PhoneNumber; | ||
email: Email; | ||
status: IncidentManagerStatus; | ||
photo: string; //URL to photo | ||
} | ||
|
||
export class TeamMember extends Struct<TeamMemberAttrs>() { | ||
static validatePhAndEmail() { | ||
//TO DO : any validations for phone number? | ||
//TO DO : any validations for email? | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Struct } from "../generic/Struct"; | ||
import { RiskAssessmentGrading } from "./RiskAssessmentGrading"; | ||
import { RiskAssessmentQuestionnaire } from "./RiskAssessmentQuestionnaire"; | ||
import { RiskAssessmentSummary } from "./RiskAssessmentSummary"; | ||
|
||
interface RiskAssessmentAttrs { | ||
riskAssessmentGrading: RiskAssessmentGrading[]; | ||
riskAssessmentSummary: RiskAssessmentSummary; | ||
riskAssessmentQuestionnaire: RiskAssessmentQuestionnaire[]; | ||
} | ||
|
||
export class RiskAssessment extends Struct<RiskAssessmentAttrs>() {} |
118 changes: 118 additions & 0 deletions
118
src/domain/entities/risk-assessment/RiskAssessmentGrading.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { Ref } from "../Ref"; | ||
import { Struct } from "../generic/Struct"; | ||
|
||
type WeightedOptions = { | ||
label: "Low" | "Medium" | "High"; | ||
weight: 1 | 2 | 3; | ||
}; | ||
|
||
export const LowWeightedOption: WeightedOptions = { | ||
label: "Low", | ||
weight: 1, | ||
}; | ||
export const MediumWeightedOption: WeightedOptions = { | ||
label: "Medium", | ||
weight: 2, | ||
}; | ||
export const HighWeightedOption: WeightedOptions = { | ||
label: "High", | ||
weight: 3, | ||
}; | ||
|
||
type PopulationWeightOptions = { | ||
label: "Less than 0.1%" | "Between 0.1% to 0.25%" | "Above 0.25%"; | ||
weight: 1 | 2 | 3; | ||
}; | ||
|
||
export const LowPopulationAtRisk: PopulationWeightOptions = { | ||
label: "Less than 0.1%", | ||
weight: 1, | ||
}; | ||
export const MediumPopulationAtRisk: PopulationWeightOptions = { | ||
label: "Between 0.1% to 0.25%", | ||
weight: 2, | ||
}; | ||
export const HighPopulationAtRisk: PopulationWeightOptions = { | ||
label: "Above 0.25%", | ||
weight: 3, | ||
}; | ||
|
||
type GeographicalSpreadOptions = { | ||
label: | ||
| "Within a district" | ||
| "Within a province with more than one district affected" | ||
| "More than one province affected with high threat of spread locally and internationally"; | ||
weight: 1 | 2 | 3; | ||
}; | ||
|
||
export const LowGeographicalSpread: GeographicalSpreadOptions = { | ||
label: "Within a district", | ||
weight: 1, | ||
}; | ||
export const MediumGeographicalSpread: GeographicalSpreadOptions = { | ||
label: "Within a province with more than one district affected", | ||
weight: 2, | ||
}; | ||
export const HighGeographicalSpread: GeographicalSpreadOptions = { | ||
label: "More than one province affected with high threat of spread locally and internationally", | ||
weight: 3, | ||
}; | ||
|
||
type CapacityOptions = { | ||
label: | ||
| "Available within the district with support from provincial and national level " | ||
| "Available within the province with minimal support from national level" | ||
| " Available at national with support required from international"; | ||
weight: 1 | 2 | 3; | ||
}; | ||
|
||
export const LowCapacity: CapacityOptions = { | ||
label: "Available within the district with support from provincial and national level ", | ||
weight: 1, | ||
}; | ||
export const MediumCapacity: CapacityOptions = { | ||
label: "Available within the province with minimal support from national level", | ||
weight: 2, | ||
}; | ||
export const HighCapacity: CapacityOptions = { | ||
label: " Available at national with support required from international", | ||
weight: 3, | ||
}; | ||
|
||
export type Grade = "Grade 1" | "Grade 2" | "Grade 3"; | ||
|
||
interface RiskAssessmentGradingAttrs extends Ref { | ||
lastUpdated: Date; | ||
populationAtRisk: PopulationWeightOptions; | ||
attackRate: WeightedOptions; | ||
geographicalSpread: GeographicalSpreadOptions; | ||
complexity: WeightedOptions; | ||
capacity: CapacityOptions; | ||
reputationalRisk: WeightedOptions; | ||
severity: WeightedOptions; | ||
// capability: WeightedOptions; | ||
grade?: Grade; | ||
} | ||
|
||
export class RiskAssessmentGrading extends Struct<RiskAssessmentGradingAttrs>() { | ||
calculateAndSetGrade(): void { | ||
const totalWeight = | ||
this.populationAtRisk.weight + | ||
this.attackRate.weight + | ||
this.geographicalSpread.weight + | ||
this.complexity.weight + | ||
this.capacity.weight + | ||
this.reputationalRisk.weight + | ||
this.severity.weight; | ||
// this.capability.weight; | ||
|
||
if (totalWeight > 21) throw new Error("Invalid grade"); | ||
|
||
this.grade = | ||
totalWeight <= 7 | ||
? "Grade 1" | ||
: totalWeight > 7 && totalWeight <= 14 | ||
? "Grade 2" | ||
: "Grade 3"; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/domain/entities/risk-assessment/RiskAssessmentQuestionnaire.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Property } from "../Properties"; | ||
import { Struct } from "../generic/Struct"; | ||
|
||
interface RiskAssessmentQuestionnaireAttrs { | ||
questions: Property[]; | ||
} | ||
|
||
export class RiskAssessmentQuestionnaire extends Struct<RiskAssessmentQuestionnaireAttrs>() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Property } from "../Properties"; | ||
import { Struct } from "../generic/Struct"; | ||
|
||
interface RiskAssessmentSummaryAttrs { | ||
properties: Property[]; | ||
} | ||
|
||
export class RiskAssessmentSummary extends Struct<RiskAssessmentSummaryAttrs>() {} |
Oops, something went wrong.