-- Modify "MedicineGroup" table
ALTER TABLE "public"."MedicineGroup" ALTER COLUMN "Code" TYPE character varying(10), ALTER COLUMN "Name" TYPE character varying(50);
-- Modify "MedicineMethod" table
ALTER TABLE "public"."MedicineMethod" ALTER COLUMN "Code" TYPE character varying(10), ALTER COLUMN "Name" TYPE character varying(50);
-- Create "Encounter" table
CREATE TABLE "public"."Encounter" (
  "Id" bigserial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Patient_Id" bigint NULL,
  "RegisteredAt" timestamptz NULL,
  "Class_Code" character varying(10) NOT NULL,
  "Unit_Id" bigint NULL,
  "VisitDate" timestamptz NULL,
  "Assignment_Doctor_Id" bigint NULL,
  "Responsible_Doctor_Id" bigint NULL,
  "DischardeMethod_Code" character varying(10) NULL,
  "RefSource_Name" character varying(100) NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "fk_Encounter_Assignment_Doctor" FOREIGN KEY ("Assignment_Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT "fk_Encounter_Patient" FOREIGN KEY ("Patient_Id") REFERENCES "public"."Patient" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT "fk_Encounter_Responsible_Doctor" FOREIGN KEY ("Responsible_Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT "fk_Encounter_Unit" FOREIGN KEY ("Unit_Id") REFERENCES "public"."Unit" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
