diff --git a/faker/main.py b/faker/main.py index 5ef0c26..82d77df 100644 --- a/faker/main.py +++ b/faker/main.py @@ -7,6 +7,7 @@ fake = Faker('fr_FR') department_dict = { + # IDF '75': ['Paris', 'Paris 2', 'Paris 3'], '77': ['Meaux', 'Chelles', 'Melun'], '78': ['Versailles', 'Yvelines', 'Rambouillet'], @@ -15,9 +16,31 @@ '93': ['Saint-Denis', 'Montreuil', 'Aubervilliers'], '94': ['Créteil', 'Vincennes', 'Ivry-sur-Seine'], '95': ['Cergy', 'Argenteuil', 'Sarcelles'], - '86': ['Poitiers', 'Jaunay-clan', 'Chatellerault'], - '17': ['La Rochelle', 'Aytré', 'Ronce-les-bains'], - '14': ['Cabourg', 'Honfleur', 'Trouville'], + # NORMANDIE + '14': ['a'], + '27': ['a'], + '50': ['a'], + '61': ['a'], + '76': ['a'], + # NOUVELLE AQUITAINE + '16': ['B'], + '17': ['B'], + '19': ['B'], + '23': ['B'], + '24': ['B'], + '33': ['B'], + '40': ['B'], + '47': ['B'], + '64': ['B'], + '79': ['B'], + '86': ['B'], + '87': ['B'], + # HAUTS DE FRANCE + '02': ['c'], + '59': ['c'], + '60': ['c'], + '62': ['c'], + '80': ['c'], } category_1 = ['suicide', 'avc', 'cancer', 'tuberculose', 'thrombose'] diff --git a/webapp-next/.env.example b/webapp-next/.env.example index 80fd248..4230d22 100644 --- a/webapp-next/.env.example +++ b/webapp-next/.env.example @@ -9,6 +9,9 @@ OPENAI_API_KEY=xxx # ElasticApi key name NEXT_PUBLIC_ELASTIC_API_KEY_NAME=cm2d_api_key +# Max associate causes +NEXT_PUBLIC_MAX_ASSOCIATE_CAUSE_SELECTION=3 + # Mailer NODEMAILER_HOST=ex4.mail.ovh.net NODEMAILER_PORT=587 diff --git a/webapp-next/Dockerfile b/webapp-next/Dockerfile index bac283d..f5fe24f 100644 --- a/webapp-next/Dockerfile +++ b/webapp-next/Dockerfile @@ -21,6 +21,7 @@ FROM node:16-alpine3.17 AS builder ARG ELASTIC_HOST ARG ELASTIC_PASSWORD ARG NEXT_PUBLIC_ELASTIC_API_KEY_NAME +ARG NEXT_PUBLIC_MAX_ASSOCIATE_CAUSE_SELECTION ARG NODEMAILER_HOST ARG NODEMAILER_PORT ARG NODEMAILER_USER diff --git a/webapp-next/components/charts/doughnut/Doughnut.tsx b/webapp-next/components/charts/doughnut/Doughnut.tsx index ca7c0f1..afe396a 100644 --- a/webapp-next/components/charts/doughnut/Doughnut.tsx +++ b/webapp-next/components/charts/doughnut/Doughnut.tsx @@ -6,7 +6,6 @@ import { chartsAvailableColors, getLabelFromKey } from '@/utils/tools'; -import { Box, Flex } from '@chakra-ui/react'; import { useContext, useEffect, useState } from 'react'; import { Doughnut } from 'react-chartjs-2'; diff --git a/webapp-next/components/charts/map/Map.tsx b/webapp-next/components/charts/map/Map.tsx index 5b678c3..eeb1c97 100644 --- a/webapp-next/components/charts/map/Map.tsx +++ b/webapp-next/components/charts/map/Map.tsx @@ -22,14 +22,19 @@ export default function MapIframe(props: Props) { throw new Error('Menu must be used within a Cm2dProvider'); } - const { saveAggregateX } = context; + const { filters, saveAggregateX } = context; const writeHTMLToIframe = () => { const iframe = iframeRef.current; if (iframe) { const doc = (iframe as any).contentWindow.document; - const mapProps = getMapProps(id, datasets, saveAggregateX); + const mapProps = getMapProps( + id, + datasets, + filters.region_departments, + saveAggregateX + ); doc.open(); doc.write(` diff --git a/webapp-next/components/filters/AssociateCauses.tsx b/webapp-next/components/filters/AssociateCauses.tsx index 9b331ef..2e0fbfc 100644 --- a/webapp-next/components/filters/AssociateCauses.tsx +++ b/webapp-next/components/filters/AssociateCauses.tsx @@ -2,14 +2,17 @@ import { useAssociateCauses } from '@/utils/api'; import { Cm2dContext } from '@/utils/cm2d-provider'; import { capitalizeString, removeAccents } from '@/utils/tools'; import { CloseIcon } from '@chakra-ui/icons'; +import { InfoOutlineIcon } from '@chakra-ui/icons'; import { Box, Button, Checkbox, + Flex, Input, InputGroup, InputRightElement, Link, + ListItem, Modal, ModalBody, ModalCloseButton, @@ -20,6 +23,7 @@ import { Spinner, Tag, Text, + UnorderedList, useDisclosure } from '@chakra-ui/react'; import { useContext, useEffect, useState } from 'react'; @@ -38,6 +42,9 @@ export const FilterAssociateCauses = (props: Props) => { const [isSearching, setIsSearching] = useState(false); const [search, setSearch] = useState(''); const debouncedSearchTerm = useDebounce(search, 300); + const maxSelection = parseInt( + (process.env.NEXT_PUBLIC_MAX_ASSOCIATE_CAUSE_SELECTION as string) || '2' + ); const { isOpen, onOpen, onClose } = useDisclosure(); useEffect(() => { @@ -118,7 +125,9 @@ export const FilterAssociateCauses = (props: Props) => { - Gestion des causes associées + + Gestion des causes associées (maximum {maxSelection}) + @@ -164,6 +173,10 @@ export const FilterAssociateCauses = (props: Props) => { { if (e.target.checked) { filters.categories_associate.push(ac.value); @@ -190,7 +203,13 @@ export const FilterAssociateCauses = (props: Props) => { - + + + Attention : sont + comptabilisés tous les certificats faisant mention de la cause{' '} + {capitalizeString(filters.categories[0])} et d'au moins une + des causes associées sélectionnées. + diff --git a/webapp-next/components/filters/Departments.tsx b/webapp-next/components/filters/Departments.tsx index b75f471..1ae6d3d 100644 --- a/webapp-next/components/filters/Departments.tsx +++ b/webapp-next/components/filters/Departments.tsx @@ -21,7 +21,7 @@ export const FiltersDepartments = (props: Props) => { const { filters, setFilters, selectedFiltersPile, setSelectedFiltersPile } = context; - const { data } = useDepartments(); + const { data } = useDepartments(filters.region_departments); if (!data) return <>...; @@ -76,7 +76,9 @@ export const FiltersDepartments = (props: Props) => { departmentRefs[ department.label as keyof typeof departmentRefs ] - } (${department.label})` + } (${department.label.toString().length > 1 ? '' : `0`}${ + department.label + })` : `Inconnu (${department.label})`} diff --git a/webapp-next/components/filters/Regions.tsx b/webapp-next/components/filters/Regions.tsx new file mode 100644 index 0000000..af3c10c --- /dev/null +++ b/webapp-next/components/filters/Regions.tsx @@ -0,0 +1,156 @@ +import { Cm2dContext } from '@/utils/cm2d-provider'; +import { ChevronDownIcon } from '@chakra-ui/icons'; +import { Flex, Menu, MenuButton, MenuItem, MenuList } from '@chakra-ui/react'; +import { useRouter } from 'next/router'; +import { useContext, useEffect, useState } from 'react'; + +type Props = {}; + +export const RegionFilter = (props: Props) => { + const context = useContext(Cm2dContext); + const router = useRouter(); + const { mode } = router.query; + + if (!context) { + throw new Error('Menu must be used within a Cm2dProvider'); + } + + const { filters, setFilters } = context; + + const [selectedFilter, setSelectedFilter] = useState( + filters.region_departments + ); + + let regionFilters: { label: string; value: string[] }[] = [ + { + label: 'Ile-de-France', + value: ['75', '77', '78', '91', '92', '93', '94', '95'] + }, + { label: 'Normandie', value: ['14', '27', '50', '61', '76'] }, + { + label: 'Nouvelle-Aquitaine', + value: [ + '16', + '17', + '19', + '23', + '24', + '33', + '40', + '47', + '64', + '79', + '86', + '87' + ] + }, + { label: 'Hauts-de-France', value: ['2', '59', '60', '62', '80'] } + ]; + + if (mode === 'dev') { + regionFilters = [ + ...regionFilters, + { + label: 'Auvergne-Rhône-Alpes', + value: [ + '1', + '3', + '7', + '15', + '26', + '38', + '42', + '43', + '63', + '69', + '73', + '74' + ] + }, + { + label: 'Bourgogne-Franche-Comté', + value: ['21', '25', '39', '58', '70', '71', '89', '90'] + }, + { label: 'Bretagne', value: ['22', '29', '35', '56'] }, + { + label: 'Centre-Val de Loire', + value: ['18', '28', '36', '37', '41', '45'] + }, + { label: 'Corse', value: ['2A', '2B'] }, + { + label: 'Grand Est', + value: ['8', '10', '51', '52', '54', '55', '57', '67', '68', '88'] + }, + { + label: 'Occitanie', + value: [ + '9', + '11', + '12', + '30', + '31', + '32', + '34', + '46', + '48', + '65', + '66', + '81', + '82' + ] + }, + { label: 'Pays de la Loire', value: ['44', '49', '53', '72', '85'] }, + { + label: "Provence-Alpes-Côte d'Azur", + value: ['4', '5', '6', '13', '83', '84'] + } + ]; + } + + const getLabelFromValue = (value: string[]) => { + return ( + regionFilters.find( + df => JSON.stringify(df.value) === JSON.stringify(value) + )?.label || '' + ); + }; + + useEffect(() => { + if (selectedFilter) + setFilters({ ...filters, region_departments: selectedFilter }); + }, [selectedFilter]); + + return ( + + + + {getLabelFromValue(selectedFilter)} + + + + + {regionFilters.map(filter => ( + { + setSelectedFilter(filter.value); + }} + > + {filter.label} + + ))} + + + ); +}; diff --git a/webapp-next/components/layouts/Menu.tsx b/webapp-next/components/layouts/Menu.tsx index 4682f49..fad50de 100644 --- a/webapp-next/components/layouts/Menu.tsx +++ b/webapp-next/components/layouts/Menu.tsx @@ -1,50 +1,51 @@ -import { Box, Flex, Image, Spacer, Stack } from "@chakra-ui/react"; -import { Cm2dContext, baseFilters } from "@/utils/cm2d-provider"; -import { useContext } from "react"; -import { FiltersAges } from "../filters/Ages"; -import { FilterCauses } from "../filters/Causes"; -import { FiltersDeathLocations } from "../filters/DeathLocations"; -import { FiltersSexes } from "../filters/Sexes"; -import { MenuTitle } from "./MenuTitle"; -import { SubMenu } from "./SubMenu"; -import { MenuLinks } from "./MenuLinks"; -import { UserCard } from "./UserCard"; -import { FilterDates } from "../filters/Dates"; -import { FiltersDepartments } from "../filters/Departments"; -import cookie from "js-cookie"; -import { hasAtLeastOneFilter, ELASTIC_API_KEY_NAME } from "@/utils/tools"; -import { FilterAssociateCauses } from "../filters/AssociateCauses"; +import { Box, Flex, Image, Spacer, Stack } from '@chakra-ui/react'; +import { Cm2dContext, baseFilters } from '@/utils/cm2d-provider'; +import { useContext } from 'react'; +import { FiltersAges } from '../filters/Ages'; +import { FilterCauses } from '../filters/Causes'; +import { FiltersDeathLocations } from '../filters/DeathLocations'; +import { FiltersSexes } from '../filters/Sexes'; +import { MenuTitle } from './MenuTitle'; +import { SubMenu } from './SubMenu'; +import { MenuLinks } from './MenuLinks'; +import { UserCard } from './UserCard'; +import { FilterDates } from '../filters/Dates'; +import { FiltersDepartments } from '../filters/Departments'; +import cookie from 'js-cookie'; +import { hasAtLeastOneFilter, ELASTIC_API_KEY_NAME } from '@/utils/tools'; +import { FilterAssociateCauses } from '../filters/AssociateCauses'; +import { RegionFilter } from '../filters/Regions'; export const ageRanges = [ - { from: 0, to: 0, key: "Moins de 1 an" }, - { from: 1, to: 5, key: "1-5 ans" }, - { from: 6, to: 10, key: "6-10 ans" }, - { from: 11, to: 20, key: "11-20 ans" }, - { from: 21, to: 30, key: "21-30 ans" }, - { from: 31, to: 40, key: "31-40 ans" }, - { from: 41, to: 50, key: "41-50 ans" }, - { from: 51, to: 60, key: "51-60 ans" }, - { from: 61, to: 70, key: "61-70 ans" }, - { from: 71, key: "71 ans et +" }, + { from: 0, to: 0, key: 'Moins de 1 an' }, + { from: 1, to: 5, key: '1-5 ans' }, + { from: 6, to: 10, key: '6-10 ans' }, + { from: 11, to: 20, key: '11-20 ans' }, + { from: 21, to: 30, key: '21-30 ans' }, + { from: 31, to: 40, key: '31-40 ans' }, + { from: 41, to: 50, key: '41-50 ans' }, + { from: 51, to: 60, key: '51-60 ans' }, + { from: 61, to: 70, key: '61-70 ans' }, + { from: 71, key: '71 ans et +' } ]; export function Menu() { const context = useContext(Cm2dContext); if (!context) { - throw new Error("Menu must be used within a Cm2dProvider"); + throw new Error('Menu must be used within a Cm2dProvider'); } const { filters, setFilters, user } = context; return ( + + + + @@ -69,15 +74,15 @@ export function Menu() { button={ hasAtLeastOneFilter(filters) ? { - label: "Réinitialiser", + label: 'Réinitialiser', onClick: () => { setFilters({ ...baseFilters, categories: filters.categories, start_date: filters.start_date, - end_date: filters.end_date, + end_date: filters.end_date }); - }, + } } : undefined } @@ -91,9 +96,9 @@ export function Menu() { } icon={{ - src: "icons/user-search-blue.svg", - srcOpen: "icons/user-search.svg", - alt: "Onglet démographie", + src: 'icons/user-search-blue.svg', + srcOpen: 'icons/user-search.svg', + alt: 'Onglet démographie' }} > @@ -110,32 +115,32 @@ export function Menu() { } icon={{ - src: "icons/file-list-search-blue.svg", - srcOpen: "icons/file-list-search.svg", - alt: "Onglet données du décès", + src: 'icons/file-list-search-blue.svg', + srcOpen: 'icons/file-list-search.svg', + alt: 'Onglet données du décès' }} > - + Causes associées} icon={{ - src: "icons/folder-open-blue.svg", - srcOpen: "icons/folder-open.svg", - alt: "Onglet causes associées", + src: 'icons/folder-open-blue.svg', + srcOpen: 'icons/folder-open.svg', + alt: 'Onglet causes associées' }} isDisabled={ - !filters.categories.length || filters.categories_search !== "full" + !filters.categories.length || filters.categories_search !== 'full' } disabledMessage={ !filters.categories.length - ? "Veuillez sélectionner une cause de décès pour accéder aux causes associées" + ? 'Veuillez sélectionner une cause de décès pour accéder aux causes associées' : 'Pour associer des causes, veuillez désélectionner "Rechercher uniquement dans le processus morbide"' } - forceCollapse={filters.categories_search !== "full"} + forceCollapse={filters.categories_search !== 'full'} > @@ -147,24 +152,24 @@ export function Menu() { { cookie.remove(ELASTIC_API_KEY_NAME); window.location.reload(); }, - link: "/", - }, + link: '/' + } ]} /> diff --git a/webapp-next/utils/api.ts b/webapp-next/utils/api.ts index 0682dbd..89d6b8f 100644 --- a/webapp-next/utils/api.ts +++ b/webapp-next/utils/api.ts @@ -83,9 +83,14 @@ export function useAssociateCauses() { }; } -export function useDepartments() { +export function useDepartments(departments: number[]) { const params = { - index: 'cm2d_departments' + index: 'cm2d_departments', + filters: JSON.stringify({ + terms: { + department: departments + } + }) }; const { data, error } = useSWR( diff --git a/webapp-next/utils/cm2d-provider.tsx b/webapp-next/utils/cm2d-provider.tsx index 64fdb79..f412cc3 100644 --- a/webapp-next/utils/cm2d-provider.tsx +++ b/webapp-next/utils/cm2d-provider.tsx @@ -20,6 +20,7 @@ export type Filters = { }[]; sex: string[]; department: string[]; + region_departments: string[]; start_date?: string; end_date?: string; }; @@ -67,7 +68,8 @@ export const baseFilters: Filters = { death_location: [], age: [], sex: [], - department: [] + department: [], + region_departments: ['75', '77', '78', '91', '92', '93', '94', '95'] }; export const baseAggregation = { aggregated_date: { @@ -80,6 +82,7 @@ export const baseAggregation = { export function Cm2dProvider({ children }: Cm2dProviderProps) { const [filters, setFilters] = useState(baseFilters); + console.log(filters); const [selectedFiltersPile, setSelectedFiltersPile] = useState([]); const [aggregations, setAggregations] = useState(baseAggregation); diff --git a/webapp-next/utils/map/props.ts b/webapp-next/utils/map/props.ts index 24f88c6..c38c39d 100644 --- a/webapp-next/utils/map/props.ts +++ b/webapp-next/utils/map/props.ts @@ -1,10 +1,18 @@ import { orders, sortByOrder } from '../orders'; -import { capitalizeString, getLabelFromKey, hexToRGB, isNC } from '../tools'; +import { + capitalizeString, + departmentRefs, + departmentsCodes, + getLabelFromKey, + hexToRGB, + isNC +} from '../tools'; import { MapConfig } from './type'; export const getMapProps = ( id: string, datasets: { hits: any[]; total?: number }[], + departments: string[], saveAggregateX?: string ): { config?: MapConfig; @@ -59,24 +67,24 @@ export const getMapProps = ( } }; - const getCountFromKey = (key: number): number => { - const hit = hits.find(h => h.key === key.toString()); + const getCountFromKey = (key: string): number => { + const hit = hits.find(h => h.key === key); // return hit ? (isNC(hit.doc_count) ? 'NC' : hit.doc_count) : 0; return hit ? hit.doc_count : 0; }; - const getPercentage = (key: number): string => { - const hit = hits.find(h => h.key === key.toString()); + const getPercentage = (key: string): string => { + const hit = hits.find(h => h.key === key); if (!hit || !total) return '0%'; // if (isNC(hit.doc_count)) return 'NC'; return `${Math.round((hit.doc_count / total) * 10000) / 100}%`; }; const getColorFromPercentage = ( - key: number, + key: string, kind: 'initial' | 'hover' ): string => { - const hit = hits.find(h => h.key === key.toString()); + const hit = hits.find(h => h.key === key); if (!hit || !total) return stateColors.NEUTRAL[kind]; const percentage = hit.doc_count / total; @@ -86,8 +94,8 @@ export const getMapProps = ( return stateColors.RED[kind]; }; - const getFullDescription = (key: number): string => { - const hit = hits.find(h => h.key === key.toString()); + const getFullDescription = (key: string): string => { + const hit = hits.find(h => h.key === key); if (!hit) return ''; if (hit.children) { @@ -117,6 +125,23 @@ export const getMapProps = ( return `Nombre de décès : ${getCountFromKey(key)}`; }; + const states: { + [key: string]: { + name: string; + description: string; + color: string; + hover_color: string; + }; + } = {}; + departments.forEach(d => { + states[departmentsCodes[d.toString()]] = { + name: `${departmentRefs[d.toString()]} (${getPercentage(d)})`, + description: getFullDescription(d), + color: getColorFromPercentage(d, 'initial'), + hover_color: getColorFromPercentage(d, 'hover') + }; + }); + const config: MapConfig = { main_settings: { //General settings @@ -190,69 +215,11 @@ export const getMapProps = ( state_image_position: '', location_image_url: '' }, - state_specific: { - FRA5289: { - name: `Essonne (${getPercentage(91)})`, - description: getFullDescription(91), - color: getColorFromPercentage(91, 'initial'), - hover_color: getColorFromPercentage(91, 'hover') - }, - FRA5306: { - name: `Hauts-de-Seine (${getPercentage(92)})`, - description: getFullDescription(92), - color: getColorFromPercentage(92, 'initial'), - hover_color: getColorFromPercentage(92, 'hover') - }, - FRA5333: { - name: `Paris (${getPercentage(75)})`, - description: getFullDescription(75), - color: getColorFromPercentage(75, 'initial'), - hover_color: getColorFromPercentage(75, 'hover') - }, - FRA5342: { - name: `Seine-et-Marne (${getPercentage(77)})`, - description: getFullDescription(77), - color: getColorFromPercentage(77, 'initial'), - hover_color: getColorFromPercentage(77, 'hover') - }, - FRA5344: { - name: `Seine-Saint-Denis (${getPercentage(93)})`, - description: getFullDescription(93), - color: getColorFromPercentage(93, 'initial'), - hover_color: getColorFromPercentage(93, 'hover') - }, - FRA5349: { - name: `Val-d'Oise (${getPercentage(95)})`, - description: getFullDescription(95), - color: getColorFromPercentage(95, 'initial'), - hover_color: getColorFromPercentage(95, 'hover') - }, - FRA5350: { - name: `Val-de-Marne (${getPercentage(94)})`, - description: getFullDescription(94), - color: getColorFromPercentage(94, 'initial'), - hover_color: getColorFromPercentage(94, 'hover') - }, - FRA5357: { - name: `Yvelines (${getPercentage(78)})`, - description: getFullDescription(78), - color: getColorFromPercentage(78, 'initial'), - hover_color: getColorFromPercentage(78, 'hover') - } - }, + state_specific: states, regions: { '0': { - states: [ - 'FRA5333', - 'FRA5342', - 'FRA5357', - 'FRA5289', - 'FRA5306', - 'FRA5344', - 'FRA5350', - 'FRA5349' - ], - name: 'Ile-de-France', + states: Object.keys(states), + name: '', zoomable: 'no' } } diff --git a/webapp-next/utils/overrides.css b/webapp-next/utils/overrides.css index 671f252..6d76fc6 100644 --- a/webapp-next/utils/overrides.css +++ b/webapp-next/utils/overrides.css @@ -106,6 +106,10 @@ background-color: #246cf9; } +.react-datepicker-popper { + z-index: 9; +} + .react-datepicker .react-datepicker__month-wrapper .react-datepicker__month-text--keyboard-selected { diff --git a/webapp-next/utils/tools.ts b/webapp-next/utils/tools.ts index 1617e97..762813e 100644 --- a/webapp-next/utils/tools.ts +++ b/webapp-next/utils/tools.ts @@ -10,10 +10,96 @@ export const viewRefs: { label: string; value: View }[] = [ { label: 'Vue tableau', value: 'table' } ]; -export const departmentRefs = { +export const departmentRefs: { [key: string]: string } = { + '1': 'Ain', + '2': 'Aisne', + '3': 'Allier', + '4': 'Alpes-de-Haute-Provence', + '5': 'Hautes-Alpes', + '6': 'Alpes-Maritimes', + '7': 'Ardèche', + '8': 'Ardennes', + '9': 'Ariège', + '10': 'Aube', + '11': 'Aude', + '12': 'Aveyron', + '13': 'Bouches-du-Rhône', + '14': 'Calvados', + '15': 'Cantal', + '16': 'Charente', + '17': 'Charente-Maritime', + '18': 'Cher', + '19': 'Corrèze', + '21': "Côte-d'Or", + '22': "Côtes-d'Armor", + '23': 'Creuse', + '24': 'Dordogne', + '25': 'Doubs', + '26': 'Drôme', + '27': 'Eure', + '28': 'Eure-et-Loir', + '29': 'Finistère', + '30': 'Gard', + '31': 'Haute-Garonne', + '32': 'Gers', + '33': 'Gironde', + '34': 'Hérault', + '35': 'Ille-et-Vilaine', + '36': 'Indre', + '37': 'Indre-et-Loire', + '38': 'Isère', + '39': 'Jura', + '40': 'Landes', + '41': 'Loir-et-Cher', + '42': 'Loire', + '43': 'Haute-Loire', + '44': 'Loire-Atlantique', + '45': 'Loiret', + '46': 'Lot', + '47': 'Lot-et-Garonne', + '48': 'Lozère', + '49': 'Maine-et-Loire', + '50': 'Manche', + '51': 'Marne', + '52': 'Haute-Marne', + '53': 'Mayenne', + '54': 'Meurthe-et-Moselle', + '55': 'Meuse', + '56': 'Morbihan', + '57': 'Moselle', + '58': 'Nièvre', + '59': 'Nord', + '60': 'Oise', + '61': 'Orne', + '62': 'Pas-de-Calais', + '63': 'Puy-de-Dôme', + '64': 'Pyrénées-Atlantiques', + '65': 'Hautes-Pyrénées', + '66': 'Pyrénées-Orientales', + '67': 'Bas-Rhin', + '68': 'Haut-Rhin', + '69': 'Rhône', + '70': 'Haute-Saône', + '71': 'Saône-et-Loire', + '72': 'Sarthe', + '73': 'Savoie', + '74': 'Haute-Savoie', '75': 'Paris', + '76': 'Seine-Maritime', '77': 'Seine-et-Marne', '78': 'Yvelines', + '79': 'Deux-Sèvres', + '80': 'Somme', + '81': 'Tarn', + '82': 'Tarn-et-Garonne', + '83': 'Var', + '84': 'Vaucluse', + '85': 'Vendée', + '86': 'Vienne', + '87': 'Haute-Vienne', + '88': 'Vosges', + '89': 'Yonne', + '90': 'Territoire de Belfort', '91': 'Essonne', '92': 'Hauts-de-Seine', '93': 'Seine-Saint-Denis', @@ -21,6 +107,105 @@ export const departmentRefs = { '95': "Val-d'Oise" }; +export const departmentsCodes: { [key: string]: string } = { + '1': 'FRA5262', // Ain + '2': 'FRA5263', // Aisne + '3': 'FRA5264', // Allier + '4': 'FRA5265', // Alpes-de-Haute-Provence + '6': 'FRA5266', // Alpes-Maritimes + '7': 'FRA5267', // Ardèche + '8': 'FRA5268', // Ardennes + '9': 'FRA5269', // Ariège + '10': 'FRA5270', // Aube + '11': 'FRA5271', // Aude + '12': 'FRA5272', // Aveyron + '67': 'FRA5273', // Bas-Rhin + '13': 'FRA5274', // Bouches-du-Rhône + '14': 'FRA5275', // Calvados + '15': 'FRA5276', // Cantal + '16': 'FRA5277', // Charente + '17': 'FRA5278', // Charente-Maritime + '18': 'FRA5279', // Cher + '19': 'FRA5280', // Corrèze + '2A': 'FRA5281', // Corse-du-Sud + '21': 'FRA5282', // Côte-d'Or + '22': 'FRA5283', // Côtes-d'Armor + '23': 'FRA5284', // Creuse + '79': 'FRA5285', // Deux-Sèvres + '24': 'FRA5286', // Dordogne + '25': 'FRA5287', // Doubs + '26': 'FRA5288', // Drôme + '91': 'FRA5289', // Essonne + '27': 'FRA5290', // Eure + '28': 'FRA5291', // Eure-et-Loir + '29': 'FRA5292', // Finistère + '30': 'FRA5293', // Gard + '32': 'FRA5294', // Gers + '33': 'FRA5295', // Gironde + '68': 'FRA5296', // Haute-Rhin + '2B': 'FRA5297', // Haute-Corse + '31': 'FRA5298', // Haute-Garonne + '43': 'FRA5299', // Haute-Loire + '52': 'FRA5300', // Haute-Marne + '70': 'FRA5301', // Haute-Saône + '74': 'FRA5302', // Haute-Savoie + '87': 'FRA5303', // Haute-Vienne + '05': 'FRA5304', // Hautes-Alpes + '65': 'FRA5305', // Hautes-Pyrénées + '92': 'FRA5306', // Hauts-de-Seine + '34': 'FRA5307', // Hérault + '35': 'FRA5308', // Ille-et-Vilaine + '36': 'FRA5309', // Indre + '37': 'FRA5310', // Indre-et-Loire + '38': 'FRA5311', // Isère + '39': 'FRA5312', // Jura + '40': 'FRA5313', // Landes + '41': 'FRA5314', // Loir-et-Cher + '42': 'FRA5315', // Loire + '44': 'FRA5316', // Loire-Atlantique + '45': 'FRA5317', // Loiret + '46': 'FRA5318', // Lot + '47': 'FRA5319', // Lot-et-Garonne + '48': 'FRA5320', // Lozère + '49': 'FRA5321', // Maine-et-Loire + '50': 'FRA5322', // Manche + '51': 'FRA5323', // Marne + '53': 'FRA5324', // Mayenne + '54': 'FRA5325', // Meurthe-et-Moselle + '55': 'FRA5326', // Meuse + '56': 'FRA5327', // Morbihan + '57': 'FRA5328', // Moselle + '58': 'FRA5329', // Nièvre + '59': 'FRA5330', // Nord + '60': 'FRA5331', // Oise + '61': 'FRA5332', // Orne + '75': 'FRA5333', // Paris + '62': 'FRA5334', // Pas-de-Calais + '63': 'FRA5335', // Puy-de-Dôme + '64': 'FRA5336', // Pyrénées-Atlantiques + '66': 'FRA5337', // Pyrénées-Orientales + '69': 'FRA5338', // Rhône + '71': 'FRA5339', // Saône-et-Loire + '72': 'FRA5340', // Sarthe + '73': 'FRA5341', // Savoie + '77': 'FRA5342', // Seine-et-Marne + '76': 'FRA5343', // Seine-Maritime + '93': 'FRA5344', // Seine-Saint-Denis + '80': 'FRA5345', // Somme + '81': 'FRA5346', // Tarn + '82': 'FRA5347', // Tarn-et-Garonne + '90': 'FRA5348', // Territoire de Belfort + '95': 'FRA5349', // Val-d'Oise + '94': 'FRA5350', // Val-de-Marne + '83': 'FRA5351', // Var + '84': 'FRA5352', // Vaucluse + '85': 'FRA5353', // Vendée + '86': 'FRA5354', // Vienne + '88': 'FRA5355', // Vosges + '89': 'FRA5356', // Yonne + '78': 'FRA5357' // Yvelines +}; + const elkFields = [ { value: 'sex', label: 'Sexe' }, { value: 'age', label: 'Age' }, @@ -168,7 +353,7 @@ export function transformFilters(filters: Filters): any[] { department: filters.department.length > 0 ? filters.department - : ['91', '92', '93', '94', '95', '77', '78', '75'] + : filters.region_departments } });