statistiques/src/data/EvenementFamille.ts

81 lines
2.5 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 isProcedurePenaleHorsGendarmerie(
evenement: EvenementFamille
): boolean {
return (
isProcedurePenale(evenement) &&
evenement.Type !== "Gendarmerie/Forces de l'ordre"
);
}
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 === "Refus CRPC" || evenement.Type === "Acceptation 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 === "Gendarmerie/Forces de l'ordre";
2024-09-05 09:23:27 +02:00
}
export function isProcureur(e: EvenementFamille): boolean {
return e.Type === "Audition procureur" || isCRPC(e) || isCompositionPenale(e);
2024-09-07 22:11:20 +02:00
}
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" ||
e.Type === "Information préoccupante 4"
2024-09-05 09:23:27 +02:00
);
}