-- Name: VIEW v_message_inbox; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_message_inbox IS 'Denormalized messages for the providers and/or patients.
Using UNION makes sure we get the right level of uniqueness.';


--
-- Name: v_org_unit_comms; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_org_unit_comms AS
 SELECT d_lo2c.fk_org_unit AS pk_org_unit,
    ect.description AS comm_type,
    public._(ect.description) AS l10n_comm_type,
    d_lo2c.url,
    d_lo2c.comment,
    d_lo2c.is_confidential,
    d_lo2c.pk AS pk_lnk_org_unit2comm,
    d_lo2c.fk_type AS pk_type,
    d_lo2c.xmin AS xmin_lnk_org_unit2comm
   FROM (dem.lnk_org_unit2comm d_lo2c
     JOIN dem.enum_comm_types ect ON ((d_lo2c.fk_type = ect.pk)));


ALTER TABLE dem.v_org_unit_comms OWNER TO "gm-dbo";

--
-- Name: VIEW v_org_unit_comms; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_org_unit_comms IS 'denormalizes org units to communication channels';


--
-- Name: v_org_units; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_org_units AS
 SELECT d_ou.pk AS pk_org_unit,
    d_o.description AS organization,
    d_ou.description AS unit,
    d_oc_o.description AS organization_category,
    public._(d_oc_o.description) AS l10n_organization_category,
    d_oc_u.description AS unit_category,
    public._(d_oc_u.description) AS l10n_unit_category,
    (EXISTS ( SELECT 1
           FROM dem.praxis_branch d_pb
          WHERE (d_pb.fk_org_unit = d_ou.pk))) AS is_praxis_branch,
    d_o.pk AS pk_org,
    d_o.fk_category AS pk_category_org,
    d_ou.fk_category AS pk_category_unit,
    d_ou.fk_address AS pk_address,
    d_ou.xmin AS xmin_org_unit
   FROM (((dem.org_unit d_ou
     JOIN dem.org d_o ON ((d_o.pk = d_ou.fk_org)))
     LEFT JOIN dem.org_category d_oc_u ON ((d_ou.fk_category = d_oc_u.pk)))
     LEFT JOIN dem.org_category d_oc_o ON ((d_o.fk_category = d_oc_o.pk)));


ALTER TABLE dem.v_org_units OWNER TO "gm-dbo";

--
-- Name: v_org_units_no_praxis_check; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_org_units_no_praxis_check AS
 SELECT d_ou.pk AS pk_org_unit,
    d_o.description AS organization,
    d_ou.description AS unit,
    d_oc_o.description AS organization_category,
    public._(d_oc_o.description) AS l10n_organization_category,
    d_oc_u.description AS unit_category,
    public._(d_oc_u.description) AS l10n_unit_category,
    d_o.pk AS pk_org,
    d_o.fk_category AS pk_category_org,
    d_ou.fk_category AS pk_category_unit,
    d_ou.fk_address AS pk_address,
    d_ou.xmin AS xmin_org_unit
   FROM (((dem.org_unit d_ou
     JOIN dem.org d_o ON ((d_o.pk = d_ou.fk_org)))
     LEFT JOIN dem.org_category d_oc_u ON ((d_ou.fk_category = d_oc_u.pk)))
     LEFT JOIN dem.org_category d_oc_o ON ((d_o.fk_category = d_oc_o.pk)));


ALTER TABLE dem.v_org_units_no_praxis_check OWNER TO "gm-dbo";

--
-- Name: v_orgs; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_orgs AS
 SELECT d_o.pk AS pk_org,
    d_o.description AS organization,
    d_oc.description AS category,
    public._(d_oc.description) AS l10n_category,
    (EXISTS ( SELECT 1
           FROM dem.praxis_branch d_pb
          WHERE (d_pb.fk_org_unit IN ( SELECT d_ou.pk
                   FROM dem.org_unit d_ou
                  WHERE (d_ou.fk_org = d_o.pk))))) AS is_praxis,
    d_o.fk_category AS pk_category_org,
    d_o.xmin AS xmin_org
   FROM (dem.org d_o
     LEFT JOIN dem.org_category d_oc ON ((d_o.fk_category = d_oc.pk)));


ALTER TABLE dem.v_orgs OWNER TO "gm-dbo";

--
-- Name: v_pat_addresses; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_pat_addresses AS
 SELECT d_vp.pk_identity,
    d_va.pk_address,
    d_at.name AS address_type,
    public._(d_at.name) AS l10n_address_type,
    d_vp.title,
    d_vp.firstnames,
    d_vp.lastnames,
    d_vp.dob,
    d_vp.gender,
    d_vp.l10n_gender,
    d_vp.preferred,
    d_va.street,
    d_va.postcode,
    d_va.notes_street,
    d_va.number,
    d_va.subunit,
    d_va.notes_subunit,
    d_va.lat_lon_address,
    d_va.postcode_street,
    d_va.lat_lon_street,
    d_va.suburb,
    d_va.urb,
    d_va.postcode_urb,
    d_va.lat_lon_urb,
    d_va.code_region,
    d_va.region,
    d_va.l10n_region,
    d_va.code_country,
    d_va.country,
    d_va.l10n_country,
    d_va.country_deprecated,
    d_va.pk_street,
    d_va.pk_urb,
    d_va.pk_region,
    d_lpoa.id AS pk_lnk_person_org_address,
    d_lpoa.id_type AS pk_address_type,
    d_lpoa.xmin AS xmin_lnk_person_org_address
   FROM (((dem.lnk_person_org_address d_lpoa
     JOIN dem.v_address d_va ON ((d_lpoa.id_address = d_va.pk_address)))
     JOIN dem.address_type d_at ON ((d_lpoa.id_type = d_at.id)))
     JOIN dem.v_all_persons d_vp ON ((d_lpoa.id_identity = d_vp.pk_identity)));


ALTER TABLE dem.v_pat_addresses OWNER TO "gm-dbo";

--
-- Name: VIEW v_pat_addresses; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_pat_addresses IS 'denormalized addresses per person';


--
-- Name: v_person_comms; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_person_comms AS
 SELECT li2c.fk_identity AS pk_identity,
    ect.description AS comm_type,
    public._(ect.description) AS l10n_comm_type,
    li2c.url,
    li2c.is_confidential,
    li2c.comment,
    li2c.pk AS pk_lnk_identity2comm,
    li2c.fk_address AS pk_address,
    li2c.fk_type AS pk_type,
    li2c.xmin AS xmin_lnk_identity2comm
   FROM dem.lnk_identity2comm li2c,
    dem.enum_comm_types ect
  WHERE (li2c.fk_type = ect.pk);


ALTER TABLE dem.v_person_comms OWNER TO "gm-dbo";

--
-- Name: VIEW v_person_comms; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_person_comms IS 'denormalizes persons to communications channels';


--
-- Name: v_person_jobs; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_person_jobs AS
 SELECT lj2p.fk_identity AS pk_identity,
    o.name AS occupation,
    public._(o.name) AS l10n_occupation,
    lj2p.activities,
    lj2p.modified_when,
    lj2p.fk_occupation AS pk_occupation,
    lj2p.pk AS pk_lnk_job2person,
    lj2p.xmin AS xmin_lnk_job2person
   FROM (dem.lnk_job2person lj2p
     JOIN dem.occupation o ON ((lj2p.fk_occupation = o.id)));


ALTER TABLE dem.v_person_jobs OWNER TO "gm-dbo";

--
-- Name: VIEW v_person_jobs; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_person_jobs IS 'denormalizes the jobs a person has';


--
-- Name: v_person_names; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_person_names AS
 SELECT d_i.pk AS pk_identity,
    d_n.active AS active_name,
    d_i.title,
    d_n.firstnames,
    d_n.lastnames,
    d_n.preferred,
    d_n.comment,
    d_i.comment AS comment_identity,
    d_i.gender,
    d_i.dob,
    d_i.tob,
    d_i.deceased AS dod,
    d_i.deleted AS identity_deleted,
    (d_i.deceased IS NOT NULL) AS deceased,
    d_n.id AS pk_name,
    d_n.xmin AS xmin_name
   FROM (dem.names d_n
     JOIN dem.identity d_i ON ((d_n.id_identity = d_i.pk)))
  WHERE (d_i.pk = d_n.id_identity);


ALTER TABLE dem.v_person_names OWNER TO "gm-dbo";

--
-- Name: v_persons; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_persons AS
 SELECT i.pk AS pk_identity,
    i.title,
    n.firstnames,
    n.preferred,
    n.lastnames,
    i.gender,
    public._(i.gender) AS l10n_gender,
    i.dob AS dob_only,
    (date_trunc('day'::text, i.dob) + (COALESCE(i.tob, (i.dob)::time without time zone))::interval) AS dob,
    i.tob,
    i.deceased,
        CASE
            WHEN (i.fk_marital_status IS NULL) THEN 'unknown'::text
            ELSE ( SELECT ms.name
               FROM dem.marital_status ms,
                dem.identity i1
              WHERE ((ms.pk = i.fk_marital_status) AND (i1.pk = i.pk)))
        END AS marital_status,
        CASE
            WHEN (i.fk_marital_status IS NULL) THEN public._('unknown'::text)
            ELSE ( SELECT public._(ms1.name) AS _
               FROM dem.marital_status ms1,
                dem.identity i1
              WHERE ((ms1.pk = i.fk_marital_status) AND (i1.pk = i.pk)))
        END AS l10n_marital_status,
    i.emergency_contact,
    i.comment,
    i.deleted AS is_deleted,
    i.fk_marital_status AS pk_marital_status,
    n.id AS pk_active_name,
    i.fk_emergency_contact AS pk_emergency_contact,
    i.fk_primary_provider AS pk_primary_provider,
    i.xmin AS xmin_identity,
    i.dob_is_estimated
   FROM dem.identity i,
    dem.names n
  WHERE ((n.active IS TRUE) AND (n.id_identity = i.pk));


ALTER TABLE dem.v_persons OWNER TO "gm-dbo";

--
-- Name: VIEW v_persons; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_persons IS 'This view denormalizes persons with their active name.';


--
-- Name: v_praxis_branches; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_praxis_branches AS
 SELECT branches_w_orgs.pk_praxis_branch,
    branches_w_orgs.branch,
    branches_w_orgs.pk_org_unit,
    branches_w_orgs.pk_category_unit,
    branches_w_orgs.pk_address,
    branches_w_orgs.pk_org,
    branches_w_orgs.xmin_praxis_branch,
    branches_w_orgs.xmin_org_unit,
    branches_w_orgs.praxis,
    branches_w_orgs.pk_category_org,
    d_ocat.description AS organization_category,
    public._(d_ocat.description) AS l10n_organization_category,
    d_ucat.description AS unit_category,
    public._(d_ucat.description) AS l10n_unit_category
   FROM ((( SELECT branches_w_units.pk_praxis_branch,
            branches_w_units.branch,
            branches_w_units.pk_org_unit,
            branches_w_units.pk_category_unit,
            branches_w_units.pk_address,
            branches_w_units.pk_org,
            branches_w_units.xmin_praxis_branch,
            branches_w_units.xmin_org_unit,
            d_o.description AS praxis,
            d_o.fk_category AS pk_category_org
           FROM (( SELECT d_pb.pk AS pk_praxis_branch,
                    d_ou.description AS branch,
                    d_pb.fk_org_unit AS pk_org_unit,
                    d_ou.fk_category AS pk_category_unit,
                    d_ou.fk_address AS pk_address,
                    d_ou.fk_org AS pk_org,
                    d_pb.xmin AS xmin_praxis_branch,
                    d_ou.xmin AS xmin_org_unit
                   FROM (dem.praxis_branch d_pb
                     JOIN dem.org_unit d_ou ON ((d_pb.fk_org_unit = d_ou.pk)))) branches_w_units
             JOIN dem.org d_o ON ((d_o.pk = branches_w_units.pk_org)))) branches_w_orgs
     LEFT JOIN dem.org_category d_ucat ON ((branches_w_orgs.pk_category_unit = d_ucat.pk)))
     LEFT JOIN dem.org_category d_ocat ON ((branches_w_orgs.pk_category_org = d_ocat.pk)));


ALTER TABLE dem.v_praxis_branches OWNER TO "gm-dbo";

--
-- Name: VIEW v_praxis_branches; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_praxis_branches IS 'Denormalized praxis branches with their praxis.';


--
-- Name: v_region; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_region AS
 SELECT d_r.pk AS pk_region,
    d_r.code AS code_region,
    d_r.name AS region,
    public._(d_r.name) AS l10n_region,
    d_r.country AS code_country,
    c.name AS country,
    public._(c.name) AS l10n_country,
    c.deprecated AS country_deprecated,
    d_r.xmin AS xmin_region
   FROM (dem.region d_r
     LEFT JOIN dem.country c ON ((d_r.country = c.code)));


ALTER TABLE dem.v_region OWNER TO "gm-dbo";

--
-- Name: VIEW v_region; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_region IS 'denormalizes region information';


--
-- Name: v_staff; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_staff AS
 SELECT d_vp.pk_identity,
    d_s.pk AS pk_staff,
    d_vp.title,
    d_vp.firstnames,
    d_vp.lastnames,
    d_s.short_alias,
        CASE
            WHEN ( SELECT (EXISTS ( SELECT 1
                       FROM pg_group
                      WHERE ((pg_group.groname = 'gm-doctors'::name) AND (( SELECT pg_user.usesysid
                               FROM pg_user
                              WHERE (pg_user.usename = d_s.db_user)) = ANY (pg_group.grolist))))) AS "exists") THEN 'full clinical access'::text
            WHEN ( SELECT (EXISTS ( SELECT 1
                       FROM pg_group
                      WHERE ((pg_group.groname = 'gm-nurses'::name) AND (( SELECT pg_user.usesysid
                               FROM pg_user
                              WHERE (pg_user.usename = d_s.db_user)) = ANY (pg_group.grolist))))) AS "exists") THEN 'limited clinical access'::text
            WHEN ( SELECT (EXISTS ( SELECT 1
                       FROM pg_group
                      WHERE ((pg_group.groname = 'gm-staff'::name) AND (( SELECT pg_user.usesysid
                               FROM pg_user
                              WHERE (pg_user.usename = d_s.db_user)) = ANY (pg_group.grolist))))) AS "exists") THEN 'non-clinical access'::text
            WHEN ( SELECT (EXISTS ( SELECT 1
                       FROM pg_group
                      WHERE ((pg_group.groname = 'gm-public'::name) AND (( SELECT pg_user.usesysid
                               FROM pg_user
                              WHERE (pg_user.usename = d_s.db_user)) = ANY (pg_group.grolist))))) AS "exists") THEN 'public access'::text
            ELSE NULL::text
        END AS role,
    d_vp.dob,
    d_vp.gender,
    d_s.db_user,
    d_s.comment,
    d_s.is_active,
    d_vp.is_deleted AS person_is_deleted,
    ( SELECT (( SELECT (EXISTS ( SELECT 1
                           FROM pg_group
                          WHERE ((( SELECT pg_user.usesysid
                                   FROM pg_user
                                  WHERE (pg_user.usename = d_s.db_user)) = ANY (pg_group.grolist)) AND (pg_group.groname = current_database())))) AS "exists") AND ( SELECT (EXISTS ( SELECT 1
                           FROM pg_group
                          WHERE ((( SELECT pg_user.usesysid
                                   FROM pg_user
                                  WHERE (pg_user.usename = d_s.db_user)) = ANY (pg_group.grolist)) AND (pg_group.groname = 'gm-logins'::name)))) AS "exists"))) AS can_login,
    d_s.xmin AS xmin_staff
   FROM (dem.staff d_s
     JOIN dem.v_all_persons d_vp ON ((d_s.fk_identity = d_vp.pk_identity)));


ALTER TABLE dem.v_staff OWNER TO "gm-dbo";

--
-- Name: VIEW v_staff; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_staff IS 'Denormalized staff data.';


--
-- Name: v_urb; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_urb AS
 SELECT d_u.id AS pk_urb,
    d_u.name AS urb,
    d_u.postcode AS postcode_urb,
    d_u.lat_lon AS lat_lon_urb,
    d_vr.code_region,
    d_vr.region,
    d_vr.l10n_region,
    d_vr.code_country,
    d_vr.country,
    d_vr.l10n_country,
    d_vr.country_deprecated,
    d_u.fk_region AS pk_region,
    d_u.xmin AS xmin_urb
   FROM (dem.urb d_u
     LEFT JOIN dem.v_region d_vr ON ((d_vr.pk_region = d_u.fk_region)));


ALTER TABLE dem.v_urb OWNER TO "gm-dbo";

--
-- Name: VIEW v_urb; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_urb IS 'denormalizes urb data';


--
-- Name: v_street; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_street AS
 SELECT d_st.id AS pk_street,
    d_st.name AS street,
    COALESCE(d_st.postcode, d_vu.postcode_urb) AS postcode,
    d_st.postcode AS postcode_street,
    d_st.lat_lon AS lat_lon_street,
    d_st.suburb,
    d_vu.urb,
    d_vu.postcode_urb,
    d_vu.lat_lon_urb,
    d_vu.code_region,
    d_vu.region,
    d_vu.l10n_region,
    d_vu.code_country,
    d_vu.country,
    d_vu.l10n_country,
    d_vu.country_deprecated,
    d_st.id_urb AS pk_urb,
    d_vu.pk_region,
    d_st.xmin AS xmin_street
   FROM (dem.street d_st
     LEFT JOIN dem.v_urb d_vu ON ((d_st.id_urb = d_vu.pk_urb)));


ALTER TABLE dem.v_street OWNER TO "gm-dbo";

--
-- Name: VIEW v_street; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_street IS 'denormalizes street data';


--
-- Name: v_zip2street; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_zip2street AS
 SELECT COALESCE(d_str.postcode, d_u.postcode) AS postcode,
    d_str.name AS street,
    d_str.suburb,
    d_r.name AS region,
    d_r.code AS code_region,
    d_u.name AS urb,
    d_c.name AS country,
    public._(d_c.name) AS l10n_country,
    d_r.country AS code_country
   FROM dem.street d_str,
    dem.urb d_u,
    dem.region d_r,
    dem.country d_c
  WHERE ((d_str.postcode IS NOT NULL) AND (d_str.id_urb = d_u.id) AND (d_u.fk_region = d_r.pk) AND (d_r.country = d_c.code));


ALTER TABLE dem.v_zip2street OWNER TO "gm-dbo";

