From aeffa7db65e5143f30b8726bf466919cfa54727e Mon Sep 17 00:00:00 2001 From: vanilia Date: Thu, 23 Oct 2025 11:37:07 +0700 Subject: [PATCH] add new entity for authentication and encounter --- .../migrations/20251023044432.sql | 90 ++++++++++++++ cmd/main-migration/migrations/atlas.sum | 115 +++++++++--------- .../main-entities/adm-employee-hist/entity.go | 16 +++ .../main-entities/division-position/entity.go | 2 +- .../domain/main-entities/employee/entity.go | 20 +-- .../installation-position/entity.go | 18 +++ .../responsible-doctor-hist/entity.go | 16 +++ .../specialist-position/entity.go | 18 +++ .../subspecialist-position/entity.go | 18 +++ .../main-entities/unit-position/entity.go | 18 +++ internal/domain/main-entities/user/dto.go | 14 +-- internal/interface/migration/main-entities.go | 12 ++ 12 files changed, 282 insertions(+), 75 deletions(-) create mode 100644 cmd/main-migration/migrations/20251023044432.sql create mode 100644 internal/domain/main-entities/adm-employee-hist/entity.go create mode 100644 internal/domain/main-entities/installation-position/entity.go create mode 100644 internal/domain/main-entities/responsible-doctor-hist/entity.go create mode 100644 internal/domain/main-entities/specialist-position/entity.go create mode 100644 internal/domain/main-entities/subspecialist-position/entity.go create mode 100644 internal/domain/main-entities/unit-position/entity.go diff --git a/cmd/main-migration/migrations/20251023044432.sql b/cmd/main-migration/migrations/20251023044432.sql new file mode 100644 index 00000000..6a1d962b --- /dev/null +++ b/cmd/main-migration/migrations/20251023044432.sql @@ -0,0 +1,90 @@ +-- Create "AdmEmployeeHist" table +CREATE TABLE "public"."AdmEmployeeHist" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Employee_Id" bigint NULL, + "StartedAt" timestamptz NULL, + "FinishedAt" timestamptz NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_AdmEmployeeHist_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "InstallationPosition" table +CREATE TABLE "public"."InstallationPosition" ( + "Id" serial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Installation_Id" integer NOT NULL, + "Code" character varying(10) NOT NULL, + "Name" character varying(30) NOT NULL, + "HeadStatus" boolean NULL, + "Employee_Id" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_InstallationPosition_Code" UNIQUE ("Code"), + CONSTRAINT "fk_InstallationPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_InstallationPosition_Installation" FOREIGN KEY ("Installation_Id") REFERENCES "public"."Installation" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "ResponsibleDoctorHist" table +CREATE TABLE "public"."ResponsibleDoctorHist" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Doctor_Id" bigint NULL, + "StartedAt" timestamptz NULL, + "FinishedAt" timestamptz NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_ResponsibleDoctorHist_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "SpecialistPosition" table +CREATE TABLE "public"."SpecialistPosition" ( + "Id" serial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Specialist_Id" integer NOT NULL, + "Code" character varying(10) NOT NULL, + "Name" character varying(30) NOT NULL, + "HeadStatus" boolean NULL, + "Employee_Id" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_SpecialistPosition_Code" UNIQUE ("Code"), + CONSTRAINT "fk_SpecialistPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_SpecialistPosition_Specialist" FOREIGN KEY ("Specialist_Id") REFERENCES "public"."Specialist" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "SubspecialistPosition" table +CREATE TABLE "public"."SubspecialistPosition" ( + "Id" serial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Subspecialist_Id" integer NOT NULL, + "Code" character varying(10) NOT NULL, + "Name" character varying(30) NOT NULL, + "HeadStatus" boolean NULL, + "Employee_Id" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_SubspecialistPosition_Code" UNIQUE ("Code"), + CONSTRAINT "fk_SubspecialistPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_SubspecialistPosition_Subspecialist" FOREIGN KEY ("Subspecialist_Id") REFERENCES "public"."Subspecialist" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "UnitPosition" table +CREATE TABLE "public"."UnitPosition" ( + "Id" serial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Unit_Id" integer NOT NULL, + "Code" character varying(10) NOT NULL, + "Name" character varying(30) NOT NULL, + "HeadStatus" boolean NULL, + "Employee_Id" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_UnitPosition_Code" UNIQUE ("Code"), + CONSTRAINT "fk_UnitPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_UnitPosition_Unit" FOREIGN KEY ("Unit_Id") REFERENCES "public"."Unit" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 49982d7c..26b28019 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,57 +1,58 @@ -h1:9voEyn7242M8hCdJhgPotJkwJ0DX7UiXrqu3+trN7jw= -20250904105930.sql h1:Vv4vCurl7m7/ZB6TjRpkubHpQ4RYwSUn0QHdzfoGpzY= -20250904141448.sql h1:FYCHH9Os4KkrZMDu/jR8FMP+wLMRW+Mb0PkLU/9BRDg= -20250908062237.sql h1:oanBpKZd+akPu2I/xYhUSbd0G5tAFbXzKLER/Zs8ENI= -20250908062323.sql h1:miNG9COddXkD1jGTgaROMAZ618eT6oiLGiJhXWnQwhE= -20250908073811.sql h1:gOi5cnGG1htlpfizybYmUIT0vYjZTBfXiI0nPSYK2u8= -20250908073839.sql h1:cWNDA4YikjoOteAJuNLFILjQUJPFB6o8Wxreiek4QyI= -20250910055902.sql h1:nxxOGnU0BbH/v3IPgeIOXOwH8d3tKomw7h6FTeMnnBs= -20250915123412.sql h1:mz7SiWfrdf0qE1VTSAAnA/147d6gyp6ry5vZ2bR9SH0= -20250916043819.sql h1:RHXVtmMkB6wfv06HfPyHMBmUfIpFt1xveafNz0kwKnE= -20250917040616.sql h1:MYVDht+akBlzQGKNu2hTTTLPEcH1bxT/Q8MK6WEtuhs= -20250917040751.sql h1:J79YyS2JzWgh5oKXMTgh67uo3gLxKaAsxRiZmSIfjBs= -20250917045138.sql h1:/SM1N4O8X3yxpoJgMEARmS1uOkuLKsTOy4PLsRCOKaQ= -20250917093645.sql h1:PNBTGZ7s10e5b5+Tie8YfVQBN0zKtJ5T34oK1iOUEb4= -20250918073552.sql h1:jG7+g3i8ODYaJdcdZz12v3nbsZ5mB9wG6kWnGyTQIRI= -20250918073742.sql h1:j+rgw7puxE7s+phqPVZHmPk0af3rcaA56Itp86y1suY= -20250918074745.sql h1:rPmP4DXs6OnY4Vp+xO/z9jFpJt/RrJ52SJJjIIxeDvc= -20250923025134.sql h1:2r6pcwnBSU5Y9Czk1OHBoh4yZXiMtEca9X8843fTEX0= -20250924051317.sql h1:iUAk2gsGoEGIPQ0lEEUp8maMSId8emNbP+kP712ABIA= -20250929034321.sql h1:UlpALNVmdi95zOIT0yc6ZyTj9bBjQEIpZhvgrc52M+k= -20250929034428.sql h1:feF+H4nDyHh5bdx48Oiz0A1qecZfi6v3qTTdjzJ45Dg= -20250930025550.sql h1:6XT1kXI3Z3ZIxxmvT7poufZWWCW0QiejZPaFV5wBnjI= -20250930140351.sql h1:HxnmAbh9gCy8jwl/9ycGktiByaUripsjFFvohofY2CY= -20251002085604.sql h1:SjLPi+ZN6qDccK3DaEQCgNsZpPwr5kynWXwbwEsziCI= -20251003032030.sql h1:oHfxNSuqTxU8Zaf9H+h8TuUb1Da03wcyc6hZjDrUQ2s= -20251005060450.sql h1:GIuCcrd4MwjmXpvbzDzPYL18BV3QaZZ+Y2FmEzjvi0E= -20251006041122.sql h1:uNDQbSw0M08lYoMvUNlQtS3iDzpPM1ixT13ugSAoWjE= -20251006045658.sql h1:z+t7yCK54Q4SSiF9kUyUhkYB2F+kzSW9TB7ogxd9wzw= -20251006045928.sql h1:1lATLFLp4BWwGZqAjZdP0Dc6ypNXiYcwjoNkqGa8NFE= -20251007022859.sql h1:HXXwWrkyvzJzJGAt9mGskCRBBV/c1JfPmfjDocmJhQ4= -20251008031337.sql h1:Ln5pCF3Hxa5foHZLcds+z/us2eH6VAhhEj3w0TAGlVs= -20251008031554.sql h1:aB4MUS2lmqG0//4HKUWorcPSpWya0VC4QItvGyskEVI= -20251008052346.sql h1:MI3AZgU5XcwZT2OvvlWAxdRtL0eJ3jjRwt56IY1+pRU= -20251008073620.sql h1:sztWXuSNYwpEraaSapSsYwno75LO5H/N7ob7OJQ8X/A= -20251009042854.sql h1:TnPXj+dCJls3IU//cuqJZymyBzZMKs7ayazfgtAFRxM= -20251009052657.sql h1:leXbs0CP8r5dRilmYyLRk1MICqak3ea1/LWMtFrijqQ= -20251010031743.sql h1:SgHNY/lQ88G2F4nZyMfiOkDntb+gtOR+nEQLqXBTwv4= -20251010070721.sql h1:AnJnhXsMzDvK4AFgYw6B16Kpo/hljrZtcpc9m2VOSHQ= -20251010072711.sql h1:aXPTtNwLcTuw8C/yAxwxvqs0ayEjNzI1uuE0vE3ERa8= -20251013044536.sql h1:7Pq6JcvTpPBYDCW2dz3HdgUwY65HlhEVWy9TiG8iONE= -20251013051438.sql h1:X6t8bkqpUYYokBunSufMQUe5vCg0VyO6dxbm7ngosUc= -20251013081808.sql h1:495pLguXL2Ozh+ycn4UYZgZbn6WbjXNbyZUc3JU8qhI= -20251014060047.sql h1:nCgImMRGHhziiW57O1ofWaXCAPGaCOHN7PldQ3OSmM4= -20251014063537.sql h1:2cLmID79jP6cuQ1YJaWTtghFiM1GtHMC0ZQl30Hpy1M= -20251014063720.sql h1:bzLKKVAjSHgDFoiI/glj7t1ETlSAKx+AlsIAaP0ru2g= -20251015045455.sql h1:S547+UugQhlTRcn1Lm1IfqT5RNPttIWIiD+RTx69YaE= -20251016010845.sql h1:c9DUvxl17pUkf0azdYGM/YDzYxIJkLcfZOcMI4rL+R0= -20251016011023.sql h1:u3ivg83bXgYHBbojbWpemLxPE9Dmmj53B6LXo664jxw= -20251016062912.sql h1:W9n1hWchfYkqNX9LO9uxFxEXAb/iY+Pexjnhmp6PbgI= -20251017060617.sql h1:VU6yZ2+LfHpDZ3+TIH40t3F5YXPCpTppuF9+uSqa4b8= -20251017082207.sql h1:QshZslfedckz7iDpSGmPyY9sP6dy6ckHbs8L1TuXIA4= -20251018032635.sql h1:M1U/9W/F9wlW5YDmVAmHFfUJU7FWFaX0DblpfZcYWrE= -20251018040322.sql h1:Zk/vw0e6AzWFO2ElLOzB+OrSz6k+h1Ynxp0TImAzxwY= -20251019093915.sql h1:3Q0kPiZwJnHn5rAvdh0w1LBdiA7W2xBmZWncoPXb044= -20251020062553.sql h1:mJwC/J8GzPAIXckNMvy1f/Nguk2VVf8roD/Raclhbao= -20251021041042.sql h1:d1BAOGAQhqr+oOwcpAVozUsTh457VSDEk2qQFavGG58= -20251021075552.sql h1:TNChGQ1Zlr/1iQ6qvK4iDTAJpe6L/z/M6e/O0SkQVaM= +h1:JmnFn6HtgFEjn6R7vQ/qii2smCP5Ye2B2JgnKEpkkLs= +20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= +20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= +20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= +20250908062323.sql h1:oXl6Z143tOpIl4EfP4B8JNU8LrMvVmHEtCgAfiB4gs8= +20250908073811.sql h1:m2aNXfnGxnLq1+rVWrh4f60q7fhyhV3gEwNu/OIqQlE= +20250908073839.sql h1:cPk54xjLdMs26uY8ZHjNWLuyfAMzV7Zb0/9oJQrsw04= +20250910055902.sql h1:5xwjAV6QbtZT9empTJKfhyAjdknbHzb15B0Ku5dzqtQ= +20250915123412.sql h1:D83xaU2YlDEd21HLup/YQpQ2easMToYCyy/oK6AFgQs= +20250916043819.sql h1:ekoTJsBqQZ8G8n0qJ03d13+eoNoc7sAUEQGA5D/CCxk= +20250917040616.sql h1:zoCnmcXuM7AVv85SmN7RmFglCgJnoDmpRWExH0LAc9Q= +20250917040751.sql h1:J1xyRrh32y1+lezwAyNwPcUQ6ABBSgbvzNLva4SVdQU= +20250917045138.sql h1:jKe1Z0uOLG4SGBYM+S/3P+/zMPztmgoderD5swnMuCg= +20250917093645.sql h1:cNI3Pbz1R3LxvIXLuexafJFCXUXrmuFCgXXJ2sG+FW0= +20250918073552.sql h1:RJ1SvMzP6aeWnoPVD3eVAmIQOkcp6Php8z3QRri6v4g= +20250918073742.sql h1:+cEsnJTJFybe2fR69ZoOiX2R6c6iITl4m6WTZ1hjyzY= +20250918074745.sql h1:2hNVQCXF/dVYXAh+T/7oBFgERGWxzVb2FXJjwkFWGCI= +20250923025134.sql h1:Ykz/qpHiGDXPsCsWTjydQFVSibZP2D+h2fIeb2h2JGA= +20250924051317.sql h1:yQuW6SwJxIOM5fcxeAaie5lSm1oLysU/C2hH2xNCVoQ= +20250929034321.sql h1:101FJ8VH12mrZWlt/X1gvKUGOhoiF8tFbjiapAjnHzg= +20250929034428.sql h1:i+pROD9p+g5dOmmZma6WF/0Hw5g3Ha28NN85iTo1K34= +20250930025550.sql h1:+F+CsCUXD/ql0tHGEow70GhPBX1ZybVn+bh/T4YMh7Y= +20250930140351.sql h1:9AAEG1AnOAH+o0+oHL5G7I8vqlWOhwRlCGyyCpT/y1Q= +20251002085604.sql h1:3xZ68eYp4urXRnvotNH1XvG2mYOSDV/j3zHEZ/txg5E= +20251003032030.sql h1:HB+mQ2lXMNomHDpaRhB/9IwYI9/YiDO5eOJ+nAQH/jw= +20251005060450.sql h1:LbtCE2b+8osM3CvnmQJH1uCPtn+d7WchsslBOz8bL3Q= +20251006041122.sql h1:MlS7f21z06sutnf9dIekt5fuHJr4lgcQ4uCuCXAGsfc= +20251006045658.sql h1:3FmGCPCzjgMPdWDRodZTsx3KVaodd9zB9ilib69aewk= +20251006045928.sql h1:Z5g31PmnzNwk/OKdODcxZGm8fjJQdMFK32Xfnt3bRHg= +20251007022859.sql h1:FO03zEfaNEk/aXwY81d5Lp3MoBB9kPQuXlXJ4BPiSR8= +20251008031337.sql h1:l+sxUAGvcTfj3I6kAFHo+T6AYodC9k9GkR+jaKO2xXc= +20251008031554.sql h1:AqrVfIhSzY3PCy8ZlP5W91wn2iznfIuj5qQfubp6/94= +20251008052346.sql h1:nxnXmooIJ6r1mmzwnw+6efxLfc/k9h2aE6RMptPRons= +20251008073620.sql h1:6YsJp1W4SmQJ1lxpqF27BBlDC1zqhw7Yhc7pLzQTY6M= +20251009042854.sql h1:nkBV+R6j0fg7/JY6wH3eb5Vv0asJLnXmb6lINfT/GLQ= +20251009052657.sql h1:EPvdsib5rzCGPryd10HShGKvFPwM/R5S2lIVwtYxpms= +20251010031743.sql h1:T8IZmx8/btRFKLzTe78MzcBsPJNodnLvB0tby9QkirQ= +20251010070721.sql h1:5NQUk/yOV6sABLCB7swx++YIOyJe6MnU+yt1nRzde5w= +20251010072711.sql h1:ZJNqR2piyu8xJhBvVABSlnGEoKSKae3wuEs+wshPe4k= +20251013044536.sql h1:0Xjw8fNILiT8nnfrJDZgQnPf3dntmIoilbapnih8AE4= +20251013051438.sql h1:lfSuw5mgJnePBJamvhZ81osFIouXeiIEiSZ/evdwo48= +20251013081808.sql h1:ijgjNX08G6GBjA/ks8EKtb7P7Y7Cg7zbhqEOruGnv6M= +20251014060047.sql h1:0jqj49WTtneEIMQDBoo4c095ZGi8sCrA8NnHBrPU6D8= +20251014063537.sql h1:VZLXol0PTsTW21Epg6vBPsztWkDtcxup9F/z88EGgIg= +20251014063720.sql h1:2HVUyCV0ud3BJJDH2GEKZN/+IWLFPCsN1KqhP6csO14= +20251015045455.sql h1:MeLWmMhAOAz8b15Dd7IAQnt6JxjSml02XCXK22C0Lpg= +20251016010845.sql h1:4BncQdDOasRZJkzVJrSJJA7091A9VPNVx/faUCUPhBM= +20251016011023.sql h1:9JB9eFZKURK5RoCVDKR6glSvdJ8NTXrN7K/4q51zkz4= +20251016062912.sql h1:ACNn0fe+EMqUt3hoY+Dr3uqAV/QICBa1+mIW7fUc9Fk= +20251017060617.sql h1:4T3t9ifWrEQTPMSM0XJ98pF7Qdt+UfgtMui17bhrnWI= +20251017082207.sql h1:8vLG1l/saRRMHXkyA4nelJyjaSddhZd6r7R+Uo4JS/c= +20251018032635.sql h1:2xey5gnO3y2XSOrU8MLlIfoylPKbRGDRtHDD07B3MbQ= +20251018040322.sql h1:k/pdNiSoT8zFPqNQ/avOD0vYkNh3BTD64IlHrfVXr7I= +20251019093915.sql h1:hFcQE0y+p5dZiVwePGsRGto9m/q6kJNiUZbVDd5Rnjk= +20251020062553.sql h1:Iw7hulcm5iRQlfW+ygA4iTPxLqkxx6h9vXMXEwUAHKs= +20251021041042.sql h1:wMgSivBV2A0NDcsLmKGIp0kMcVh2IODSG9b4dgzCaOM= +20251021075552.sql h1:8gfSMAglflNO6L0sSzxFNEubYN8/O4thT7OQT+WH+3M= +20251023044432.sql h1:nax2UtrrEp7vE3uFbUbsExTPCvFr5Hv44NEPPTXTMtA= diff --git a/internal/domain/main-entities/adm-employee-hist/entity.go b/internal/domain/main-entities/adm-employee-hist/entity.go new file mode 100644 index 00000000..9077f438 --- /dev/null +++ b/internal/domain/main-entities/adm-employee-hist/entity.go @@ -0,0 +1,16 @@ +package adm_employee_hist + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + "time" +) + +type AdmEmployeeHist struct { + ecore.Main // adjust this according to the needs + Encounter_Id *uint `json:"encounter_id"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + StartedAt *time.Time `json:"startedAt"` + FinishedAt *time.Time `json:"finishedAt"` +} diff --git a/internal/domain/main-entities/division-position/entity.go b/internal/domain/main-entities/division-position/entity.go index 5bb3160a..c7d70968 100644 --- a/internal/domain/main-entities/division-position/entity.go +++ b/internal/domain/main-entities/division-position/entity.go @@ -9,7 +9,7 @@ import ( type DivisionPosition struct { ecore.SmallMain // adjust this according to the needs Division_Id *uint16 `json:"division_id"` - Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id"` + Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id;references:Id"` Code string `json:"code" gorm:"unique;size:10"` Name string `json:"name" gorm:"size:50"` HeadStatus bool `json:"headStatus"` diff --git a/internal/domain/main-entities/employee/entity.go b/internal/domain/main-entities/employee/entity.go index 2e8cd953..1177abe9 100644 --- a/internal/domain/main-entities/employee/entity.go +++ b/internal/domain/main-entities/employee/entity.go @@ -10,14 +10,14 @@ import ( ) type Employee struct { - ecore.Main // adjust this according to the needs - User_Id *uint `json:"user_id"` - User *eu.User `json:"user,omitempty" gorm:"foreignKey:User_Id;references:Id"` - Person_Id *uint `json:"person_id"` - Person *ep.Person `json:"person,omitempty" gorm:"foreignKey:Person_Id;references:Id"` - Position_Code *erg.EmployeePosisitionCode `json:"position_code" gorm:"size:20"` - Division_Code *string `json:"division_code"` - Division *ed.Division `json:"division,omitempty" gorm:"foreignKey:Division_Code;references:Code"` - Number *string `json:"number" gorm:"size:20"` - Status_Code erc.ActiveStatusCode `json:"status_code" gorm:"not null;size:10"` + ecore.Main // adjust this according to the needs + User_Id *uint `json:"user_id"` + User *eu.User `json:"user,omitempty" gorm:"foreignKey:User_Id;references:Id"` + Person_Id *uint `json:"person_id"` + Person *ep.Person `json:"person,omitempty" gorm:"foreignKey:Person_Id;references:Id"` + Position_Code *erg.EmployeePositionCode `json:"position_code" gorm:"size:20"` + Division_Code *string `json:"division_code"` + Division *ed.Division `json:"division,omitempty" gorm:"foreignKey:Division_Code;references:Code"` + Number *string `json:"number" gorm:"size:20"` + Status_Code erc.ActiveStatusCode `json:"status_code" gorm:"not null;size:10"` } diff --git a/internal/domain/main-entities/installation-position/entity.go b/internal/domain/main-entities/installation-position/entity.go new file mode 100644 index 00000000..03571326 --- /dev/null +++ b/internal/domain/main-entities/installation-position/entity.go @@ -0,0 +1,18 @@ +package installation_position + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + ei "simrs-vx/internal/domain/main-entities/installation" +) + +type InstallationPosition struct { + ecore.SmallMain // adjust this according to the needs + Installation_Id *uint16 `json:"installation_id" gorm:"not null"` + Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Id;references:Id"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} diff --git a/internal/domain/main-entities/responsible-doctor-hist/entity.go b/internal/domain/main-entities/responsible-doctor-hist/entity.go new file mode 100644 index 00000000..c9df2c13 --- /dev/null +++ b/internal/domain/main-entities/responsible-doctor-hist/entity.go @@ -0,0 +1,16 @@ +package responsible_doctor_hist + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ed "simrs-vx/internal/domain/main-entities/doctor" + "time" +) + +type ResponsibleDoctorHist struct { + ecore.Main // adjust this according to the needs + Encounter_Id *uint `json:"encounter_id"` + Doctor_Id *uint `json:"doctor_id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + StartedAt *time.Time `json:"startedAt"` + FinishedAt *time.Time `json:"finishedAt"` +} diff --git a/internal/domain/main-entities/specialist-position/entity.go b/internal/domain/main-entities/specialist-position/entity.go new file mode 100644 index 00000000..0afa5ba3 --- /dev/null +++ b/internal/domain/main-entities/specialist-position/entity.go @@ -0,0 +1,18 @@ +package specialist_position + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + es "simrs-vx/internal/domain/main-entities/specialist" +) + +type SpecialistPosition struct { + ecore.SmallMain // adjust this according to the needs + Specialist_Id *uint16 `json:"specialist_id" gorm:"not null"` + Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} diff --git a/internal/domain/main-entities/subspecialist-position/entity.go b/internal/domain/main-entities/subspecialist-position/entity.go new file mode 100644 index 00000000..5d4bdcb8 --- /dev/null +++ b/internal/domain/main-entities/subspecialist-position/entity.go @@ -0,0 +1,18 @@ +package subspecialist_position + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + es "simrs-vx/internal/domain/main-entities/subspecialist" +) + +type SubspecialistPosition struct { + ecore.SmallMain // adjust this according to the needs + Subspecialist_Id *uint16 `json:"subspecialist_id" gorm:"not null"` + Subspecialist *es.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} diff --git a/internal/domain/main-entities/unit-position/entity.go b/internal/domain/main-entities/unit-position/entity.go new file mode 100644 index 00000000..3bd10d9e --- /dev/null +++ b/internal/domain/main-entities/unit-position/entity.go @@ -0,0 +1,18 @@ +package unit_position + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + eu "simrs-vx/internal/domain/main-entities/unit" +) + +type UnitPosition struct { + ecore.SmallMain // adjust this according to the needs + Unit_Id *uint16 `json:"unit_id" gorm:"not null"` + Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} diff --git a/internal/domain/main-entities/user/dto.go b/internal/domain/main-entities/user/dto.go index 767cef3e..b06a4bb0 100644 --- a/internal/domain/main-entities/user/dto.go +++ b/internal/domain/main-entities/user/dto.go @@ -84,13 +84,13 @@ func (d *User) ToResponse() ResponseDto { } type EmployeUpdateDto struct { - Id uint `json:"id"` - User_Id *uint `json:"-"` - Person_Id *uint `json:"-"` - Division_Code *string `json:"division_code"` - Number *string `json:"number" validate:"maxLength=20"` - Position_Code erg.EmployeePosisitionCode `json:"position_code" validate:"maxLength=20"` - Status_Code erc.ActiveStatusCode `json:"status_code" validate:"maxLength=10"` + Id uint `json:"id"` + User_Id *uint `json:"-"` + Person_Id *uint `json:"-"` + Division_Code *string `json:"division_code"` + Number *string `json:"number" validate:"maxLength=20"` + Position_Code erg.EmployeePositionCode `json:"position_code" validate:"maxLength=20"` + Status_Code erc.ActiveStatusCode `json:"status_code" validate:"maxLength=10"` } func ToResponseList(data []User) []ResponseDto { diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 597c3f77..eadae620 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -2,6 +2,7 @@ package migration import ( adime "simrs-vx/internal/domain/main-entities/adime" + admemployeehist "simrs-vx/internal/domain/main-entities/adm-employee-hist" ambulancetransportreq "simrs-vx/internal/domain/main-entities/ambulance-transport-req" ambulatory "simrs-vx/internal/domain/main-entities/ambulatory" appointment "simrs-vx/internal/domain/main-entities/appointment" @@ -27,6 +28,7 @@ import ( infra "simrs-vx/internal/domain/main-entities/infra" inpatient "simrs-vx/internal/domain/main-entities/inpatient" installation "simrs-vx/internal/domain/main-entities/installation" + installationposition "simrs-vx/internal/domain/main-entities/installation-position" insurancecompany "simrs-vx/internal/domain/main-entities/insurance-company" intern "simrs-vx/internal/domain/main-entities/intern" internalreference "simrs-vx/internal/domain/main-entities/internal-reference" @@ -71,14 +73,18 @@ import ( proceduresrc "simrs-vx/internal/domain/main-entities/procedure-src" province "simrs-vx/internal/domain/main-entities/province" regency "simrs-vx/internal/domain/main-entities/regency" + responsibledoctorhist "simrs-vx/internal/domain/main-entities/responsible-doctor-hist" room "simrs-vx/internal/domain/main-entities/room" sbar "simrs-vx/internal/domain/main-entities/sbar" soapi "simrs-vx/internal/domain/main-entities/soapi" specialist "simrs-vx/internal/domain/main-entities/specialist" specialistintern "simrs-vx/internal/domain/main-entities/specialist-intern" + specialistposition "simrs-vx/internal/domain/main-entities/specialist-position" subspecialist "simrs-vx/internal/domain/main-entities/subspecialist" + subspecialistposition "simrs-vx/internal/domain/main-entities/subspecialist-position" therapyprotocol "simrs-vx/internal/domain/main-entities/therapy-protocol" unit "simrs-vx/internal/domain/main-entities/unit" + unitposition "simrs-vx/internal/domain/main-entities/unit-position" uom "simrs-vx/internal/domain/main-entities/uom" user "simrs-vx/internal/domain/main-entities/user" vehicle "simrs-vx/internal/domain/main-entities/vehicle" @@ -179,5 +185,11 @@ func getMainEntities() []any { &eduassesment.EduAssessment{}, &generalconsent.GeneralConsent{}, &deathcause.DeathCause{}, + &installationposition.InstallationPosition{}, + &unitposition.UnitPosition{}, + &specialistposition.SpecialistPosition{}, + &subspecialistposition.SubspecialistPosition{}, + &responsibledoctorhist.ResponsibleDoctorHist{}, + &admemployeehist.AdmEmployeeHist{}, } }