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 === "Refus CRPC" || evenement.Type === "Acceptation 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 === "Gendarmerie/Forces de l'ordre"; } export function isProcureur(e: EvenementFamille): boolean { return e.Type === "Audition procureur" || isCRPC(e) || isCompositionPenale(e); } 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" || e.Type === "Information préoccupante 4" ); }