--
-- Name: VIEW v_zip2street; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_zip2street IS 'list known data for streets that have a zip code';


--
-- Name: v_uniq_zipped_urbs; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_uniq_zipped_urbs AS
 SELECT d_u.postcode,
    d_u.name,
    d_r.name AS region,
    d_r.code AS code_region,
    d_c.name AS country,
    public._(d_c.name) AS l10n_country,
    d_r.country AS code_country
   FROM dem.urb d_u,
    dem.region d_r,
    dem.country d_c
  WHERE ((d_u.postcode IS NOT NULL) AND (NOT (EXISTS ( SELECT 1
           FROM dem.v_zip2street d_vz2str
          WHERE ((d_vz2str.postcode = d_u.postcode) AND (d_vz2str.urb = d_u.name))))) AND (d_u.fk_region = d_r.pk) AND (d_r.country = d_c.code));


ALTER TABLE dem.v_uniq_zipped_urbs OWNER TO "gm-dbo";

--
-- Name: VIEW v_uniq_zipped_urbs; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_uniq_zipped_urbs IS 'convenience view that selects urbs which:
	 - have a zip code
	 - are not referenced in table "street" with that zip code';


--
-- Name: v_zip2data; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_zip2data AS
 SELECT d_vz2s.postcode AS zip,
    d_vz2s.street,
    d_vz2s.suburb,
    d_vz2s.urb,
    d_vz2s.region,
    d_vz2s.code_region,
    d_vz2s.country,
    d_vz2s.l10n_country,
    d_vz2s.code_country
   FROM dem.v_zip2street d_vz2s
UNION
 SELECT d_vuzu.postcode AS zip,
    NULL::text AS street,
    NULL::text AS suburb,
    d_vuzu.name AS urb,
    d_vuzu.region,
    d_vuzu.code_region,
    d_vuzu.country,
    d_vuzu.l10n_country,
    d_vuzu.code_country
   FROM dem.v_uniq_zipped_urbs d_vuzu;


ALTER TABLE dem.v_zip2data OWNER TO "gm-dbo";

--
-- Name: VIEW v_zip2data; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_zip2data IS 'aggregates nearly all known data per zip code';


--
-- Name: v_zip2urb; Type: VIEW; Schema: dem; Owner: gm-dbo
--

CREATE VIEW dem.v_zip2urb AS
 SELECT d_u.postcode,
    d_u.name AS urb,
    d_r.name AS region,
    d_r.code AS code_region,
    public._(d_c.name) AS country,
    d_r.country AS code_country
   FROM dem.urb d_u,
    dem.region d_r,
    dem.country d_c
  WHERE ((d_u.postcode IS NOT NULL) AND (d_u.fk_region = d_r.pk) AND (d_r.country = d_c.code));


ALTER TABLE dem.v_zip2urb OWNER TO "gm-dbo";

--
-- Name: VIEW v_zip2urb; Type: COMMENT; Schema: dem; Owner: gm-dbo
--

COMMENT ON VIEW dem.v_zip2urb IS 'list known data for urbs that have a zip code';


--
-- Name: access_log_pk_seq; Type: SEQUENCE; Schema: gm; Owner: gm-dbo
--

CREATE SEQUENCE gm.access_log_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE gm.access_log_pk_seq OWNER TO "gm-dbo";

--
-- Name: access_log_pk_seq; Type: SEQUENCE OWNED BY; Schema: gm; Owner: gm-dbo
--

ALTER SEQUENCE gm.access_log_pk_seq OWNED BY gm.access_log.pk;


--
-- Name: schema_revision; Type: TABLE; Schema: gm; Owner: gm-dbo
--

CREATE TABLE gm.schema_revision (
    pk integer NOT NULL,
    filename text NOT NULL,
    version text NOT NULL,
    imported timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE gm.schema_revision OWNER TO "gm-dbo";

--
-- Name: TABLE schema_revision; Type: COMMENT; Schema: gm; Owner: gm-dbo
--

COMMENT ON TABLE gm.schema_revision IS 'this table holds the revisions of all SQL scripts ever
	 inserted into this database, the values are preferably
	 provided by CVS tags in the scripts themselves, see above
	 for a convenient way to do that';


--
-- Name: COLUMN schema_revision.filename; Type: COMMENT; Schema: gm; Owner: gm-dbo
--

COMMENT ON COLUMN gm.schema_revision.filename IS 'the name of the script, handled most easily by CVS via "RCSfile"';


--
-- Name: COLUMN schema_revision.version; Type: COMMENT; Schema: gm; Owner: gm-dbo
--

COMMENT ON COLUMN gm.schema_revision.version IS 'the version of the script, handled most easily by CVS via "Revision"';


--
-- Name: COLUMN schema_revision.imported; Type: COMMENT; Schema: gm; Owner: gm-dbo
--

COMMENT ON COLUMN gm.schema_revision.imported IS 'when this script was imported, mainly for debugging';


--
-- Name: gm_schema_revision_pk_seq; Type: SEQUENCE; Schema: gm; Owner: gm-dbo
--

CREATE SEQUENCE gm.gm_schema_revision_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE gm.gm_schema_revision_pk_seq OWNER TO "gm-dbo";

--
-- Name: gm_schema_revision_pk_seq; Type: SEQUENCE OWNED BY; Schema: gm; Owner: gm-dbo
--

ALTER SEQUENCE gm.gm_schema_revision_pk_seq OWNED BY gm.schema_revision.pk;


--
-- Name: notifying_tables; Type: TABLE; Schema: gm; Owner: gm-dbo
--

CREATE TABLE gm.notifying_tables (
    pk integer NOT NULL,
    schema_name name DEFAULT 'public'::name NOT NULL,
    table_name name NOT NULL
);


ALTER TABLE gm.notifying_tables OWNER TO "gm-dbo";

--
-- Name: TABLE notifying_tables; Type: COMMENT; Schema: gm; Owner: gm-dbo
--

COMMENT ON TABLE gm.notifying_tables IS 'All tables that want to send standard notifications
	 must be recorded in this table. Notification triggers
	 will be generated automatically for all tables recorded
	 here.';


--
-- Name: notifying_tables_pk_seq; Type: SEQUENCE; Schema: gm; Owner: gm-dbo
--

CREATE SEQUENCE gm.notifying_tables_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE gm.notifying_tables_pk_seq OWNER TO "gm-dbo";

--
-- Name: notifying_tables_pk_seq; Type: SEQUENCE OWNED BY; Schema: gm; Owner: gm-dbo
--

ALTER SEQUENCE gm.notifying_tables_pk_seq OWNED BY gm.notifying_tables.pk;


--
-- Name: curr_lang; Type: TABLE; Schema: i18n; Owner: gm-dbo
--

CREATE TABLE i18n.curr_lang (
    pk integer NOT NULL,
    db_user name DEFAULT "current_user"() NOT NULL,
    lang text NOT NULL,
    CONSTRAINT user_must_exist CHECK ((gm.user_exists(db_user) IS TRUE))
);


ALTER TABLE i18n.curr_lang OWNER TO "gm-dbo";

--
-- Name: TABLE curr_lang; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON TABLE i18n.curr_lang IS 'holds the currently selected per-user default
	 language for fixed strings in the database';


--
-- Name: COLUMN curr_lang.db_user; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON COLUMN i18n.curr_lang.db_user IS 'The database account this language setting applies to.';


--
-- Name: curr_lang_pk_seq; Type: SEQUENCE; Schema: i18n; Owner: gm-dbo
--

CREATE SEQUENCE i18n.curr_lang_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE i18n.curr_lang_pk_seq OWNER TO "gm-dbo";

--
-- Name: curr_lang_pk_seq; Type: SEQUENCE OWNED BY; Schema: i18n; Owner: gm-dbo
--

ALTER SEQUENCE i18n.curr_lang_pk_seq OWNED BY i18n.curr_lang.pk;


--
-- Name: keys; Type: TABLE; Schema: i18n; Owner: gm-dbo
--

CREATE TABLE i18n.keys (
    pk integer NOT NULL,
    orig text NOT NULL
);


ALTER TABLE i18n.keys OWNER TO "gm-dbo";

--
-- Name: TABLE keys; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON TABLE i18n.keys IS 'this table holds all the original strings that need
	 translation so give this to your language teams,
	 the function i18n.i18n() will take care to enter relevant
	 strings into this table, the table table does NOT
	 play any role in runtime translation activity';


--
-- Name: keys_pk_seq; Type: SEQUENCE; Schema: i18n; Owner: gm-dbo
--

CREATE SEQUENCE i18n.keys_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE i18n.keys_pk_seq OWNER TO "gm-dbo";

--
-- Name: keys_pk_seq; Type: SEQUENCE OWNED BY; Schema: i18n; Owner: gm-dbo
--

ALTER SEQUENCE i18n.keys_pk_seq OWNED BY i18n.keys.pk;


--
-- Name: translations; Type: TABLE; Schema: i18n; Owner: gm-dbo
--

CREATE TABLE i18n.translations (
    pk integer NOT NULL,
    lang text NOT NULL,
    orig text NOT NULL,
    trans text NOT NULL,
    CONSTRAINT i18n_translations_sane_trans CHECK ((trans <> orig))
);


ALTER TABLE i18n.translations OWNER TO "gm-dbo";

--
-- Name: TABLE translations; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON TABLE i18n.translations IS 'this table holds all the translated strings';


--
-- Name: COLUMN translations.lang; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON COLUMN i18n.translations.lang IS 'the language (corresponding to i18n.curr_lang for
	 a given user) that this translation belongs to';


--
-- Name: COLUMN translations.orig; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON COLUMN i18n.translations.orig IS 'the original, untranslated string, used as the search key.';


--
-- Name: COLUMN translations.trans; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON COLUMN i18n.translations.trans IS 'the translation of <orig> into <lang>';


--
-- Name: translations_pk_seq; Type: SEQUENCE; Schema: i18n; Owner: gm-dbo
--

CREATE SEQUENCE i18n.translations_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE i18n.translations_pk_seq OWNER TO "gm-dbo";

--
-- Name: translations_pk_seq; Type: SEQUENCE OWNED BY; Schema: i18n; Owner: gm-dbo
--

ALTER SEQUENCE i18n.translations_pk_seq OWNED BY i18n.translations.pk;


--
-- Name: v_missing_translations; Type: VIEW; Schema: i18n; Owner: gm-dbo
--

CREATE VIEW i18n.v_missing_translations AS
 SELECT i_cl.lang,
    i_k.orig,
    public._(i_k.orig, 'en'::text) AS english
   FROM ( SELECT DISTINCT ON (curr_lang.lang) curr_lang.lang
           FROM i18n.curr_lang) i_cl,
    i18n.keys i_k
  WHERE (NOT (i_k.orig IN ( SELECT i_t.orig
           FROM i18n.translations i_t
          WHERE (i_t.lang = i_cl.lang))));


ALTER TABLE i18n.v_missing_translations OWNER TO "gm-dbo";

--
-- Name: VIEW v_missing_translations; Type: COMMENT; Schema: i18n; Owner: gm-dbo
--

COMMENT ON VIEW i18n.v_missing_translations IS 'lists per language which strings are lacking a translation';


--
-- Name: basic_unit; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.basic_unit (
    pk integer NOT NULL,
    name_short text NOT NULL,
    name_long text
);


ALTER TABLE public.basic_unit OWNER TO "gm-dbo";

--
-- Name: TABLE basic_unit; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.basic_unit IS 'basic units are SI units, units derived from them and the Unity';


--
-- Name: basic_unit_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.basic_unit_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.basic_unit_pk_seq OWNER TO "gm-dbo";

--
-- Name: basic_unit_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.basic_unit_pk_seq OWNED BY public.basic_unit.pk;


--
-- Name: form_field_types; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.form_field_types (
    name text,
    pk integer NOT NULL
);


ALTER TABLE public.form_field_types OWNER TO "gm-dbo";

--
-- Name: form_field_types_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.form_field_types_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.form_field_types_pk_seq OWNER TO "gm-dbo";

--
-- Name: form_field_types_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.form_field_types_pk_seq OWNED BY public.form_field_types.pk;


--
-- Name: form_fields; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.form_fields (
    pk integer NOT NULL,
    fk_form integer NOT NULL,
    long_name text NOT NULL,
    template_placeholder text NOT NULL,
    help text,
    fk_type integer NOT NULL,
    param text,
    display_order integer
);


ALTER TABLE public.form_fields OWNER TO "gm-dbo";

--
-- Name: TABLE form_fields; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.form_fields IS 'List of fields for a particular form';


--
-- Name: COLUMN form_fields.long_name; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_fields.long_name IS 'The full name of the form field as presented to the user';


--
-- Name: COLUMN form_fields.template_placeholder; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_fields.template_placeholder IS 'The name of the field as exposed to the form template.
	 In other words, the placeholder in form_defs.template where
	 the value entered into this field ist to be substituted.
	 Must be a valid identifier in the form template''s
	 script language (viz. Python)';


--
-- Name: COLUMN form_fields.help; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_fields.help IS 'longer help text';


--
-- Name: COLUMN form_fields.fk_type; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_fields.fk_type IS 'the field type';


--
-- Name: COLUMN form_fields.param; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_fields.param IS 'a parameter for the field''s behaviour, meaning is type-dependent';


--
-- Name: COLUMN form_fields.display_order; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_fields.display_order IS 'used to *suggest* display order, but client may ignore';


--
-- Name: form_fields_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.form_fields_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.form_fields_pk_seq OWNER TO "gm-dbo";

--
-- Name: form_fields_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.form_fields_pk_seq OWNED BY public.form_fields.pk;


--
-- Name: form_job_queue; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.form_job_queue (
    pk integer NOT NULL,
    fk_form_instance integer NOT NULL,
    form bytea NOT NULL,
    fk_job_target integer NOT NULL,
    submitted_when timestamp with time zone DEFAULT now() NOT NULL,
    fk_submitted_by integer NOT NULL,
    submitted_from text NOT NULL,
    status text DEFAULT 'submitted'::text NOT NULL
);


ALTER TABLE public.form_job_queue OWNER TO "gm-dbo";

--
-- Name: TABLE form_job_queue; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.form_job_queue IS 'Queue table for rendered form instances. Note that
	 the rows in this table will get deleted after processing.
	 This is NOT an archive of form jobs.';


--
-- Name: COLUMN form_job_queue.fk_form_instance; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_job_queue.fk_form_instance IS 'points to the unrendered source instance of the form,
	 useful for recalling submitted jobs for changing';


--
-- Name: COLUMN form_job_queue.form; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_job_queue.form IS 'the rendered form, IOW binary data such as a PDF file';


--
-- Name: COLUMN form_job_queue.fk_job_target; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_job_queue.fk_job_target IS 'points to the job target';


--
-- Name: COLUMN form_job_queue.submitted_when; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_job_queue.submitted_when IS 'when was this form job submitted';


--
-- Name: COLUMN form_job_queue.fk_submitted_by; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_job_queue.fk_submitted_by IS 'who of the staff submitted this form job';


--
-- Name: COLUMN form_job_queue.submitted_from; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_job_queue.submitted_from IS 'the workplace this form job was submitted from';


--
-- Name: COLUMN form_job_queue.status; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_job_queue.status IS 'status of the form job:
	 - submitted: ready for processing
	 - in progress: being processed
	 - removable: fit for removal (either cancelled, timed out or done)
	 - halted: do not process';


--
-- Name: form_job_queue_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.form_job_queue_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.form_job_queue_pk_seq OWNER TO "gm-dbo";

--
-- Name: form_job_queue_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.form_job_queue_pk_seq OWNED BY public.form_job_queue.pk;


--
-- Name: form_job_targets; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.form_job_targets (
    pk integer NOT NULL,
    target text NOT NULL
);


ALTER TABLE public.form_job_targets OWNER TO "gm-dbo";

--
-- Name: TABLE form_job_targets; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.form_job_targets IS 'the form job targets (eg. printers, faxes, smtp servers) in
	 whatever granularity is needed locally, can be used for load
	 balancing/round robin servicing busy queues';


--
-- Name: form_job_targets_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.form_job_targets_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.form_job_targets_pk_seq OWNER TO "gm-dbo";

--
-- Name: form_job_targets_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.form_job_targets_pk_seq OWNED BY public.form_job_targets.pk;


--
-- Name: form_print_defs; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.form_print_defs (
    pk integer NOT NULL,
    fk_form integer NOT NULL,
    fk_papersize integer NOT NULL,
    offset_top integer DEFAULT 0 NOT NULL,
    offset_left integer DEFAULT 0 NOT NULL,
    pages integer DEFAULT 1 NOT NULL,
    printer text NOT NULL,
    tray text NOT NULL,
    manual_feed boolean DEFAULT false NOT NULL,
    papertype text NOT NULL,
    eject_direction character(1) NOT NULL,
    orientation character(1) NOT NULL
);


ALTER TABLE public.form_print_defs OWNER TO "gm-dbo";

--
-- Name: COLUMN form_print_defs.offset_top; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_print_defs.offset_top IS 'in mm - and yes, they do change even within one
	 type of form, but we do not want to change the
	 offset for all the fields in that case';


--
-- Name: COLUMN form_print_defs.papertype; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.form_print_defs.papertype IS 'type of paper such as "watermarked rose",
	 mainly for user interaction on manual_feed==true';


--
-- Name: form_print_defs_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.form_print_defs_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.form_print_defs_pk_seq OWNER TO "gm-dbo";

--
-- Name: form_print_defs_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.form_print_defs_pk_seq OWNED BY public.form_print_defs.pk;


--
-- Name: gm_client_db_match; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.gm_client_db_match (
    pk integer NOT NULL,
    client_type text NOT NULL,
    client_version text NOT NULL,
    db_identity_hash text NOT NULL
);


ALTER TABLE public.gm_client_db_match OWNER TO "gm-dbo";

--
-- Name: TABLE gm_client_db_match; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.gm_client_db_match IS 'allows lookup of whether a given client version
	 can work with a particular database revision';


--
-- Name: COLUMN gm_client_db_match.client_type; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.gm_client_db_match.client_type IS 'the type of client this row refers to';


--
-- Name: COLUMN gm_client_db_match.client_version; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.gm_client_db_match.client_version IS 'the version of the client this row refers to';


--
-- Name: COLUMN gm_client_db_match.db_identity_hash; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.gm_client_db_match.db_identity_hash IS 'the identity_hash of a database revision that
	 the client version can work with';


