Files
medical-monitoring-system/migrations/backup_tar.sql
T

3610 lines
184 KiB
SQL
Raw Normal View History

2026-07-12 15:08:43 +04:00
toc.dat0000600 0004000 0002000 00000255700 15113325243 0014447 0ustar00postgrespostgres0000000 0000000 PGDMP0 }register_office16.416.4ç900ENCODINGENCODINGSET client_encoding = 'UTF8';
false:00
STDSTRINGS
STDSTRINGS(SET standard_conforming_strings = 'on';
false;00
SEARCHPATH
SEARCHPATH8SELECT pg_catalog.set_config('search_path', '', false);
false<1262177510register_officeDATABASEƒCREATE DATABASE register_office WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'Russian_Russia.1251';
DROP DATABASE register_office;
postgresfalse3079185870pgcrypto EXTENSION<CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
DROP EXTENSION pgcrypto;
false=00EXTENSION pgcryptoCOMMENT<COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
false2°1247177518examination_categories_enumTYPEqCREATE TYPE public.examination_categories_enum AS ENUM (
'physical',
'laboratory',
'instrumental'
);
.DROP TYPE public.examination_categories_enum;
publicpostgresfalse­1247177512 gender_enumTYPEECREATE TYPE public.gender_enum AS ENUM (
'male',
'female'
);
DROP TYPE public.gender_enum;
publicpostgresfalse³1247177526hospital_discharge_reason_enumTYPEmCREATE TYPE public.hospital_discharge_reason_enum AS ENUM (
'death',
'improvement',
'refusal'
);
1DROP TYPE public.hospital_discharge_reason_enum;
publicpostgresfalse1247177534unit_context_enumTYPEVCREATE TYPE public.unit_context_enum AS ENUM (
'examination',
'medication'
);
$DROP TYPE public.unit_context_enum;
publicpostgresfalse(1255180112check_active_hospitalization()FUNCTIONqCREATE FUNCTION public.check_active_hospitalization() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
open_hospitalization boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
get_hospitalization_periods (NEW.patient_id)
WHERE
discharge_datetime IS NULL) INTO open_hospitalization;
IF open_hospitalization THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = 'ГоÑÐ¿Ð¸Ñ‚Ð°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð´Ð°Ð½Ð½Ð¾Ð³Ð¾ пациента еще не завершена';
END IF;
RETURN NEW;
END;
$$;
5DROP FUNCTION public.check_active_hospitalization();
publicpostgresfalse)1255180116!check_discharge_after_admission()FUNCTIONCREATE FUNCTION public.check_discharge_after_admission() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
admission_time timestamp;
BEGIN
SELECT
admission_datetime INTO admission_time
FROM
hospital_admission
WHERE
hospital_admission_id = NEW.hospital_admission_id;
IF NEW.discharge_datetime <= admission_time THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10003: DISCHARGE_BEFORE_ADMISSION';
END IF;
RETURN NEW;
END;
$$;
8DROP FUNCTION public.check_discharge_after_admission();
publicpostgresfalse&1255185907Ccheck_enter_in_person_account(character varying, character varying)FUNCTIONªCREATE FUNCTION public.check_enter_in_person_account(_login character varying, _password character varying) RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
_hash_password varchar := null;
_person_id int;
BEGIN
-- Получаем person_id и проверÑем авторизацию
SELECT pa.person_id, pa.password
INTO _person_id, _hash_password
FROM person_account pa
WHERE pa.login = _login
AND pa.password = crypt(_password, pa.password);
-- ЕÑли запиÑÑŒ не найдена
IF _person_id IS NULL THEN
RAISE EXCEPTION еверный логин или пароль!';
END IF;
RETURN _person_id;
END;
$$;
kDROP FUNCTION public.check_enter_in_person_account(_login character varying, _password character varying);
publicpostgresfalse'1255180113check_hospitalization_overlap()FUNCTION¤CREATE FUNCTION public.check_hospitalization_overlap() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
overlap_found boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
get_hospitalization_periods (NEW.patient_id)
WHERE
discharge_datetime IS NOT NULL
AND NEW.admission_datetime < discharge_datetime
AND NEW.admission_datetime > admission_datetime) INTO overlap_found;
IF overlap_found THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10002: HOSPITALIZATION_OVERLAP';
END IF;
RETURN NEW;
END;
$$;
6DROP FUNCTION public.check_hospitalization_overlap();
publicpostgresfalse$1255180120!check_numeric_result_uniqueness()FUNCTION5CREATE FUNCTION public.check_numeric_result_uniqueness() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
qualitative_exists boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
qualitative_result
WHERE
result_id = NEW.result_id) INTO qualitative_exists;
IF qualitative_exists THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10005: QUALITATIVE_RESULT_ALREADY_EXISTS_FOR_THIS_EXAMINATION';
END IF;
RETURN NEW;
END;
$$;
8DROP FUNCTION public.check_numeric_result_uniqueness();
publicpostgresfalse*1255185866!check_password(character varying)FUNCTIONCREATE FUNCTION public.check_password(_password character varying) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
IF (trim(_password) = '')
THEN
RAISE EXCEPTION 'Пароль не может быть пуÑтым!';
END IF;
IF (trim(_password) <> _password)
THEN
RAISE EXCEPTION 'Пароль должен быть без пробелов!';
END IF;
IF (length(_password) < 8)
THEN
RAISE EXCEPTION 'Пароль должен иметь больше 8 знаков!';
END IF;
IF (lower(_password) = _password OR _password !~ '[0-9]')
THEN
RAISE EXCEPTION 'Пароль должен иметь пропиÑные и заглавные буквы, а также цифры!';
END IF;
IF ((SELECT COUNT(*) AS letter_count
FROM ( SELECT regexp_split_to_table(_password, '') AS letter) AS letters
GROUP BY letter
ORDER BY letter
LIMIT 1) >= length(_password)/2)
THEN
RAISE EXCEPTION 'Пароль не должен иметь больше половины одинаковых Ñимволов!';
END IF;
END
$$;
BDROP FUNCTION public.check_password(_password character varying);
publicpostgresfalse1255180122%check_qualitative_result_uniqueness()FUNCTION%CREATE FUNCTION public.check_qualitative_result_uniqueness() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
numeric_exists boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
numeric_result
WHERE
result_id = NEW.result_id) INTO numeric_exists;
IF numeric_exists THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10006: NUMERIC_RESULT_ALREADY_EXISTS_FOR_THIS_EXAMINATION';
END IF;
RETURN NEW;
END;
$$;
<DROP FUNCTION public.check_qualitative_result_uniqueness();
publicpostgresfalse%1255180118check_unique_discharge()FUNCTION(CREATE FUNCTION public.check_unique_discharge() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
discharge_count integer;
BEGIN
SELECT
COUNT(*) INTO discharge_count
FROM
hospital_discharge
WHERE
hospital_admission_id = NEW.hospital_admission_id
AND hospital_discharge_id <> COALESCE(NEW.hospital_discharge_id, -1);
IF discharge_count > 0 THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10004: DISCHARGE_ALREADY_EXISTS';
END IF;
RETURN NEW;
END;
$$;
/DROP FUNCTION public.check_unique_discharge();
publicpostgresfalse+1255185867create_person_account()FUNCTIONõCREATE FUNCTION public.create_person_account() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
role int;
BEGIN
PERFORM check_password(NEW.password);
NEW.password := crypt(NEW.password, gen_salt('bf'));
RETURN NEW;
END;
$$;
.DROP FUNCTION public.create_person_account();
publicpostgresfalse#1255177549default_str_check(text)FUNCTIONCREATE FUNCTION public.default_str_check(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str IS NULL
OR no_double_space (str)
AND no_space_start_end (str)
AND str_length_between (str, 1, 128);
END;
$$;
2DROP FUNCTION public.default_str_check(str text);
publicpostgresfalse"1255177548default_word_check(text)FUNCTIONÚCREATE FUNCTION public.default_word_check(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str IS NULL
OR no_space (str)
AND str_length_between (str, 1, 64);
END;
$$;
3DROP FUNCTION public.default_word_check(str text);
publicpostgresfalse1255180111$get_hospitalization_periods(integer)FUNCTIONèCREATE FUNCTION public.get_hospitalization_periods(p_patient_id integer) RETURNS TABLE(admission_datetime timestamp without time zone, discharge_datetime timestamp without time zone)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
ha.admission_datetime,
hd.discharge_datetime
FROM
hospital_admission ha
LEFT JOIN hospital_discharge hd ON ha.hospital_admission_id = hd.hospital_admission_id
WHERE
ha.patient_id = p_patient_id;
END;
$$;
HDROP FUNCTION public.get_hospitalization_periods(p_patient_id integer);
publicpostgresfalseG1255185911
get_results()FUNCTIONbCREATE FUNCTION public.get_results() RETURNS TABLE("Пациент" text, "ОбÑледование" text, "Результат" character varying)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY(SELECT pa.policy_number, et.name, COALESCE(qr.value::varchar, CONCAT(nr.value || ' ' || u.name))
FROM patient pa
LEFT JOIN prescription pr
ON pa.patient_id = pr.patient_id
LEFT JOIN examination_type_prescription etp
ON pr.prescription_id = etp.prescription_id
LEFT JOIN examination_type et
ON et.examination_type_id = etp.examination_type_id
LEFT JOIN result r
ON etp.result_id = r.result_id
LEFT JOIN qualitative_result qr
ON r.result_id = qr.result_id
LEFT JOIN numeric_result nr
ON r.result_id = nr.result_id
LEFT JOIN unit u
ON nr.unit_id = u.unit_id
WHERE et.name IS NOT NULL);
END;
$$;
$DROP FUNCTION public.get_results();
publicpostgresfalse1255177544no_double_space(text)FUNCTIONCREATE FUNCTION public.no_double_space(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str !~ E'\s{2,}';
END;
$$;
0DROP FUNCTION public.no_double_space(str text);
publicpostgresfalse 1255177546no_space(text)FUNCTIONCREATE FUNCTION public.no_space(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str !~ E'\s';
END;
$$;
)DROP FUNCTION public.no_space(str text);
publicpostgresfalse1255177545no_space_start_end(text)FUNCTION²CREATE FUNCTION public.no_space_start_end(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $_$
BEGIN
RETURN str !~ E'^\s'
AND str !~ E'\s$';
END;
$_$;
3DROP FUNCTION public.no_space_start_end(str text);
publicpostgresfalse1255180274random_int(integer, integer)FUNCTIONÇCREATE FUNCTION public.random_int(min_val integer, max_val integer) RETURNS integer
LANGUAGE plpgsql
AS $$
BEGIN
RETURN min_val + trunc(random() * (max_val - min_val + 1))::int;
END;
$$;
CDROP FUNCTION public.random_int(min_val integer, max_val integer);
publicpostgresfalse!1255177547*str_length_between(text, integer, integer)FUNCTIONÒCREATE FUNCTION public.str_length_between(str text, min_len integer, max_len integer) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN LENGTH(str) BETWEEN min_len AND max_len;
END;
$$;
UDROP FUNCTION public.str_length_between(str text, min_len integer, max_len integer);
publicpostgresfalseõ1259179932diseaseTABLE¿CREATE TABLE public.disease (
disease_id integer NOT NULL,
name text NOT NULL,
icd_code text NOT NULL,
CONSTRAINT disease_name_check CHECK (public.default_str_check(name))
);
DROP TABLE public.disease;
publicheappostgresfalse291ô1259179931disease_disease_id_seqSEQUENCEŽCREATE SEQUENCE public.disease_disease_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
-DROP SEQUENCE public.disease_disease_id_seq;
publicpostgresfalse245>00disease_disease_id_seqSEQUENCE OWNED BYQALTER SEQUENCE public.disease_disease_id_seq OWNED BY public.disease.disease_id;
publicpostgresfalse244÷1259179947disease_syndromeTABLECREATE TABLE public.disease_syndrome (
disease_syndrome_id integer NOT NULL,
disease_id integer NOT NULL,
syndrome_id integer NOT NULL
);
$DROP TABLE public.disease_syndrome;
publicheappostgresfalseö1259179946(disease_syndrome_disease_syndrome_id_seqSEQUENCE CREATE SEQUENCE public.disease_syndrome_disease_syndrome_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
?DROP SEQUENCE public.disease_syndrome_disease_syndrome_id_seq;
publicpostgresfalse247?00(disease_syndrome_disease_syndrome_id_seqSEQUENCE OWNED BYuALTER SEQUENCE public.disease_syndrome_disease_syndrome_id_seq OWNED BY public.disease_syndrome.disease_syndrome_id;
publicpostgresfalse246ß1259179728doctorTABLE?CREATE TABLE public.doctor (
doctor_id integer NOT NULL
);
DROP TABLE public.doctor;
publicheappostgresfalseù1259180014drug_intake_methodTABLEÅCREATE TABLE public.drug_intake_method (
drug_intake_method_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT drug_intake_method_name_check CHECK (public.default_word_check(name))
);
&DROP TABLE public.drug_intake_method;
publicheappostgresfalse290ø1259180013,drug_intake_method_drug_intake_method_id_seqSEQUENCE¤CREATE SEQUENCE public.drug_intake_method_drug_intake_method_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CDROP SEQUENCE public.drug_intake_method_drug_intake_method_id_seq;
publicpostgresfalse249@00,drug_intake_method_drug_intake_method_id_seqSEQUENCE OWNED BY}ALTER SEQUENCE public.drug_intake_method_drug_intake_method_id_seq OWNED BY public.drug_intake_method.drug_intake_method_id;
publicpostgresfalse248û1259180026 drug_typeTABLErCREATE TABLE public.drug_type (
drug_type_id integer NOT NULL,
international_name_ru text NOT NULL,
international_name_en text,
international_name_la text,
brand_name_ru text,
CONSTRAINT drug_type_brand_name_ru_check CHECK (public.default_word_check(brand_name_ru)),
CONSTRAINT drug_type_international_name_en_check CHECK (public.default_word_check(international_name_en)),
CONSTRAINT drug_type_international_name_la_check CHECK (public.default_word_check(international_name_la)),
CONSTRAINT drug_type_international_name_ru_check CHECK (public.default_word_check(international_name_ru))
);
DROP TABLE public.drug_type;
publicheappostgresfalse290290290290ú1259180025drug_type_drug_type_id_seqSEQUENCECREATE SEQUENCE public.drug_type_drug_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
1DROP SEQUENCE public.drug_type_drug_type_id_seq;
publicpostgresfalse251A00drug_type_drug_type_id_seqSEQUENCE OWNED BYYALTER SEQUENCE public.drug_type_drug_type_id_seq OWNED BY public.drug_type.drug_type_id;
publicpostgresfalse250ý1259180047drug_type_prescriptionTABLEÓCREATE TABLE public.drug_type_prescription (
drug_prescription_id integer NOT NULL,
prescription_id integer NOT NULL,
drug_type_id integer NOT NULL,
dose numeric NOT NULL,
dose_unit_id integer NOT NULL,
intake_method_id integer NOT NULL,
duration_days integer NOT NULL,
CONSTRAINT drug_type_prescription_dose_check CHECK ((dose > (0)::numeric)),
CONSTRAINT drug_type_prescription_duration_days_check CHECK ((duration_days > 0))
);
*DROP TABLE public.drug_type_prescription;
publicheappostgresfalseü1259180046/drug_type_prescription_drug_prescription_id_seqSEQUENCE§CREATE SEQUENCE public.drug_type_prescription_drug_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
FDROP SEQUENCE public.drug_type_prescription_drug_prescription_id_seq;
publicpostgresfalse253B00/drug_type_prescription_drug_prescription_id_seqSEQUENCE OWNED BYƒALTER SEQUENCE public.drug_type_prescription_drug_prescription_id_seq OWNED BY public.drug_type_prescription.drug_prescription_id;
publicpostgresfalse252æ1259179778examination_typeTABLEÛCREATE TABLE public.examination_type (
examination_type_id integer NOT NULL,
name text NOT NULL,
category text NOT NULL,
CONSTRAINT examination_type_name_check CHECK (public.default_word_check(name))
);
$DROP TABLE public.examination_type;
publicheappostgresfalse290å1259179777(examination_type_examination_type_id_seqSEQUENCE CREATE SEQUENCE public.examination_type_examination_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
?DROP SEQUENCE public.examination_type_examination_type_id_seq;
publicpostgresfalse230C00(examination_type_examination_type_id_seqSEQUENCE OWNED BYuALTER SEQUENCE public.examination_type_examination_type_id_seq OWNED BY public.examination_type.examination_type_id;
publicpostgresfalse229ê1259179804examination_type_prescriptionTABLEÏCREATE TABLE public.examination_type_prescription (
examination_prescription_id integer NOT NULL,
prescription_id integer NOT NULL,
result_id integer,
examination_type_id integer NOT NULL
);
1DROP TABLE public.examination_type_prescription;
publicheappostgresfalseé1259179803=examination_type_prescription_examination_prescription_id_seqSEQUENCEµCREATE SEQUENCE public.examination_type_prescription_examination_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
TDROP SEQUENCE public.examination_type_prescription_examination_prescription_id_seq;
publicpostgresfalse234D00=examination_type_prescription_examination_prescription_id_seqSEQUENCE OWNED BYŸALTER SEQUENCE public.examination_type_prescription_examination_prescription_id_seq OWNED BY public.examination_type_prescription.examination_prescription_id;
publicpostgresfalse2331259185812hospital_admissionTABLEPCREATE TABLE public.hospital_admission (
hospital_admission_id integer NOT NULL,
patient_id integer NOT NULL,
preliminary_disease_id integer NOT NULL,
admission_datetime timestamp without time zone NOT NULL,
CONSTRAINT hospital_admission_admission_datetime_check CHECK ((admission_datetime <= CURRENT_TIMESTAMP))
);
&DROP TABLE public.hospital_admission;
publicheappostgresfalse1259185811,hospital_admission_hospital_admission_id_seqSEQUENCE¤CREATE SEQUENCE public.hospital_admission_hospital_admission_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CDROP SEQUENCE public.hospital_admission_hospital_admission_id_seq;
publicpostgresfalse259E00,hospital_admission_hospital_admission_id_seqSEQUENCE OWNED BY}ALTER SEQUENCE public.hospital_admission_hospital_admission_id_seq OWNED BY public.hospital_admission.hospital_admission_id;
publicpostgresfalse2581259185830hospital_dischargeTABLEoCREATE TABLE public.hospital_discharge (
hospital_discharge_id integer NOT NULL,
hospital_admission_id integer NOT NULL,
discharge_datetime timestamp without time zone NOT NULL,
final_disease_id integer NOT NULL,
reason text NOT NULL,
CONSTRAINT hospital_discharge_discharge_datetime_check CHECK ((discharge_datetime <= CURRENT_TIMESTAMP))
);
&DROP TABLE public.hospital_discharge;
publicheappostgresfalse1259185829,hospital_discharge_hospital_discharge_id_seqSEQUENCE¤CREATE SEQUENCE public.hospital_discharge_hospital_discharge_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CDROP SEQUENCE public.hospital_discharge_hospital_discharge_id_seq;
publicpostgresfalse261F00,hospital_discharge_hospital_discharge_id_seqSEQUENCE OWNED BY}ALTER SEQUENCE public.hospital_discharge_hospital_discharge_id_seq OWNED BY public.hospital_discharge.hospital_discharge_id;
publicpostgresfalse260ë1259179827numeric_resultTABLECREATE TABLE public.numeric_result (
result_id integer NOT NULL,
value numeric NOT NULL,
unit_id integer NOT NULL
);
"DROP TABLE public.numeric_result;
publicheappostgresfalseÞ1259179715patientTABLE¼CREATE TABLE public.patient (
patient_id integer NOT NULL,
policy_number text NOT NULL,
CONSTRAINT patient_policy_number_check CHECK ((policy_number ~ '^[0-9]{16}$'::text))
);
DROP TABLE public.patient;
publicheappostgresfalseÝ1259179702personTABLECREATE TABLE public.person (
person_id integer NOT NULL,
middle_name text NOT NULL,
first_name text NOT NULL,
last_name text,
birth_date date NOT NULL,
gender text NOT NULL,
address text NOT NULL,
CONSTRAINT person_address_check CHECK (public.default_str_check(address)),
CONSTRAINT person_birth_date_check CHECK ((birth_date <= CURRENT_DATE)),
CONSTRAINT person_first_name_check CHECK (public.default_word_check(first_name)),
CONSTRAINT person_last_name_check CHECK (public.default_word_check(middle_name)),
CONSTRAINT person_middle_name_check CHECK (public.default_word_check(last_name))
);
DROP TABLE public.person;
publicheappostgresfalse2912902902901259185853person_accountTABLEâCREATE TABLE public.person_account (
person_id integer NOT NULL,
login character varying(60) NOT NULL,
password character varying NOT NULL,
CONSTRAINT empty_login CHECK ((TRIM(BOTH FROM login) <> ''::text))
);
"DROP TABLE public.person_account;
publicheappostgresfalseÜ1259179701person_person_id_seqSEQUENCEŒCREATE SEQUENCE public.person_person_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
+DROP SEQUENCE public.person_person_id_seq;
publicpostgresfalse221G00person_person_id_seqSEQUENCE OWNED BYMALTER SEQUENCE public.person_person_id_seq OWNED BY public.person.person_id;
publicpostgresfalse220ä1259179761 prescriptionTABLEŒCREATE TABLE public.prescription (
prescription_id integer NOT NULL,
patient_id integer NOT NULL,
doctor_id integer NOT NULL
);
DROP TABLE public.prescription;
publicheappostgresfalseã1259179760 prescription_prescription_id_seqSEQUENCE˜CREATE SEQUENCE public.prescription_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
7DROP SEQUENCE public.prescription_prescription_id_seq;
publicpostgresfalse228H00 prescription_prescription_id_seqSEQUENCE OWNED BYeALTER SEQUENCE public.prescription_prescription_id_seq OWNED BY public.prescription.prescription_id;
publicpostgresfalse227ÿ1259180080procedure_typeTABLE¹CREATE TABLE public.procedure_type (
procedure_type_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT procedure_type_name_check CHECK (public.default_word_check(name))
);
"DROP TABLE public.procedure_type;
publicheappostgresfalse2901259180092procedure_type_prescriptionTABLEïCREATE TABLE public.procedure_type_prescription (
procedure_prescription_id integer NOT NULL,
prescription_id integer NOT NULL,
procedure_type_id integer NOT NULL,
scheduled_datetime timestamp without time zone NOT NULL
);
/DROP TABLE public.procedure_type_prescription;
publicheappostgresfalse12591800919procedure_type_prescription_procedure_prescription_id_seqSEQUENCE±CREATE SEQUENCE public.procedure_type_prescription_procedure_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
PDROP SEQUENCE public.procedure_type_prescription_procedure_prescription_id_seq;
publicpostgresfalse257I009procedure_type_prescription_procedure_prescription_id_seqSEQUENCE OWNED BYALTER SEQUENCE public.procedure_type_prescription_procedure_prescription_id_seq OWNED BY public.procedure_type_prescription.procedure_prescription_id;
publicpostgresfalse256þ1259180079$procedure_type_procedure_type_id_seqSEQUENCEœCREATE SEQUENCE public.procedure_type_procedure_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
;DROP SEQUENCE public.procedure_type_procedure_type_id_seq;
publicpostgresfalse255J00$procedure_type_procedure_type_id_seqSEQUENCE OWNED BYmALTER SEQUENCE public.procedure_type_procedure_type_id_seq OWNED BY public.procedure_type.procedure_type_id;
publicpostgresfalse254ì1259179844qualitative_resultTABLEgCREATE TABLE public.qualitative_result (
result_id integer NOT NULL,
value boolean NOT NULL
);
&DROP TABLE public.qualitative_result;
publicheappostgresfalseï1259179869reference_numeric_valueTABLE¥CREATE TABLE public.reference_numeric_value (
reference_value_id integer NOT NULL,
min_value numeric,
max_value numeric,
unit_id integer NOT NULL
);
+DROP TABLE public.reference_numeric_value;
publicheappostgresfalseð1259179886reference_qualitative_valueTABLECREATE TABLE public.reference_qualitative_value (
reference_value_id integer NOT NULL,
description_true text NOT NULL,
description_false text NOT NULL,
CONSTRAINT reference_qualitative_value_description_false_check CHECK (public.default_word_check(description_false)),
CONSTRAINT reference_qualitative_value_description_true_check CHECK (public.default_word_check(description_true))
);
/DROP TABLE public.reference_qualitative_value;
publicheappostgresfalse290290î1259179855reference_valueTABLE$CREATE TABLE public.reference_value (
reference_value_id integer NOT NULL,
examination_type_id integer NOT NULL,
gender text,
age_min integer,
age_max integer,
CONSTRAINT reference_value_check CHECK (((age_min IS NULL) OR (age_max IS NULL) OR (age_min < age_max)))
);
#DROP TABLE public.reference_value;
publicheappostgresfalseí1259179854&reference_value_reference_value_id_seqSEQUENCEžCREATE SEQUENCE public.reference_value_reference_value_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
=DROP SEQUENCE public.reference_value_reference_value_id_seq;
publicpostgresfalse238K00&reference_value_reference_value_id_seqSEQUENCE OWNED BYqALTER SEQUENCE public.reference_value_reference_value_id_seq OWNED BY public.reference_value.reference_value_id;
publicpostgresfalse237à1259179738 registrarTABLEECREATE TABLE public.registrar (
registrar_id integer NOT NULL
);
DROP TABLE public.registrar;
publicheappostgresfalseè1259179790resultTABLEdCREATE TABLE public.result (
result_id integer NOT NULL,
examination_id integer NOT NULL
);
DROP TABLE public.result;
publicheappostgresfalseç1259179789result_result_id_seqSEQUENCEŒCREATE SEQUENCE public.result_result_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
+DROP SEQUENCE public.result_result_id_seq;
publicpostgresfalse232L00result_result_id_seqSEQUENCE OWNED BYMALTER SEQUENCE public.result_result_id_seq OWNED BY public.result.result_id;
publicpostgresfalse231ó1259179914syndrome_examination_typeTABLE~CREATE TABLE public.syndrome_examination_type (
syndrome_id integer NOT NULL,
examination_type_id integer NOT NULL
);
-DROP TABLE public.syndrome_examination_type;
publicheappostgresfalseò1259179903
syndrome_typeTABLECREATE TABLE public.syndrome_type (
syndrome_type_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT syndrome_type_name_check CHECK (public.default_word_check(name))
);
!DROP TABLE public.syndrome_type;
publicheappostgresfalse290ñ1259179902"syndrome_type_syndrome_type_id_seqSEQUENCEšCREATE SEQUENCE public.syndrome_type_syndrome_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
9DROP SEQUENCE public.syndrome_type_syndrome_type_id_seq;
publicpostgresfalse242M00"syndrome_type_syndrome_type_id_seqSEQUENCE OWNED BYiALTER SEQUENCE public.syndrome_type_syndrome_type_id_seq OWNED BY public.syndrome_type.syndrome_type_id;
publicpostgresfalse241â1259179749unitTABLEÐCREATE TABLE public.unit (
unit_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT unit_name_check CHECK (((name ~ '^[а-ÑÐ-ЯёÐ%^/]+$'::text) AND public.str_length_between(name, 1, 16)))
);
DROP TABLE public.unit;
publicheappostgresfalse289á1259179748unit_unit_id_seqSEQUENCEˆCREATE SEQUENCE public.unit_unit_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
'DROP SEQUENCE public.unit_unit_id_seq;
publicpostgresfalse226N00unit_unit_id_seqSEQUENCE OWNED BYEALTER SEQUENCE public.unit_unit_id_seq OWNED BY public.unit.unit_id;
publicpostgresfalse225Ý2604179935disease disease_idDEFAULTxALTER TABLE ONLY public.disease ALTER COLUMN disease_id SET DEFAULT nextval('public.disease_disease_id_seq'::regclass);
AALTER TABLE public.disease ALTER COLUMN disease_id DROP DEFAULT;
publicpostgresfalse245244245Þ2604179950$disease_syndrome disease_syndrome_idDEFAULTœALTER TABLE ONLY public.disease_syndrome ALTER COLUMN disease_syndrome_id SET DEFAULT nextval('public.disease_syndrome_disease_syndrome_id_seq'::regclass);
SALTER TABLE public.disease_syndrome ALTER COLUMN disease_syndrome_id DROP DEFAULT;
publicpostgresfalse246247247ß2604180017(drug_intake_method drug_intake_method_idDEFAULT¤ALTER TABLE ONLY public.drug_intake_method ALTER COLUMN drug_intake_method_id SET DEFAULT nextval('public.drug_intake_method_drug_intake_method_id_seq'::regclass);
WALTER TABLE public.drug_intake_method ALTER COLUMN drug_intake_method_id DROP DEFAULT;
publicpostgresfalse248249249à2604180029drug_type drug_type_idDEFAULTALTER TABLE ONLY public.drug_type ALTER COLUMN drug_type_id SET DEFAULT nextval('public.drug_type_drug_type_id_seq'::regclass);
EALTER TABLE public.drug_type ALTER COLUMN drug_type_id DROP DEFAULT;
publicpostgresfalse251250251á2604180050+drug_type_prescription drug_prescription_idDEFAULTªALTER TABLE ONLY public.drug_type_prescription ALTER COLUMN drug_prescription_id SET DEFAULT nextval('public.drug_type_prescription_drug_prescription_id_seq'::regclass);
ZALTER TABLE public.drug_type_prescription ALTER COLUMN drug_prescription_id DROP DEFAULT;
publicpostgresfalse253252253Ø2604179781$examination_type examination_type_idDEFAULTœALTER TABLE ONLY public.examination_type ALTER COLUMN examination_type_id SET DEFAULT nextval('public.examination_type_examination_type_id_seq'::regclass);
SALTER TABLE public.examination_type ALTER COLUMN examination_type_id DROP DEFAULT;
publicpostgresfalse230229230Ú26041798079examination_type_prescription examination_prescription_idDEFAULTÆALTER TABLE ONLY public.examination_type_prescription ALTER COLUMN examination_prescription_id SET DEFAULT nextval('public.examination_type_prescription_examination_prescription_id_seq'::regclass);
hALTER TABLE public.examination_type_prescription ALTER COLUMN examination_prescription_id DROP DEFAULT;
publicpostgresfalse233234234ä2604185815(hospital_admission hospital_admission_idDEFAULT¤ALTER TABLE ONLY public.hospital_admission ALTER COLUMN hospital_admission_id SET DEFAULT nextval('public.hospital_admission_hospital_admission_id_seq'::regclass);
WALTER TABLE public.hospital_admission ALTER COLUMN hospital_admission_id DROP DEFAULT;
publicpostgresfalse259258259å2604185833(hospital_discharge hospital_discharge_idDEFAULT¤ALTER TABLE ONLY public.hospital_discharge ALTER COLUMN hospital_discharge_id SET DEFAULT nextval('public.hospital_discharge_hospital_discharge_id_seq'::regclass);
WALTER TABLE public.hospital_discharge ALTER COLUMN hospital_discharge_id DROP DEFAULT;
publicpostgresfalse260261261Õ2604179705person person_idDEFAULTtALTER TABLE ONLY public.person ALTER COLUMN person_id SET DEFAULT nextval('public.person_person_id_seq'::regclass);
?ALTER TABLE public.person ALTER COLUMN person_id DROP DEFAULT;
publicpostgresfalse220221221×2604179764prescription prescription_idDEFAULTŒALTER TABLE ONLY public.prescription ALTER COLUMN prescription_id SET DEFAULT nextval('public.prescription_prescription_id_seq'::regclass);
KALTER TABLE public.prescription ALTER COLUMN prescription_id DROP DEFAULT;
publicpostgresfalse227228228â2604180083 procedure_type procedure_type_idDEFAULTALTER TABLE ONLY public.procedure_type ALTER COLUMN procedure_type_id SET DEFAULT nextval('public.procedure_type_procedure_type_id_seq'::regclass);
OALTER TABLE public.procedure_type ALTER COLUMN procedure_type_id DROP DEFAULT;
publicpostgresfalse254255255ã26041800955procedure_type_prescription procedure_prescription_idDEFAULT¾ALTER TABLE ONLY public.procedure_type_prescription ALTER COLUMN procedure_prescription_id SET DEFAULT nextval('public.procedure_type_prescription_procedure_prescription_id_seq'::regclass);
dALTER TABLE public.procedure_type_prescription ALTER COLUMN procedure_prescription_id DROP DEFAULT;
publicpostgresfalse256257257Û2604179858"reference_value reference_value_idDEFAULT˜ALTER TABLE ONLY public.reference_value ALTER COLUMN reference_value_id SET DEFAULT nextval('public.reference_value_reference_value_id_seq'::regclass);
QALTER TABLE public.reference_value ALTER COLUMN reference_value_id DROP DEFAULT;
publicpostgresfalse237238238Ù2604179793result result_idDEFAULTtALTER TABLE ONLY public.result ALTER COLUMN result_id SET DEFAULT nextval('public.result_result_id_seq'::regclass);
?ALTER TABLE public.result ALTER COLUMN result_id DROP DEFAULT;
publicpostgresfalse232231232Ü2604179906syndrome_type syndrome_type_idDEFAULTALTER TABLE ONLY public.syndrome_type ALTER COLUMN syndrome_type_id SET DEFAULT nextval('public.syndrome_type_syndrome_type_id_seq'::regclass);
MALTER TABLE public.syndrome_type ALTER COLUMN syndrome_type_id DROP DEFAULT;
publicpostgresfalse242241242Ö2604179752 unit unit_idDEFAULTlALTER TABLE ONLY public.unit ALTER COLUMN unit_id SET DEFAULT nextval('public.unit_unit_id_seq'::regclass);
;ALTER TABLE public.unit ALTER COLUMN unit_id DROP DEFAULT;
publicpostgresfalse225226226%0179932disease
TABLE DATA=COPY public.disease (disease_id, name, icd_code) FROM stdin;
publicpostgresfalse2455157.dat'0179947disease_syndrome
TABLE DATAXCOPY public.disease_syndrome (disease_syndrome_id, disease_id, syndrome_id) FROM stdin;
publicpostgresfalse2475159.dat0179728doctor
TABLE DATA+COPY public.doctor (doctor_id) FROM stdin;
publicpostgresfalse2235135.dat)0180014drug_intake_method
TABLE DATAICOPY public.drug_intake_method (drug_intake_method_id, name) FROM stdin;
publicpostgresfalse2495161.dat+0180026 drug_type
TABLE DATACOPY public.drug_type (drug_type_id, international_name_ru, international_name_en, international_name_la, brand_name_ru) FROM stdin;
publicpostgresfalse2515163.dat-0180047drug_type_prescription
TABLE DATAšCOPY public.drug_type_prescription (drug_prescription_id, prescription_id, drug_type_id, dose, dose_unit_id, intake_method_id, duration_days) FROM stdin;
publicpostgresfalse2535165.dat0179778examination_type
TABLE DATAOCOPY public.examination_type (examination_type_id, name, category) FROM stdin;
publicpostgresfalse2305142.dat0179804examination_type_prescription
TABLE DATACOPY public.examination_type_prescription (examination_prescription_id, prescription_id, result_id, examination_type_id) FROM stdin;
publicpostgresfalse2345146.dat30185812hospital_admission
TABLE DATA{COPY public.hospital_admission (hospital_admission_id, patient_id, preliminary_disease_id, admission_datetime) FROM stdin;
publicpostgresfalse2595171.dat50185830hospital_discharge
TABLE DATAˆCOPY public.hospital_discharge (hospital_discharge_id, hospital_admission_id, discharge_datetime, final_disease_id, reason) FROM stdin;
publicpostgresfalse2615173.dat0179827numeric_result
TABLE DATACCOPY public.numeric_result (result_id, value, unit_id) FROM stdin;
publicpostgresfalse2355147.dat0179715patient
TABLE DATA<COPY public.patient (patient_id, policy_number) FROM stdin;
publicpostgresfalse2225134.dat
0179702person
TABLE DATAlCOPY public.person (person_id, middle_name, first_name, last_name, birth_date, gender, address) FROM stdin;
publicpostgresfalse2215133.dat60185853person_account
TABLE DATADCOPY public.person_account (person_id, login, password) FROM stdin;
publicpostgresfalse2625174.dat0179761 prescription
TABLE DATANCOPY public.prescription (prescription_id, patient_id, doctor_id) FROM stdin;
publicpostgresfalse2285140.dat/0180080procedure_type
TABLE DATAACOPY public.procedure_type (procedure_type_id, name) FROM stdin;
publicpostgresfalse2555167.dat10180092procedure_type_prescription
TABLE DATAˆCOPY public.procedure_type_prescription (procedure_prescription_id, prescription_id, procedure_type_id, scheduled_datetime) FROM stdin;
publicpostgresfalse2575169.dat0179844qualitative_result
TABLE DATA>COPY public.qualitative_result (result_id, value) FROM stdin;
publicpostgresfalse2365148.dat0179869reference_numeric_value
TABLE DATAdCOPY public.reference_numeric_value (reference_value_id, min_value, max_value, unit_id) FROM stdin;
publicpostgresfalse2395151.dat 0179886reference_qualitative_value
TABLE DATAnCOPY public.reference_qualitative_value (reference_value_id, description_true, description_false) FROM stdin;
publicpostgresfalse2405152.dat0179855reference_value
TABLE DATAlCOPY public.reference_value (reference_value_id, examination_type_id, gender, age_min, age_max) FROM stdin;
publicpostgresfalse2385150.dat0179738 registrar
TABLE DATA1COPY public.registrar (registrar_id) FROM stdin;
publicpostgresfalse2245136.dat0179790result
TABLE DATA;COPY public.result (result_id, examination_id) FROM stdin;
publicpostgresfalse2325144.dat#0179914syndrome_examination_type
TABLE DATAUCOPY public.syndrome_examination_type (syndrome_id, examination_type_id) FROM stdin;
publicpostgresfalse2435155.dat"0179903
syndrome_type
TABLE DATA?COPY public.syndrome_type (syndrome_type_id, name) FROM stdin;
publicpostgresfalse2425154.dat0179749unit
TABLE DATA-COPY public.unit (unit_id, name) FROM stdin;
publicpostgresfalse2265138.datO00disease_disease_id_seq SEQUENCE SETESELECT pg_catalog.setval('public.disease_disease_id_seq', 36, true);
publicpostgresfalse244P00(disease_syndrome_disease_syndrome_id_seq SEQUENCE SETVSELECT pg_catalog.setval('public.disease_syndrome_disease_syndrome_id_seq', 2, true);
publicpostgresfalse246Q00,drug_intake_method_drug_intake_method_id_seq SEQUENCE SETZSELECT pg_catalog.setval('public.drug_intake_method_drug_intake_method_id_seq', 2, true);
publicpostgresfalse248R00drug_type_drug_type_id_seq SEQUENCE SETHSELECT pg_catalog.setval('public.drug_type_drug_type_id_seq', 3, true);
publicpostgresfalse250S00/drug_type_prescription_drug_prescription_id_seq SEQUENCE SET]SELECT pg_catalog.setval('public.drug_type_prescription_drug_prescription_id_seq', 1, true);
publicpostgresfalse252T00(examination_type_examination_type_id_seq SEQUENCE SETVSELECT pg_catalog.setval('public.examination_type_examination_type_id_seq', 3, true);
publicpostgresfalse229U00=examination_type_prescription_examination_prescription_id_seq SEQUENCE SETlSELECT pg_catalog.setval('public.examination_type_prescription_examination_prescription_id_seq', 12, true);
publicpostgresfalse233V00,hospital_admission_hospital_admission_id_seq SEQUENCE SET[SELECT pg_catalog.setval('public.hospital_admission_hospital_admission_id_seq', 31, true);
publicpostgresfalse258W00,hospital_discharge_hospital_discharge_id_seq SEQUENCE SETZSELECT pg_catalog.setval('public.hospital_discharge_hospital_discharge_id_seq', 1, true);
publicpostgresfalse260X00person_person_id_seq SEQUENCE SETBSELECT pg_catalog.setval('public.person_person_id_seq', 8, true);
publicpostgresfalse220Y00 prescription_prescription_id_seq SEQUENCE SETOSELECT pg_catalog.setval('public.prescription_prescription_id_seq', 24, true);
publicpostgresfalse227Z009procedure_type_prescription_procedure_prescription_id_seq SEQUENCE SETgSELECT pg_catalog.setval('public.procedure_type_prescription_procedure_prescription_id_seq', 7, true);
publicpostgresfalse256[00$procedure_type_procedure_type_id_seq SEQUENCE SETRSELECT pg_catalog.setval('public.procedure_type_procedure_type_id_seq', 3, true);
publicpostgresfalse254\00&reference_value_reference_value_id_seq SEQUENCE SETTSELECT pg_catalog.setval('public.reference_value_reference_value_id_seq', 5, true);
publicpostgresfalse237]00result_result_id_seq SEQUENCE SETCSELECT pg_catalog.setval('public.result_result_id_seq', 10, true);
publicpostgresfalse231^00"syndrome_type_syndrome_type_id_seq SEQUENCE SETPSELECT pg_catalog.setval('public.syndrome_type_syndrome_type_id_seq', 2, true);
publicpostgresfalse241_00unit_unit_id_seq SEQUENCE SET?SELECT pg_catalog.setval('public.unit_unit_id_seq', 10, true);
publicpostgresfalse225ò2606180455disease disease_icd_code_checkCHECK CONSTRAINTALTER TABLE public.disease
ADD CONSTRAINT disease_icd_code_check CHECK ((icd_code ~ '^[A-Z][0-9]{2}\.[0-9]$'::text)) NOT VALID;
CALTER TABLE public.disease DROP CONSTRAINT disease_icd_code_check;
publicpostgresfalse245245.2606179945disease disease_icd_code_key
CONSTRAINT[ALTER TABLE ONLY public.disease
ADD CONSTRAINT disease_icd_code_key UNIQUE (icd_code);
FALTER TABLE ONLY public.disease DROP CONSTRAINT disease_icd_code_key;
publicpostgresfalse24502606179943disease disease_name_key
CONSTRAINTSALTER TABLE ONLY public.disease
ADD CONSTRAINT disease_name_key UNIQUE (name);
BALTER TABLE ONLY public.disease DROP CONSTRAINT disease_name_key;
publicpostgresfalse24522606179941disease disease_pkey
CONSTRAINTZALTER TABLE ONLY public.disease
ADD CONSTRAINT disease_pkey PRIMARY KEY (disease_id);
>ALTER TABLE ONLY public.disease DROP CONSTRAINT disease_pkey;
publicpostgresfalse24542606179954<disease_syndrome disease_syndrome_disease_id_syndrome_id_key
CONSTRAINTŠALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_disease_id_syndrome_id_key UNIQUE (disease_id, syndrome_id);
fALTER TABLE ONLY public.disease_syndrome DROP CONSTRAINT disease_syndrome_disease_id_syndrome_id_key;
publicpostgresfalse24724762606179952&disease_syndrome disease_syndrome_pkey
CONSTRAINTuALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_pkey PRIMARY KEY (disease_syndrome_id);
PALTER TABLE ONLY public.disease_syndrome DROP CONSTRAINT disease_syndrome_pkey;
publicpostgresfalse2472606179732doctor doctor_pkey
CONSTRAINTWALTER TABLE ONLY public.doctor
ADD CONSTRAINT doctor_pkey PRIMARY KEY (doctor_id);
<ALTER TABLE ONLY public.doctor DROP CONSTRAINT doctor_pkey;
publicpostgresfalse22382606180024.drug_intake_method drug_intake_method_name_key
CONSTRAINTiALTER TABLE ONLY public.drug_intake_method
ADD CONSTRAINT drug_intake_method_name_key UNIQUE (name);
XALTER TABLE ONLY public.drug_intake_method DROP CONSTRAINT drug_intake_method_name_key;
publicpostgresfalse249:2606180022*drug_intake_method drug_intake_method_pkey
CONSTRAINT{ALTER TABLE ONLY public.drug_intake_method
ADD CONSTRAINT drug_intake_method_pkey PRIMARY KEY (drug_intake_method_id);
TALTER TABLE ONLY public.drug_intake_method DROP CONSTRAINT drug_intake_method_pkey;
publicpostgresfalse249<2606180045%drug_type drug_type_brand_name_ru_key
CONSTRAINTiALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_brand_name_ru_key UNIQUE (brand_name_ru);
OALTER TABLE ONLY public.drug_type DROP CONSTRAINT drug_type_brand_name_ru_key;
publicpostgresfalse251>2606180041-drug_type drug_type_international_name_en_key
CONSTRAINTyALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_international_name_en_key UNIQUE (international_name_en);
WALTER TABLE ONLY public.drug_type DROP CONSTRAINT drug_type_international_name_en_key;
publicpostgresfalse251@2606180043-drug_type drug_type_international_name_la_key
CONSTRAINTyALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_international_name_la_key UNIQUE (international_name_la);
WALTER TABLE ONLY public.drug_type DROP CONSTRAINT drug_type_international_name_la_key;
publicpostgresfalse251B2606180039-drug_type drug_type_international_name_ru_key
CONSTRAINTyALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_international_name_ru_key UNIQUE (international_name_ru);
WALTER TABLE ONLY public.drug_type DROP CONSTRAINT drug_type_international_name_ru_key;
publicpostgresfalse251D2606180037drug_type drug_type_pkey
CONSTRAINT`ALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_pkey PRIMARY KEY (drug_type_id);
BALTER TABLE ONLY public.drug_type DROP CONSTRAINT drug_type_pkey;
publicpostgresfalse251F26061800562drug_type_prescription drug_type_prescription_pkey
CONSTRAINTALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_pkey PRIMARY KEY (drug_prescription_id);
\ALTER TABLE ONLY public.drug_type_prescription DROP CONSTRAINT drug_type_prescription_pkey;
publicpostgresfalse253H2606180058Adrug_type_prescription drug_type_prescription_prescription_id_key
CONSTRAINTALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_prescription_id_key UNIQUE (prescription_id);
kALTER TABLE ONLY public.drug_type_prescription DROP CONSTRAINT drug_type_prescription_prescription_id_key;
publicpostgresfalse2532606179788*examination_type examination_type_name_key
CONSTRAINTeALTER TABLE ONLY public.examination_type
ADD CONSTRAINT examination_type_name_key UNIQUE (name);
TALTER TABLE ONLY public.examination_type DROP CONSTRAINT examination_type_name_key;
publicpostgresfalse2302606179786&examination_type examination_type_pkey
CONSTRAINTuALTER TABLE ONLY public.examination_type
ADD CONSTRAINT examination_type_pkey PRIMARY KEY (examination_type_id);
PALTER TABLE ONLY public.examination_type DROP CONSTRAINT examination_type_pkey;
publicpostgresfalse2302606179809@examination_type_prescription examination_type_prescription_pkey
CONSTRAINTALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_pkey PRIMARY KEY (examination_prescription_id);
jALTER TABLE ONLY public.examination_type_prescription DROP CONSTRAINT examination_type_prescription_pkey;
publicpostgresfalse2342606179811Oexamination_type_prescription examination_type_prescription_prescription_id_key
CONSTRAINTALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_prescription_id_key UNIQUE (prescription_id);
yALTER TABLE ONLY public.examination_type_prescription DROP CONSTRAINT examination_type_prescription_prescription_id_key;
publicpostgresfalse234R2606185818*hospital_admission hospital_admission_pkey
CONSTRAINT{ALTER TABLE ONLY public.hospital_admission
ADD CONSTRAINT hospital_admission_pkey PRIMARY KEY (hospital_admission_id);
TALTER TABLE ONLY public.hospital_admission DROP CONSTRAINT hospital_admission_pkey;
publicpostgresfalse259T2606185838*hospital_discharge hospital_discharge_pkey
CONSTRAINT{ALTER TABLE ONLY public.hospital_discharge
ADD CONSTRAINT hospital_discharge_pkey PRIMARY KEY (hospital_discharge_id);
TALTER TABLE ONLY public.hospital_discharge DROP CONSTRAINT hospital_discharge_pkey;
publicpostgresfalse2612606179833"numeric_result numeric_result_pkey
CONSTRAINTgALTER TABLE ONLY public.numeric_result
ADD CONSTRAINT numeric_result_pkey PRIMARY KEY (result_id);
LALTER TABLE ONLY public.numeric_result DROP CONSTRAINT numeric_result_pkey;
publicpostgresfalse2352606179722patient patient_pkey
CONSTRAINTZALTER TABLE ONLY public.patient
ADD CONSTRAINT patient_pkey PRIMARY KEY (patient_id);
>ALTER TABLE ONLY public.patient DROP CONSTRAINT patient_pkey;
publicpostgresfalse222V2606185860+person_account person_account_person_id_key
CONSTRAINTkALTER TABLE ONLY public.person_account
ADD CONSTRAINT person_account_person_id_key UNIQUE (person_id);
UALTER TABLE ONLY public.person_account DROP CONSTRAINT person_account_person_id_key;
publicpostgresfalse2622606179714person person_pkey
CONSTRAINTWALTER TABLE ONLY public.person
ADD CONSTRAINT person_pkey PRIMARY KEY (person_id);
<ALTER TABLE ONLY public.person DROP CONSTRAINT person_pkey;
publicpostgresfalse221 2606179766prescription prescription_pkey
CONSTRAINTiALTER TABLE ONLY public.prescription
ADD CONSTRAINT prescription_pkey PRIMARY KEY (prescription_id);
HALTER TABLE ONLY public.prescription DROP CONSTRAINT prescription_pkey;
publicpostgresfalse228J2606180090&procedure_type procedure_type_name_key
CONSTRAINTaALTER TABLE ONLY public.procedure_type
ADD CONSTRAINT procedure_type_name_key UNIQUE (name);
PALTER TABLE ONLY public.procedure_type DROP CONSTRAINT procedure_type_name_key;
publicpostgresfalse255L2606180088"procedure_type procedure_type_pkey
CONSTRAINToALTER TABLE ONLY public.procedure_type
ADD CONSTRAINT procedure_type_pkey PRIMARY KEY (procedure_type_id);
LALTER TABLE ONLY public.procedure_type DROP CONSTRAINT procedure_type_pkey;
publicpostgresfalse255N2606180097<procedure_type_prescription procedure_type_prescription_pkey
CONSTRAINTALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_pkey PRIMARY KEY (procedure_prescription_id);
fALTER TABLE ONLY public.procedure_type_prescription DROP CONSTRAINT procedure_type_prescription_pkey;
publicpostgresfalse257P2606180099Kprocedure_type_prescription procedure_type_prescription_prescription_id_key
CONSTRAINTALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_prescription_id_key UNIQUE (prescription_id);
uALTER TABLE ONLY public.procedure_type_prescription DROP CONSTRAINT procedure_type_prescription_prescription_id_key;
publicpostgresfalse2572606179848*qualitative_result qualitative_result_pkey
CONSTRAINToALTER TABLE ONLY public.qualitative_result
ADD CONSTRAINT qualitative_result_pkey PRIMARY KEY (result_id);
TALTER TABLE ONLY public.qualitative_result DROP CONSTRAINT qualitative_result_pkey;
publicpostgresfalse236 26061798754reference_numeric_value reference_numeric_value_pkey
CONSTRAINTALTER TABLE ONLY public.reference_numeric_value
ADD CONSTRAINT reference_numeric_value_pkey PRIMARY KEY (reference_value_id);
^ALTER TABLE ONLY public.reference_numeric_value DROP CONSTRAINT reference_numeric_value_pkey;
publicpostgresfalse239"2606179896[reference_qualitative_value reference_qualitative_value_description_true_description_fa_key
CONSTRAINTµALTER TABLE ONLY public.reference_qualitative_value
ADD CONSTRAINT reference_qualitative_value_description_true_description_fa_key UNIQUE (description_true, description_false);
ALTER TABLE ONLY public.reference_qualitative_value DROP CONSTRAINT reference_qualitative_value_description_true_description_fa_key;
publicpostgresfalse240240$2606179894<reference_qualitative_value reference_qualitative_value_pkey
CONSTRAINTŠALTER TABLE ONLY public.reference_qualitative_value
ADD CONSTRAINT reference_qualitative_value_pkey PRIMARY KEY (reference_value_id);
fALTER TABLE ONLY public.reference_qualitative_value DROP CONSTRAINT reference_qualitative_value_pkey;
publicpostgresfalse2402606185773Nreference_value reference_value_examination_type_id_gender_age_min_age_max_key
CONSTRAINT²ALTER TABLE ONLY public.reference_value
ADD CONSTRAINT reference_value_examination_type_id_gender_age_min_age_max_key UNIQUE (examination_type_id, gender, age_min, age_max);
xALTER TABLE ONLY public.reference_value DROP CONSTRAINT reference_value_examination_type_id_gender_age_min_age_max_key;
publicpostgresfalse2382382382382606179861$reference_value reference_value_pkey
CONSTRAINTrALTER TABLE ONLY public.reference_value
ADD CONSTRAINT reference_value_pkey PRIMARY KEY (reference_value_id);
NALTER TABLE ONLY public.reference_value DROP CONSTRAINT reference_value_pkey;
publicpostgresfalse2382606179742registrar registrar_pkey
CONSTRAINT`ALTER TABLE ONLY public.registrar
ADD CONSTRAINT registrar_pkey PRIMARY KEY (registrar_id);
BALTER TABLE ONLY public.registrar DROP CONSTRAINT registrar_pkey;
publicpostgresfalse2242606179795result result_pkey
CONSTRAINTWALTER TABLE ONLY public.result
ADD CONSTRAINT result_pkey PRIMARY KEY (result_id);
<ALTER TABLE ONLY public.result DROP CONSTRAINT result_pkey;
publicpostgresfalse232*2606179920Ksyndrome_examination_type syndrome_examination_type_examination_type_id_key
CONSTRAINTALTER TABLE ONLY public.syndrome_examination_type
ADD CONSTRAINT syndrome_examination_type_examination_type_id_key UNIQUE (examination_type_id);
uALTER TABLE ONLY public.syndrome_examination_type DROP CONSTRAINT syndrome_examination_type_examination_type_id_key;
publicpostgresfalse243,26061799188syndrome_examination_type syndrome_examination_type_pkey
CONSTRAINTALTER TABLE ONLY public.syndrome_examination_type
ADD CONSTRAINT syndrome_examination_type_pkey PRIMARY KEY (syndrome_id);
bALTER TABLE ONLY public.syndrome_examination_type DROP CONSTRAINT syndrome_examination_type_pkey;
publicpostgresfalse243&2606179913$syndrome_type syndrome_type_name_key
CONSTRAINT_ALTER TABLE ONLY public.syndrome_type
ADD CONSTRAINT syndrome_type_name_key UNIQUE (name);
NALTER TABLE ONLY public.syndrome_type DROP CONSTRAINT syndrome_type_name_key;
publicpostgresfalse242(2606179911 syndrome_type syndrome_type_pkey
CONSTRAINTlALTER TABLE ONLY public.syndrome_type
ADD CONSTRAINT syndrome_type_pkey PRIMARY KEY (syndrome_type_id);
JALTER TABLE ONLY public.syndrome_type DROP CONSTRAINT syndrome_type_pkey;
publicpostgresfalse2422606179759unit unit_name_key
CONSTRAINTMALTER TABLE ONLY public.unit
ADD CONSTRAINT unit_name_key UNIQUE (name);
<ALTER TABLE ONLY public.unit DROP CONSTRAINT unit_name_key;
publicpostgresfalse226
2606179757unit unit_pkey
CONSTRAINTQALTER TABLE ONLY public.unit
ADD CONSTRAINT unit_pkey PRIMARY KEY (unit_id);
8ALTER TABLE ONLY public.unit DROP CONSTRAINT unit_pkey;
publicpostgresfalse226x26201858493hospital_admission trg_check_active_hospitalizationTRIGGER CREATE TRIGGER trg_check_active_hospitalization BEFORE INSERT ON public.hospital_admission FOR EACH ROW EXECUTE FUNCTION public.check_active_hospitalization();
LDROP TRIGGER trg_check_active_hospitalization ON public.hospital_admission;
publicpostgresfalse259296z26201858516hospital_discharge trg_check_discharge_after_admissionTRIGGER°CREATE TRIGGER trg_check_discharge_after_admission BEFORE INSERT OR UPDATE ON public.hospital_discharge FOR EACH ROW EXECUTE FUNCTION public.check_discharge_after_admission();
ODROP TRIGGER trg_check_discharge_after_admission ON public.hospital_discharge;
publicpostgresfalse261297y26201858504hospital_admission trg_check_hospitalization_overlapTRIGGER¢CREATE TRIGGER trg_check_hospitalization_overlap BEFORE INSERT ON public.hospital_admission FOR EACH ROW EXECUTE FUNCTION public.check_hospitalization_overlap();
MDROP TRIGGER trg_check_hospitalization_overlap ON public.hospital_admission;
publicpostgresfalse295259v26201801212numeric_result trg_check_numeric_result_uniquenessTRIGGER¬CREATE TRIGGER trg_check_numeric_result_uniqueness BEFORE INSERT OR UPDATE ON public.numeric_result FOR EACH ROW EXECUTE FUNCTION public.check_numeric_result_uniqueness();
KDROP TRIGGER trg_check_numeric_result_uniqueness ON public.numeric_result;
publicpostgresfalse292235w2620180123:qualitative_result trg_check_qualitative_result_uniquenessTRIGGER¸CREATE TRIGGER trg_check_qualitative_result_uniqueness BEFORE INSERT OR UPDATE ON public.qualitative_result FOR EACH ROW EXECUTE FUNCTION public.check_qualitative_result_uniqueness();
SDROP TRIGGER trg_check_qualitative_result_uniqueness ON public.qualitative_result;
publicpostgresfalse236278{2620185852-hospital_discharge trg_check_unique_dischargeTRIGGERžCREATE TRIGGER trg_check_unique_discharge BEFORE INSERT OR UPDATE ON public.hospital_discharge FOR EACH ROW EXECUTE FUNCTION public.check_unique_discharge();
FDROP TRIGGER trg_check_unique_discharge ON public.hospital_discharge;
publicpostgresfalse261293|2620185868%person_account trigger_create_accountTRIGGERCREATE TRIGGER trigger_create_account BEFORE INSERT ON public.person_account FOR EACH ROW EXECUTE FUNCTION public.create_person_account();
>DROP TRIGGER trigger_create_account ON public.person_account;
publicpostgresfalse262299i26061799551disease_syndrome disease_syndrome_disease_id_fkey
FK CONSTRAINT¯ALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_disease_id_fkey FOREIGN KEY (disease_id) REFERENCES public.disease(disease_id) ON DELETE CASCADE;
[ALTER TABLE ONLY public.disease_syndrome DROP CONSTRAINT disease_syndrome_disease_id_fkey;
publicpostgresfalse2472454914j26061799602disease_syndrome disease_syndrome_syndrome_id_fkey
FK CONSTRAINT½ALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_syndrome_id_fkey FOREIGN KEY (syndrome_id) REFERENCES public.syndrome_type(syndrome_type_id) ON DELETE CASCADE;
\ALTER TABLE ONLY public.disease_syndrome DROP CONSTRAINT disease_syndrome_syndrome_id_fkey;
publicpostgresfalse2424904247X2606179733doctor doctor_doctor_id_fkey
FK CONSTRAINTALTER TABLE ONLY public.doctor
ADD CONSTRAINT doctor_doctor_id_fkey FOREIGN KEY (doctor_id) REFERENCES public.person(person_id);
FALTER TABLE ONLY public.doctor DROP CONSTRAINT doctor_doctor_id_fkey;
publicpostgresfalse2212234864k2606180069?drug_type_prescription drug_type_prescription_dose_unit_id_fkey
FK CONSTRAINTºALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_dose_unit_id_fkey FOREIGN KEY (dose_unit_id) REFERENCES public.unit(unit_id) ON DELETE RESTRICT;
iALTER TABLE ONLY public.drug_type_prescription DROP CONSTRAINT drug_type_prescription_dose_unit_id_fkey;
publicpostgresfalse2532264874l2606180064?drug_type_prescription drug_type_prescription_drug_type_id_fkey
FK CONSTRAINTÄALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_drug_type_id_fkey FOREIGN KEY (drug_type_id) REFERENCES public.drug_type(drug_type_id) ON DELETE RESTRICT;
iALTER TABLE ONLY public.drug_type_prescription DROP CONSTRAINT drug_type_prescription_drug_type_id_fkey;
publicpostgresfalse2514932253m2606180074Cdrug_type_prescription drug_type_prescription_intake_method_id_fkey
FK CONSTRAINTÞALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_intake_method_id_fkey FOREIGN KEY (intake_method_id) REFERENCES public.drug_intake_method(drug_intake_method_id) ON DELETE RESTRICT;
mALTER TABLE ONLY public.drug_type_prescription DROP CONSTRAINT drug_type_prescription_intake_method_id_fkey;
publicpostgresfalse4922249253n2606180059Bdrug_type_prescription drug_type_prescription_prescription_id_fkey
FK CONSTRAINTÏALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_prescription_id_fkey FOREIGN KEY (prescription_id) REFERENCES public.prescription(prescription_id) ON DELETE CASCADE;
lALTER TABLE ONLY public.drug_type_prescription DROP CONSTRAINT drug_type_prescription_prescription_id_fkey;
publicpostgresfalse2532284876]2606179822Texamination_type_prescription examination_type_prescription_examination_type_id_fkey
FK CONSTRAINTíALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_examination_type_id_fkey FOREIGN KEY (examination_type_id) REFERENCES public.examination_type(examination_type_id) ON DELETE CASCADE;
~ALTER TABLE ONLY public.examination_type_prescription DROP CONSTRAINT examination_type_prescription_examination_type_id_fkey;
publicpostgresfalse2302344880^2606179812Pexamination_type_prescription examination_type_prescription_prescription_id_fkey
FK CONSTRAINTÝALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_prescription_id_fkey FOREIGN KEY (prescription_id) REFERENCES public.prescription(prescription_id) ON DELETE CASCADE;
zALTER TABLE ONLY public.examination_type_prescription DROP CONSTRAINT examination_type_prescription_prescription_id_fkey;
publicpostgresfalse2282344876_2606179817Jexamination_type_prescription examination_type_prescription_result_id_fkey
FK CONSTRAINTÅALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_result_id_fkey FOREIGN KEY (result_id) REFERENCES public.result(result_id) ON DELETE CASCADE;
tALTER TABLE ONLY public.examination_type_prescription DROP CONSTRAINT examination_type_prescription_result_id_fkey;
publicpostgresfalse2322344882q26061858195hospital_admission hospital_admission_patient_id_fkey
FK CONSTRAINT³ALTER TABLE ONLY public.hospital_admission
ADD CONSTRAINT hospital_admission_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patient(patient_id) ON DELETE CASCADE;
_ALTER TABLE ONLY public.hospital_admission DROP CONSTRAINT hospital_admission_patient_id_fkey;
publicpostgresfalse2224866259r2606185824Ahospital_admission hospital_admission_preliminary_disease_id_fkey
FK CONSTRAINT¹ALTER TABLE ONLY public.hospital_admission
ADD CONSTRAINT hospital_admission_preliminary_disease_id_fkey FOREIGN KEY (preliminary_disease_id) REFERENCES public.disease(disease_id);
kALTER TABLE ONLY public.hospital_admission DROP CONSTRAINT hospital_admission_preliminary_disease_id_fkey;
publicpostgresfalse4914245259s2606185844;hospital_discharge hospital_discharge_final_disease_id_fkey
FK CONSTRAINT­ALTER TABLE ONLY public.hospital_discharge
ADD CONSTRAINT hospital_discharge_final_disease_id_fkey FOREIGN KEY (final_disease_id) REFERENCES public.disease(disease_id);
eALTER TABLE ONLY public.hospital_discharge DROP CONSTRAINT hospital_discharge_final_disease_id_fkey;
publicpostgresfalse2614914245t2606185839@hospital_discharge hospital_discharge_hospital_admission_id_fkey
FK CONSTRAINTßALTER TABLE ONLY public.hospital_discharge
ADD CONSTRAINT hospital_discharge_hospital_admission_id_fkey FOREIGN KEY (hospital_admission_id) REFERENCES public.hospital_admission(hospital_admission_id) ON DELETE CASCADE;
jALTER TABLE ONLY public.hospital_discharge DROP CONSTRAINT hospital_discharge_hospital_admission_id_fkey;
publicpostgresfalse2614946259`2606180445,numeric_result numeric_result_result_id_fkey
FK CONSTRAINTŸALTER TABLE ONLY public.numeric_result
ADD CONSTRAINT numeric_result_result_id_fkey FOREIGN KEY (result_id) REFERENCES public.result(result_id) NOT VALID;
VALTER TABLE ONLY public.numeric_result DROP CONSTRAINT numeric_result_result_id_fkey;
publicpostgresfalse2324882235a2606179839*numeric_result numeric_result_unit_id_fkey
FK CONSTRAINT ALTER TABLE ONLY public.numeric_result
ADD CONSTRAINT numeric_result_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.unit(unit_id) ON DELETE RESTRICT;
TALTER TABLE ONLY public.numeric_result DROP CONSTRAINT numeric_result_unit_id_fkey;
publicpostgresfalse4874226235W2606179723patient patient_patient_id_fkey
FK CONSTRAINTALTER TABLE ONLY public.patient
ADD CONSTRAINT patient_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.person(person_id);
IALTER TABLE ONLY public.patient DROP CONSTRAINT patient_patient_id_fkey;
publicpostgresfalse2222214864u2606185861,person_account person_account_person_id_fkey
FK CONSTRAINTALTER TABLE ONLY public.person_account
ADD CONSTRAINT person_account_person_id_fkey FOREIGN KEY (person_id) REFERENCES public.person(person_id);
VALTER TABLE ONLY public.person_account DROP CONSTRAINT person_account_person_id_fkey;
publicpostgresfalse2622214864Z2606179772(prescription prescription_doctor_id_fkey
FK CONSTRAINT¤ALTER TABLE ONLY public.prescription
ADD CONSTRAINT prescription_doctor_id_fkey FOREIGN KEY (doctor_id) REFERENCES public.doctor(doctor_id) ON DELETE RESTRICT;
RALTER TABLE ONLY public.prescription DROP CONSTRAINT prescription_doctor_id_fkey;
publicpostgresfalse4868228223[2606179767)prescription prescription_patient_id_fkey
FK CONSTRAINT§ALTER TABLE ONLY public.prescription
ADD CONSTRAINT prescription_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patient(patient_id) ON DELETE CASCADE;
SALTER TABLE ONLY public.prescription DROP CONSTRAINT prescription_patient_id_fkey;
publicpostgresfalse2284866222o2606180100Lprocedure_type_prescription procedure_type_prescription_prescription_id_fkey
FK CONSTRAINTÙALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_prescription_id_fkey FOREIGN KEY (prescription_id) REFERENCES public.prescription(prescription_id) ON DELETE CASCADE;
vALTER TABLE ONLY public.procedure_type_prescription DROP CONSTRAINT procedure_type_prescription_prescription_id_fkey;
publicpostgresfalse2572284876p2606180105Nprocedure_type_prescription procedure_type_prescription_procedure_type_id_fkey
FK CONSTRAINTâALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_procedure_type_id_fkey FOREIGN KEY (procedure_type_id) REFERENCES public.procedure_type(procedure_type_id) ON DELETE RESTRICT;
xALTER TABLE ONLY public.procedure_type_prescription DROP CONSTRAINT procedure_type_prescription_procedure_type_id_fkey;
publicpostgresfalse2574940255b26061804504qualitative_result qualitative_result_result_id_fkey
FK CONSTRAINT§ALTER TABLE ONLY public.qualitative_result
ADD CONSTRAINT qualitative_result_result_id_fkey FOREIGN KEY (result_id) REFERENCES public.result(result_id) NOT VALID;
^ALTER TABLE ONLY public.qualitative_result DROP CONSTRAINT qualitative_result_result_id_fkey;
publicpostgresfalse4882232236d2606179876Greference_numeric_value reference_numeric_value_reference_value_id_fkey
FK CONSTRAINTÝALTER TABLE ONLY public.reference_numeric_value
ADD CONSTRAINT reference_numeric_value_reference_value_id_fkey FOREIGN KEY (reference_value_id) REFERENCES public.reference_value(reference_value_id) ON DELETE CASCADE;
qALTER TABLE ONLY public.reference_numeric_value DROP CONSTRAINT reference_numeric_value_reference_value_id_fkey;
publicpostgresfalse2382394894e2606179881<reference_numeric_value reference_numeric_value_unit_id_fkey
FK CONSTRAINT²ALTER TABLE ONLY public.reference_numeric_value
ADD CONSTRAINT reference_numeric_value_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.unit(unit_id) ON DELETE RESTRICT;
fALTER TABLE ONLY public.reference_numeric_value DROP CONSTRAINT reference_numeric_value_unit_id_fkey;
publicpostgresfalse2394874226f2606179897Oreference_qualitative_value reference_qualitative_value_reference_value_id_fkey
FK CONSTRAINTåALTER TABLE ONLY public.reference_qualitative_value
ADD CONSTRAINT reference_qualitative_value_reference_value_id_fkey FOREIGN KEY (reference_value_id) REFERENCES public.reference_value(reference_value_id) ON DELETE CASCADE;
yALTER TABLE ONLY public.reference_qualitative_value DROP CONSTRAINT reference_qualitative_value_reference_value_id_fkey;
publicpostgresfalse4894238240c26061798648reference_value reference_value_examination_type_id_fkey
FK CONSTRAINTÑALTER TABLE ONLY public.reference_value
ADD CONSTRAINT reference_value_examination_type_id_fkey FOREIGN KEY (examination_type_id) REFERENCES public.examination_type(examination_type_id) ON DELETE CASCADE;
bALTER TABLE ONLY public.reference_value DROP CONSTRAINT reference_value_examination_type_id_fkey;
publicpostgresfalse4880230238Y2606179743%registrar registrar_registrar_id_fkey
FK CONSTRAINTALTER TABLE ONLY public.registrar
ADD CONSTRAINT registrar_registrar_id_fkey FOREIGN KEY (registrar_id) REFERENCES public.person(person_id);
OALTER TABLE ONLY public.registrar DROP CONSTRAINT registrar_registrar_id_fkey;
publicpostgresfalse2244864221\2606179798!result result_examination_id_fkey
FK CONSTRAINTµALTER TABLE ONLY public.result
ADD CONSTRAINT result_examination_id_fkey FOREIGN KEY (examination_id) REFERENCES public.examination_type(examination_type_id) ON DELETE CASCADE;
KALTER TABLE ONLY public.result DROP CONSTRAINT result_examination_id_fkey;
publicpostgresfalse2302324880g2606179926Lsyndrome_examination_type syndrome_examination_type_examination_type_id_fkey
FK CONSTRAINTåALTER TABLE ONLY public.syndrome_examination_type
ADD CONSTRAINT syndrome_examination_type_examination_type_id_fkey FOREIGN KEY (examination_type_id) REFERENCES public.examination_type(examination_type_id) ON DELETE CASCADE;
vALTER TABLE ONLY public.syndrome_examination_type DROP CONSTRAINT syndrome_examination_type_examination_type_id_fkey;
publicpostgresfalse2432304880h2606179921Dsyndrome_examination_type syndrome_examination_type_syndrome_id_fkey
FK CONSTRAINTÏALTER TABLE ONLY public.syndrome_examination_type
ADD CONSTRAINT syndrome_examination_type_syndrome_id_fkey FOREIGN KEY (syndrome_id) REFERENCES public.syndrome_type(syndrome_type_id) ON DELETE CASCADE;
nALTER TABLE ONLY public.syndrome_examination_type DROP CONSTRAINT syndrome_examination_type_syndrome_id_fkey;
publicpostgresfalse24324249045157.dat0000600 0004000 0002000 00000000217 15113325243 0014252 0ustar00postgrespostgres0000000 0000000 34 Ð“ÑƒÐ±Ñ‡Ð°Ñ‚Ð°Ñ ÑÐ½Ñ†ÐµÑ„Ð°Ð»Ð¾Ð¿Ð°Ñ‚Ð¸Ñ A12.3
35 КраÑÐ½Ð°Ñ Ð²Ð¾Ð»Ñ‡Ð°Ð½ÐºÐ° A12.5
29 Проказа A12.4
36 Грипп A12.2
\.
5159.dat0000600 0004000 0002000 00000000014 15113325243 0014247 0ustar00postgrespostgres0000000 0000000 1 29 1
\.
5135.dat0000600 0004000 0002000 00000000013 15113325243 0014240 0ustar00postgrespostgres0000000 0000000 1
2
3
\.
5161.dat0000600 0004000 0002000 00000000042 15113325243 0014241 0ustar00postgrespostgres0000000 0000000 2 Внутримышечно
\.
5163.dat0000600 0004000 0002000 00000000114 15113325243 0014243 0ustar00postgrespostgres0000000 0000000 3 Корвалол \N \N \N
2 Парацетамол Paracetamol \N \N
\.
5165.dat0000600 0004000 0002000 00000000005 15113325243 0014244 0ustar00postgrespostgres0000000 0000000 \.
5142.dat0000600 0004000 0002000 00000000117 15113325243 0014243 0ustar00postgrespostgres0000000 0000000 2 ЭКГ Физикальное
3 ЭЭГ ИнÑтрументальное
\.
5146.dat0000600 0004000 0002000 00000000042 15113325243 0014244 0ustar00postgrespostgres0000000 0000000 7 2 5 3
11 23 9 3
12 24 10 2
\.
5171.dat0000600 0004000 0002000 00000000110 15113325243 0014236 0ustar00postgrespostgres0000000 0000000 21 8 29 2025-11-30 20:31:06.045
30 7 35 2025-11-30 20:45:06.045254
\.
5173.dat0000600 0004000 0002000 00000000104 15113325243 0014243 0ustar00postgrespostgres0000000 0000000 1 21 2025-12-01 15:59:02.624121 36 Ð›Ð¾Ð¶Ð½Ð°Ñ Ñ‚Ñ€ÐµÐ²Ð¾Ð³Ð°
\.
5147.dat0000600 0004000 0002000 00000000053 15113325243 0014247 0ustar00postgrespostgres0000000 0000000 7 1.00 7
8 1.00 7
9 12.00 3
10 1.00 3
\.
5134.dat0000600 0004000 0002000 00000000053 15113325243 0014243 0ustar00postgrespostgres0000000 0000000 7 3456789787654322
8 1232567687654231
\.
5133.dat0000600 0004000 0002000 00000001663 15113325243 0014252 0ustar00postgrespostgres0000000 0000000 1 Иванов Ðиколай Владимирович 1954-10-26 male ул. ЧайковÑкого, дом 32, квартира 46
2 Сидоров Владимир Ðнатольевич 1956-12-30 male пр. Мира, дом 37, квартира 47
3 Кузнецов Пётр Сергеевич 1978-04-12 male ул. Кирова, дом 29, квартира 55
4 Петров Иван Владимирович 2005-09-15 male ул. ЧайковÑкого, дом 16, квартира 108
5 Иванов Ðиколай Ðндреевич 1973-11-16 male ул. МолодёжнаÑ, дом 28, квартира 41
6 Иванов Егор Сергеевич 1987-05-21 male ул. Гагарина, дом 3, квартира 92
8 апраоплр апарÑпмориолтьмтич выавпаÑрмо 2001-11-28 Мужчина вавпраоплдожропав
7 впа апр авыпро 2005-11-28 Женщина впарплоро
\.
5174.dat0000600 0004000 0002000 00000000775 15113325243 0014262 0ustar00postgrespostgres0000000 0000000 1 Иванов Ð.Ð’. $2a$06$nodiIbOsbvGGiNskCgoZve5M5ZNvf6vAUKVy9GKg2.zgt1H9ZBOoa
2 Сидоров Ð’.Ð. $2a$06$46RFLNbgnecMJjhCzEWQD.90I42GPoKiQMunNKJ.sVx1jjhXcMrai
3 Кузнецов П.С. $2a$06$wN513CJW7sR/40ts3J07wuNYYm/RwAUWwiUX5jXCOL.EE1BGL0/7.
4 Петров И.В. $2a$06$zmh10qXthU9anqEX/ErdKekAeQdd2p54hozsc.VtYJIHLpRSJEmfq
5 Иванов Ð.Ð. $2a$06$89cvKSGddsBwzXzbAWNbveEaoevnF7VIQxp1VSrvoTBuEXMZcFt6q
6 Иванов Е.С. $2a$06$JT.cB1.QUOgzZbnirrFSxO.WRNw0LvD6JvIXpHapKi5FDkO9yRily
\.
5140.dat0000600 0004000 0002000 00000000031 15113325243 0014234 0ustar00postgrespostgres0000000 0000000 2 8 1
23 7 1
24 7 2
\.
5167.dat0000600 0004000 0002000 00000000040 15113325243 0014245 0ustar00postgrespostgres0000000 0000000 3 ФизиотерапиÑ
\.
5169.dat0000600 0004000 0002000 00000000046 15113325243 0014255 0ustar00postgrespostgres0000000 0000000 3 2 3 2025-11-29 11:11:25.048055
\.
5148.dat0000600 0004000 0002000 00000000011 15113325243 0014242 0ustar00postgrespostgres0000000 0000000 5 t
\.
5151.dat0000600 0004000 0002000 00000000016 15113325243 0014241 0ustar00postgrespostgres0000000 0000000 4 \N 1 7
\.
5152.dat0000600 0004000 0002000 00000000065 15113325243 0014246 0ustar00postgrespostgres0000000 0000000 4 ОтÑутÑтвует ОтÑутÑтвует
\.
5150.dat0000600 0004000 0002000 00000000067 15113325243 0014246 0ustar00postgrespostgres0000000 0000000 4 2 Мужчина \N 18
5 3 Женщина \N 18
\.
5136.dat0000600 0004000 0002000 00000000013 15113325243 0014241 0ustar00postgrespostgres0000000 0000000 4
5
6
\.
5144.dat0000600 0004000 0002000 00000000032 15113325243 0014241 0ustar00postgrespostgres0000000 0000000 5 3
7 3
8 2
9 3
10 2
\.
5155.dat0000600 0004000 0002000 00000000011 15113325243 0014240 0ustar00postgrespostgres0000000 0000000 2 3
\.
5154.dat0000600 0004000 0002000 00000000063 15113325243 0014246 0ustar00postgrespostgres0000000 0000000 1 Лихорадка
2 Боль в груди
\.
5138.dat0000600 0004000 0002000 00000000146 15113325243 0014252 0ustar00postgrespostgres0000000 0000000 2 мг/л
3 г/л
4 ммоль/л
5 мкмоль/л
6 ед/л
7 %
8 тыÑ/мкл
9 мл
10 мм
\.
restore.sql0000600 0004000 0002000 00000211311 15113325243 0015362 0ustar00postgrespostgres0000000 0000000 --
-- NOTE:
--
-- File paths need to be edited. Search for $$PATH$$ and
-- replace it with the path to the directory containing
-- the extracted data files.
--
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.4
-- Dumped by pg_dump version 16.4
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
DROP DATABASE register_office;
--
-- Name: register_office; Type: DATABASE; Schema: -; Owner: postgres
--
CREATE DATABASE register_office WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'Russian_Russia.1251';
ALTER DATABASE register_office OWNER TO postgres;
\connect register_office
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
--
-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
--
-- Name: examination_categories_enum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.examination_categories_enum AS ENUM (
'physical',
'laboratory',
'instrumental'
);
ALTER TYPE public.examination_categories_enum OWNER TO postgres;
--
-- Name: gender_enum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.gender_enum AS ENUM (
'male',
'female'
);
ALTER TYPE public.gender_enum OWNER TO postgres;
--
-- Name: hospital_discharge_reason_enum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.hospital_discharge_reason_enum AS ENUM (
'death',
'improvement',
'refusal'
);
ALTER TYPE public.hospital_discharge_reason_enum OWNER TO postgres;
--
-- Name: unit_context_enum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.unit_context_enum AS ENUM (
'examination',
'medication'
);
ALTER TYPE public.unit_context_enum OWNER TO postgres;
--
-- Name: check_active_hospitalization(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_active_hospitalization() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
open_hospitalization boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
get_hospitalization_periods (NEW.patient_id)
WHERE
discharge_datetime IS NULL) INTO open_hospitalization;
IF open_hospitalization THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = 'ГоÑÐ¿Ð¸Ñ‚Ð°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð´Ð°Ð½Ð½Ð¾Ð³Ð¾ пациента еще не завершена';
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.check_active_hospitalization() OWNER TO postgres;
--
-- Name: check_discharge_after_admission(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_discharge_after_admission() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
admission_time timestamp;
BEGIN
SELECT
admission_datetime INTO admission_time
FROM
hospital_admission
WHERE
hospital_admission_id = NEW.hospital_admission_id;
IF NEW.discharge_datetime <= admission_time THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10003: DISCHARGE_BEFORE_ADMISSION';
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.check_discharge_after_admission() OWNER TO postgres;
--
-- Name: check_enter_in_person_account(character varying, character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_enter_in_person_account(_login character varying, _password character varying) RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
_hash_password varchar := null;
_person_id int;
BEGIN
-- Получаем person_id и проверÑем авторизацию
SELECT pa.person_id, pa.password
INTO _person_id, _hash_password
FROM person_account pa
WHERE pa.login = _login
AND pa.password = crypt(_password, pa.password);
-- ЕÑли запиÑÑŒ не найдена
IF _person_id IS NULL THEN
RAISE EXCEPTION еверный логин или пароль!';
END IF;
RETURN _person_id;
END;
$$;
ALTER FUNCTION public.check_enter_in_person_account(_login character varying, _password character varying) OWNER TO postgres;
--
-- Name: check_hospitalization_overlap(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_hospitalization_overlap() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
overlap_found boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
get_hospitalization_periods (NEW.patient_id)
WHERE
discharge_datetime IS NOT NULL
AND NEW.admission_datetime < discharge_datetime
AND NEW.admission_datetime > admission_datetime) INTO overlap_found;
IF overlap_found THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10002: HOSPITALIZATION_OVERLAP';
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.check_hospitalization_overlap() OWNER TO postgres;
--
-- Name: check_numeric_result_uniqueness(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_numeric_result_uniqueness() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
qualitative_exists boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
qualitative_result
WHERE
result_id = NEW.result_id) INTO qualitative_exists;
IF qualitative_exists THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10005: QUALITATIVE_RESULT_ALREADY_EXISTS_FOR_THIS_EXAMINATION';
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.check_numeric_result_uniqueness() OWNER TO postgres;
--
-- Name: check_password(character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_password(_password character varying) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
IF (trim(_password) = '')
THEN
RAISE EXCEPTION 'Пароль не может быть пуÑтым!';
END IF;
IF (trim(_password) <> _password)
THEN
RAISE EXCEPTION 'Пароль должен быть без пробелов!';
END IF;
IF (length(_password) < 8)
THEN
RAISE EXCEPTION 'Пароль должен иметь больше 8 знаков!';
END IF;
IF (lower(_password) = _password OR _password !~ '[0-9]')
THEN
RAISE EXCEPTION 'Пароль должен иметь пропиÑные и заглавные буквы, а также цифры!';
END IF;
IF ((SELECT COUNT(*) AS letter_count
FROM ( SELECT regexp_split_to_table(_password, '') AS letter) AS letters
GROUP BY letter
ORDER BY letter
LIMIT 1) >= length(_password)/2)
THEN
RAISE EXCEPTION 'Пароль не должен иметь больше половины одинаковых Ñимволов!';
END IF;
END
$$;
ALTER FUNCTION public.check_password(_password character varying) OWNER TO postgres;
--
-- Name: check_qualitative_result_uniqueness(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_qualitative_result_uniqueness() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
numeric_exists boolean;
BEGIN
SELECT
EXISTS (
SELECT
1
FROM
numeric_result
WHERE
result_id = NEW.result_id) INTO numeric_exists;
IF numeric_exists THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10006: NUMERIC_RESULT_ALREADY_EXISTS_FOR_THIS_EXAMINATION';
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.check_qualitative_result_uniqueness() OWNER TO postgres;
--
-- Name: check_unique_discharge(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.check_unique_discharge() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
discharge_count integer;
BEGIN
SELECT
COUNT(*) INTO discharge_count
FROM
hospital_discharge
WHERE
hospital_admission_id = NEW.hospital_admission_id
AND hospital_discharge_id <> COALESCE(NEW.hospital_discharge_id, -1);
IF discharge_count > 0 THEN
RAISE EXCEPTION
USING ERRCODE = 'P0001', MESSAGE = '10004: DISCHARGE_ALREADY_EXISTS';
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.check_unique_discharge() OWNER TO postgres;
--
-- Name: create_person_account(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.create_person_account() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
role int;
BEGIN
PERFORM check_password(NEW.password);
NEW.password := crypt(NEW.password, gen_salt('bf'));
RETURN NEW;
END;
$$;
ALTER FUNCTION public.create_person_account() OWNER TO postgres;
--
-- Name: default_str_check(text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.default_str_check(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str IS NULL
OR no_double_space (str)
AND no_space_start_end (str)
AND str_length_between (str, 1, 128);
END;
$$;
ALTER FUNCTION public.default_str_check(str text) OWNER TO postgres;
--
-- Name: default_word_check(text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.default_word_check(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str IS NULL
OR no_space (str)
AND str_length_between (str, 1, 64);
END;
$$;
ALTER FUNCTION public.default_word_check(str text) OWNER TO postgres;
--
-- Name: get_hospitalization_periods(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.get_hospitalization_periods(p_patient_id integer) RETURNS TABLE(admission_datetime timestamp without time zone, discharge_datetime timestamp without time zone)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
ha.admission_datetime,
hd.discharge_datetime
FROM
hospital_admission ha
LEFT JOIN hospital_discharge hd ON ha.hospital_admission_id = hd.hospital_admission_id
WHERE
ha.patient_id = p_patient_id;
END;
$$;
ALTER FUNCTION public.get_hospitalization_periods(p_patient_id integer) OWNER TO postgres;
--
-- Name: get_results(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.get_results() RETURNS TABLE("Пациент" text, "ОбÑледование" text, "Результат" character varying)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY(SELECT pa.policy_number, et.name, COALESCE(qr.value::varchar, CONCAT(nr.value || ' ' || u.name))
FROM patient pa
LEFT JOIN prescription pr
ON pa.patient_id = pr.patient_id
LEFT JOIN examination_type_prescription etp
ON pr.prescription_id = etp.prescription_id
LEFT JOIN examination_type et
ON et.examination_type_id = etp.examination_type_id
LEFT JOIN result r
ON etp.result_id = r.result_id
LEFT JOIN qualitative_result qr
ON r.result_id = qr.result_id
LEFT JOIN numeric_result nr
ON r.result_id = nr.result_id
LEFT JOIN unit u
ON nr.unit_id = u.unit_id
WHERE et.name IS NOT NULL);
END;
$$;
ALTER FUNCTION public.get_results() OWNER TO postgres;
--
-- Name: no_double_space(text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.no_double_space(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str !~ E'\s{2,}';
END;
$$;
ALTER FUNCTION public.no_double_space(str text) OWNER TO postgres;
--
-- Name: no_space(text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.no_space(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN str !~ E'\s';
END;
$$;
ALTER FUNCTION public.no_space(str text) OWNER TO postgres;
--
-- Name: no_space_start_end(text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.no_space_start_end(str text) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $_$
BEGIN
RETURN str !~ E'^\s'
AND str !~ E'\s$';
END;
$_$;
ALTER FUNCTION public.no_space_start_end(str text) OWNER TO postgres;
--
-- Name: random_int(integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.random_int(min_val integer, max_val integer) RETURNS integer
LANGUAGE plpgsql
AS $$
BEGIN
RETURN min_val + trunc(random() * (max_val - min_val + 1))::int;
END;
$$;
ALTER FUNCTION public.random_int(min_val integer, max_val integer) OWNER TO postgres;
--
-- Name: str_length_between(text, integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.str_length_between(str text, min_len integer, max_len integer) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE
AS $$
BEGIN
RETURN LENGTH(str) BETWEEN min_len AND max_len;
END;
$$;
ALTER FUNCTION public.str_length_between(str text, min_len integer, max_len integer) OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: disease; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.disease (
disease_id integer NOT NULL,
name text NOT NULL,
icd_code text NOT NULL,
CONSTRAINT disease_name_check CHECK (public.default_str_check(name))
);
ALTER TABLE public.disease OWNER TO postgres;
--
-- Name: disease_disease_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.disease_disease_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.disease_disease_id_seq OWNER TO postgres;
--
-- Name: disease_disease_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.disease_disease_id_seq OWNED BY public.disease.disease_id;
--
-- Name: disease_syndrome; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.disease_syndrome (
disease_syndrome_id integer NOT NULL,
disease_id integer NOT NULL,
syndrome_id integer NOT NULL
);
ALTER TABLE public.disease_syndrome OWNER TO postgres;
--
-- Name: disease_syndrome_disease_syndrome_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.disease_syndrome_disease_syndrome_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.disease_syndrome_disease_syndrome_id_seq OWNER TO postgres;
--
-- Name: disease_syndrome_disease_syndrome_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.disease_syndrome_disease_syndrome_id_seq OWNED BY public.disease_syndrome.disease_syndrome_id;
--
-- Name: doctor; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.doctor (
doctor_id integer NOT NULL
);
ALTER TABLE public.doctor OWNER TO postgres;
--
-- Name: drug_intake_method; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.drug_intake_method (
drug_intake_method_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT drug_intake_method_name_check CHECK (public.default_word_check(name))
);
ALTER TABLE public.drug_intake_method OWNER TO postgres;
--
-- Name: drug_intake_method_drug_intake_method_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.drug_intake_method_drug_intake_method_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.drug_intake_method_drug_intake_method_id_seq OWNER TO postgres;
--
-- Name: drug_intake_method_drug_intake_method_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.drug_intake_method_drug_intake_method_id_seq OWNED BY public.drug_intake_method.drug_intake_method_id;
--
-- Name: drug_type; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.drug_type (
drug_type_id integer NOT NULL,
international_name_ru text NOT NULL,
international_name_en text,
international_name_la text,
brand_name_ru text,
CONSTRAINT drug_type_brand_name_ru_check CHECK (public.default_word_check(brand_name_ru)),
CONSTRAINT drug_type_international_name_en_check CHECK (public.default_word_check(international_name_en)),
CONSTRAINT drug_type_international_name_la_check CHECK (public.default_word_check(international_name_la)),
CONSTRAINT drug_type_international_name_ru_check CHECK (public.default_word_check(international_name_ru))
);
ALTER TABLE public.drug_type OWNER TO postgres;
--
-- Name: drug_type_drug_type_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.drug_type_drug_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.drug_type_drug_type_id_seq OWNER TO postgres;
--
-- Name: drug_type_drug_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.drug_type_drug_type_id_seq OWNED BY public.drug_type.drug_type_id;
--
-- Name: drug_type_prescription; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.drug_type_prescription (
drug_prescription_id integer NOT NULL,
prescription_id integer NOT NULL,
drug_type_id integer NOT NULL,
dose numeric NOT NULL,
dose_unit_id integer NOT NULL,
intake_method_id integer NOT NULL,
duration_days integer NOT NULL,
CONSTRAINT drug_type_prescription_dose_check CHECK ((dose > (0)::numeric)),
CONSTRAINT drug_type_prescription_duration_days_check CHECK ((duration_days > 0))
);
ALTER TABLE public.drug_type_prescription OWNER TO postgres;
--
-- Name: drug_type_prescription_drug_prescription_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.drug_type_prescription_drug_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.drug_type_prescription_drug_prescription_id_seq OWNER TO postgres;
--
-- Name: drug_type_prescription_drug_prescription_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.drug_type_prescription_drug_prescription_id_seq OWNED BY public.drug_type_prescription.drug_prescription_id;
--
-- Name: examination_type; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.examination_type (
examination_type_id integer NOT NULL,
name text NOT NULL,
category text NOT NULL,
CONSTRAINT examination_type_name_check CHECK (public.default_word_check(name))
);
ALTER TABLE public.examination_type OWNER TO postgres;
--
-- Name: examination_type_examination_type_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.examination_type_examination_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.examination_type_examination_type_id_seq OWNER TO postgres;
--
-- Name: examination_type_examination_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.examination_type_examination_type_id_seq OWNED BY public.examination_type.examination_type_id;
--
-- Name: examination_type_prescription; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.examination_type_prescription (
examination_prescription_id integer NOT NULL,
prescription_id integer NOT NULL,
result_id integer,
examination_type_id integer NOT NULL
);
ALTER TABLE public.examination_type_prescription OWNER TO postgres;
--
-- Name: examination_type_prescription_examination_prescription_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.examination_type_prescription_examination_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.examination_type_prescription_examination_prescription_id_seq OWNER TO postgres;
--
-- Name: examination_type_prescription_examination_prescription_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.examination_type_prescription_examination_prescription_id_seq OWNED BY public.examination_type_prescription.examination_prescription_id;
--
-- Name: hospital_admission; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.hospital_admission (
hospital_admission_id integer NOT NULL,
patient_id integer NOT NULL,
preliminary_disease_id integer NOT NULL,
admission_datetime timestamp without time zone NOT NULL,
CONSTRAINT hospital_admission_admission_datetime_check CHECK ((admission_datetime <= CURRENT_TIMESTAMP))
);
ALTER TABLE public.hospital_admission OWNER TO postgres;
--
-- Name: hospital_admission_hospital_admission_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.hospital_admission_hospital_admission_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.hospital_admission_hospital_admission_id_seq OWNER TO postgres;
--
-- Name: hospital_admission_hospital_admission_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.hospital_admission_hospital_admission_id_seq OWNED BY public.hospital_admission.hospital_admission_id;
--
-- Name: hospital_discharge; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.hospital_discharge (
hospital_discharge_id integer NOT NULL,
hospital_admission_id integer NOT NULL,
discharge_datetime timestamp without time zone NOT NULL,
final_disease_id integer NOT NULL,
reason text NOT NULL,
CONSTRAINT hospital_discharge_discharge_datetime_check CHECK ((discharge_datetime <= CURRENT_TIMESTAMP))
);
ALTER TABLE public.hospital_discharge OWNER TO postgres;
--
-- Name: hospital_discharge_hospital_discharge_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.hospital_discharge_hospital_discharge_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.hospital_discharge_hospital_discharge_id_seq OWNER TO postgres;
--
-- Name: hospital_discharge_hospital_discharge_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.hospital_discharge_hospital_discharge_id_seq OWNED BY public.hospital_discharge.hospital_discharge_id;
--
-- Name: numeric_result; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.numeric_result (
result_id integer NOT NULL,
value numeric NOT NULL,
unit_id integer NOT NULL
);
ALTER TABLE public.numeric_result OWNER TO postgres;
--
-- Name: patient; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.patient (
patient_id integer NOT NULL,
policy_number text NOT NULL,
CONSTRAINT patient_policy_number_check CHECK ((policy_number ~ '^[0-9]{16}$'::text))
);
ALTER TABLE public.patient OWNER TO postgres;
--
-- Name: person; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.person (
person_id integer NOT NULL,
middle_name text NOT NULL,
first_name text NOT NULL,
last_name text,
birth_date date NOT NULL,
gender text NOT NULL,
address text NOT NULL,
CONSTRAINT person_address_check CHECK (public.default_str_check(address)),
CONSTRAINT person_birth_date_check CHECK ((birth_date <= CURRENT_DATE)),
CONSTRAINT person_first_name_check CHECK (public.default_word_check(first_name)),
CONSTRAINT person_last_name_check CHECK (public.default_word_check(middle_name)),
CONSTRAINT person_middle_name_check CHECK (public.default_word_check(last_name))
);
ALTER TABLE public.person OWNER TO postgres;
--
-- Name: person_account; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.person_account (
person_id integer NOT NULL,
login character varying(60) NOT NULL,
password character varying NOT NULL,
CONSTRAINT empty_login CHECK ((TRIM(BOTH FROM login) <> ''::text))
);
ALTER TABLE public.person_account OWNER TO postgres;
--
-- Name: person_person_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.person_person_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.person_person_id_seq OWNER TO postgres;
--
-- Name: person_person_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.person_person_id_seq OWNED BY public.person.person_id;
--
-- Name: prescription; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.prescription (
prescription_id integer NOT NULL,
patient_id integer NOT NULL,
doctor_id integer NOT NULL
);
ALTER TABLE public.prescription OWNER TO postgres;
--
-- Name: prescription_prescription_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.prescription_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.prescription_prescription_id_seq OWNER TO postgres;
--
-- Name: prescription_prescription_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.prescription_prescription_id_seq OWNED BY public.prescription.prescription_id;
--
-- Name: procedure_type; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.procedure_type (
procedure_type_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT procedure_type_name_check CHECK (public.default_word_check(name))
);
ALTER TABLE public.procedure_type OWNER TO postgres;
--
-- Name: procedure_type_prescription; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.procedure_type_prescription (
procedure_prescription_id integer NOT NULL,
prescription_id integer NOT NULL,
procedure_type_id integer NOT NULL,
scheduled_datetime timestamp without time zone NOT NULL
);
ALTER TABLE public.procedure_type_prescription OWNER TO postgres;
--
-- Name: procedure_type_prescription_procedure_prescription_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.procedure_type_prescription_procedure_prescription_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.procedure_type_prescription_procedure_prescription_id_seq OWNER TO postgres;
--
-- Name: procedure_type_prescription_procedure_prescription_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.procedure_type_prescription_procedure_prescription_id_seq OWNED BY public.procedure_type_prescription.procedure_prescription_id;
--
-- Name: procedure_type_procedure_type_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.procedure_type_procedure_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.procedure_type_procedure_type_id_seq OWNER TO postgres;
--
-- Name: procedure_type_procedure_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.procedure_type_procedure_type_id_seq OWNED BY public.procedure_type.procedure_type_id;
--
-- Name: qualitative_result; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.qualitative_result (
result_id integer NOT NULL,
value boolean NOT NULL
);
ALTER TABLE public.qualitative_result OWNER TO postgres;
--
-- Name: reference_numeric_value; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.reference_numeric_value (
reference_value_id integer NOT NULL,
min_value numeric,
max_value numeric,
unit_id integer NOT NULL
);
ALTER TABLE public.reference_numeric_value OWNER TO postgres;
--
-- Name: reference_qualitative_value; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.reference_qualitative_value (
reference_value_id integer NOT NULL,
description_true text NOT NULL,
description_false text NOT NULL,
CONSTRAINT reference_qualitative_value_description_false_check CHECK (public.default_word_check(description_false)),
CONSTRAINT reference_qualitative_value_description_true_check CHECK (public.default_word_check(description_true))
);
ALTER TABLE public.reference_qualitative_value OWNER TO postgres;
--
-- Name: reference_value; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.reference_value (
reference_value_id integer NOT NULL,
examination_type_id integer NOT NULL,
gender text,
age_min integer,
age_max integer,
CONSTRAINT reference_value_check CHECK (((age_min IS NULL) OR (age_max IS NULL) OR (age_min < age_max)))
);
ALTER TABLE public.reference_value OWNER TO postgres;
--
-- Name: reference_value_reference_value_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.reference_value_reference_value_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.reference_value_reference_value_id_seq OWNER TO postgres;
--
-- Name: reference_value_reference_value_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.reference_value_reference_value_id_seq OWNED BY public.reference_value.reference_value_id;
--
-- Name: registrar; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.registrar (
registrar_id integer NOT NULL
);
ALTER TABLE public.registrar OWNER TO postgres;
--
-- Name: result; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.result (
result_id integer NOT NULL,
examination_id integer NOT NULL
);
ALTER TABLE public.result OWNER TO postgres;
--
-- Name: result_result_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.result_result_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.result_result_id_seq OWNER TO postgres;
--
-- Name: result_result_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.result_result_id_seq OWNED BY public.result.result_id;
--
-- Name: syndrome_examination_type; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.syndrome_examination_type (
syndrome_id integer NOT NULL,
examination_type_id integer NOT NULL
);
ALTER TABLE public.syndrome_examination_type OWNER TO postgres;
--
-- Name: syndrome_type; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.syndrome_type (
syndrome_type_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT syndrome_type_name_check CHECK (public.default_word_check(name))
);
ALTER TABLE public.syndrome_type OWNER TO postgres;
--
-- Name: syndrome_type_syndrome_type_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.syndrome_type_syndrome_type_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.syndrome_type_syndrome_type_id_seq OWNER TO postgres;
--
-- Name: syndrome_type_syndrome_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.syndrome_type_syndrome_type_id_seq OWNED BY public.syndrome_type.syndrome_type_id;
--
-- Name: unit; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.unit (
unit_id integer NOT NULL,
name text NOT NULL,
CONSTRAINT unit_name_check CHECK (((name ~ '^[а-ÑÐ-ЯёÐ%^/]+$'::text) AND public.str_length_between(name, 1, 16)))
);
ALTER TABLE public.unit OWNER TO postgres;
--
-- Name: unit_unit_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.unit_unit_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.unit_unit_id_seq OWNER TO postgres;
--
-- Name: unit_unit_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.unit_unit_id_seq OWNED BY public.unit.unit_id;
--
-- Name: disease disease_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease ALTER COLUMN disease_id SET DEFAULT nextval('public.disease_disease_id_seq'::regclass);
--
-- Name: disease_syndrome disease_syndrome_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease_syndrome ALTER COLUMN disease_syndrome_id SET DEFAULT nextval('public.disease_syndrome_disease_syndrome_id_seq'::regclass);
--
-- Name: drug_intake_method drug_intake_method_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_intake_method ALTER COLUMN drug_intake_method_id SET DEFAULT nextval('public.drug_intake_method_drug_intake_method_id_seq'::regclass);
--
-- Name: drug_type drug_type_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type ALTER COLUMN drug_type_id SET DEFAULT nextval('public.drug_type_drug_type_id_seq'::regclass);
--
-- Name: drug_type_prescription drug_prescription_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type_prescription ALTER COLUMN drug_prescription_id SET DEFAULT nextval('public.drug_type_prescription_drug_prescription_id_seq'::regclass);
--
-- Name: examination_type examination_type_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type ALTER COLUMN examination_type_id SET DEFAULT nextval('public.examination_type_examination_type_id_seq'::regclass);
--
-- Name: examination_type_prescription examination_prescription_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type_prescription ALTER COLUMN examination_prescription_id SET DEFAULT nextval('public.examination_type_prescription_examination_prescription_id_seq'::regclass);
--
-- Name: hospital_admission hospital_admission_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_admission ALTER COLUMN hospital_admission_id SET DEFAULT nextval('public.hospital_admission_hospital_admission_id_seq'::regclass);
--
-- Name: hospital_discharge hospital_discharge_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_discharge ALTER COLUMN hospital_discharge_id SET DEFAULT nextval('public.hospital_discharge_hospital_discharge_id_seq'::regclass);
--
-- Name: person person_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.person ALTER COLUMN person_id SET DEFAULT nextval('public.person_person_id_seq'::regclass);
--
-- Name: prescription prescription_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.prescription ALTER COLUMN prescription_id SET DEFAULT nextval('public.prescription_prescription_id_seq'::regclass);
--
-- Name: procedure_type procedure_type_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type ALTER COLUMN procedure_type_id SET DEFAULT nextval('public.procedure_type_procedure_type_id_seq'::regclass);
--
-- Name: procedure_type_prescription procedure_prescription_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type_prescription ALTER COLUMN procedure_prescription_id SET DEFAULT nextval('public.procedure_type_prescription_procedure_prescription_id_seq'::regclass);
--
-- Name: reference_value reference_value_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_value ALTER COLUMN reference_value_id SET DEFAULT nextval('public.reference_value_reference_value_id_seq'::regclass);
--
-- Name: result result_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.result ALTER COLUMN result_id SET DEFAULT nextval('public.result_result_id_seq'::regclass);
--
-- Name: syndrome_type syndrome_type_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.syndrome_type ALTER COLUMN syndrome_type_id SET DEFAULT nextval('public.syndrome_type_syndrome_type_id_seq'::regclass);
--
-- Name: unit unit_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.unit ALTER COLUMN unit_id SET DEFAULT nextval('public.unit_unit_id_seq'::regclass);
--
-- Data for Name: disease; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.disease (disease_id, name, icd_code) FROM stdin;
\.
COPY public.disease (disease_id, name, icd_code) FROM '$$PATH$$/5157.dat';
--
-- Data for Name: disease_syndrome; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.disease_syndrome (disease_syndrome_id, disease_id, syndrome_id) FROM stdin;
\.
COPY public.disease_syndrome (disease_syndrome_id, disease_id, syndrome_id) FROM '$$PATH$$/5159.dat';
--
-- Data for Name: doctor; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.doctor (doctor_id) FROM stdin;
\.
COPY public.doctor (doctor_id) FROM '$$PATH$$/5135.dat';
--
-- Data for Name: drug_intake_method; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.drug_intake_method (drug_intake_method_id, name) FROM stdin;
\.
COPY public.drug_intake_method (drug_intake_method_id, name) FROM '$$PATH$$/5161.dat';
--
-- Data for Name: drug_type; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.drug_type (drug_type_id, international_name_ru, international_name_en, international_name_la, brand_name_ru) FROM stdin;
\.
COPY public.drug_type (drug_type_id, international_name_ru, international_name_en, international_name_la, brand_name_ru) FROM '$$PATH$$/5163.dat';
--
-- Data for Name: drug_type_prescription; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.drug_type_prescription (drug_prescription_id, prescription_id, drug_type_id, dose, dose_unit_id, intake_method_id, duration_days) FROM stdin;
\.
COPY public.drug_type_prescription (drug_prescription_id, prescription_id, drug_type_id, dose, dose_unit_id, intake_method_id, duration_days) FROM '$$PATH$$/5165.dat';
--
-- Data for Name: examination_type; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.examination_type (examination_type_id, name, category) FROM stdin;
\.
COPY public.examination_type (examination_type_id, name, category) FROM '$$PATH$$/5142.dat';
--
-- Data for Name: examination_type_prescription; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.examination_type_prescription (examination_prescription_id, prescription_id, result_id, examination_type_id) FROM stdin;
\.
COPY public.examination_type_prescription (examination_prescription_id, prescription_id, result_id, examination_type_id) FROM '$$PATH$$/5146.dat';
--
-- Data for Name: hospital_admission; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.hospital_admission (hospital_admission_id, patient_id, preliminary_disease_id, admission_datetime) FROM stdin;
\.
COPY public.hospital_admission (hospital_admission_id, patient_id, preliminary_disease_id, admission_datetime) FROM '$$PATH$$/5171.dat';
--
-- Data for Name: hospital_discharge; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.hospital_discharge (hospital_discharge_id, hospital_admission_id, discharge_datetime, final_disease_id, reason) FROM stdin;
\.
COPY public.hospital_discharge (hospital_discharge_id, hospital_admission_id, discharge_datetime, final_disease_id, reason) FROM '$$PATH$$/5173.dat';
--
-- Data for Name: numeric_result; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.numeric_result (result_id, value, unit_id) FROM stdin;
\.
COPY public.numeric_result (result_id, value, unit_id) FROM '$$PATH$$/5147.dat';
--
-- Data for Name: patient; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.patient (patient_id, policy_number) FROM stdin;
\.
COPY public.patient (patient_id, policy_number) FROM '$$PATH$$/5134.dat';
--
-- Data for Name: person; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.person (person_id, middle_name, first_name, last_name, birth_date, gender, address) FROM stdin;
\.
COPY public.person (person_id, middle_name, first_name, last_name, birth_date, gender, address) FROM '$$PATH$$/5133.dat';
--
-- Data for Name: person_account; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.person_account (person_id, login, password) FROM stdin;
\.
COPY public.person_account (person_id, login, password) FROM '$$PATH$$/5174.dat';
--
-- Data for Name: prescription; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.prescription (prescription_id, patient_id, doctor_id) FROM stdin;
\.
COPY public.prescription (prescription_id, patient_id, doctor_id) FROM '$$PATH$$/5140.dat';
--
-- Data for Name: procedure_type; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.procedure_type (procedure_type_id, name) FROM stdin;
\.
COPY public.procedure_type (procedure_type_id, name) FROM '$$PATH$$/5167.dat';
--
-- Data for Name: procedure_type_prescription; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.procedure_type_prescription (procedure_prescription_id, prescription_id, procedure_type_id, scheduled_datetime) FROM stdin;
\.
COPY public.procedure_type_prescription (procedure_prescription_id, prescription_id, procedure_type_id, scheduled_datetime) FROM '$$PATH$$/5169.dat';
--
-- Data for Name: qualitative_result; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.qualitative_result (result_id, value) FROM stdin;
\.
COPY public.qualitative_result (result_id, value) FROM '$$PATH$$/5148.dat';
--
-- Data for Name: reference_numeric_value; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.reference_numeric_value (reference_value_id, min_value, max_value, unit_id) FROM stdin;
\.
COPY public.reference_numeric_value (reference_value_id, min_value, max_value, unit_id) FROM '$$PATH$$/5151.dat';
--
-- Data for Name: reference_qualitative_value; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.reference_qualitative_value (reference_value_id, description_true, description_false) FROM stdin;
\.
COPY public.reference_qualitative_value (reference_value_id, description_true, description_false) FROM '$$PATH$$/5152.dat';
--
-- Data for Name: reference_value; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.reference_value (reference_value_id, examination_type_id, gender, age_min, age_max) FROM stdin;
\.
COPY public.reference_value (reference_value_id, examination_type_id, gender, age_min, age_max) FROM '$$PATH$$/5150.dat';
--
-- Data for Name: registrar; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.registrar (registrar_id) FROM stdin;
\.
COPY public.registrar (registrar_id) FROM '$$PATH$$/5136.dat';
--
-- Data for Name: result; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.result (result_id, examination_id) FROM stdin;
\.
COPY public.result (result_id, examination_id) FROM '$$PATH$$/5144.dat';
--
-- Data for Name: syndrome_examination_type; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.syndrome_examination_type (syndrome_id, examination_type_id) FROM stdin;
\.
COPY public.syndrome_examination_type (syndrome_id, examination_type_id) FROM '$$PATH$$/5155.dat';
--
-- Data for Name: syndrome_type; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.syndrome_type (syndrome_type_id, name) FROM stdin;
\.
COPY public.syndrome_type (syndrome_type_id, name) FROM '$$PATH$$/5154.dat';
--
-- Data for Name: unit; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.unit (unit_id, name) FROM stdin;
\.
COPY public.unit (unit_id, name) FROM '$$PATH$$/5138.dat';
--
-- Name: disease_disease_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.disease_disease_id_seq', 36, true);
--
-- Name: disease_syndrome_disease_syndrome_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.disease_syndrome_disease_syndrome_id_seq', 2, true);
--
-- Name: drug_intake_method_drug_intake_method_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.drug_intake_method_drug_intake_method_id_seq', 2, true);
--
-- Name: drug_type_drug_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.drug_type_drug_type_id_seq', 3, true);
--
-- Name: drug_type_prescription_drug_prescription_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.drug_type_prescription_drug_prescription_id_seq', 1, true);
--
-- Name: examination_type_examination_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.examination_type_examination_type_id_seq', 3, true);
--
-- Name: examination_type_prescription_examination_prescription_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.examination_type_prescription_examination_prescription_id_seq', 12, true);
--
-- Name: hospital_admission_hospital_admission_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.hospital_admission_hospital_admission_id_seq', 31, true);
--
-- Name: hospital_discharge_hospital_discharge_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.hospital_discharge_hospital_discharge_id_seq', 1, true);
--
-- Name: person_person_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.person_person_id_seq', 8, true);
--
-- Name: prescription_prescription_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.prescription_prescription_id_seq', 24, true);
--
-- Name: procedure_type_prescription_procedure_prescription_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.procedure_type_prescription_procedure_prescription_id_seq', 7, true);
--
-- Name: procedure_type_procedure_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.procedure_type_procedure_type_id_seq', 3, true);
--
-- Name: reference_value_reference_value_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.reference_value_reference_value_id_seq', 5, true);
--
-- Name: result_result_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.result_result_id_seq', 10, true);
--
-- Name: syndrome_type_syndrome_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.syndrome_type_syndrome_type_id_seq', 2, true);
--
-- Name: unit_unit_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.unit_unit_id_seq', 10, true);
--
-- Name: disease disease_icd_code_check; Type: CHECK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE public.disease
ADD CONSTRAINT disease_icd_code_check CHECK ((icd_code ~ '^[A-Z][0-9]{2}\.[0-9]$'::text)) NOT VALID;
--
-- Name: disease disease_icd_code_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease
ADD CONSTRAINT disease_icd_code_key UNIQUE (icd_code);
--
-- Name: disease disease_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease
ADD CONSTRAINT disease_name_key UNIQUE (name);
--
-- Name: disease disease_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease
ADD CONSTRAINT disease_pkey PRIMARY KEY (disease_id);
--
-- Name: disease_syndrome disease_syndrome_disease_id_syndrome_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_disease_id_syndrome_id_key UNIQUE (disease_id, syndrome_id);
--
-- Name: disease_syndrome disease_syndrome_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_pkey PRIMARY KEY (disease_syndrome_id);
--
-- Name: doctor doctor_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.doctor
ADD CONSTRAINT doctor_pkey PRIMARY KEY (doctor_id);
--
-- Name: drug_intake_method drug_intake_method_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_intake_method
ADD CONSTRAINT drug_intake_method_name_key UNIQUE (name);
--
-- Name: drug_intake_method drug_intake_method_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_intake_method
ADD CONSTRAINT drug_intake_method_pkey PRIMARY KEY (drug_intake_method_id);
--
-- Name: drug_type drug_type_brand_name_ru_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_brand_name_ru_key UNIQUE (brand_name_ru);
--
-- Name: drug_type drug_type_international_name_en_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_international_name_en_key UNIQUE (international_name_en);
--
-- Name: drug_type drug_type_international_name_la_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_international_name_la_key UNIQUE (international_name_la);
--
-- Name: drug_type drug_type_international_name_ru_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_international_name_ru_key UNIQUE (international_name_ru);
--
-- Name: drug_type drug_type_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type
ADD CONSTRAINT drug_type_pkey PRIMARY KEY (drug_type_id);
--
-- Name: drug_type_prescription drug_type_prescription_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_pkey PRIMARY KEY (drug_prescription_id);
--
-- Name: drug_type_prescription drug_type_prescription_prescription_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_prescription_id_key UNIQUE (prescription_id);
--
-- Name: examination_type examination_type_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type
ADD CONSTRAINT examination_type_name_key UNIQUE (name);
--
-- Name: examination_type examination_type_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type
ADD CONSTRAINT examination_type_pkey PRIMARY KEY (examination_type_id);
--
-- Name: examination_type_prescription examination_type_prescription_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_pkey PRIMARY KEY (examination_prescription_id);
--
-- Name: examination_type_prescription examination_type_prescription_prescription_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_prescription_id_key UNIQUE (prescription_id);
--
-- Name: hospital_admission hospital_admission_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_admission
ADD CONSTRAINT hospital_admission_pkey PRIMARY KEY (hospital_admission_id);
--
-- Name: hospital_discharge hospital_discharge_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_discharge
ADD CONSTRAINT hospital_discharge_pkey PRIMARY KEY (hospital_discharge_id);
--
-- Name: numeric_result numeric_result_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.numeric_result
ADD CONSTRAINT numeric_result_pkey PRIMARY KEY (result_id);
--
-- Name: patient patient_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.patient
ADD CONSTRAINT patient_pkey PRIMARY KEY (patient_id);
--
-- Name: person_account person_account_person_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.person_account
ADD CONSTRAINT person_account_person_id_key UNIQUE (person_id);
--
-- Name: person person_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.person
ADD CONSTRAINT person_pkey PRIMARY KEY (person_id);
--
-- Name: prescription prescription_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.prescription
ADD CONSTRAINT prescription_pkey PRIMARY KEY (prescription_id);
--
-- Name: procedure_type procedure_type_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type
ADD CONSTRAINT procedure_type_name_key UNIQUE (name);
--
-- Name: procedure_type procedure_type_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type
ADD CONSTRAINT procedure_type_pkey PRIMARY KEY (procedure_type_id);
--
-- Name: procedure_type_prescription procedure_type_prescription_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_pkey PRIMARY KEY (procedure_prescription_id);
--
-- Name: procedure_type_prescription procedure_type_prescription_prescription_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_prescription_id_key UNIQUE (prescription_id);
--
-- Name: qualitative_result qualitative_result_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.qualitative_result
ADD CONSTRAINT qualitative_result_pkey PRIMARY KEY (result_id);
--
-- Name: reference_numeric_value reference_numeric_value_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_numeric_value
ADD CONSTRAINT reference_numeric_value_pkey PRIMARY KEY (reference_value_id);
--
-- Name: reference_qualitative_value reference_qualitative_value_description_true_description_fa_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_qualitative_value
ADD CONSTRAINT reference_qualitative_value_description_true_description_fa_key UNIQUE (description_true, description_false);
--
-- Name: reference_qualitative_value reference_qualitative_value_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_qualitative_value
ADD CONSTRAINT reference_qualitative_value_pkey PRIMARY KEY (reference_value_id);
--
-- Name: reference_value reference_value_examination_type_id_gender_age_min_age_max_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_value
ADD CONSTRAINT reference_value_examination_type_id_gender_age_min_age_max_key UNIQUE (examination_type_id, gender, age_min, age_max);
--
-- Name: reference_value reference_value_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_value
ADD CONSTRAINT reference_value_pkey PRIMARY KEY (reference_value_id);
--
-- Name: registrar registrar_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.registrar
ADD CONSTRAINT registrar_pkey PRIMARY KEY (registrar_id);
--
-- Name: result result_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.result
ADD CONSTRAINT result_pkey PRIMARY KEY (result_id);
--
-- Name: syndrome_examination_type syndrome_examination_type_examination_type_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.syndrome_examination_type
ADD CONSTRAINT syndrome_examination_type_examination_type_id_key UNIQUE (examination_type_id);
--
-- Name: syndrome_examination_type syndrome_examination_type_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.syndrome_examination_type
ADD CONSTRAINT syndrome_examination_type_pkey PRIMARY KEY (syndrome_id);
--
-- Name: syndrome_type syndrome_type_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.syndrome_type
ADD CONSTRAINT syndrome_type_name_key UNIQUE (name);
--
-- Name: syndrome_type syndrome_type_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.syndrome_type
ADD CONSTRAINT syndrome_type_pkey PRIMARY KEY (syndrome_type_id);
--
-- Name: unit unit_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.unit
ADD CONSTRAINT unit_name_key UNIQUE (name);
--
-- Name: unit unit_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.unit
ADD CONSTRAINT unit_pkey PRIMARY KEY (unit_id);
--
-- Name: hospital_admission trg_check_active_hospitalization; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trg_check_active_hospitalization BEFORE INSERT ON public.hospital_admission FOR EACH ROW EXECUTE FUNCTION public.check_active_hospitalization();
--
-- Name: hospital_discharge trg_check_discharge_after_admission; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trg_check_discharge_after_admission BEFORE INSERT OR UPDATE ON public.hospital_discharge FOR EACH ROW EXECUTE FUNCTION public.check_discharge_after_admission();
--
-- Name: hospital_admission trg_check_hospitalization_overlap; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trg_check_hospitalization_overlap BEFORE INSERT ON public.hospital_admission FOR EACH ROW EXECUTE FUNCTION public.check_hospitalization_overlap();
--
-- Name: numeric_result trg_check_numeric_result_uniqueness; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trg_check_numeric_result_uniqueness BEFORE INSERT OR UPDATE ON public.numeric_result FOR EACH ROW EXECUTE FUNCTION public.check_numeric_result_uniqueness();
--
-- Name: qualitative_result trg_check_qualitative_result_uniqueness; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trg_check_qualitative_result_uniqueness BEFORE INSERT OR UPDATE ON public.qualitative_result FOR EACH ROW EXECUTE FUNCTION public.check_qualitative_result_uniqueness();
--
-- Name: hospital_discharge trg_check_unique_discharge; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trg_check_unique_discharge BEFORE INSERT OR UPDATE ON public.hospital_discharge FOR EACH ROW EXECUTE FUNCTION public.check_unique_discharge();
--
-- Name: person_account trigger_create_account; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trigger_create_account BEFORE INSERT ON public.person_account FOR EACH ROW EXECUTE FUNCTION public.create_person_account();
--
-- Name: disease_syndrome disease_syndrome_disease_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_disease_id_fkey FOREIGN KEY (disease_id) REFERENCES public.disease(disease_id) ON DELETE CASCADE;
--
-- Name: disease_syndrome disease_syndrome_syndrome_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.disease_syndrome
ADD CONSTRAINT disease_syndrome_syndrome_id_fkey FOREIGN KEY (syndrome_id) REFERENCES public.syndrome_type(syndrome_type_id) ON DELETE CASCADE;
--
-- Name: doctor doctor_doctor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.doctor
ADD CONSTRAINT doctor_doctor_id_fkey FOREIGN KEY (doctor_id) REFERENCES public.person(person_id);
--
-- Name: drug_type_prescription drug_type_prescription_dose_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_dose_unit_id_fkey FOREIGN KEY (dose_unit_id) REFERENCES public.unit(unit_id) ON DELETE RESTRICT;
--
-- Name: drug_type_prescription drug_type_prescription_drug_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_drug_type_id_fkey FOREIGN KEY (drug_type_id) REFERENCES public.drug_type(drug_type_id) ON DELETE RESTRICT;
--
-- Name: drug_type_prescription drug_type_prescription_intake_method_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_intake_method_id_fkey FOREIGN KEY (intake_method_id) REFERENCES public.drug_intake_method(drug_intake_method_id) ON DELETE RESTRICT;
--
-- Name: drug_type_prescription drug_type_prescription_prescription_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.drug_type_prescription
ADD CONSTRAINT drug_type_prescription_prescription_id_fkey FOREIGN KEY (prescription_id) REFERENCES public.prescription(prescription_id) ON DELETE CASCADE;
--
-- Name: examination_type_prescription examination_type_prescription_examination_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_examination_type_id_fkey FOREIGN KEY (examination_type_id) REFERENCES public.examination_type(examination_type_id) ON DELETE CASCADE;
--
-- Name: examination_type_prescription examination_type_prescription_prescription_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_prescription_id_fkey FOREIGN KEY (prescription_id) REFERENCES public.prescription(prescription_id) ON DELETE CASCADE;
--
-- Name: examination_type_prescription examination_type_prescription_result_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.examination_type_prescription
ADD CONSTRAINT examination_type_prescription_result_id_fkey FOREIGN KEY (result_id) REFERENCES public.result(result_id) ON DELETE CASCADE;
--
-- Name: hospital_admission hospital_admission_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_admission
ADD CONSTRAINT hospital_admission_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patient(patient_id) ON DELETE CASCADE;
--
-- Name: hospital_admission hospital_admission_preliminary_disease_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_admission
ADD CONSTRAINT hospital_admission_preliminary_disease_id_fkey FOREIGN KEY (preliminary_disease_id) REFERENCES public.disease(disease_id);
--
-- Name: hospital_discharge hospital_discharge_final_disease_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_discharge
ADD CONSTRAINT hospital_discharge_final_disease_id_fkey FOREIGN KEY (final_disease_id) REFERENCES public.disease(disease_id);
--
-- Name: hospital_discharge hospital_discharge_hospital_admission_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hospital_discharge
ADD CONSTRAINT hospital_discharge_hospital_admission_id_fkey FOREIGN KEY (hospital_admission_id) REFERENCES public.hospital_admission(hospital_admission_id) ON DELETE CASCADE;
--
-- Name: numeric_result numeric_result_result_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.numeric_result
ADD CONSTRAINT numeric_result_result_id_fkey FOREIGN KEY (result_id) REFERENCES public.result(result_id) NOT VALID;
--
-- Name: numeric_result numeric_result_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.numeric_result
ADD CONSTRAINT numeric_result_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.unit(unit_id) ON DELETE RESTRICT;
--
-- Name: patient patient_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.patient
ADD CONSTRAINT patient_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.person(person_id);
--
-- Name: person_account person_account_person_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.person_account
ADD CONSTRAINT person_account_person_id_fkey FOREIGN KEY (person_id) REFERENCES public.person(person_id);
--
-- Name: prescription prescription_doctor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.prescription
ADD CONSTRAINT prescription_doctor_id_fkey FOREIGN KEY (doctor_id) REFERENCES public.doctor(doctor_id) ON DELETE RESTRICT;
--
-- Name: prescription prescription_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.prescription
ADD CONSTRAINT prescription_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patient(patient_id) ON DELETE CASCADE;
--
-- Name: procedure_type_prescription procedure_type_prescription_prescription_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_prescription_id_fkey FOREIGN KEY (prescription_id) REFERENCES public.prescription(prescription_id) ON DELETE CASCADE;
--
-- Name: procedure_type_prescription procedure_type_prescription_procedure_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.procedure_type_prescription
ADD CONSTRAINT procedure_type_prescription_procedure_type_id_fkey FOREIGN KEY (procedure_type_id) REFERENCES public.procedure_type(procedure_type_id) ON DELETE RESTRICT;
--
-- Name: qualitative_result qualitative_result_result_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.qualitative_result
ADD CONSTRAINT qualitative_result_result_id_fkey FOREIGN KEY (result_id) REFERENCES public.result(result_id) NOT VALID;
--
-- Name: reference_numeric_value reference_numeric_value_reference_value_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_numeric_value
ADD CONSTRAINT reference_numeric_value_reference_value_id_fkey FOREIGN KEY (reference_value_id) REFERENCES public.reference_value(reference_value_id) ON DELETE CASCADE;
--
-- Name: reference_numeric_value reference_numeric_value_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_numeric_value
ADD CONSTRAINT reference_numeric_value_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.unit(unit_id) ON DELETE RESTRICT;
--
-- Name: reference_qualitative_value reference_qualitative_value_reference_value_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_qualitative_value
ADD CONSTRAINT reference_qualitative_value_reference_value_id_fkey FOREIGN KEY (reference_value_id) REFERENCES public.reference_value(reference_value_id) ON DELETE CASCADE;
--
-- Name: reference_value reference_value_examination_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.reference_value
ADD CONSTRAINT reference_value_examination_type_id_fkey FOREIGN KEY (examination_type_id) REFERENCES public.examination_type(examination_type_id) ON DELETE CASCADE;
--
-- Name: registrar registrar_registrar_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres