FIXED import person with the new gender entity

This commit is contained in:
2025-09-02 11:03:35 +02:00
parent 5bfc7f4a02
commit c17b2ae524

View File

@@ -228,7 +228,7 @@ ALTER TABLE import.personnes ADD column mobilenumber1 text;
ALTER TABLE import.personnes ADD column phonenumber1 text;
DO $$
DECLARE
intl text := 32;
intl text := 33;
BEGIN
-- 33. Format mobile numbers
UPDATE import.personnes SET mobilenumber1=NULLIF(regexp_replace(mobilenumber, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
@@ -260,9 +260,10 @@ UPDATE import.personnes SET person_id=personid
INSERT INTO chill_person_person (
id
, nationality_id, countryofbirth_id, civility_id, maritalstatus_id
, firstname, lastname, birthdate, place_of_birth, memo, email, contactinfo, phonenumber, mobilenumber, numberofchildren, gender, deathdate, proxyaccompanyingperiodopenstate
, firstname, lastname, birthdate, place_of_birth, memo, email, contactinfo, phonenumber, mobilenumber, numberofchildren, deathdate, proxyaccompanyingperiodopenstate
, createdat, updatedat, createdby_id, updatedby_id
, center_id
, gender_id
, gendercomment_comment, gendercomment_userid, gendercomment_date
/*
, maritalstatusdate
@@ -275,10 +276,11 @@ INSERT INTO chill_person_person (
, (SELECT c.id FROM country c WHERE c.name::jsonb->>'fr' = ip.countryofbirth1::jsonb->>'fr' AND ip.countryofbirth1 IS NOT NULL ) -- countryofbirth_id,
, (SELECT c.id FROM chill_main_civility c WHERE c.name::jsonb->>'fr' = ip.civility1::jsonb->>'fr' AND ip.civility1 IS NOT NULL ) -- civility_id
, (SELECT ms.id FROM chill_person_marital_status ms WHERE ms.name::jsonb->>'fr' = ip.maritalstatus1::jsonb->>'fr' AND ip.maritalstatus1 IS NOT NULL ) -- maritalstatus_id,
, TRIM(firstname), UPPER(TRIM(lastname)), birthdate1, TRIM(placeofbirth1), TRIM(memo1), TRIM(email), TRIM(contactinfo), phonenumber1, mobilenumber1, numberofchildren1, gender1, deathdate1, false
, COALESCE(TRIM(firstname),''), UPPER(TRIM(lastname)), birthdate1, TRIM(placeofbirth1), TRIM(memo1), TRIM(email), TRIM(contactinfo), phonenumber1, mobilenumber1, numberofchildren1, deathdate1, false
, CURRENT_DATE, CURRENT_DATE -- createdat, updatedat (= import date)
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users) -- createdby_id, updatedby_id
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM centers) -- center_id
, (SELECT g.id FROM chill_main_gender g WHERE g.gendertranslation = ip.gender1)
, TRIM(gendercomment), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), date(date_trunc('year', CURRENT_DATE)) --gendercomment_<comment|userid|date>
/*
, -- maritalstatusdate