--
-- Name: gm_client_db_match_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.gm_client_db_match_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.gm_client_db_match_pk_seq OWNER TO "gm-dbo";

--
-- Name: gm_client_db_match_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.gm_client_db_match_pk_seq OWNED BY public.gm_client_db_match.pk;


--
-- Name: housekeeping_todo; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.housekeeping_todo (
    pk integer NOT NULL,
    reported_when timestamp with time zone DEFAULT now() NOT NULL,
    reported_by text DEFAULT "current_user"() NOT NULL,
    reported_to text DEFAULT 'admin'::text NOT NULL,
    problem text NOT NULL,
    solution text,
    context text,
    category text NOT NULL,
    cookie text,
    CONSTRAINT housekeeping_todo_reported_to_check CHECK ((reported_to = ANY (ARRAY['user'::text, 'admin'::text])))
);


ALTER TABLE public.housekeeping_todo OWNER TO "gm-dbo";

--
-- Name: TABLE housekeeping_todo; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.housekeeping_todo IS 'this table stores items that originate in headless processes
	 running in the background but need to be brought to the
	 attention of someone, say, errors that an integrity checker
	 may find';


--
-- Name: COLUMN housekeeping_todo.reported_by; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.housekeeping_todo.reported_by IS 'who or what reported this condition, may be a user or software';


--
-- Name: COLUMN housekeeping_todo.reported_to; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.housekeeping_todo.reported_to IS 'who is this condition reported to, user or admin,
	 used for filtering';


--
-- Name: COLUMN housekeeping_todo.problem; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.housekeeping_todo.problem IS 'a description of the reported condition';


--
-- Name: COLUMN housekeeping_todo.solution; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.housekeeping_todo.solution IS 'a proposed solution to the problem';


--
-- Name: COLUMN housekeeping_todo.context; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.housekeeping_todo.context IS 'specific context for this condition that would
	 make the problem field unnecessary complex and bulky';


--
-- Name: COLUMN housekeeping_todo.category; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.housekeeping_todo.category IS 'a category for the condition, this is used
	 for filtering, too';


--
-- Name: COLUMN housekeeping_todo.cookie; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.housekeeping_todo.cookie IS 'stores arbitrary information related to the condition,
	 mostly used for semantic duplicates detection, eg.
	 do not report on a single problem more than once in
	 subsequent runs of, say, an import script';


--
-- Name: housekeeping_todo_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.housekeeping_todo_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.housekeeping_todo_pk_seq OWNER TO "gm-dbo";

--
-- Name: housekeeping_todo_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.housekeeping_todo_pk_seq OWNED BY public.housekeeping_todo.pk;


--
-- Name: test_norm; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.test_norm (
    pk integer NOT NULL,
    fk_ref_src integer NOT NULL,
    data text NOT NULL,
    comment text
);


ALTER TABLE public.test_norm OWNER TO "gm-dbo";

--
-- Name: TABLE test_norm; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.test_norm IS 'each row defines one set of measurement reference data';


--
-- Name: COLUMN test_norm.fk_ref_src; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.test_norm.fk_ref_src IS 'source this reference data set was taken from';


--
-- Name: COLUMN test_norm.data; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.test_norm.data IS 'the actual reference data in some format,
	 say, XML or like in a *.conf file';


--
-- Name: test_norm_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.test_norm_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.test_norm_pk_seq OWNER TO "gm-dbo";

--
-- Name: test_norm_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.test_norm_pk_seq OWNED BY public.test_norm.pk;


--
-- Name: unit; Type: TABLE; Schema: public; Owner: gm-dbo
--

CREATE TABLE public.unit (
    pk integer NOT NULL,
    fk_basic_unit integer,
    name_short text NOT NULL,
    name_long text,
    factor double precision DEFAULT 1.0 NOT NULL,
    shift double precision DEFAULT 0.0 NOT NULL
);


ALTER TABLE public.unit OWNER TO "gm-dbo";

--
-- Name: TABLE unit; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON TABLE public.unit IS 'units as used in real life';


--
-- Name: COLUMN unit.fk_basic_unit; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.unit.fk_basic_unit IS 'what is the SI-Standard unit for this, e.g. for the unit mg it is kg';


--
-- Name: COLUMN unit.factor; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.unit.factor IS 'what factor the value with this unit has to be multiplied with to get values in the basic_unit';


--
-- Name: COLUMN unit.shift; Type: COMMENT; Schema: public; Owner: gm-dbo
--

COMMENT ON COLUMN public.unit.shift IS 'what has to be added (after multiplying by factor) to a value with this unit to get values in the basic_unit';


--
-- Name: unit_pk_seq; Type: SEQUENCE; Schema: public; Owner: gm-dbo
--

CREATE SEQUENCE public.unit_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.unit_pk_seq OWNER TO "gm-dbo";

--
-- Name: unit_pk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gm-dbo
--

ALTER SEQUENCE public.unit_pk_seq OWNED BY public.unit.pk;


