statistiques/src/data/EvenementFamille.ts

78 lines
2.4 KiB
TypeScript
Raw Normal View History

import { Period } from "../period/Period";
import { isPeriodContaining } from "../period/isPeriodContaining";
import { TypeEvenement } from "./TypeEvenement";
2024-09-07 22:11:20 +02:00
import { typesEvenementsPenal } from "./TypeEvenementsPenal";
import { TypeEvenementsPenal } from "./TypeEvenementsPenal";
import { typesEvenementsSocial as typesEvenementsCivil } from "./TypeEvenementsSocial";
import { TypesEvenementsSocial as TypesEvenementsCivil } from "./TypeEvenementsSocial";
2024-09-06 13:33:16 +02:00
export type EvenementFamille = Readonly<{
notionId: string;
notionIdFamille: string;
Évènement: string;
Date: Date | null;
Type: TypeEvenement;
"Enfants concernés": string;
2024-09-06 13:33:16 +02:00
}>;
export function isProcedurePenale(evenement: EvenementFamille): boolean {
2024-09-07 22:11:20 +02:00
return (
typesEvenementsPenal.includes(evenement.Type as TypeEvenementsPenal) &&
evenement.Type !== "Mise en demeure de scolarisation"
);
}
export function isCompositionPenale(evenement: EvenementFamille): boolean {
return (
evenement.Type === "Composition pénale acceptée" ||
evenement.Type === "Composition pénale refusée"
);
}
export function isCRPC(evenement: EvenementFamille): boolean {
return (
evenement.Type === "Convocation CRPC" ||
evenement.Type === "Audience CRPC" ||
evenement.Type === "Refus CRPC"
);
}
export function isProcedureCivile(evenement: EvenementFamille): boolean {
2024-09-07 22:11:20 +02:00
return typesEvenementsCivil.includes(evenement.Type as TypesEvenementsCivil);
}
export function isEvenementInPeriod(
evt: EvenementFamille,
period: Period
): boolean {
return evt.Date !== null && isPeriodContaining(period, evt.Date);
}
2024-06-05 21:35:55 +02:00
export function isEvenementBefore(evt: EvenementFamille, date: Date): boolean {
if (evt.Date === null) {
2024-09-05 09:23:27 +02:00
// Assume lack of date are oldest events
return true;
}
return evt.Date < date;
}
2024-06-05 21:35:55 +02:00
2024-09-05 09:23:27 +02:00
export function isGendarmerie(e: EvenementFamille): boolean {
return (
e.Type === "Audition gendarmerie / police" ||
e.Type === "Gendarmerie/Forces de l'ordre" ||
e.Type === "Récidive gendarmerie" ||
e.Type === "Passage police municipale"
);
}
2024-09-06 13:45:27 +02:00
export function isAuditionProcureurOuCRPC(e: EvenementFamille): boolean {
2024-09-07 22:11:20 +02:00
return e.Type === "Audition procureur" || e.Type === "Audience CRPC";
}
export function isInformationPreoccupante(e: EvenementFamille): boolean {
2024-09-05 09:23:27 +02:00
return (
2024-09-07 22:11:20 +02:00
e.Type === "Information préoccupante 1" ||
e.Type === "Information préoccupante 2" ||
e.Type === "Information préoccupante 3"
2024-09-05 09:23:27 +02:00
);
}