statistiques/src/data/EvenementFamille.ts
2024-09-07 22:34:22 +02:00

77 lines
2.4 KiB
TypeScript

import { Period } from "../period/Period";
import { isPeriodContaining } from "../period/isPeriodContaining";
import { TypeEvenement } from "./TypeEvenement";
import { typesEvenementsPenal } from "./TypeEvenementsPenal";
import { TypeEvenementsPenal } from "./TypeEvenementsPenal";
import { typesEvenementsSocial as typesEvenementsCivil } from "./TypeEvenementsSocial";
import { TypesEvenementsSocial as TypesEvenementsCivil } from "./TypeEvenementsSocial";
export type EvenementFamille = Readonly<{
notionId: string;
notionIdFamille: string;
Évènement: string;
Date: Date | null;
Type: TypeEvenement;
"Enfants concernés": string;
}>;
export function isProcedurePenale(evenement: EvenementFamille): boolean {
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 {
return typesEvenementsCivil.includes(evenement.Type as TypesEvenementsCivil);
}
export function isEvenementInPeriod(
evt: EvenementFamille,
period: Period
): boolean {
return evt.Date !== null && isPeriodContaining(period, evt.Date);
}
export function isEvenementBefore(evt: EvenementFamille, date: Date): boolean {
if (evt.Date === null) {
// Assume lack of date are oldest events
return true;
}
return evt.Date < date;
}
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"
);
}
export function isAuditionProcureurOuCRPC(e: EvenementFamille): boolean {
return e.Type === "Audition procureur" || e.Type === "Audience CRPC";
}
export function isInformationPreoccupante(e: EvenementFamille): boolean {
return (
e.Type === "Information préoccupante 1" ||
e.Type === "Information préoccupante 2" ||
e.Type === "Information préoccupante 3"
);
}