--
-- Name: atc; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.atc (
    pk integer NOT NULL,
    administration_route text
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.atc OWNER TO "gm-dbo";

--
-- Name: TABLE atc; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.atc IS 'holds ATC data';


--
-- Name: COLUMN atc.code; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.atc.code IS 'holds the ATC code';


--
-- Name: COLUMN atc.term; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.atc.term IS 'the name of the drug component';


--
-- Name: COLUMN atc.comment; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.atc.comment IS 'a comment on this ATC';


--
-- Name: COLUMN atc.administration_route; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.atc.administration_route IS 'by what route this drug is to be given';


--
-- Name: atc_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.atc_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.atc_pk_seq OWNER TO "gm-dbo";

--
-- Name: atc_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.atc_pk_seq OWNED BY ref.atc.pk;


--
-- Name: atc_staging; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.atc_staging (
    atc text,
    name text,
    ddd text,
    unit text,
    adro text,
    comment text
);


ALTER TABLE ref.atc_staging OWNER TO "gm-dbo";

--
-- Name: TABLE atc_staging; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.atc_staging IS 'used for importing ATC data';


--
-- Name: auto_hint_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.auto_hint_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.auto_hint_pk_seq OWNER TO "gm-dbo";

--
-- Name: auto_hint_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.auto_hint_pk_seq OWNED BY ref.auto_hint.pk;


--
-- Name: billable_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.billable_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.billable_pk_seq OWNER TO "gm-dbo";

--
-- Name: billable_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.billable_pk_seq OWNED BY ref.billable.pk;


--
-- Name: coda; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.coda (
    pk integer NOT NULL,
    icd10_text text,
    CONSTRAINT chk_ref_coda_sane_icd10_text CHECK ((gm.is_null_or_blank_string(icd10_text) IS FALSE))
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.coda OWNER TO "gm-dbo";

--
-- Name: TABLE coda; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.coda IS 'Holds CodA/CodZ codes.';


--
-- Name: COLUMN coda.term; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.coda.term IS 'The Reason-For-Encounter like meaning of the code.';


--
-- Name: COLUMN coda.icd10_text; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.coda.icd10_text IS 'The text of the corresponding ICD-10 code.';


--
-- Name: coda_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.coda_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.coda_pk_seq OWNER TO "gm-dbo";

--
-- Name: coda_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.coda_pk_seq OWNED BY ref.coda.pk;


--
-- Name: code_thesaurus_root; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.code_thesaurus_root (
    pk_thesaurus integer NOT NULL,
    fk_code integer NOT NULL,
    synonym text,
    CONSTRAINT ref_code_thes_root_sane_synonym CHECK ((gm.is_null_or_blank_string(synonym) IS FALSE))
);


ALTER TABLE ref.code_thesaurus_root OWNER TO "gm-dbo";

--
-- Name: TABLE code_thesaurus_root; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.code_thesaurus_root IS 'Synonyms for coded terms.';


--
-- Name: code_thesaurus_root_pk_thesaurus_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.code_thesaurus_root_pk_thesaurus_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.code_thesaurus_root_pk_thesaurus_seq OWNER TO "gm-dbo";

--
-- Name: code_thesaurus_root_pk_thesaurus_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.code_thesaurus_root_pk_thesaurus_seq OWNED BY ref.code_thesaurus_root.pk_thesaurus;


--
-- Name: coding_system_root_pk_coding_system_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.coding_system_root_pk_coding_system_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.coding_system_root_pk_coding_system_seq OWNER TO "gm-dbo";

--
-- Name: coding_system_root_pk_coding_system_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.coding_system_root_pk_coding_system_seq OWNED BY ref.coding_system_root.pk_coding_system;


--
-- Name: data_source_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.data_source_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.data_source_pk_seq OWNER TO "gm-dbo";

--
-- Name: data_source_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.data_source_pk_seq OWNED BY ref.data_source.pk;


--
-- Name: document_type_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.document_type_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.document_type_pk_seq OWNER TO "gm-dbo";

--
-- Name: document_type_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.document_type_pk_seq OWNED BY ref.document_type.pk;


--
-- Name: dose_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.dose_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.dose_pk_seq OWNER TO "gm-dbo";

--
-- Name: dose_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.dose_pk_seq OWNED BY ref.dose.pk;


--
-- Name: form_types; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.form_types (
    name text NOT NULL,
    pk integer NOT NULL
);


ALTER TABLE ref.form_types OWNER TO "gm-dbo";

--
-- Name: TABLE form_types; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.form_types IS 'types of forms which are available, generally by purpose
	 (radiology, pathology, sick leave, Therapiebericht etc.)';


--
-- Name: form_types_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.form_types_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.form_types_pk_seq OWNER TO "gm-dbo";

--
-- Name: form_types_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.form_types_pk_seq OWNED BY ref.form_types.pk;


--
-- Name: icd10; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.icd10 (
    pk integer NOT NULL,
    star_code text,
    aux_code text,
    CONSTRAINT chk_ref_icd10_sane_aux_code CHECK ((gm.is_null_or_non_empty_string(aux_code) IS TRUE)),
    CONSTRAINT chk_ref_icd10_sane_star_code CHECK ((gm.is_null_or_non_empty_string(star_code) IS TRUE))
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.icd10 OWNER TO "gm-dbo";

--
-- Name: TABLE icd10; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.icd10 IS 'Holds ICD-10 codes.';


--
-- Name: COLUMN icd10.star_code; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icd10.star_code IS 'The star code which needs to be combined with the primary code to define the term.';


--
-- Name: COLUMN icd10.aux_code; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icd10.aux_code IS 'The auxiliary code which needs to be combined with the primary code to define the term.';


--
-- Name: icd10_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.icd10_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.icd10_pk_seq OWNER TO "gm-dbo";

--
-- Name: icd10_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.icd10_pk_seq OWNED BY ref.icd10.pk;


--
-- Name: icd9; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.icd9 (
    pk integer NOT NULL
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.icd9 OWNER TO "gm-dbo";

--
-- Name: TABLE icd9; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.icd9 IS 'Holds ICD-9 codes.';


--
-- Name: icd9_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.icd9_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.icd9_pk_seq OWNER TO "gm-dbo";

--
-- Name: icd9_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.icd9_pk_seq OWNED BY ref.icd9.pk;


--
-- Name: icpc; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.icpc (
    pk integer NOT NULL,
    code_extension text,
    short_description text,
    icd10 text[],
    criteria text,
    inclusions text,
    exclusions text[],
    see_also text[],
    fk_component smallint NOT NULL,
    fk_chapter character(1) NOT NULL,
    CONSTRAINT ref_icpc_sane_code_ext CHECK ((gm.is_null_or_non_empty_string(code_extension) IS TRUE)),
    CONSTRAINT ref_icpc_sane_criteria CHECK ((gm.is_null_or_non_empty_string(criteria) IS TRUE)),
    CONSTRAINT ref_icpc_sane_exclusions CHECK (((exclusions IS NULL) OR (array_length(exclusions, 1) > 0))),
    CONSTRAINT ref_icpc_sane_icd10 CHECK (((icd10 IS NULL) OR (array_length(icd10, 1) > 0))),
    CONSTRAINT ref_icpc_sane_inclusions CHECK ((gm.is_null_or_non_empty_string(inclusions) IS TRUE)),
    CONSTRAINT ref_icpc_sane_see_also CHECK (((see_also IS NULL) OR (array_length(see_also, 1) > 0))),
    CONSTRAINT ref_icpc_sane_term CHECK ((gm.is_null_or_blank_string(term) IS FALSE))
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.icpc OWNER TO "gm-dbo";

--
-- Name: TABLE icpc; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.icpc IS 'This table holds ICPC2 codes along with local extensions.';


--
-- Name: COLUMN icpc.code_extension; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc.code_extension IS 'An extension to the bare code as defined in, say, the Netherlands or Australia.';


--
-- Name: COLUMN icpc.short_description; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc.short_description IS 'A shorter term for this item';


--
-- Name: COLUMN icpc.icd10; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc.icd10 IS 'Array of corresponding ICD-10 codes.';


--
-- Name: COLUMN icpc.criteria; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc.criteria IS 'Criteria to guide in selection of the appropriate code.';


--
-- Name: COLUMN icpc.inclusions; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc.inclusions IS 'Items included under this code.';


--
-- Name: COLUMN icpc.exclusions; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc.exclusions IS 'Items NOT included under this code because there is another code for them.';


--
-- Name: COLUMN icpc.see_also; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc.see_also IS 'See also under these items.';


--
-- Name: icpc_chapter; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.icpc_chapter (
    pk integer NOT NULL,
    chapter character(1) NOT NULL,
    description text,
    CONSTRAINT ref_icpc_chapter_sane_desc CHECK ((gm.is_null_or_blank_string(description) IS FALSE))
);


ALTER TABLE ref.icpc_chapter OWNER TO "gm-dbo";

--
-- Name: TABLE icpc_chapter; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.icpc_chapter IS 'The chapters of the ICPC.';


--
-- Name: icpc_chapter_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.icpc_chapter_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.icpc_chapter_pk_seq OWNER TO "gm-dbo";

--
-- Name: icpc_chapter_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.icpc_chapter_pk_seq OWNED BY ref.icpc_chapter.pk;


--
-- Name: icpc_component; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.icpc_component (
    pk integer NOT NULL,
    component smallint NOT NULL,
    description text,
    typical_soap_cat text[],
    CONSTRAINT ref_icpc_component_sane_desc CHECK ((gm.is_null_or_blank_string(description) IS FALSE))
);


ALTER TABLE ref.icpc_component OWNER TO "gm-dbo";

--
-- Name: TABLE icpc_component; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.icpc_component IS 'The Components of the ICPC chapters.';


--
-- Name: COLUMN icpc_component.typical_soap_cat; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.icpc_component.typical_soap_cat IS 'An array of SOAP categories which codes from this component are typically used for.';


--
-- Name: icpc_component_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.icpc_component_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.icpc_component_pk_seq OWNER TO "gm-dbo";

--
-- Name: icpc_component_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.icpc_component_pk_seq OWNED BY ref.icpc_component.pk;


--
-- Name: icpc_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.icpc_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.icpc_pk_seq OWNER TO "gm-dbo";

--
-- Name: icpc_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.icpc_pk_seq OWNED BY ref.icpc.pk;


--
-- Name: icpc_thesaurus; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.icpc_thesaurus (
    pk integer NOT NULL,
    CONSTRAINT ref_icpc_thes_sane_synonym CHECK ((gm.is_null_or_blank_string(synonym) IS FALSE))
)
INHERITS (ref.code_thesaurus_root);


ALTER TABLE ref.icpc_thesaurus OWNER TO "gm-dbo";

--
-- Name: TABLE icpc_thesaurus; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.icpc_thesaurus IS 'Synonyms for ICPC terms.';


--
-- Name: icpc_thesaurus_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.icpc_thesaurus_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.icpc_thesaurus_pk_seq OWNER TO "gm-dbo";

--
-- Name: icpc_thesaurus_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.icpc_thesaurus_pk_seq OWNED BY ref.icpc_thesaurus.pk;


--
-- Name: keyword_expansion; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.keyword_expansion (
    pk integer NOT NULL,
    fk_staff integer,
    keyword text NOT NULL,
    textual_data text,
    owner text DEFAULT "current_user"() NOT NULL,
    encrypted boolean DEFAULT false NOT NULL,
    binary_data bytea,
    CONSTRAINT keyword_expansion_keyword_check CHECK ((btrim(keyword) <> ''::text)),
    CONSTRAINT ref_kwd_exp_binary_xor_textual CHECK ((((binary_data IS NULL) AND (textual_data IS NOT NULL)) OR ((binary_data IS NOT NULL) AND (textual_data IS NULL)))),
    CONSTRAINT ref_kwd_exp_sane_data CHECK (((binary_data IS NULL) OR (octet_length(binary_data) > 0))),
    CONSTRAINT ref_kwd_exp_sane_keyword CHECK ((gm.is_null_or_blank_string(keyword) IS FALSE)),
    CONSTRAINT ref_kwd_exp_sane_text CHECK ((gm.is_null_or_non_empty_string(textual_data) IS TRUE))
);


ALTER TABLE ref.keyword_expansion OWNER TO "gm-dbo";

--
-- Name: TABLE keyword_expansion; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.keyword_expansion IS 'Arbitrary binary or textual snippets of data. Used as text macros or document "ribbons".';


--
-- Name: COLUMN keyword_expansion.fk_staff; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.keyword_expansion.fk_staff IS 'The provider this expansion applies to.
If NULL: applies to all providers.';


--
-- Name: COLUMN keyword_expansion.keyword; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.keyword_expansion.keyword IS 'A keyword by which to uniquely identify this snippet. Can only exist once per provider.';


--
-- Name: COLUMN keyword_expansion.textual_data; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.keyword_expansion.textual_data IS 'This holds the text of non-binary snippets.';


--
-- Name: COLUMN keyword_expansion.owner; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.keyword_expansion.owner IS 'Who "owns" this text expansion.';


--
-- Name: COLUMN keyword_expansion.encrypted; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.keyword_expansion.encrypted IS 'If true the snippet is encrypted with GnuPG.';


--
-- Name: COLUMN keyword_expansion.binary_data; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.keyword_expansion.binary_data IS 'This holds the binary data of non-textual snippets';


--
-- Name: keyword_expansion_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.keyword_expansion_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.keyword_expansion_pk_seq OWNER TO "gm-dbo";

--
-- Name: keyword_expansion_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.keyword_expansion_pk_seq OWNED BY ref.keyword_expansion.pk;


--
-- Name: lnk_dose2drug_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.lnk_dose2drug_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.lnk_dose2drug_pk_seq OWNER TO "gm-dbo";

--
-- Name: lnk_dose2drug_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.lnk_dose2drug_pk_seq OWNED BY ref.lnk_dose2drug.pk;


--
-- Name: lnk_loinc2substance_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.lnk_loinc2substance_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.lnk_loinc2substance_pk_seq OWNER TO "gm-dbo";

--
-- Name: lnk_loinc2substance_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.lnk_loinc2substance_pk_seq OWNED BY ref.lnk_loinc2substance.pk;


--
-- Name: loinc; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.loinc (
    pk integer NOT NULL,
    component text,
    property text,
    time_aspect text,
    system text,
    scale_type text,
    method_type text,
    related_names_1_old text,
    grouping_class text,
    loinc_internal_source text,
    dt_last_change text,
    change_type text,
    answer_list text,
    code_status text,
    maps_to text,
    scope text,
    normal_range text,
    ipcc_units text,
    reference text,
    exact_component_synonym text,
    molar_mass text,
    grouping_class_type smallint,
    formula text,
    species text,
    example_answers text,
    acs_synonyms text,
    base_name text,
    final text,
    naa_ccr_id text,
    code_table text,
    is_set_root boolean,
    panel_elements text,
    survey_question_text text,
    survey_question_source text,
    units_required text,
    submitted_units text,
    related_names_2 text,
    short_name text,
    order_obs text,
    cdisc_common_tests text,
    hl7_field_subfield_id text,
    external_copyright_notice text,
    example_units text,
    inpc_percentage text,
    long_common_name text
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.loinc OWNER TO "gm-dbo";

--
-- Name: TABLE loinc; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.loinc IS 'holds LOINC codes';


--
-- Name: COLUMN loinc.code; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.loinc.code IS 'holds LOINC_NUM';


--
-- Name: COLUMN loinc.term; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.loinc.term IS 'holds either long_common_name or a ":".join of .component to .method_type';


--
-- Name: COLUMN loinc.fk_data_source; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.loinc.fk_data_source IS 'points to a particular data source which in turn holds the version';


--
-- Name: loinc_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.loinc_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.loinc_pk_seq OWNER TO "gm-dbo";

--
-- Name: loinc_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.loinc_pk_seq OWNED BY ref.loinc.pk;


--
-- Name: ops; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.ops (
    pk integer NOT NULL,
    second_code text,
    requires_laterality boolean
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.ops OWNER TO "gm-dbo";

--
-- Name: TABLE ops; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.ops IS 'Holds OPS (German ICPM-CM) codes.';


--
-- Name: ops_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.ops_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.ops_pk_seq OWNER TO "gm-dbo";

--
-- Name: ops_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.ops_pk_seq OWNED BY ref.ops.pk;


--
-- Name: other_code; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.other_code (
    pk integer NOT NULL
)
INHERITS (ref.coding_system_root);


ALTER TABLE ref.other_code OWNER TO "gm-dbo";

--
-- Name: TABLE other_code; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.other_code IS 'Holds codes from "other" coding systems for which no specific tables exist just yet.';


--
-- Name: other_code_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.other_code_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.other_code_pk_seq OWNER TO "gm-dbo";

--
-- Name: other_code_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.other_code_pk_seq OWNED BY ref.other_code.pk;


--
-- Name: papersizes; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.papersizes (
    pk integer NOT NULL,
    name text NOT NULL,
    size point NOT NULL
);


ALTER TABLE ref.papersizes OWNER TO "gm-dbo";

--
-- Name: COLUMN papersizes.size; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.papersizes.size IS '(cm, cm)';


--
-- Name: papersizes_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.papersizes_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.papersizes_pk_seq OWNER TO "gm-dbo";

--
-- Name: papersizes_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.papersizes_pk_seq OWNED BY ref.papersizes.pk;


--
-- Name: paperwork_templates; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.paperwork_templates (
    pk integer NOT NULL,
    fk_template_type integer NOT NULL,
    instance_type text,
    name_short text NOT NULL,
    name_long text NOT NULL,
    external_version text NOT NULL,
    gnumed_revision double precision,
    engine text DEFAULT 'O'::text NOT NULL,
    in_use boolean DEFAULT true NOT NULL,
    filename text,
    data bytea,
    edit_after_substitution boolean DEFAULT true NOT NULL,
    CONSTRAINT ref_templates_engine_range CHECK ((engine = ANY (ARRAY['T'::text, 'L'::text, 'H'::text, 'O'::text, 'I'::text, 'G'::text, 'P'::text, 'A'::text, 'X'::text, 'S'::text])))
)
INHERITS (audit.audit_fields);


ALTER TABLE ref.paperwork_templates OWNER TO "gm-dbo";

--
-- Name: TABLE paperwork_templates; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.paperwork_templates IS 'form and letter template definitions';


--
-- Name: COLUMN paperwork_templates.instance_type; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.instance_type IS 'default document type to store documents generated from
	 this form under, note that this may generate rows in
	 blobs.doc_type if set to a non-existant document type';


--
-- Name: COLUMN paperwork_templates.name_short; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.name_short IS 'a short name for use in a GUI or some such';


--
-- Name: COLUMN paperwork_templates.name_long; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.name_long IS 'a long name unambigously describing the form';


--
-- Name: COLUMN paperwork_templates.gnumed_revision; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.gnumed_revision IS 'GnuMed internal form def version, may
	 occur if we rolled out a faulty form def';


--
-- Name: COLUMN paperwork_templates.engine; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.engine IS 'the business layer forms engine used to process this form,
	currently:
	- T: plain text (generic postprocessing)
	- L: LaTeX
	- H: HTML
	- O: OpenOffice
	- I: image editor (visual progress notes)
	- G: gnuplot scripts (test results graphing)
	- P: PDF form (FDF based)
	- A: AbiWord
	- X: Xe(La)TeX
	- S: XSLT';


--
-- Name: COLUMN paperwork_templates.in_use; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.in_use IS 'whether this template is currently actively
	 used in a given practice';


--
-- Name: COLUMN paperwork_templates.filename; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.filename IS 'the filename from when the template data was imported if applicable,
	 used by some engines (such as OOo) to differentiate what to do
	 with certain files, such as *.ott vs. *.ods, GNUmed uses it
	 to derive a file extension when exporting the template data';


--
-- Name: COLUMN paperwork_templates.data; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.data IS 'the template complete with placeholders in
	 the format accepted by the engine defined in
	 ref.paperwork_templates.engine';


--
-- Name: COLUMN paperwork_templates.edit_after_substitution; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON COLUMN ref.paperwork_templates.edit_after_substitution IS 'Whether to offer last-minute, manual, generic editing inbetween placeholder substitution and final output generation.';


--
-- Name: paperwork_templates_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.paperwork_templates_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.paperwork_templates_pk_seq OWNER TO "gm-dbo";

--
-- Name: paperwork_templates_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.paperwork_templates_pk_seq OWNED BY ref.paperwork_templates.pk;


--
-- Name: substance_brand_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.substance_brand_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.substance_brand_pk_seq OWNER TO "gm-dbo";

--
-- Name: substance_brand_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.substance_brand_pk_seq OWNED BY ref.drug_product.pk;


--
-- Name: substance_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.substance_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.substance_pk_seq OWNER TO "gm-dbo";

--
-- Name: substance_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.substance_pk_seq OWNED BY ref.substance.pk;


--
-- Name: tag_image_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.tag_image_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.tag_image_pk_seq OWNER TO "gm-dbo";

--
-- Name: tag_image_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.tag_image_pk_seq OWNED BY ref.tag_image.pk;


--
-- Name: v_atc; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_atc AS
 SELECT a.pk AS pk_atc,
    a.code AS atc,
    a.term,
    a.administration_route,
    a.comment,
    (octet_length(a.code) < 7) AS is_group_code,
    (octet_length(a.code) - (octet_length(a.code) / 3)) AS atc_level,
    rds.name_long,
    rds.name_short,
    rds.version,
    rds.lang,
    a.pk_coding_system,
    a.fk_data_source AS pk_data_source
   FROM (ref.atc a
     JOIN ref.data_source rds ON ((rds.pk = a.fk_data_source)));


ALTER TABLE ref.v_atc OWNER TO "gm-dbo";

--
-- Name: v_billables; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_billables AS
 SELECT r_b.pk AS pk_billable,
    r_b.code AS billable_code,
    r_b.term AS billable_description,
    r_b.amount AS raw_amount,
    (r_b.amount + (r_b.amount * r_b.vat_multiplier)) AS amount_with_vat,
    r_b.currency,
    r_b.comment,
    r_b.vat_multiplier,
    r_b.active,
    r_b.discountable,
    r_ds.name_long AS catalog_long,
    r_ds.name_short AS catalog_short,
    r_ds.version AS catalog_version,
    r_ds.lang AS catalog_language,
    r_b.fk_data_source AS pk_data_source,
    r_b.pk_coding_system AS pk_coding_system_root,
    r_b.xmin AS xmin_billable
   FROM (ref.billable r_b
     LEFT JOIN ref.data_source r_ds ON ((r_b.fk_data_source = r_ds.pk)));


ALTER TABLE ref.v_billables OWNER TO "gm-dbo";

--
-- Name: v_coded_terms; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_coded_terms AS
 SELECT r_csr.code,
    r_csr.term,
    r_ds.name_short AS coding_system,
    r_ds.name_long AS coding_system_long,
    r_ds.version,
    r_ds.lang,
    r_csr.pk_coding_system AS pk_generic_code
   FROM (ref.coding_system_root r_csr
     JOIN ref.data_source r_ds ON ((r_csr.fk_data_source = r_ds.pk)))
UNION
 SELECT ri.code,
    r_it.synonym AS term,
    r_ds.name_short AS coding_system,
    r_ds.name_long AS coding_system_long,
    r_ds.version,
    r_ds.lang,
    r_it.fk_code AS pk_generic_code
   FROM ((ref.icpc_thesaurus r_it
     LEFT JOIN ref.icpc ri ON ((r_it.fk_code = ri.pk_coding_system)))
     LEFT JOIN ref.data_source r_ds ON ((ri.fk_data_source = r_ds.pk)));


ALTER TABLE ref.v_coded_terms OWNER TO "gm-dbo";

--
-- Name: VIEW v_coded_terms; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_coded_terms IS 'This view aggregates all official (reference) terms, including "official" synonyms, for which a corresponding code is known to the system.';


--
-- Name: v_substances; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_substances AS
 SELECT r_s.pk AS pk_substance,
    r_s.description AS substance,
    r_s.intake_instructions,
    r_s.atc,
    ARRAY( SELECT row_to_json(loinc_row.*) AS row_to_json
           FROM ( SELECT r_ll2s.loinc,
                    r_ll2s.comment,
                    date_part('epoch'::text, r_ll2s.max_age) AS max_age_in_secs,
                    (r_ll2s.max_age)::text AS max_age_str
                   FROM ref.lnk_loinc2substance r_ll2s
                  WHERE (r_ll2s.fk_substance = r_s.pk)) loinc_row) AS loincs,
    r_s.xmin AS xmin_substance
   FROM ref.substance r_s;


ALTER TABLE ref.v_substances OWNER TO "gm-dbo";

--
-- Name: v_substance_doses; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_substance_doses AS
 SELECT r_d.pk AS pk_dose,
    r_vs.substance,
    r_d.amount,
    r_d.unit,
    r_d.dose_unit,
    r_vs.intake_instructions,
    r_vs.atc AS atc_substance,
    r_vs.loincs,
    r_vs.pk_substance,
    r_d.xmin AS xmin_dose
   FROM (ref.dose r_d
     JOIN ref.v_substances r_vs ON ((r_d.fk_substance = r_vs.pk_substance)));


ALTER TABLE ref.v_substance_doses OWNER TO "gm-dbo";

--
-- Name: v_drug_components; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_drug_components AS
 SELECT r_ld2d.pk AS pk_component,
    r_dp.description AS product,
    r_vsd.substance,
    r_vsd.amount,
    r_vsd.unit,
    r_vsd.dose_unit,
    r_dp.preparation,
    public._(r_dp.preparation) AS l10n_preparation,
    r_vsd.intake_instructions,
    r_vsd.loincs,
    r_vsd.atc_substance,
    r_dp.atc_code AS atc_drug,
    r_dp.external_code,
    r_dp.external_code_type,
    r_dp.is_fake AS is_fake_product,
    (EXISTS ( SELECT 1
           FROM clin.substance_intake c_si
          WHERE (c_si.fk_drug_component = r_ld2d.pk)
         LIMIT 1)) AS is_in_use,
    r_dp.pk AS pk_drug_product,
    r_vsd.pk_dose,
    r_vsd.pk_substance,
    r_dp.fk_data_source AS pk_data_source,
    r_ld2d.xmin AS xmin_lnk_dose2drug
   FROM ((ref.lnk_dose2drug r_ld2d
     JOIN ref.drug_product r_dp ON ((r_ld2d.fk_drug_product = r_dp.pk)))
     JOIN ref.v_substance_doses r_vsd ON ((r_ld2d.fk_dose = r_vsd.pk_dose)));


ALTER TABLE ref.v_drug_components OWNER TO "gm-dbo";

--
-- Name: v_drug_products; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_drug_products AS
 SELECT r_dp.pk AS pk_drug_product,
    r_dp.description AS product,
    r_dp.preparation,
    public._(r_dp.preparation) AS l10n_preparation,
    r_dp.atc_code AS atc,
    r_dp.external_code,
    r_dp.external_code_type,
    r_dp.is_fake AS is_fake_product,
    (EXISTS ( SELECT 1
           FROM ref.vaccine c_v
          WHERE (c_v.fk_drug_product = r_dp.pk))) AS is_vaccine,
    ARRAY( SELECT row_to_json(component_row.*) AS row_to_json
           FROM ( SELECT r_vsd.substance,
                    r_vsd.amount,
                    r_vsd.unit,
                    r_vsd.dose_unit,
                    r_vsd.intake_instructions,
                    r_vsd.loincs,
                    r_vsd.atc_substance,
                    r_ld2d.pk AS pk_component,
                    r_vsd.pk_dose,
                    r_vsd.pk_substance
                   FROM (ref.lnk_dose2drug r_ld2d
                     JOIN ref.v_substance_doses r_vsd ON ((r_ld2d.fk_dose = r_vsd.pk_dose)))
                  WHERE (r_ld2d.fk_drug_product = r_dp.pk)) component_row) AS components,
    r_dp.fk_data_source AS pk_data_source,
    r_dp.xmin AS xmin_drug_product
   FROM ref.drug_product r_dp;


ALTER TABLE ref.v_drug_products OWNER TO "gm-dbo";

--
-- Name: v_generic_codes; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_generic_codes AS
 SELECT r_csr.pk_coding_system AS pk_generic_code,
    r_csr.code,
    r_csr.term,
    r_ds.name_long,
    r_ds.name_short,
    r_ds.version,
    r_ds.lang,
    (r_csr.tableoid)::regclass AS code_table,
    r_csr.fk_data_source AS pk_data_source
   FROM (ref.coding_system_root r_csr
     JOIN ref.data_source r_ds ON ((r_ds.pk = r_csr.fk_data_source)));


ALTER TABLE ref.v_generic_codes OWNER TO "gm-dbo";

--
-- Name: VIEW v_generic_codes; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_generic_codes IS 'Denormalized generic codes.';


--
-- Name: v_icpc; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_icpc AS
 SELECT ri.code,
    ri.code_extension,
    (ri.code || COALESCE(ri.code_extension, ''::text)) AS extended_code,
    ri.term,
    ri.short_description,
    ri.fk_chapter AS code_chapter,
    rich.description AS chapter,
    public._(rich.description) AS l10n_chapter,
    ri.fk_component AS code_component,
    rico.description AS component,
    public._(rico.description) AS l10n_component,
    rico.typical_soap_cat,
    ri.icd10,
    ri.criteria,
    ri.inclusions,
    ri.exclusions,
    ri.see_also,
    ri.comment,
    rds.name_short,
    rds.name_long,
    rds.version,
    rds.lang,
    ri.pk AS pk_icpc,
    ri.fk_data_source AS pk_data_source
   FROM (((ref.icpc ri
     JOIN ref.data_source rds ON ((ri.fk_data_source = rds.pk)))
     JOIN ref.icpc_chapter rich ON ((ri.fk_chapter = rich.chapter)))
     JOIN ref.icpc_component rico ON ((ri.fk_component = rico.component)));


ALTER TABLE ref.v_icpc OWNER TO "gm-dbo";

--
-- Name: VIEW v_icpc; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_icpc IS 'View over denormalized ICPC2 data.';


--
-- Name: v_icpc_thesaurus; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_icpc_thesaurus AS
 SELECT rit.pk AS pk_icpc_thesaurus,
    ri.code,
    ri.term,
    rit.synonym,
    rit.pk_thesaurus,
    rit.fk_code AS pk_coding_system,
    ri.pk AS pk_icpc
   FROM (ref.icpc_thesaurus rit
     JOIN ref.icpc ri ON ((rit.fk_code = ri.pk_coding_system)));


ALTER TABLE ref.v_icpc_thesaurus OWNER TO "gm-dbo";

--
-- Name: VIEW v_icpc_thesaurus; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_icpc_thesaurus IS 'View over denormalized ICPC2 thesaurus.';


--
-- Name: vacc_route; Type: TABLE; Schema: ref; Owner: gm-dbo
--

CREATE TABLE ref.vacc_route (
    id integer NOT NULL,
    abbreviation text NOT NULL,
    description text NOT NULL
)
INHERITS (audit.audit_fields);


ALTER TABLE ref.vacc_route OWNER TO "gm-dbo";

--
-- Name: TABLE vacc_route; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON TABLE ref.vacc_route IS 'definition of route via which vaccine is given,
	 currently i.m. and p.o. only but may include
	 "via genetically engineered food" etc in the
	 future';


--
-- Name: v_indications4vaccine; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_indications4vaccine AS
 SELECT r_v.pk AS pk_vaccine,
    r_dp.description AS vaccine,
    r_dp.preparation,
    public._(r_dp.preparation) AS l10n_preparation,
    r_dp.atc_code,
    r_dp.is_fake AS is_fake_vaccine,
    r_vr.abbreviation AS route_abbreviation,
    r_vr.description AS route_description,
    r_v.is_live,
    r_v.min_age,
    r_v.max_age,
    r_v.comment,
    public._((r_s.atc || '-target'::text), 'en'::text) AS indication,
        CASE
            WHEN (public._((r_s.atc || '-target'::text)) = (r_s.atc || '-target'::text)) THEN public._((r_s.atc || '-target'::text), 'en'::text)
            ELSE public._((r_s.atc || '-target'::text))
        END AS l10n_indication,
    r_dp.external_code,
    r_dp.external_code_type,
    ARRAY( SELECT row_to_json(indication_row.*) AS row_to_json
           FROM ( SELECT public._((r_s_1.atc || '-target'::text), 'en'::text) AS indication,
                        CASE
                            WHEN (public._((r_s_1.atc || '-target'::text)) = (r_s_1.atc || '-target'::text)) THEN public._((r_s_1.atc || '-target'::text), 'en'::text)
                            ELSE public._((r_s_1.atc || '-target'::text))
                        END AS l10n_indication,
                    r_s_1.atc AS atc_indication
                   FROM ((ref.lnk_dose2drug r_ld2d_1
                     JOIN ref.dose r_d_1 ON ((r_d_1.pk = r_ld2d_1.fk_dose)))
                     JOIN ref.substance r_s_1 ON ((r_d_1.fk_substance = r_s_1.pk)))
                  WHERE (r_ld2d_1.fk_drug_product = r_dp.pk)) indication_row) AS indications,
    r_v.id_route AS pk_route,
    r_v.fk_drug_product AS pk_drug_product,
    r_dp.fk_data_source AS pk_data_source,
    r_s.atc AS atc_indication,
    r_v.xmin AS xmin_vaccine
   FROM (((((ref.vaccine r_v
     LEFT JOIN ref.vacc_route r_vr ON ((r_vr.id = r_v.id_route)))
     JOIN ref.drug_product r_dp ON ((r_dp.pk = r_v.fk_drug_product)))
     JOIN ref.lnk_dose2drug r_ld2d ON ((r_ld2d.fk_drug_product = r_dp.pk)))
     JOIN ref.dose r_d ON ((r_d.pk = r_ld2d.fk_dose)))
     JOIN ref.substance r_s ON ((r_d.fk_substance = r_s.pk)));


ALTER TABLE ref.v_indications4vaccine OWNER TO "gm-dbo";

--
-- Name: VIEW v_indications4vaccine; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_indications4vaccine IS 'Denormalizes indications per vaccine.';


--
-- Name: v_keyword_expansions; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_keyword_expansions AS
 SELECT r_ke.pk AS pk_expansion,
    r_ke.fk_staff AS pk_staff,
    r_ke.keyword,
    r_ke.textual_data AS expansion,
    r_ke.encrypted AS is_encrypted,
    (r_ke.binary_data IS NULL) AS is_textual,
    octet_length(r_ke.binary_data) AS data_size,
    (r_ke.fk_staff IS NULL) AS public_expansion,
    (r_ke.fk_staff IS NOT NULL) AS private_expansion,
    r_ke.owner,
    r_ke.xmin AS xmin_expansion
   FROM ref.keyword_expansion r_ke;


ALTER TABLE ref.v_keyword_expansions OWNER TO "gm-dbo";

--
-- Name: VIEW v_keyword_expansions; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_keyword_expansions IS 'Just a slightly more convenient view over expansions.';


--
-- Name: v_lnk_loincs2substances; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_lnk_loincs2substances AS
 SELECT r_ll2s.pk AS pk_lnk_loinc2substance,
    r_s.description AS substance,
    r_ll2s.loinc,
    r_ll2s.max_age,
    r_ll2s.comment,
    r_s.atc,
    r_s.pk AS pk_substance,
    r_ll2s.xmin AS xmin_lnk_loinc2substance
   FROM (ref.substance r_s
     JOIN ref.lnk_loinc2substance r_ll2s ON ((r_ll2s.fk_substance = r_s.pk)));


ALTER TABLE ref.v_lnk_loincs2substances OWNER TO "gm-dbo";

--
-- Name: v_paperwork_templates; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_paperwork_templates AS
 SELECT r_pt.pk AS pk_paperwork_template,
    r_pt.name_short,
    r_pt.name_long,
    r_pt.external_version,
    r_pt.gnumed_revision,
    ( SELECT r_ft.name
           FROM ref.form_types r_ft
          WHERE (r_ft.pk = r_pt.fk_template_type)) AS template_type,
    ( SELECT public._(r_ft.name) AS _
           FROM ref.form_types r_ft
          WHERE (r_ft.pk = r_pt.fk_template_type)) AS l10n_template_type,
    COALESCE(r_pt.instance_type, ( SELECT r_ft.name
           FROM ref.form_types r_ft
          WHERE (r_ft.pk = r_pt.fk_template_type))) AS instance_type,
    COALESCE(public._(r_pt.instance_type), ( SELECT public._(r_ft.name) AS _
           FROM ref.form_types r_ft
          WHERE (r_ft.pk = r_pt.fk_template_type))) AS l10n_instance_type,
    r_pt.engine,
    r_pt.in_use,
    r_pt.edit_after_substitution,
    r_pt.filename,
        CASE
            WHEN (r_pt.data IS NOT NULL) THEN true
            ELSE false
        END AS has_template_data,
    r_pt.modified_when AS last_modified,
    COALESCE(( SELECT d_s.short_alias
           FROM dem.staff d_s
          WHERE (d_s.db_user = r_pt.modified_by)), (('<'::text || (r_pt.modified_by)::text) || '>'::text)) AS modified_by,
    r_pt.fk_template_type AS pk_template_type,
    r_pt.xmin AS xmin_paperwork_template
   FROM ref.paperwork_templates r_pt;


ALTER TABLE ref.v_paperwork_templates OWNER TO "gm-dbo";

--
-- Name: v_tag_images_no_data; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_tag_images_no_data AS
 SELECT rti.pk AS pk_tag_image,
    rti.description,
    public._(rti.description) AS l10n_description,
    rti.filename,
    octet_length(COALESCE(rti.image, '\x'::bytea)) AS size,
    (EXISTS ( SELECT 1
           FROM dem.identity_tag dit
          WHERE (dit.fk_tag = rti.pk)
         LIMIT 1)) AS is_in_use,
    rti.xmin AS xmin_tag_image
   FROM ref.tag_image rti;


ALTER TABLE ref.v_tag_images_no_data OWNER TO "gm-dbo";

--
-- Name: v_vaccines; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_vaccines AS
 SELECT r_v.pk AS pk_vaccine,
    r_dp.description AS vaccine,
    r_dp.preparation,
    public._(r_dp.preparation) AS l10n_preparation,
    r_dp.atc_code,
    r_dp.is_fake AS is_fake_vaccine,
    r_vr.abbreviation AS route_abbreviation,
    r_vr.description AS route_description,
    r_v.is_live,
    r_v.min_age,
    r_v.max_age,
    r_v.comment,
    ARRAY( SELECT row_to_json(indication_row.*) AS row_to_json
           FROM ( SELECT public._((r_s.atc || '-target'::text), 'en'::text) AS indication,
                        CASE
                            WHEN (public._((r_s.atc || '-target'::text)) = (r_s.atc || '-target'::text)) THEN public._((r_s.atc || '-target'::text), 'en'::text)
                            ELSE public._((r_s.atc || '-target'::text))
                        END AS l10n_indication,
                    r_s.atc AS atc_indication
                   FROM ((ref.lnk_dose2drug r_ld2d
                     JOIN ref.dose r_d ON ((r_d.pk = r_ld2d.fk_dose)))
                     JOIN ref.substance r_s ON ((r_d.fk_substance = r_s.pk)))
                  WHERE (r_ld2d.fk_drug_product = r_dp.pk)) indication_row) AS indications,
    r_dp.external_code,
    r_dp.external_code_type,
    r_v.id_route AS pk_route,
    r_v.fk_drug_product AS pk_drug_product,
    r_dp.fk_data_source AS pk_data_source,
    r_v.xmin AS xmin_vaccine
   FROM ((ref.vaccine r_v
     JOIN ref.drug_product r_dp ON ((r_v.fk_drug_product = r_dp.pk)))
     LEFT JOIN ref.vacc_route r_vr ON ((r_v.id_route = r_vr.id)));


ALTER TABLE ref.v_vaccines OWNER TO "gm-dbo";

--
-- Name: VIEW v_vaccines; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_vaccines IS 'A list of vaccines.';


--
-- Name: v_your_keyword_expansions; Type: VIEW; Schema: ref; Owner: gm-dbo
--

CREATE VIEW ref.v_your_keyword_expansions AS
 SELECT DISTINCT ON (union_result.keyword) union_result.pk_expansion,
    union_result.pk_staff,
    union_result.keyword,
    union_result.expansion,
    union_result.is_encrypted,
    union_result.is_textual,
    union_result.data_size,
    union_result.public_expansion,
    union_result.private_expansion,
    union_result.owner,
    union_result.xmin_expansion
   FROM ( SELECT r_ke.pk AS pk_expansion,
            r_ke.fk_staff AS pk_staff,
            r_ke.keyword,
            r_ke.textual_data AS expansion,
            r_ke.encrypted AS is_encrypted,
            (r_ke.binary_data IS NULL) AS is_textual,
            octet_length(r_ke.binary_data) AS data_size,
            false AS public_expansion,
            true AS private_expansion,
            r_ke.owner,
            r_ke.xmin AS xmin_expansion
           FROM ref.keyword_expansion r_ke
          WHERE (r_ke.fk_staff = ( SELECT staff.pk
                   FROM dem.staff
                  WHERE (staff.db_user = "current_user"())))
        UNION ALL
         SELECT r_ke.pk AS pk_expansion,
            r_ke.fk_staff AS pk_staff,
            r_ke.keyword,
            r_ke.textual_data AS expansion,
            r_ke.encrypted AS is_encrypted,
            (r_ke.binary_data IS NULL) AS is_textual,
            octet_length(r_ke.binary_data) AS data_size,
            true AS public_expansion,
            false AS private_expansion,
            r_ke.owner,
            r_ke.xmin AS xmin_expansion
           FROM ref.keyword_expansion r_ke
          WHERE (r_ke.fk_staff IS NULL)
  ORDER BY 9 DESC) union_result;


ALTER TABLE ref.v_your_keyword_expansions OWNER TO "gm-dbo";

--
-- Name: VIEW v_your_keyword_expansions; Type: COMMENT; Schema: ref; Owner: gm-dbo
--

COMMENT ON VIEW ref.v_your_keyword_expansions IS 'View over the text expansions relevant to the current user:
a private expansion set up for the current user overrides a
public expansion of the same keyword.';


--
-- Name: vacc_route_id_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.vacc_route_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.vacc_route_id_seq OWNER TO "gm-dbo";

--
-- Name: vacc_route_id_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.vacc_route_id_seq OWNED BY ref.vacc_route.id;


--
-- Name: vaccine_pk_seq; Type: SEQUENCE; Schema: ref; Owner: gm-dbo
--

CREATE SEQUENCE ref.vaccine_pk_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ref.vaccine_pk_seq OWNER TO "gm-dbo";

--
-- Name: vaccine_pk_seq; Type: SEQUENCE OWNED BY; Schema: ref; Owner: gm-dbo
--

ALTER SEQUENCE ref.vaccine_pk_seq OWNED BY ref.vaccine.pk;


--
-- Name: lab_request; Type: TABLE; Schema: staging; Owner: gm-dbo
--

CREATE TABLE staging.lab_request (
    pk_audit integer DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass) NOT NULL,
    row_version integer DEFAULT 0 NOT NULL,
    modified_when timestamp with time zone DEFAULT now() NOT NULL,
    modified_by name DEFAULT "current_user"() NOT NULL,
    pk_item integer DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass) NOT NULL,
    clin_when timestamp with time zone DEFAULT now() NOT NULL,
    fk_episode integer NOT NULL,
    narrative text,
    soap_cat text DEFAULT 'p'::text,
    pk integer DEFAULT nextval('clin.lab_request_pk_seq'::regclass) NOT NULL,
    fk_test_org integer NOT NULL,
    request_id text NOT NULL,
    fk_requestor integer,
    lab_request_id text,
    lab_rxd_when timestamp with time zone,
    results_reported_when timestamp with time zone,
    request_status text NOT NULL,
    is_pending boolean DEFAULT true NOT NULL,
    diagnostic_service_section text,
    ordered_service text,
    fk_incoming_data_unmatched integer NOT NULL,
    CONSTRAINT clin_root_item_soap_cat_check CHECK (((soap_cat IS NULL) OR (lower(soap_cat) = ANY (ARRAY['s'::text, 'o'::text, 'a'::text, 'p'::text])))),
    CONSTRAINT lab_request_request_id_check CHECK ((btrim(request_id) <> ''::text)),
    CONSTRAINT lab_request_request_status_check CHECK ((request_status = ANY (ARRAY['pending'::text, 'preliminary'::text, 'partial'::text, 'final'::text]))),
    CONSTRAINT staging_request_sane_request_id CHECK ((gm.is_null_or_blank_string(request_id) IS FALSE)),
    CONSTRAINT staging_request_sane_status CHECK ((request_status = ANY (ARRAY['pending'::text, 'preliminary'::text, 'partial'::text, 'final'::text])))
);


ALTER TABLE staging.lab_request OWNER TO "gm-dbo";

--
-- Name: TABLE lab_request; Type: COMMENT; Schema: staging; Owner: gm-dbo
--

COMMENT ON TABLE staging.lab_request IS 'Used to stage lab requests (from hl7 files, currently).';


--
-- Name: lnk_vacc_ind2subst_dose; Type: TABLE; Schema: staging; Owner: gm-dbo
--

CREATE UNLOGGED TABLE staging.lnk_vacc_ind2subst_dose (
    fk_indication integer NOT NULL,
    fk_dose integer NOT NULL,
    is_live boolean DEFAULT false NOT NULL
);


ALTER TABLE staging.lnk_vacc_ind2subst_dose OWNER TO "gm-dbo";

--
-- Name: loinc_staging; Type: TABLE; Schema: staging; Owner: gm-dbo
--

CREATE TABLE staging.loinc_staging (
    loinc_num text,
    component text,
    property text,
    time_aspect text,
    system text,
    scale_type text,
    method_type text,
    related_names_1_old text,
    class text,
    source text,
    dt_last_change text,
    change_type text,
    comments text,
    answer_list text,
    status text,
    map_to text,
    scope text,
    normal_range text,
    ipcc_units text,
    reference text,
    exact_component_synonym text,
    molar_mass text,
    class_type text,
    formula text,
    species text,
    example_answers text,
    acs_synonyms text,
    base_name text,
    final text,
    naa_ccr_id text,
    code_table text,
    is_set_root text,
    panel_elements text,
    survey_question_text text,
    survey_question_source text,
    units_required text,
    submitted_units text,
    related_names_2 text,
    short_name text,
    order_obs text,
    cdisc_common_tests text,
    hl7_field_subfield_id text,
    external_copyright_notice text,
    example_units text,
    inpc_percentage text,
    long_common_name text
);


ALTER TABLE staging.loinc_staging OWNER TO "gm-dbo";

--
-- Name: TABLE loinc_staging; Type: COMMENT; Schema: staging; Owner: gm-dbo
--

COMMENT ON TABLE staging.loinc_staging IS 'used for importing LOINC data, columns correspond 1:1 with the LOINC CSV file fields';


--
-- Name: test_result; Type: TABLE; Schema: staging; Owner: gm-dbo
--

CREATE TABLE staging.test_result (
    pk_audit integer DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass) NOT NULL,
    row_version integer DEFAULT 0 NOT NULL,
    modified_when timestamp with time zone DEFAULT now() NOT NULL,
    modified_by name DEFAULT "current_user"() NOT NULL,
    pk_item integer DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass) NOT NULL,
    clin_when timestamp with time zone DEFAULT now() NOT NULL,
    fk_episode integer NOT NULL,
    narrative text,
    soap_cat text DEFAULT 'p'::text,
    pk integer DEFAULT nextval('clin.test_result_pk_seq'::regclass) NOT NULL,
    fk_type integer NOT NULL,
    val_num numeric,
    val_alpha text,
    val_unit text,
    val_normal_min numeric,
    val_normal_max numeric,
    val_normal_range text,
    val_target_min numeric,
    val_target_max numeric,
    val_target_range text,
    abnormality_indicator text,
    norm_ref_group text,
    note_test_org text,
    material text,
    material_detail text,
    fk_intended_reviewer integer NOT NULL,
    fk_request integer NOT NULL,
    orig_intended_reviewer text,
    CONSTRAINT clin_root_item_soap_cat_check CHECK (((soap_cat IS NULL) OR (lower(soap_cat) = ANY (ARRAY['s'::text, 'o'::text, 'a'::text, 'p'::text])))),
    CONSTRAINT numval_needs_unit CHECK ((((val_num IS NOT NULL) AND (btrim(COALESCE(val_unit, ''::text)) <> ''::text)) OR (val_num IS NULL))),
    CONSTRAINT staging_numval_needs_unit CHECK ((((val_num IS NOT NULL) AND (btrim(COALESCE(val_unit, ''::text)) <> ''::text)) OR (val_num IS NULL))),
    CONSTRAINT staging_sane_value CHECK (((val_num IS NOT NULL) OR (val_alpha IS NOT NULL) OR ((val_num IS NULL) AND (val_alpha <> ''::text) AND (val_alpha IS NOT NULL)))),
    CONSTRAINT test_result_check CHECK (((val_num IS NOT NULL) OR (val_alpha IS NOT NULL) OR ((val_num IS NULL) AND (val_alpha <> ''::text) AND (val_alpha IS NOT NULL))))
);


ALTER TABLE staging.test_result OWNER TO "gm-dbo";

--
-- Name: TABLE test_result; Type: COMMENT; Schema: staging; Owner: gm-dbo
--

COMMENT ON TABLE staging.test_result IS 'Used to stage test results (from hl7 files, currently).';


--
-- Name: referral pk_audit; Type: DEFAULT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: referral row_version; Type: DEFAULT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: referral modified_when; Type: DEFAULT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: referral modified_by; Type: DEFAULT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: referral pk_item; Type: DEFAULT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: referral clin_when; Type: DEFAULT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: referral id; Type: DEFAULT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral ALTER COLUMN id SET DEFAULT nextval('au.referral_id_seq'::regclass);


--
-- Name: audit_fields pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.audit_fields ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: audit_trail pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.audit_trail ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: audited_tables id; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.audited_tables ALTER COLUMN id SET DEFAULT nextval('audit.audited_tables_id_seq'::regclass);


--
-- Name: log_access_log orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_access_log ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_access_log audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_access_log ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_access_log audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_access_log ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_address orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_address ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_address audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_address ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_address audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_address ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_allergy orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_allergy ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_allergy audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_allergy ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_allergy audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_allergy ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_allergy_state orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_allergy_state ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_allergy_state audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_allergy_state ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_allergy_state audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_allergy_state ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_auto_hint orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_auto_hint ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_auto_hint audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_auto_hint ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_auto_hint audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_auto_hint ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_beh_fall_typ orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_beh_fall_typ ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_beh_fall_typ audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_beh_fall_typ ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_beh_fall_typ audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_beh_fall_typ ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_bill orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_bill ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_bill audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_bill ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_bill audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_bill ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_bill_item orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_bill_item ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_bill_item audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_bill_item ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_bill_item audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_bill_item ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_billable pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_billable ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: log_billable orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_billable ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_billable audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_billable ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_billable audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_billable ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_clin_aux_note orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_aux_note ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_clin_aux_note audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_aux_note ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_clin_aux_note audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_aux_note ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_clin_diag orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_diag ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_clin_diag audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_diag ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_clin_diag audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_diag ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_clin_item_type orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_item_type ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_clin_item_type audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_item_type ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_clin_item_type audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_item_type ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_clin_narrative orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_narrative ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_clin_narrative audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_narrative ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_clin_narrative audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_clin_narrative ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_consumable_substance orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_consumable_substance ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_consumable_substance audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_consumable_substance ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_consumable_substance audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_consumable_substance ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_consumed_substance orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_consumed_substance ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_consumed_substance audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_consumed_substance ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_consumed_substance audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_consumed_substance ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_data_source orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_data_source ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_data_source audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_data_source ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_data_source audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_data_source ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_doc_desc orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_doc_desc ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_doc_desc audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_doc_desc ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_doc_desc audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_doc_desc ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_doc_med orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_doc_med ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_doc_med audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_doc_med ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_doc_med audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_doc_med ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_dose pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_dose ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: log_dose orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_dose ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_dose audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_dose ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_dose audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_dose ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_drug_product orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_drug_product ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_drug_product audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_drug_product ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_drug_product audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_drug_product ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_encounter orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_encounter ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_encounter audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_encounter ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_encounter audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_encounter ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_episode orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_episode ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_episode audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_episode ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_episode audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_episode ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_external_care orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_external_care ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_external_care audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_external_care ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_external_care audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_external_care ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_family_history orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_family_history ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_family_history audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_family_history ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_family_history audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_family_history ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_fhx_relation_type orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_fhx_relation_type ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_fhx_relation_type audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_fhx_relation_type ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_fhx_relation_type audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_fhx_relation_type ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_form_data orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_form_data ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_form_data audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_form_data ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_form_data audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_form_data ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_form_instances orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_form_instances ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_form_instances audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_form_instances ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_form_instances audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_form_instances ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_gender_label orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_gender_label ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_gender_label audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_gender_label ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_gender_label audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_gender_label ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_health_issue orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_health_issue ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_health_issue audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_health_issue ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_health_issue audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_health_issue ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_hospital_stay orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_hospital_stay ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_hospital_stay audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_hospital_stay ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_hospital_stay audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_hospital_stay ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_hx_family_item orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_hx_family_item ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_hx_family_item audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_hx_family_item ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_hx_family_item audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_hx_family_item ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_identity orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_identity ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_identity audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_identity ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_identity audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_identity ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_identity_tag orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_identity_tag ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_identity_tag audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_identity_tag ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_identity_tag audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_identity_tag ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_inbox_item_category orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_inbox_item_category ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_inbox_item_category audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_inbox_item_category ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_inbox_item_category audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_inbox_item_category ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_inbox_item_type orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_inbox_item_type ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_inbox_item_type audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_inbox_item_type ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_inbox_item_type audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_inbox_item_type ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_incoming_data_unmatchable orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_incoming_data_unmatchable ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_incoming_data_unmatchable audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_incoming_data_unmatchable ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_incoming_data_unmatchable audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_incoming_data_unmatchable ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_incoming_data_unmatched orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_incoming_data_unmatched ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_incoming_data_unmatched audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_incoming_data_unmatched ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_incoming_data_unmatched audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_incoming_data_unmatched ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lab_request orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lab_request ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lab_request audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lab_request ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lab_request audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lab_request ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lab_test_gnr orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lab_test_gnr ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lab_test_gnr audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lab_test_gnr ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lab_test_gnr audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lab_test_gnr ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2aoe orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2aoe ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2aoe audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2aoe ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2aoe audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2aoe ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2episode orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2episode ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2episode audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2episode ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2episode audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2episode ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2fhx orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2fhx ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2fhx audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2fhx ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2fhx audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2fhx ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2h_issue orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2h_issue ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2h_issue audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2h_issue ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2h_issue audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2h_issue ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2narrative orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2narrative ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2narrative audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2narrative ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2narrative audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2narrative ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2procedure orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2procedure ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2procedure audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2procedure ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2procedure audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2procedure ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2rfe orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2rfe ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2rfe audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2rfe ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2rfe audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2rfe ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_code2tst_pnl orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2tst_pnl ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_code2tst_pnl audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2tst_pnl ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_code2tst_pnl audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_code2tst_pnl ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_constraint2vacc_course orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_constraint2vacc_course ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_constraint2vacc_course audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_constraint2vacc_course ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_constraint2vacc_course audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_constraint2vacc_course ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_dose2drug pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_dose2drug ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: log_lnk_dose2drug orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_dose2drug ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_dose2drug audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_dose2drug ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_dose2drug audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_dose2drug ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_identity2ext_id orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_identity2ext_id ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_identity2ext_id audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_identity2ext_id ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_identity2ext_id audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_identity2ext_id ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_identity2primary_doc pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_identity2primary_doc ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: log_lnk_identity2primary_doc orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_identity2primary_doc ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_identity2primary_doc audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_identity2primary_doc ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_identity2primary_doc audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_identity2primary_doc ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_job2person orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_job2person ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_job2person audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_job2person ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_job2person audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_job2person ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_loinc2substance pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2substance ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: log_lnk_loinc2substance orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2substance ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_loinc2substance audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2substance ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_loinc2substance audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2substance ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_loinc2test_panel pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2test_panel ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: log_lnk_loinc2test_panel orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2test_panel ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_loinc2test_panel audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2test_panel ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_loinc2test_panel audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_loinc2test_panel ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_org_unit2comm orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_org_unit2comm ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_org_unit2comm audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_org_unit2comm ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_org_unit2comm audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_org_unit2comm ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_org_unit2ext_id orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_org_unit2ext_id ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_org_unit2ext_id audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_org_unit2ext_id ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_org_unit2ext_id audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_org_unit2ext_id ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_pat2vaccination_course orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_pat2vaccination_course ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_pat2vaccination_course audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_pat2vaccination_course ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_pat2vaccination_course audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_pat2vaccination_course ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_person2relative orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_person2relative ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_person2relative audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_person2relative ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_person2relative audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_person2relative ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_substance2brand orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_substance2brand ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_substance2brand audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_substance2brand ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_substance2brand audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_substance2brand ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_tst2norm orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_tst2norm ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_tst2norm audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_tst2norm ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_tst2norm audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_tst2norm ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_type2item orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_type2item ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_type2item audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_type2item ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_type2item audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_type2item ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_vaccination_course2schedule orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_vaccination_course2schedule ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_vaccination_course2schedule audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_vaccination_course2schedule ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_vaccination_course2schedule audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_vaccination_course2schedule ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_lnk_vaccine2inds orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_vaccine2inds ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_lnk_vaccine2inds audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_vaccine2inds ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_lnk_vaccine2inds audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_lnk_vaccine2inds ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_message_inbox orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_message_inbox ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_message_inbox audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_message_inbox ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_message_inbox audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_message_inbox ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_occupation orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_occupation ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_occupation audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_occupation ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_occupation audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_occupation ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_operation orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_operation ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_operation audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_operation ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_operation audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_operation ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_org orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_org ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_org audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_org ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_org audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_org ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_org_unit orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_org_unit ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_org_unit audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_org_unit ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_org_unit audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_org_unit ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_paperwork_templates orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_paperwork_templates ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_paperwork_templates audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_paperwork_templates ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_paperwork_templates audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_paperwork_templates ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_patient orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_patient ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_patient audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_patient ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_patient audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_patient ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_prax_geb_paid orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_prax_geb_paid ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_prax_geb_paid audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_prax_geb_paid ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_prax_geb_paid audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_prax_geb_paid ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_praxis_branch orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_praxis_branch ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_praxis_branch audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_praxis_branch ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_praxis_branch audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_praxis_branch ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_procedure orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_procedure ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_procedure audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_procedure ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_procedure audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_procedure ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_referral orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_referral ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_referral audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_referral ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_referral audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_referral ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_region orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_region ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_region audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_region ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_region audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_region ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_relation_types orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_relation_types ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_relation_types audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_relation_types ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_relation_types audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_relation_types ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_report_query orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_report_query ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_report_query audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_report_query ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_report_query audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_report_query ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_staff orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_staff ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_staff audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_staff ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_staff audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_staff ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_street orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_street ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_street audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_street ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_street audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_street ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_substance pk_audit; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass);


--
-- Name: log_substance orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_substance audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_substance audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_substance_in_brand orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance_in_brand ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_substance_in_brand audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance_in_brand ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_substance_in_brand audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance_in_brand ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_substance_intake orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance_intake ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_substance_intake audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance_intake ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_substance_intake audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_substance_intake ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_suppressed_hint orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_suppressed_hint ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_suppressed_hint audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_suppressed_hint ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_suppressed_hint audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_suppressed_hint ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_tag_image orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_tag_image ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_tag_image audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_tag_image ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_tag_image audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_tag_image ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_test_org orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_org ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_test_org audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_org ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_test_org audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_org ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_test_panel orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_panel ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_test_panel audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_panel ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_test_panel audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_panel ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_test_result orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_result ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_test_result audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_result ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_test_result audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_result ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_test_type orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_type ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_test_type audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_type ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_test_type audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_test_type ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_urb orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_urb ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_urb audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_urb ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_urb audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_urb ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vacc_indication orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vacc_indication ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vacc_indication audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vacc_indication ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vacc_indication audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vacc_indication ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vacc_route orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vacc_route ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vacc_route audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vacc_route ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vacc_route audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vacc_route ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vaccination orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vaccination audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vaccination audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vaccination_course orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_course ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vaccination_course audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_course ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vaccination_course audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_course ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vaccination_course_constraint orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_course_constraint ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vaccination_course_constraint audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_course_constraint ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vaccination_course_constraint audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_course_constraint ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vaccination_definition orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_definition ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vaccination_definition audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_definition ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vaccination_definition audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_definition ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vaccination_schedule orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_schedule ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vaccination_schedule audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_schedule ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vaccination_schedule audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccination_schedule ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vaccine orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccine ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vaccine audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccine ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vaccine audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccine ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_vaccine_batches orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccine_batches ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_vaccine_batches audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccine_batches ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_vaccine_batches audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_vaccine_batches ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_waiting_list orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_waiting_list ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_waiting_list audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_waiting_list ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_waiting_list audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_waiting_list ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: log_xlnk_identity orig_version; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_xlnk_identity ALTER COLUMN orig_version SET DEFAULT 0;


--
-- Name: log_xlnk_identity audit_when; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_xlnk_identity ALTER COLUMN audit_when SET DEFAULT now();


--
-- Name: log_xlnk_identity audit_by; Type: DEFAULT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.log_xlnk_identity ALTER COLUMN audit_by SET DEFAULT "current_user"();


--
-- Name: bill pk_audit; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: bill row_version; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: bill modified_when; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: bill modified_by; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: bill pk; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill ALTER COLUMN pk SET DEFAULT nextval('bill.bill_pk_seq'::regclass);


--
-- Name: bill_item pk_audit; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill_item ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: bill_item row_version; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill_item ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: bill_item modified_when; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill_item ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: bill_item modified_by; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill_item ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: bill_item pk; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.bill_item ALTER COLUMN pk SET DEFAULT nextval('bill.bill_item_pk_seq'::regclass);


--
-- Name: lnk_enc_type2billable pk; Type: DEFAULT; Schema: bill; Owner: gm-dbo
--

ALTER TABLE ONLY bill.lnk_enc_type2billable ALTER COLUMN pk SET DEFAULT nextval('bill.lnk_enc_type2billable_pk_seq'::regclass);


--
-- Name: doc_desc pk_audit; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_desc ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: doc_desc row_version; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_desc ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: doc_desc modified_when; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_desc ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: doc_desc modified_by; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_desc ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: doc_desc pk; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_desc ALTER COLUMN pk SET DEFAULT nextval('blobs.doc_desc_pk_seq'::regclass);


--
-- Name: doc_med pk_audit; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_med ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: doc_med row_version; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_med ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: doc_med modified_when; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_med ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: doc_med modified_by; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_med ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: doc_med pk; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_med ALTER COLUMN pk SET DEFAULT nextval('blobs.doc_med_pk_seq'::regclass);


--
-- Name: doc_obj pk; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_obj ALTER COLUMN pk SET DEFAULT nextval('blobs.doc_obj_pk_seq'::regclass);


--
-- Name: doc_type pk; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.doc_type ALTER COLUMN pk SET DEFAULT nextval('blobs.doc_type_pk_seq'::regclass);


--
-- Name: lnk_doc_med2episode pk_audit; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.lnk_doc_med2episode ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_doc_med2episode row_version; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.lnk_doc_med2episode ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_doc_med2episode modified_when; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.lnk_doc_med2episode ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_doc_med2episode modified_by; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.lnk_doc_med2episode ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_doc_med2episode pk; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.lnk_doc_med2episode ALTER COLUMN pk SET DEFAULT nextval('blobs.lnk_doc_med2episode_pk_seq'::regclass);


--
-- Name: reviewed_doc_objs pk_audit; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.reviewed_doc_objs ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: reviewed_doc_objs row_version; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.reviewed_doc_objs ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: reviewed_doc_objs modified_when; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.reviewed_doc_objs ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: reviewed_doc_objs modified_by; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.reviewed_doc_objs ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: reviewed_doc_objs pk; Type: DEFAULT; Schema: blobs; Owner: gm-dbo
--

ALTER TABLE ONLY blobs.reviewed_doc_objs ALTER COLUMN pk SET DEFAULT nextval('clin.review_root_pk_seq'::regclass);


--
-- Name: cfg_data pk; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.cfg_data ALTER COLUMN pk SET DEFAULT nextval('cfg.cfg_data_pk_seq'::regclass);


--
-- Name: cfg_item pk; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.cfg_item ALTER COLUMN pk SET DEFAULT nextval('cfg.cfg_item_pk_seq'::regclass);


--
-- Name: cfg_numeric pk; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.cfg_numeric ALTER COLUMN pk SET DEFAULT nextval('cfg.cfg_numeric_pk_seq'::regclass);


--
-- Name: cfg_str_array pk; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.cfg_str_array ALTER COLUMN pk SET DEFAULT nextval('cfg.cfg_str_array_pk_seq'::regclass);


--
-- Name: cfg_string pk; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.cfg_string ALTER COLUMN pk SET DEFAULT nextval('cfg.cfg_string_pk_seq'::regclass);


--
-- Name: cfg_template pk; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.cfg_template ALTER COLUMN pk SET DEFAULT nextval('cfg.cfg_template_pk_seq'::regclass);


--
-- Name: config id; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.config ALTER COLUMN id SET DEFAULT nextval('cfg.config_id_seq'::regclass);


--
-- Name: report_query pk_audit; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.report_query ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: report_query row_version; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.report_query ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: report_query modified_when; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.report_query ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: report_query modified_by; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.report_query ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: report_query pk; Type: DEFAULT; Schema: cfg; Owner: gm-dbo
--

ALTER TABLE ONLY cfg.report_query ALTER COLUMN pk SET DEFAULT nextval('cfg.report_query_pk_seq'::regclass);


--
-- Name: _enum_allergy_type pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin._enum_allergy_type ALTER COLUMN pk SET DEFAULT nextval('clin._enum_allergy_type_id_seq'::regclass);


--
-- Name: allergy pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: allergy row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: allergy modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: allergy modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: allergy pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: allergy clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: allergy soap_cat; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN soap_cat SET DEFAULT 'o'::text;


--
-- Name: allergy pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy ALTER COLUMN pk SET DEFAULT nextval('clin.allergy_id_seq'::regclass);


--
-- Name: allergy_state pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy_state ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: allergy_state row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy_state ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: allergy_state modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy_state ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: allergy_state modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy_state ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: allergy_state pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.allergy_state ALTER COLUMN pk SET DEFAULT nextval('clin.allergy_state_id_seq'::regclass);


--
-- Name: clin_aux_note pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_aux_note ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: clin_aux_note row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_aux_note ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: clin_aux_note modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_aux_note ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: clin_aux_note modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_aux_note ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: clin_aux_note pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_aux_note ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: clin_aux_note clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_aux_note ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: clin_aux_note pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_aux_note ALTER COLUMN pk SET DEFAULT nextval('clin.clin_aux_note_pk_seq'::regclass);


--
-- Name: clin_diag pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_diag ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: clin_diag row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_diag ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: clin_diag modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_diag ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: clin_diag modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_diag ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: clin_diag pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_diag ALTER COLUMN pk SET DEFAULT nextval('clin.clin_diag_pk_seq'::regclass);


--
-- Name: clin_item_type pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_item_type ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: clin_item_type row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_item_type ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: clin_item_type modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_item_type ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: clin_item_type modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_item_type ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: clin_item_type pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_item_type ALTER COLUMN pk SET DEFAULT nextval('clin.clin_item_type_pk_seq'::regclass);


--
-- Name: clin_narrative pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_narrative ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: clin_narrative row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_narrative ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: clin_narrative modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_narrative ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: clin_narrative modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_narrative ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: clin_narrative pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_narrative ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: clin_narrative clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_narrative ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: clin_narrative pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_narrative ALTER COLUMN pk SET DEFAULT nextval('clin.clin_narrative_pk_seq'::regclass);


--
-- Name: clin_root_item pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_root_item ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: clin_root_item row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_root_item ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: clin_root_item modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_root_item ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: clin_root_item modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_root_item ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: clin_root_item pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.clin_root_item ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: encounter pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.encounter ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: encounter row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.encounter ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: encounter modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.encounter ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: encounter modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.encounter ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: encounter pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.encounter ALTER COLUMN pk SET DEFAULT nextval('clin.encounter_pk_seq'::regclass);


--
-- Name: encounter_type pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.encounter_type ALTER COLUMN pk SET DEFAULT nextval('clin.encounter_type_pk_seq'::regclass);


--
-- Name: episode pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.episode ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: episode row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.episode ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: episode modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.episode ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: episode modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.episode ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: episode pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.episode ALTER COLUMN pk SET DEFAULT nextval('clin.episode_pk_seq'::regclass);


--
-- Name: export_item pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.export_item ALTER COLUMN pk SET DEFAULT nextval('clin.export_item_pk_seq'::regclass);


--
-- Name: external_care pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.external_care ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: external_care row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.external_care ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: external_care modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.external_care ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: external_care modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.external_care ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: external_care pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.external_care ALTER COLUMN pk SET DEFAULT nextval('clin.external_care_pk_seq'::regclass);


--
-- Name: family_history pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.family_history ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: family_history row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.family_history ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: family_history modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.family_history ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: family_history modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.family_history ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: family_history pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.family_history ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: family_history clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.family_history ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: family_history pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.family_history ALTER COLUMN pk SET DEFAULT nextval('clin.clin_hx_family_pk_seq'::regclass);


--
-- Name: fhx_relation_type pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.fhx_relation_type ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: fhx_relation_type row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.fhx_relation_type ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: fhx_relation_type modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.fhx_relation_type ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: fhx_relation_type modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.fhx_relation_type ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: fhx_relation_type pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.fhx_relation_type ALTER COLUMN pk SET DEFAULT nextval('clin.fhx_relation_type_pk_seq'::regclass);


--
-- Name: form_data pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_data ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: form_data row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_data ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: form_data modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_data ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: form_data modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_data ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: form_data pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_data ALTER COLUMN pk SET DEFAULT nextval('clin.form_data_pk_seq'::regclass);


--
-- Name: form_instances pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_instances ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: form_instances row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_instances ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: form_instances modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_instances ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: form_instances modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_instances ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: form_instances pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_instances ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: form_instances clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_instances ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: form_instances pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.form_instances ALTER COLUMN pk SET DEFAULT nextval('clin.form_instances_pk_seq'::regclass);


--
-- Name: health_issue pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.health_issue ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: health_issue row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.health_issue ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: health_issue modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.health_issue ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: health_issue modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.health_issue ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: health_issue pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.health_issue ALTER COLUMN pk SET DEFAULT nextval('clin.health_issue_pk_seq'::regclass);


--
-- Name: hospital_stay pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.hospital_stay ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: hospital_stay row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.hospital_stay ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: hospital_stay modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.hospital_stay ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: hospital_stay modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.hospital_stay ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: hospital_stay pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.hospital_stay ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: hospital_stay clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.hospital_stay ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: hospital_stay pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.hospital_stay ALTER COLUMN pk SET DEFAULT nextval('clin.hospital_stay_pk_seq'::regclass);


--
-- Name: incoming_data_unmatchable pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatchable ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: incoming_data_unmatchable row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatchable ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: incoming_data_unmatchable modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatchable ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: incoming_data_unmatchable modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatchable ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: incoming_data_unmatchable pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatchable ALTER COLUMN pk SET DEFAULT nextval('clin.incoming_data_unmatchable_pk_seq'::regclass);


--
-- Name: incoming_data_unmatched pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatched ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: incoming_data_unmatched row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatched ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: incoming_data_unmatched modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatched ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: incoming_data_unmatched modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatched ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: incoming_data_unmatched pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.incoming_data_unmatched ALTER COLUMN pk SET DEFAULT nextval('clin.incoming_data_unmatched_pk_seq'::regclass);


--
-- Name: lab_request pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lab_request row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lab_request modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lab_request modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lab_request pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: lab_request clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: lab_request soap_cat; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN soap_cat SET DEFAULT 'p'::text;


--
-- Name: lab_request pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lab_request ALTER COLUMN pk SET DEFAULT nextval('clin.lab_request_pk_seq'::regclass);


--
-- Name: lnk_code2aoe pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2aoe ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2aoe row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2aoe ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2aoe modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2aoe ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2aoe modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2aoe ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2aoe pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2aoe ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2aoe pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2aoe ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2aoe_pk_seq'::regclass);


--
-- Name: lnk_code2episode pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2episode ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2episode row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2episode ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2episode modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2episode ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2episode modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2episode ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2episode pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2episode ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2episode pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2episode ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2episode_pk_seq'::regclass);


--
-- Name: lnk_code2fhx pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2fhx ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2fhx row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2fhx ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2fhx modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2fhx ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2fhx modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2fhx ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2fhx pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2fhx ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2fhx pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2fhx ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2fhx_pk_seq'::regclass);


--
-- Name: lnk_code2h_issue pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2h_issue ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2h_issue row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2h_issue ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2h_issue modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2h_issue ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2h_issue modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2h_issue ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2h_issue pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2h_issue ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2h_issue pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2h_issue ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2h_issue_pk_seq'::regclass);


--
-- Name: lnk_code2item_root pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2item_root ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2item_root row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2item_root ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2item_root modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2item_root ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2item_root modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2item_root ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2item_root pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2item_root ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2narrative pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2narrative ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2narrative row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2narrative ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2narrative modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2narrative ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2narrative modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2narrative ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2narrative pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2narrative ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2narrative pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2narrative ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2narrative_pk_seq'::regclass);


--
-- Name: lnk_code2procedure pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2procedure ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2procedure row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2procedure ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2procedure modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2procedure ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2procedure modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2procedure ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2procedure pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2procedure ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2procedure pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2procedure ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2procedure_pk_seq'::regclass);


--
-- Name: lnk_code2rfe pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2rfe ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2rfe row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2rfe ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2rfe modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2rfe ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2rfe modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2rfe ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2rfe pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2rfe ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2rfe pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2rfe ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2rfe_pk_seq'::regclass);


--
-- Name: lnk_code2tst_pnl pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2tst_pnl ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_code2tst_pnl row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2tst_pnl ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_code2tst_pnl modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2tst_pnl ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_code2tst_pnl modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2tst_pnl ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_code2tst_pnl pk_lnk_code2item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2tst_pnl ALTER COLUMN pk_lnk_code2item SET DEFAULT nextval('clin.lnk_code2item_root_pk_lnk_code2item_seq'::regclass);


--
-- Name: lnk_code2tst_pnl pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_code2tst_pnl ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_code2tst_pnl_pk_seq'::regclass);


--
-- Name: lnk_constraint2vacc_course pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_constraint2vacc_course ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_constraint2vacc_course row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_constraint2vacc_course ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_constraint2vacc_course modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_constraint2vacc_course ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_constraint2vacc_course modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_constraint2vacc_course ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_constraint2vacc_course pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_constraint2vacc_course ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_constraint2vacc_course_pk_seq'::regclass);


--
-- Name: lnk_loinc2test_panel pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_loinc2test_panel ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_loinc2test_panel row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_loinc2test_panel ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_loinc2test_panel modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_loinc2test_panel ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_loinc2test_panel modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_loinc2test_panel ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_loinc2test_panel pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_loinc2test_panel ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_loinc2test_panel_pk_seq'::regclass);


--
-- Name: lnk_pat2vaccination_course pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_pat2vaccination_course ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_pat2vaccination_course row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_pat2vaccination_course ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_pat2vaccination_course modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_pat2vaccination_course ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_pat2vaccination_course modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_pat2vaccination_course ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_pat2vaccination_course pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_pat2vaccination_course ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_pat2vaccination_course_pk_seq'::regclass);


--
-- Name: lnk_substance2episode pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_substance2episode ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_substance2episode row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_substance2episode ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_substance2episode modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_substance2episode ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_substance2episode modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_substance2episode ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_substance2episode pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_substance2episode ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_substance2episode_pk_seq'::regclass);


--
-- Name: lnk_tst2norm pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_tst2norm ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_tst2norm row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_tst2norm ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_tst2norm modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_tst2norm ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_tst2norm modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_tst2norm ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_tst2norm id; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_tst2norm ALTER COLUMN id SET DEFAULT nextval('clin.lnk_tst2norm_id_seq'::regclass);


--
-- Name: lnk_type2item pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_type2item ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_type2item row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_type2item ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_type2item modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_type2item ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_type2item modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_type2item ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_type2item pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_type2item ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_type2item_pk_seq'::regclass);


--
-- Name: lnk_vaccination_course2schedule pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_vaccination_course2schedule ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_vaccination_course2schedule row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_vaccination_course2schedule ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_vaccination_course2schedule modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_vaccination_course2schedule ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_vaccination_course2schedule modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_vaccination_course2schedule ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_vaccination_course2schedule pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.lnk_vaccination_course2schedule ALTER COLUMN pk SET DEFAULT nextval('clin.lnk_vaccination_course2schedule_pk_seq'::regclass);


--
-- Name: meta_test_type pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.meta_test_type ALTER COLUMN pk SET DEFAULT nextval('clin.test_type_unified_pk_seq'::regclass);


--
-- Name: patient pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.patient ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: patient row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.patient ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: patient modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.patient ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: patient modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.patient ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: patient pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.patient ALTER COLUMN pk SET DEFAULT nextval('clin.patient_pk_seq'::regclass);


--
-- Name: procedure pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: procedure row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: procedure modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: procedure modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: procedure pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: procedure clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: procedure soap_cat; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN soap_cat SET DEFAULT 'p'::text;


--
-- Name: procedure pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.procedure ALTER COLUMN pk SET DEFAULT nextval('clin.procedure_pk_seq'::regclass);


--
-- Name: review_root pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.review_root ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: review_root row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.review_root ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: review_root modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.review_root ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: review_root modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.review_root ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: review_root pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.review_root ALTER COLUMN pk SET DEFAULT nextval('clin.review_root_pk_seq'::regclass);


--
-- Name: reviewed_test_results pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.reviewed_test_results ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: reviewed_test_results row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.reviewed_test_results ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: reviewed_test_results modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.reviewed_test_results ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: reviewed_test_results modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.reviewed_test_results ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: reviewed_test_results pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.reviewed_test_results ALTER COLUMN pk SET DEFAULT nextval('clin.review_root_pk_seq'::regclass);


--
-- Name: reviewed_test_results fk_reviewer; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.reviewed_test_results ALTER COLUMN fk_reviewer SET DEFAULT clin.f_fk_reviewer_default();


--
-- Name: soap_cat_ranks pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.soap_cat_ranks ALTER COLUMN pk SET DEFAULT nextval('clin.soap_cat_ranks_pk_seq'::regclass);


--
-- Name: substance_intake pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: substance_intake row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: substance_intake modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: substance_intake modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: substance_intake pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: substance_intake clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: substance_intake soap_cat; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN soap_cat SET DEFAULT 'p'::text;


--
-- Name: substance_intake pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.substance_intake ALTER COLUMN pk SET DEFAULT nextval('clin.substance_intake_pk_seq'::regclass);


--
-- Name: suppressed_hint pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.suppressed_hint ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: suppressed_hint row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.suppressed_hint ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: suppressed_hint modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.suppressed_hint ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: suppressed_hint modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.suppressed_hint ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: suppressed_hint pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.suppressed_hint ALTER COLUMN pk SET DEFAULT nextval('clin.suppressed_hint_pk_seq'::regclass);


--
-- Name: test_org pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_org ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: test_org row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_org ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: test_org modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_org ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: test_org modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_org ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: test_org pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_org ALTER COLUMN pk SET DEFAULT nextval('clin.test_org_pk_seq'::regclass);


--
-- Name: test_panel pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_panel ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: test_panel row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_panel ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: test_panel modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_panel ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: test_panel modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_panel ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: test_panel pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_panel ALTER COLUMN pk SET DEFAULT nextval('clin.test_panel_pk_seq'::regclass);


--
-- Name: test_result pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: test_result row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: test_result modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: test_result modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: test_result pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: test_result clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: test_result soap_cat; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN soap_cat SET DEFAULT 'o'::text;


--
-- Name: test_result pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_result ALTER COLUMN pk SET DEFAULT nextval('clin.test_result_pk_seq'::regclass);


--
-- Name: test_type pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_type ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: test_type row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_type ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: test_type modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_type ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: test_type modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_type ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: test_type pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.test_type ALTER COLUMN pk SET DEFAULT nextval('clin.test_type_pk_seq'::regclass);


--
-- Name: vaccination pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: vaccination row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: vaccination modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: vaccination modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: vaccination pk_item; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN pk_item SET DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass);


--
-- Name: vaccination clin_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN clin_when SET DEFAULT now();


--
-- Name: vaccination soap_cat; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN soap_cat SET DEFAULT 'p'::text;


--
-- Name: vaccination pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination ALTER COLUMN pk SET DEFAULT nextval('clin.vaccination_id_seq'::regclass);


--
-- Name: vaccination_course pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: vaccination_course row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: vaccination_course modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: vaccination_course modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: vaccination_course pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course ALTER COLUMN pk SET DEFAULT nextval('clin.vaccination_course_pk_seq'::regclass);


--
-- Name: vaccination_course_constraint pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course_constraint ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: vaccination_course_constraint row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course_constraint ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: vaccination_course_constraint modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course_constraint ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: vaccination_course_constraint modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course_constraint ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: vaccination_course_constraint pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_course_constraint ALTER COLUMN pk SET DEFAULT nextval('clin.vaccination_course_constraint_pk_seq'::regclass);


--
-- Name: vaccination_definition pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_definition ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: vaccination_definition row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_definition ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: vaccination_definition modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_definition ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: vaccination_definition modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_definition ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: vaccination_definition id; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_definition ALTER COLUMN id SET DEFAULT nextval('clin.vaccination_definition_id_seq'::regclass);


--
-- Name: vaccination_schedule pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_schedule ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: vaccination_schedule row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_schedule ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: vaccination_schedule modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_schedule ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: vaccination_schedule modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_schedule ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: vaccination_schedule pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.vaccination_schedule ALTER COLUMN pk SET DEFAULT nextval('clin.vaccination_schedule_pk_seq'::regclass);


--
-- Name: waiting_list pk_audit; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.waiting_list ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: waiting_list row_version; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.waiting_list ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: waiting_list modified_when; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.waiting_list ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: waiting_list modified_by; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.waiting_list ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: waiting_list pk; Type: DEFAULT; Schema: clin; Owner: gm-dbo
--

ALTER TABLE ONLY clin.waiting_list ALTER COLUMN pk SET DEFAULT nextval('clin.waiting_list_pk_seq'::regclass);


--
-- Name: beh_fall_typ pk_audit; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.beh_fall_typ ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: beh_fall_typ row_version; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.beh_fall_typ ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: beh_fall_typ modified_when; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.beh_fall_typ ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: beh_fall_typ modified_by; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.beh_fall_typ ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: beh_fall_typ pk; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.beh_fall_typ ALTER COLUMN pk SET DEFAULT nextval('de_de.beh_fall_typ_pk_seq'::regclass);


--
-- Name: kvk pk; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.kvk ALTER COLUMN pk SET DEFAULT nextval('de_de.kvk_pk_seq'::regclass);


--
-- Name: lab_test_gnr pk_audit; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.lab_test_gnr ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lab_test_gnr row_version; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.lab_test_gnr ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lab_test_gnr modified_when; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.lab_test_gnr ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lab_test_gnr modified_by; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.lab_test_gnr ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lab_test_gnr id; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.lab_test_gnr ALTER COLUMN id SET DEFAULT nextval('de_de.lab_test_gnr_id_seq'::regclass);


--
-- Name: payment_method pk; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.payment_method ALTER COLUMN pk SET DEFAULT nextval('de_de.payment_method_pk_seq'::regclass);


--
-- Name: prax_geb_paid pk_audit; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.prax_geb_paid ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: prax_geb_paid row_version; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.prax_geb_paid ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: prax_geb_paid modified_when; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.prax_geb_paid ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: prax_geb_paid modified_by; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.prax_geb_paid ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: prax_geb_paid pk; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.prax_geb_paid ALTER COLUMN pk SET DEFAULT nextval('de_de.prax_geb_paid_pk_seq'::regclass);


--
-- Name: zuzahlungsbefreiung id; Type: DEFAULT; Schema: de_de; Owner: gm-dbo
--

ALTER TABLE ONLY de_de.zuzahlungsbefreiung ALTER COLUMN id SET DEFAULT nextval('de_de.zuzahlungsbefreiung_id_seq'::regclass);


--
-- Name: address pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.address ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: address row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.address ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: address modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.address ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: address modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.address ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: address id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.address ALTER COLUMN id SET DEFAULT nextval('dem.address_id_seq'::regclass);


--
-- Name: address_type id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.address_type ALTER COLUMN id SET DEFAULT nextval('dem.address_type_id_seq'::regclass);


--
-- Name: country id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.country ALTER COLUMN id SET DEFAULT nextval('dem.country_id_seq'::regclass);


--
-- Name: enum_comm_types pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.enum_comm_types ALTER COLUMN pk SET DEFAULT nextval('dem.enum_comm_types_id_seq'::regclass);


--
-- Name: enum_ext_id_types pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.enum_ext_id_types ALTER COLUMN pk SET DEFAULT nextval('dem.enum_ext_id_types_pk_seq'::regclass);


--
-- Name: gender_label pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.gender_label ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: gender_label row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.gender_label ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: gender_label modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.gender_label ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: gender_label modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.gender_label ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: gender_label pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.gender_label ALTER COLUMN pk SET DEFAULT nextval('dem.gender_label_pk_seq'::regclass);


--
-- Name: identity pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: identity row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: identity modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: identity modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: identity pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity ALTER COLUMN pk SET DEFAULT nextval('dem.identity_pk_seq'::regclass);


--
-- Name: identity_tag pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity_tag ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: identity_tag row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity_tag ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: identity_tag modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity_tag ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: identity_tag modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity_tag ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: identity_tag pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.identity_tag ALTER COLUMN pk SET DEFAULT nextval('dem.identity_tag_pk_seq'::regclass);


--
-- Name: inbox_item_category pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_category ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: inbox_item_category row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_category ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: inbox_item_category modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_category ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: inbox_item_category modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_category ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: inbox_item_category pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_category ALTER COLUMN pk SET DEFAULT nextval('dem.inbox_item_category_pk_seq'::regclass);


--
-- Name: inbox_item_type pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_type ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: inbox_item_type row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_type ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: inbox_item_type modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_type ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: inbox_item_type modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_type ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: inbox_item_type pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.inbox_item_type ALTER COLUMN pk SET DEFAULT nextval('dem.inbox_item_type_pk_seq'::regclass);


--
-- Name: lnk_identity2comm pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_identity2comm ALTER COLUMN pk SET DEFAULT nextval('dem.lnk_identity2comm_id_seq'::regclass);


--
-- Name: lnk_identity2ext_id pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_identity2ext_id ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_identity2ext_id row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_identity2ext_id ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_identity2ext_id modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_identity2ext_id ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_identity2ext_id modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_identity2ext_id ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_identity2ext_id id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_identity2ext_id ALTER COLUMN id SET DEFAULT nextval('dem.lnk_identity2ext_id_id_seq'::regclass);


--
-- Name: lnk_job2person pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_job2person ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_job2person row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_job2person ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_job2person modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_job2person ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_job2person modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_job2person ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_job2person pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_job2person ALTER COLUMN pk SET DEFAULT nextval('dem.lnk_job2person_id_seq'::regclass);


--
-- Name: lnk_org_unit2comm pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2comm ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_org_unit2comm row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2comm ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_org_unit2comm modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2comm ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_org_unit2comm modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2comm ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_org_unit2comm pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2comm ALTER COLUMN pk SET DEFAULT nextval('dem.lnk_org_unit2comm_pk_seq'::regclass);


--
-- Name: lnk_org_unit2ext_id pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2ext_id ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_org_unit2ext_id row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2ext_id ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_org_unit2ext_id modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2ext_id ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_org_unit2ext_id modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2ext_id ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_org_unit2ext_id pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_org_unit2ext_id ALTER COLUMN pk SET DEFAULT nextval('dem.lnk_org_unit2ext_id_pk_seq'::regclass);


--
-- Name: lnk_person2relative pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_person2relative ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_person2relative row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_person2relative ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_person2relative modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_person2relative ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_person2relative modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_person2relative ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_person2relative id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_person2relative ALTER COLUMN id SET DEFAULT nextval('dem.lnk_person2relative_id_seq'::regclass);


--
-- Name: lnk_person_org_address id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.lnk_person_org_address ALTER COLUMN id SET DEFAULT nextval('dem.lnk_person_org_address_id_seq'::regclass);


--
-- Name: marital_status pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.marital_status ALTER COLUMN pk SET DEFAULT nextval('dem.marital_status_pk_seq'::regclass);


--
-- Name: message_inbox pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.message_inbox ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: message_inbox row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.message_inbox ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: message_inbox modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.message_inbox ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: message_inbox modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.message_inbox ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: message_inbox pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.message_inbox ALTER COLUMN pk SET DEFAULT nextval('dem.provider_inbox_pk_seq'::regclass);


--
-- Name: name_gender_map id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.name_gender_map ALTER COLUMN id SET DEFAULT nextval('dem.name_gender_map_id_seq'::regclass);


--
-- Name: names id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.names ALTER COLUMN id SET DEFAULT nextval('dem.names_id_seq'::regclass);


--
-- Name: occupation pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.occupation ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: occupation row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.occupation ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: occupation modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.occupation ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: occupation modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.occupation ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: occupation id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.occupation ALTER COLUMN id SET DEFAULT nextval('dem.occupation_id_seq'::regclass);


--
-- Name: org pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: org row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: org modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: org modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: org pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org ALTER COLUMN pk SET DEFAULT nextval('dem.org_pk_seq'::regclass);


--
-- Name: org_category pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org_category ALTER COLUMN pk SET DEFAULT nextval('dem.org_category_id_seq'::regclass);


--
-- Name: org_unit pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org_unit ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: org_unit row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org_unit ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: org_unit modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org_unit ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: org_unit modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org_unit ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: org_unit pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.org_unit ALTER COLUMN pk SET DEFAULT nextval('dem.org_unit_pk_seq'::regclass);


--
-- Name: praxis_branch pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.praxis_branch ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: praxis_branch row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.praxis_branch ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: praxis_branch modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.praxis_branch ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: praxis_branch modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.praxis_branch ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: praxis_branch pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.praxis_branch ALTER COLUMN pk SET DEFAULT nextval('dem.praxis_branch_pk_seq'::regclass);


--
-- Name: region pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.region ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: region row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.region ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: region modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.region ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: region modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.region ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: region pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.region ALTER COLUMN pk SET DEFAULT nextval('dem.state_id_seq'::regclass);


--
-- Name: relation_types pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.relation_types ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: relation_types row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.relation_types ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: relation_types modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.relation_types ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: relation_types modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.relation_types ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: relation_types id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.relation_types ALTER COLUMN id SET DEFAULT nextval('dem.relation_types_id_seq'::regclass);


--
-- Name: staff pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.staff ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: staff row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.staff ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: staff modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.staff ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: staff modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.staff ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: staff pk; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.staff ALTER COLUMN pk SET DEFAULT nextval('dem.staff_pk_seq'::regclass);


--
-- Name: street pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.street ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: street row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.street ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: street modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.street ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: street modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.street ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: street id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.street ALTER COLUMN id SET DEFAULT nextval('dem.street_id_seq'::regclass);


--
-- Name: urb pk_audit; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.urb ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: urb row_version; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.urb ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: urb modified_when; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.urb ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: urb modified_by; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.urb ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: urb id; Type: DEFAULT; Schema: dem; Owner: gm-dbo
--

ALTER TABLE ONLY dem.urb ALTER COLUMN id SET DEFAULT nextval('dem.urb_id_seq'::regclass);


--
-- Name: access_log pk_audit; Type: DEFAULT; Schema: gm; Owner: gm-dbo
--

ALTER TABLE ONLY gm.access_log ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: access_log row_version; Type: DEFAULT; Schema: gm; Owner: gm-dbo
--

ALTER TABLE ONLY gm.access_log ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: access_log modified_when; Type: DEFAULT; Schema: gm; Owner: gm-dbo
--

ALTER TABLE ONLY gm.access_log ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: access_log modified_by; Type: DEFAULT; Schema: gm; Owner: gm-dbo
--

ALTER TABLE ONLY gm.access_log ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: access_log pk; Type: DEFAULT; Schema: gm; Owner: gm-dbo
--

ALTER TABLE ONLY gm.access_log ALTER COLUMN pk SET DEFAULT nextval('gm.access_log_pk_seq'::regclass);


--
-- Name: notifying_tables pk; Type: DEFAULT; Schema: gm; Owner: gm-dbo
--

ALTER TABLE ONLY gm.notifying_tables ALTER COLUMN pk SET DEFAULT nextval('gm.notifying_tables_pk_seq'::regclass);


--
-- Name: schema_revision pk; Type: DEFAULT; Schema: gm; Owner: gm-dbo
--

ALTER TABLE ONLY gm.schema_revision ALTER COLUMN pk SET DEFAULT nextval('gm.gm_schema_revision_pk_seq'::regclass);


--
-- Name: curr_lang pk; Type: DEFAULT; Schema: i18n; Owner: gm-dbo
--

ALTER TABLE ONLY i18n.curr_lang ALTER COLUMN pk SET DEFAULT nextval('i18n.curr_lang_pk_seq'::regclass);


--
-- Name: keys pk; Type: DEFAULT; Schema: i18n; Owner: gm-dbo
--

ALTER TABLE ONLY i18n.keys ALTER COLUMN pk SET DEFAULT nextval('i18n.keys_pk_seq'::regclass);


--
-- Name: translations pk; Type: DEFAULT; Schema: i18n; Owner: gm-dbo
--

ALTER TABLE ONLY i18n.translations ALTER COLUMN pk SET DEFAULT nextval('i18n.translations_pk_seq'::regclass);


--
-- Name: basic_unit pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.basic_unit ALTER COLUMN pk SET DEFAULT nextval('public.basic_unit_pk_seq'::regclass);


--
-- Name: form_field_types pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.form_field_types ALTER COLUMN pk SET DEFAULT nextval('public.form_field_types_pk_seq'::regclass);


--
-- Name: form_fields pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.form_fields ALTER COLUMN pk SET DEFAULT nextval('public.form_fields_pk_seq'::regclass);


--
-- Name: form_job_queue pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.form_job_queue ALTER COLUMN pk SET DEFAULT nextval('public.form_job_queue_pk_seq'::regclass);


--
-- Name: form_job_targets pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.form_job_targets ALTER COLUMN pk SET DEFAULT nextval('public.form_job_targets_pk_seq'::regclass);


--
-- Name: form_print_defs pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.form_print_defs ALTER COLUMN pk SET DEFAULT nextval('public.form_print_defs_pk_seq'::regclass);


--
-- Name: gm_client_db_match pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.gm_client_db_match ALTER COLUMN pk SET DEFAULT nextval('public.gm_client_db_match_pk_seq'::regclass);


--
-- Name: housekeeping_todo pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.housekeeping_todo ALTER COLUMN pk SET DEFAULT nextval('public.housekeeping_todo_pk_seq'::regclass);


--
-- Name: test_norm pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.test_norm ALTER COLUMN pk SET DEFAULT nextval('public.test_norm_pk_seq'::regclass);


--
-- Name: unit pk; Type: DEFAULT; Schema: public; Owner: gm-dbo
--

ALTER TABLE ONLY public.unit ALTER COLUMN pk SET DEFAULT nextval('public.unit_pk_seq'::regclass);


--
-- Name: atc pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.atc ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: atc pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.atc ALTER COLUMN pk SET DEFAULT nextval('ref.atc_pk_seq'::regclass);


--
-- Name: auto_hint pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.auto_hint ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: auto_hint row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.auto_hint ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: auto_hint modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.auto_hint ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: auto_hint modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.auto_hint ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: auto_hint pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.auto_hint ALTER COLUMN pk SET DEFAULT nextval('ref.auto_hint_pk_seq'::regclass);


--
-- Name: billable pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.billable ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: billable pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.billable ALTER COLUMN pk SET DEFAULT nextval('ref.billable_pk_seq'::regclass);


--
-- Name: coda pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.coda ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: coda pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.coda ALTER COLUMN pk SET DEFAULT nextval('ref.coda_pk_seq'::regclass);


--
-- Name: code_thesaurus_root pk_thesaurus; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.code_thesaurus_root ALTER COLUMN pk_thesaurus SET DEFAULT nextval('ref.code_thesaurus_root_pk_thesaurus_seq'::regclass);


--
-- Name: coding_system_root pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.coding_system_root ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: data_source pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.data_source ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: data_source row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.data_source ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: data_source modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.data_source ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: data_source modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.data_source ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: data_source pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.data_source ALTER COLUMN pk SET DEFAULT nextval('ref.data_source_pk_seq'::regclass);


--
-- Name: document_type pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.document_type ALTER COLUMN pk SET DEFAULT nextval('ref.document_type_pk_seq'::regclass);


--
-- Name: dose pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.dose ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: dose row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.dose ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: dose modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.dose ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: dose modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.dose ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: dose pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.dose ALTER COLUMN pk SET DEFAULT nextval('ref.dose_pk_seq'::regclass);


--
-- Name: drug_product pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.drug_product ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: drug_product row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.drug_product ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: drug_product modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.drug_product ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: drug_product modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.drug_product ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: drug_product pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.drug_product ALTER COLUMN pk SET DEFAULT nextval('ref.substance_brand_pk_seq'::regclass);


--
-- Name: form_types pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.form_types ALTER COLUMN pk SET DEFAULT nextval('ref.form_types_pk_seq'::regclass);


--
-- Name: icd10 pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icd10 ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: icd10 pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icd10 ALTER COLUMN pk SET DEFAULT nextval('ref.icd10_pk_seq'::regclass);


--
-- Name: icd9 pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icd9 ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: icd9 pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icd9 ALTER COLUMN pk SET DEFAULT nextval('ref.icd9_pk_seq'::regclass);


--
-- Name: icpc pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icpc ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: icpc pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icpc ALTER COLUMN pk SET DEFAULT nextval('ref.icpc_pk_seq'::regclass);


--
-- Name: icpc_chapter pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icpc_chapter ALTER COLUMN pk SET DEFAULT nextval('ref.icpc_chapter_pk_seq'::regclass);


--
-- Name: icpc_component pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icpc_component ALTER COLUMN pk SET DEFAULT nextval('ref.icpc_component_pk_seq'::regclass);


--
-- Name: icpc_thesaurus pk_thesaurus; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icpc_thesaurus ALTER COLUMN pk_thesaurus SET DEFAULT nextval('ref.code_thesaurus_root_pk_thesaurus_seq'::regclass);


--
-- Name: icpc_thesaurus pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.icpc_thesaurus ALTER COLUMN pk SET DEFAULT nextval('ref.icpc_thesaurus_pk_seq'::regclass);


--
-- Name: keyword_expansion pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.keyword_expansion ALTER COLUMN pk SET DEFAULT nextval('ref.keyword_expansion_pk_seq'::regclass);


--
-- Name: lnk_dose2drug pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_dose2drug ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_dose2drug row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_dose2drug ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_dose2drug modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_dose2drug ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_dose2drug modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_dose2drug ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_dose2drug pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_dose2drug ALTER COLUMN pk SET DEFAULT nextval('ref.lnk_dose2drug_pk_seq'::regclass);


--
-- Name: lnk_loinc2substance pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_loinc2substance ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: lnk_loinc2substance row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_loinc2substance ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: lnk_loinc2substance modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_loinc2substance ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: lnk_loinc2substance modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_loinc2substance ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: lnk_loinc2substance pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.lnk_loinc2substance ALTER COLUMN pk SET DEFAULT nextval('ref.lnk_loinc2substance_pk_seq'::regclass);


--
-- Name: loinc pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.loinc ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: loinc pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.loinc ALTER COLUMN pk SET DEFAULT nextval('ref.loinc_pk_seq'::regclass);


--
-- Name: ops pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.ops ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: ops pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.ops ALTER COLUMN pk SET DEFAULT nextval('ref.ops_pk_seq'::regclass);


--
-- Name: other_code pk_coding_system; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.other_code ALTER COLUMN pk_coding_system SET DEFAULT nextval('ref.coding_system_root_pk_coding_system_seq'::regclass);


--
-- Name: other_code pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.other_code ALTER COLUMN pk SET DEFAULT nextval('ref.other_code_pk_seq'::regclass);


--
-- Name: papersizes pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.papersizes ALTER COLUMN pk SET DEFAULT nextval('ref.papersizes_pk_seq'::regclass);


--
-- Name: paperwork_templates pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.paperwork_templates ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: paperwork_templates row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.paperwork_templates ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: paperwork_templates modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.paperwork_templates ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: paperwork_templates modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.paperwork_templates ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: paperwork_templates pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.paperwork_templates ALTER COLUMN pk SET DEFAULT nextval('ref.paperwork_templates_pk_seq'::regclass);


--
-- Name: substance pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.substance ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: substance row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.substance ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: substance modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.substance ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: substance modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.substance ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: substance pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.substance ALTER COLUMN pk SET DEFAULT nextval('ref.substance_pk_seq'::regclass);


--
-- Name: tag_image pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.tag_image ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: tag_image row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.tag_image ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: tag_image modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.tag_image ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: tag_image modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.tag_image ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: tag_image pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.tag_image ALTER COLUMN pk SET DEFAULT nextval('ref.tag_image_pk_seq'::regclass);


--
-- Name: vacc_route pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vacc_route ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: vacc_route row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vacc_route ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: vacc_route modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vacc_route ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: vacc_route modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vacc_route ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: vacc_route id; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vacc_route ALTER COLUMN id SET DEFAULT nextval('ref.vacc_route_id_seq'::regclass);


--
-- Name: vaccine pk_audit; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vaccine ALTER COLUMN pk_audit SET DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass);


