-- Create "DeathCause" table
CREATE TABLE "public"."DeathCause" (
  "Id" bigserial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Encounter_Id" bigint NOT NULL,
  "Value" text NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "fk_DeathCause_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "EduAssessment" table
CREATE TABLE "public"."EduAssessment" (
  "Id" bigserial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Encounter_Id" bigint NOT NULL,
  "GeneralEdus" text NULL,
  "SpecialEdus" text NULL,
  "Assessments" text NULL,
  "Plan" text NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "fk_EduAssessment_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "GeneralConsent" table
CREATE TABLE "public"."GeneralConsent" (
  "Id" bigserial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Encounter_Id" bigint NOT NULL,
  "Value" text NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "fk_GeneralConsent_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "TherapyProtocol" table
CREATE TABLE "public"."TherapyProtocol" (
  "Id" bigserial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Encounter_Id" bigint NOT NULL,
  "Doctor_Id" bigint NULL,
  "Anamnesis" character varying(2048) NULL,
  "MedicalDiagnoses" text NULL,
  "FunctionDiagnoses" text NULL,
  "Procedures" text NULL,
  "SupportingExams" character varying(2048) NULL,
  "Instruction" character varying(2048) NULL,
  "Evaluation" character varying(2048) NULL,
  "WorkCauseStatus" character varying(2048) NULL,
  "Frequency" bigint NULL,
  "IntervalUnit_Code" character varying(10) NULL,
  "Duration" bigint NULL,
  "DurationUnit_Code" character varying(10) NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "fk_TherapyProtocol_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT "fk_TherapyProtocol_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
