You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems to be a very non-SQL-specific problem but since we are working with Django every table needs to have a primary key field. This is why I want to share my workflow to remedy this situation:
The primary key field for the PATIENT table is set twice. Once in the postgres_add_indices.sql and once in the postgres_add_constraints.sql, which was run manually after running the Makefile. FYI: The latter is not part of the Makefile.
Comment lines 13-16 in postgres_add_constraints.sql
Save this in postgres_add_missing_constraints.sql:
ALTERTABLE admissiondrug DROP CONSTRAINT IF EXISTS admissiondrug_pk;
ALTERTABLE admissiondrug ADD CONSTRAINT admissiondrug_pk PRIMARY KEY (admissiondrugid);
ALTERTABLE allergy DROP CONSTRAINT IF EXISTS allergy_pk;
ALTERTABLE allergy ADD CONSTRAINT allergy_pk PRIMARY KEY (allergyid);
ALTERTABLE customlab DROP CONSTRAINT IF EXISTS customlab_pk;
ALTERTABLE customlab ADD CONSTRAINT customlab_pk PRIMARY KEY (customlabid);
ALTERTABLE infusiondrug DROP CONSTRAINT IF EXISTS infusiondrug_pk;
ALTERTABLE infusiondrug ADD CONSTRAINT infusiondrug_pk PRIMARY KEY (infusiondrugid);
ALTERTABLE intakeoutput DROP CONSTRAINT IF EXISTS intakeoutput_pk;
ALTERTABLE intakeoutput ADD CONSTRAINT intakeoutput_pk PRIMARY KEY (intakeoutputid);
ALTERTABLE medication DROP CONSTRAINT IF EXISTS medication_pk;
ALTERTABLE medication ADD CONSTRAINT medication_pk PRIMARY KEY (medicationid);
ALTERTABLE microlab DROP CONSTRAINT IF EXISTS microlab_pk;
ALTERTABLE microlab ADD CONSTRAINT microlab_pk PRIMARY KEY (microlabid);
ALTERTABLE note DROP CONSTRAINT IF EXISTS note_pk;
ALTERTABLE note ADD CONSTRAINT note_pk PRIMARY KEY (noteid);
ALTERTABLE nurseassessment DROP CONSTRAINT IF EXISTS nurseassessment_pk;
ALTERTABLE nurseassessment ADD CONSTRAINT nurseassessment_pk PRIMARY KEY (nurseassessid);
ALTERTABLE nursecare DROP CONSTRAINT IF EXISTS nursecare_pk;
ALTERTABLE nursecare ADD CONSTRAINT nursecare_pk PRIMARY KEY (nursecareid);
ALTERTABLE nursecharting DROP CONSTRAINT IF EXISTS nursecharting_pk;
ALTERTABLE nursecharting ADD CONSTRAINT nursecharting_pk PRIMARY KEY (nursingchartid);
ALTERTABLE physicalexam DROP CONSTRAINT IF EXISTS physicalexam_pk;
ALTERTABLE physicalexam ADD CONSTRAINT physicalexam_pk PRIMARY KEY (physicalexamid);
ALTERTABLE respiratorycare DROP CONSTRAINT IF EXISTS respiratorycare_pk;
ALTERTABLE respiratorycare ADD CONSTRAINT respiratorycare_pk PRIMARY KEY (respcareid);
ALTERTABLE respiratorycharting DROP CONSTRAINT IF EXISTS respiratorycharting_pk;
ALTERTABLE respiratorycharting ADD CONSTRAINT respiratorycharting_pk PRIMARY KEY (respchartid);
ALTERTABLE treatment DROP CONSTRAINT IF EXISTS treatment_pk;
ALTERTABLE treatment ADD CONSTRAINT treatment_pk PRIMARY KEY (treatmentid);
via psql "dbname=eicu user=eicu options=--search_path=eicu_crd" -v ON_ERROR_STOP=1 -f postgres_add_missing_constraints.sql or load it in any other way suitable for your workflow.
Hope this helps. Feel free to integrate this into this repository.
The text was updated successfully, but these errors were encountered:
This seems to be a very non-SQL-specific problem but since we are working with Django every table needs to have a primary key field. This is why I want to share my workflow to remedy this situation:
postgres_add_indices.sql
and once in thepostgres_add_constraints.sql
, which was run manually after running the Makefile. FYI: The latter is not part of the Makefile.postgres_add_constraints.sql
postgres_add_missing_constraints.sql
:via
psql "dbname=eicu user=eicu options=--search_path=eicu_crd" -v ON_ERROR_STOP=1 -f postgres_add_missing_constraints.sql
or load it in any other way suitable for your workflow.Hope this helps. Feel free to integrate this into this repository.
The text was updated successfully, but these errors were encountered: