SORMAS-Foundation / SORMAS-Project

SORMAS (Surveillance, Outbreak Response Management and Analysis System) is an early warning and management system to fight the spread of infectious diseases.
https://sormas.org
GNU General Public License v3.0
291 stars 140 forks source link

Feature 13068 self reporting directory #13081

Closed leventegal-she closed 5 months ago

leventegal-she commented 5 months ago

Fixes #13068

Utility script for creating self reports in the DB:

DO $$
    DECLARE LOCATION_ID INT;
    DECLARE USER_ID INT;
    DECLARE HOUSE_NUMBER INT = 123;
    DECLARE FIRST_NAME text = 'James';
    DECLARE LAST_NAME text = 'Smith';
    BEGIN
        SELECT * FROM users WHERE username = 'NatUser' INTO USER_ID;
        INSERT INTO location (id, uuid, changedate, creationdate, change_user_id, city, street, housenumber) VALUES (nextval('entity_seq'), generate_base32_uuid(), now(), now(), USER_ID, 'City', 'Street', HOUSE_NUMBER) RETURNING id INTO LOCATION_ID;
        INSERT INTO selfreports (id, uuid, changedate, creationdate, change_user_id, deleted, deletionreason, otherdeletionreason, archived, archiveundonereason, endofprocessingdate, type, reportdate, casereference, disease, diseasevariant, firstname, lastname, sex, birthdatedd, birthdatemm, birthdateyyyy, nationalhealthid, email, phonenumber, address_id, comment, responsibleuser_id, investigationstatus, processingstatus)
        VALUES (nextval('entity_seq'), generate_base32_uuid(), now(), now(), USER_ID, false, null, null, false, null, null, 'CASE', now(), '1234567890', 'CORONAVIRUS', null, FIRST_NAME, LAST_NAME, 'MALE', 1, 1, 1990, '1234567890', concat(FIRST_NAME, '.', LAST_NAME, '@email.com'), '1234567890', LOCATION_ID, 'Comment', USER_ID, 'PENDING', 'UNPROCESSED');
    END;
$$ LANGUAGE plpgsql;