--
-- Name: vaccine row_version; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vaccine ALTER COLUMN row_version SET DEFAULT 0;


--
-- Name: vaccine modified_when; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vaccine ALTER COLUMN modified_when SET DEFAULT now();


--
-- Name: vaccine modified_by; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vaccine ALTER COLUMN modified_by SET DEFAULT "current_user"();


--
-- Name: vaccine pk; Type: DEFAULT; Schema: ref; Owner: gm-dbo
--

ALTER TABLE ONLY ref.vaccine ALTER COLUMN pk SET DEFAULT nextval('ref.vaccine_pk_seq'::regclass);


--
-- Name: referral referral_pkey; Type: CONSTRAINT; Schema: au; Owner: gm-dbo
--

ALTER TABLE ONLY au.referral
    ADD CONSTRAINT referral_pkey PRIMARY KEY (id);


--
-- Name: audit_fields audit_fields_pkey; Type: CONSTRAINT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.audit_fields
    ADD CONSTRAINT audit_fields_pkey PRIMARY KEY (pk_audit);


--
-- Name: audit_trail audit_trail_pkey; Type: CONSTRAINT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.audit_trail
    ADD CONSTRAINT audit_trail_pkey PRIMARY KEY (pk_audit);


--
-- Name: audited_tables audited_tables_pkey; Type: CONSTRAINT; Schema: audit; Owner: gm-dbo
--

ALTER TABLE ONLY audit.audited_tables
    ADD CONSTRAINT audited_tables_pkey PRIMARY KEY (id);


--
