fix conflict

This commit is contained in:
vanilia
2025-10-27 06:31:56 +07:00
73 changed files with 641 additions and 355 deletions
+2 -1
View File
@@ -5,7 +5,8 @@
"payload-bad": "struktur data tidak sesuai standar",
"auth-required": "butuh autentikasi",
"auth-missingHeader": "Header autentikasi tidak ditemukan",
"auth-getData-failed": "gagal mengambil data user",
"auth-missingHeader": "header autentikasi tidak ditemukan",
"auth-forbidden": "tidak diijinkan",
"auth-login-success": "login berhasil",
"auth-login-incorrect": "Username atau Password Tidak Sesuai",
@@ -0,0 +1,2 @@
-- Modify "Employee" table
ALTER TABLE "public"."Employee" DROP COLUMN "Division_Code";
+60 -59
View File
@@ -1,59 +1,60 @@
h1:HozaE+KMdV5bp0Z1QR6FiU5dW3npmFwbvxo+noqNuRQ=
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=
20251023044432.sql h1:GA2AdJk2ULyjr6igtu9C/CEi4YUIks8r9jXGGaCvPsk=
20251024034832.sql h1:RXmbEhMkOLK5g1QL6up8iRPcwYfo89oLP26ZHvrUK9o=
h1:ieMeKh35/dro1YBBO11ZP0nZan9aJ5aFSqnEAi+T+WQ=
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:MkvajJs3bfk9+wHvQ43/ccAluJEBARm1gWr1u92ccLA=
20251024034832.sql h1:x3s3VEVYLOSKLAFxJGb2+c1FyTMMvPE+9k4Ew7rKQaI=
20251024074315.sql h1:EjAjelgi5qAfcRq/8vPTlGGYHvAKxNTllm8f0SzZDns=
+5 -2
View File
@@ -1,13 +1,16 @@
package adime
import (
// std
"time"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain
ecore "simrs-vx/internal/domain/base-entities/core"
eem "simrs-vx/internal/domain/main-entities/employee"
ee "simrs-vx/internal/domain/main-entities/encounter"
pa "simrs-vx/pkg/auth-helper"
)
type CreateDto struct {
+8 -4
View File
@@ -1,16 +1,20 @@
package chemo
import (
// std
"time"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - references
erc "simrs-vx/internal/domain/references/common"
// internal - domain - main-entities
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
eun "simrs-vx/internal/domain/main-entities/unit"
eus "simrs-vx/internal/domain/main-entities/user"
erc "simrs-vx/internal/domain/references/common"
pa "simrs-vx/pkg/auth-helper"
)
type CreateDto struct {
@@ -1,14 +1,19 @@
package consultation
import (
// std
"time"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - main-entities
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
eu "simrs-vx/internal/domain/main-entities/unit"
pa "simrs-vx/pkg/auth-helper"
)
type CreateDto struct {
@@ -1,13 +1,18 @@
package deviceorder
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - references
erc "simrs-vx/internal/domain/references/common"
pa "simrs-vx/pkg/auth-helper"
// internal - domain - main-entities
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
)
type CreateDto struct {
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Division_Id *uint16 `json:"division_id"`
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
}
func (Basic) TableName() string {
return "DivisionPosition"
}
@@ -1,18 +1,11 @@
package divisionposition
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/division"
ee "simrs-vx/internal/domain/main-entities/employee"
eb "simrs-vx/internal/domain/main-entities/division-position/base"
)
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;references:Id"`
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
eb.Basic
Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id;references:Id"`
}
+16 -12
View File
@@ -2,6 +2,7 @@ package division
import (
ecore "simrs-vx/internal/domain/base-entities/core"
edpb "simrs-vx/internal/domain/main-entities/division-position/base"
)
type CreateDto struct {
@@ -26,8 +27,9 @@ type FilterDto struct {
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Code *string `json:"code"`
Id uint16 `json:"id"`
Code *string `json:"code"`
Includes string `json:"includes"`
}
type UpdateDto struct {
@@ -47,20 +49,22 @@ type MetaDto struct {
type ResponseDto struct {
ecore.SmallMain
Code string `json:"code"`
Name string `json:"name"`
Parent_Id *uint16 `json:"parent_id"`
Parent *Division `json:"parent,omitempty"`
Childrens []Division `json:"childrens,omitempty"`
Code string `json:"code"`
Name string `json:"name"`
Parent_Id *uint16 `json:"parent_id"`
Parent *Division `json:"parent,omitempty"`
Childrens []Division `json:"childrens,omitempty"`
DivisionPosition []edpb.Basic `json:"divisionPositions,omitempty"`
}
func (d Division) ToResponse() ResponseDto {
resp := ResponseDto{
Code: d.Code,
Name: d.Name,
Parent_Id: d.Parent_Id,
Parent: d.Parent,
Childrens: d.Childrens,
Code: d.Code,
Name: d.Name,
Parent_Id: d.Parent_Id,
Parent: d.Parent,
Childrens: d.Childrens,
DivisionPosition: d.DivisionPositions,
}
resp.SmallMain = d.SmallMain
return resp
@@ -2,13 +2,15 @@ package division
import (
ecore "simrs-vx/internal/domain/base-entities/core"
edpb "simrs-vx/internal/domain/main-entities/division-position/base"
)
type Division struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Parent_Id *uint16 `json:"parent_id"`
Parent *Division `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"`
Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Parent_Id *uint16 `json:"parent_id"`
Parent *Division `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"`
Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self
DivisionPositions []edpb.Basic `json:"divisionPositions,omitempty" gorm:"foreignKey:Division_Id;references:Id"`
}
+13 -22
View File
@@ -2,18 +2,16 @@ package employee
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/division"
ep "simrs-vx/internal/domain/main-entities/person"
eu "simrs-vx/internal/domain/main-entities/user"
erg "simrs-vx/internal/domain/references/organization"
erc "simrs-vx/internal/domain/references/common"
erg "simrs-vx/internal/domain/references/organization"
)
type CreateDto struct {
User_Id *uint `json:"user_id"`
Person_Id *uint `json:"person_id"`
Division_Code *string `json:"division_code"`
Number *string `json:"number" validate:"maxLength=20"`
Status_Code erc.ActiveStatusCode `json:"status_code" validate:"maxLength=10"`
Position_Code *erg.EmployeePositionCode `json:"position_code"`
@@ -28,7 +26,6 @@ type ReadListDto struct {
type FilterDto struct {
User_Id *uint `json:"user-id"`
Person_Id *uint `json:"person-id"`
Division_Code *string `json:"division-code"`
Position_Code *string `json:"position-code"`
Number *string `json:"number"`
Status_Code erc.ActiveStatusCode `json:"status-code"`
@@ -58,28 +55,22 @@ type MetaDto struct {
type ResponseDto struct {
ecore.Main
User_Id *uint `json:"user_id"`
User *eu.User `json:"user,omitempty"`
Person_Id *uint `json:"person_id"`
Person *ep.Person `json:"person,omitempty"`
Division_Code *string `json:"division_code"`
Division *ed.Division `json:"division,omitempty"`
Position_Code *erg.EmployeePositionCode `json:"position_code"`
Number *string `json:"number"`
Status_Code erc.ActiveStatusCode `json:"status_code"`
User_Id *uint `json:"user_id"`
User *eu.User `json:"user,omitempty"`
Person_Id *uint `json:"person_id"`
Person *ep.Person `json:"person,omitempty"`
Number *string `json:"number"`
Status_Code erc.ActiveStatusCode `json:"status_code"`
}
func (d Employee) ToResponse() ResponseDto {
resp := ResponseDto{
User_Id: d.User_Id,
User: d.User,
Person_Id: d.Person_Id,
Person: d.Person,
Division_Code: d.Division_Code,
Division: d.Division,
Number: d.Number,
Status_Code: d.Status_Code,
Position_Code: d.Position_Code,
User_Id: d.User_Id,
User: d.User,
Person_Id: d.Person_Id,
Person: d.Person,
Number: d.Number,
Status_Code: d.Status_Code,
}
resp.Main = d.Main
return resp
@@ -2,7 +2,6 @@ package employee
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/division"
ep "simrs-vx/internal/domain/main-entities/person"
eu "simrs-vx/internal/domain/main-entities/user"
erc "simrs-vx/internal/domain/references/common"
@@ -16,8 +15,6 @@ type Employee struct {
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"`
}
+13 -5
View File
@@ -1,9 +1,20 @@
package encounter
import (
// std
"time"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - references
erc "simrs-vx/internal/domain/references/common"
ere "simrs-vx/internal/domain/references/encounter"
// internal - domain - main-entities
evs "simrs-vx/internal/domain/bpjs-entities/vclaim-sep"
ea "simrs-vx/internal/domain/main-entities/appointment"
ed "simrs-vx/internal/domain/main-entities/doctor"
@@ -13,11 +24,6 @@ import (
es "simrs-vx/internal/domain/main-entities/specialist"
ess "simrs-vx/internal/domain/main-entities/subspecialist"
eu "simrs-vx/internal/domain/main-entities/unit"
erc "simrs-vx/internal/domain/references/common"
ere "simrs-vx/internal/domain/references/encounter"
pa "simrs-vx/pkg/auth-helper"
)
type CreateDto struct {
@@ -48,6 +54,8 @@ type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Pagination ecore.Pagination
pa.AuthInfo
}
type FilterDto struct {
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Installation_Id *uint16 `json:"installation_id" gorm:"not null"`
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"`
}
func (Basic) TableName() string {
return "InstallationPosition"
}
@@ -1,18 +1,11 @@
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"
eib "simrs-vx/internal/domain/main-entities/installation-position/base"
)
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"`
eib.Basic // adjust this according to the needs
Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Id;references:Id"`
}
@@ -2,6 +2,7 @@ package installation
import (
ecore "simrs-vx/internal/domain/base-entities/core"
eipb "simrs-vx/internal/domain/main-entities/installation-position/base"
ere "simrs-vx/internal/domain/references/encounter"
)
@@ -27,8 +28,9 @@ type FilterDto struct {
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Code *string `json:"code"`
Id uint16 `json:"id"`
Code *string `json:"code"`
Includes string `json:"includes"`
}
type UpdateDto struct {
@@ -48,16 +50,18 @@ type MetaDto struct {
type ResponseDto struct {
ecore.SmallMain
Code string `json:"code"`
Name string `json:"name"`
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code"`
Code string `json:"code"`
Name string `json:"name"`
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code"`
InstallationPositions []eipb.Basic `json:"installationPositions,omitempty"`
}
func (d Installation) ToResponse() ResponseDto {
resp := ResponseDto{
Code: d.Code,
Name: d.Name,
EncounterClass_Code: d.EncounterClass_Code,
Code: d.Code,
Name: d.Name,
EncounterClass_Code: d.EncounterClass_Code,
InstallationPositions: d.InstallationPositions,
}
resp.SmallMain = d.SmallMain
return resp
@@ -2,12 +2,14 @@ package installation
import (
ecore "simrs-vx/internal/domain/base-entities/core"
eipb "simrs-vx/internal/domain/main-entities/installation-position/base"
ere "simrs-vx/internal/domain/references/encounter"
)
type Installation struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" gorm:"size:10"`
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" gorm:"size:10"`
InstallationPositions []eipb.Basic `json:"installationPositions,omitempty" gorm:"foreignKey:Installation_Id;references:Id"`
}
@@ -1,13 +1,18 @@
package materialorder
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - references
erc "simrs-vx/internal/domain/references/common"
pa "simrs-vx/pkg/auth-helper"
// internal - domain - main-entities
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
)
type CreateDto struct {
+13 -6
View File
@@ -1,15 +1,22 @@
package mcuorder
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
// std
"time"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - references
ercl "simrs-vx/internal/domain/references/clinical"
erc "simrs-vx/internal/domain/references/common"
pa "simrs-vx/pkg/auth-helper"
// internal - domain - main-entities
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
)
type CreateDto struct {
@@ -20,7 +27,7 @@ type CreateDto struct {
ExaminationDate *time.Time `json:"examinationDate"`
Number uint8 `json:"number"`
Temperature float64 `json:"temperature"`
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code""`
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code"`
pa.AuthInfo
}
@@ -39,7 +46,7 @@ type FilterDto struct {
ExaminationDate *time.Time `json:"examinationDate"`
Number uint8 `json:"number"`
Temperature float64 `json:"temperature"`
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel-code""`
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel-code"`
}
type ReadDetailDto struct {
Id uint `json:"id"`
@@ -1,12 +1,17 @@
package medicationitem
import (
ecore "simrs-vx/internal/domain/base-entities/core"
emi "simrs-vx/internal/domain/main-entities/medication-item"
pa "simrs-vx/pkg/auth-helper"
// std
"time"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - main-entities
emi "simrs-vx/internal/domain/main-entities/medication-item"
)
type CreateDto struct {
@@ -1,15 +1,21 @@
package medication
import (
// std
"time"
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ep "simrs-vx/internal/domain/main-entities/pharmacist"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - references
erc "simrs-vx/internal/domain/references/common"
pa "simrs-vx/pkg/auth-helper"
// internal - domain - main-entities
ee "simrs-vx/internal/domain/main-entities/encounter"
ep "simrs-vx/internal/domain/main-entities/pharmacist"
)
type CreateDto struct {
+2 -2
View File
@@ -57,8 +57,8 @@ type DeleteDto struct {
}
type SearchDto struct {
Search string `json:"search"`
Mode SearchMode `json:"mode"`
Search string `json:"search"`
Pagination ecore.Pagination
}
type UploadDto struct {
@@ -7,6 +7,8 @@ import (
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
pa "simrs-vx/internal/lib/auth"
erc "simrs-vx/internal/domain/references/common"
)
@@ -15,6 +17,8 @@ type CreateDto struct {
Doctor_Id *uint `json:"doctor_id"`
IssuedAt *time.Time `json:"issuedAt"`
Status_Code erc.DataStatusCode `json:"status_code"`
pa.AuthInfo
}
type ReadListDto struct {
+7 -2
View File
@@ -1,13 +1,18 @@
package sbar
import (
// std
"time"
// internal - lib
pa "simrs-vx/internal/lib/auth"
// internal - domain - base-entities
ecore "simrs-vx/internal/domain/base-entities/core"
// internal - domain - main-entities
eem "simrs-vx/internal/domain/main-entities/employee"
ee "simrs-vx/internal/domain/main-entities/encounter"
pa "simrs-vx/pkg/auth-helper"
)
type CreateDto struct {
+1 -1
View File
@@ -9,7 +9,7 @@ import (
erc "simrs-vx/internal/domain/references/clinical"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
)
type CreateDto struct {
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Specialist_Id *uint16 `json:"specialist_id" gorm:"not null"`
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"`
}
func (Basic) TableName() string {
return "SpecialistPosition"
}
@@ -1,18 +1,11 @@
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"
esb "simrs-vx/internal/domain/main-entities/specialist-position/base"
)
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"`
esb.Basic
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"`
}
@@ -2,6 +2,7 @@ package specialist
import (
ecore "simrs-vx/internal/domain/base-entities/core"
espb "simrs-vx/internal/domain/main-entities/specialist-position/base"
)
type CreateDto struct {
@@ -25,8 +26,9 @@ type FilterDto struct {
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Code *string `json:"code"`
Id uint16 `json:"id"`
Code *string `json:"code"`
Includes string `json:"includes"`
}
type UpdateDto struct {
@@ -46,16 +48,18 @@ type MetaDto struct {
type ResponseDto struct {
ecore.SmallMain
Code string `json:"code"`
Name string `json:"name"`
Unit_Id *uint16 `json:"unit_id"`
Code string `json:"code"`
Name string `json:"name"`
Unit_Id *uint16 `json:"unit_id"`
SpecialistPositions []espb.Basic `json:"specialistPositions,omitempty"`
}
func (d Specialist) ToResponse() ResponseDto {
resp := ResponseDto{
Code: d.Code,
Name: d.Name,
Unit_Id: d.Unit_Id,
Code: d.Code,
Name: d.Name,
Unit_Id: d.Unit_Id,
SpecialistPositions: d.SpecialistPositions,
}
resp.SmallMain = d.SmallMain
return resp
@@ -2,13 +2,15 @@ package specialist
import (
ecore "simrs-vx/internal/domain/base-entities/core"
eub "simrs-vx/internal/domain/main-entities/specialist-position/base"
eu "simrs-vx/internal/domain/main-entities/unit"
)
type Specialist struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Unit_Id *uint16 `json:"unit_id"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"`
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Unit_Id *uint16 `json:"unit_id"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"`
SpecialistPositions []eub.Basic `json:"specialistPositions,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"`
}
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Subspecialist_Id *uint16 `json:"subspecialist_id" gorm:"not null"`
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"`
}
func (Basic) TableName() string {
return "SubspecialistPosition"
}
@@ -1,18 +1,11 @@
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"
esb "simrs-vx/internal/domain/main-entities/subspecialist-position/base"
)
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"`
esb.Basic
Subspecialist *es.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"`
}
@@ -2,6 +2,7 @@ package subspecialist
import (
ecore "simrs-vx/internal/domain/base-entities/core"
espb "simrs-vx/internal/domain/main-entities/subspecialist-position/base"
)
type CreateDto struct {
@@ -25,8 +26,9 @@ type FilterDto struct {
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Code *string `json:"code"`
Id uint16 `json:"id"`
Code *string `json:"code"`
Includes string `json:"includes"`
}
type UpdateDto struct {
@@ -46,9 +48,10 @@ type MetaDto struct {
type ResponseDto struct {
ecore.SmallMain
Code string `json:"code"`
Name string `json:"name"`
Specialist_Id *uint16 `json:"specialist_id"`
Code string `json:"code"`
Name string `json:"name"`
Specialist_Id *uint16 `json:"specialist_id"`
Subspecialist []espb.Basic `json:"subspecialistPositions,omitempty"`
}
func (d Subspecialist) ToResponse() ResponseDto {
@@ -56,6 +59,7 @@ func (d Subspecialist) ToResponse() ResponseDto {
Code: d.Code,
Name: d.Name,
Specialist_Id: d.Specialist_Id,
Subspecialist: d.SubspecialistPositions,
}
resp.SmallMain = d.SmallMain
return resp
@@ -3,12 +3,14 @@ package subspecialist
import (
ecore "simrs-vx/internal/domain/base-entities/core"
es "simrs-vx/internal/domain/main-entities/specialist"
espb "simrs-vx/internal/domain/main-entities/subspecialist-position/base"
)
type Subspecialist struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Specialist_Id *uint16 `json:"specialist_id"`
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"`
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Specialist_Id *uint16 `json:"specialist_id"`
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"`
SubspecialistPositions []espb.Basic `json:"subspecialistPositions,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"`
}
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Unit_Id *uint16 `json:"unit_id" gorm:"not null"`
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"`
}
func (Basic) TableName() string {
return "UnitPosition"
}
@@ -1,18 +1,11 @@
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"
eub "simrs-vx/internal/domain/main-entities/unit-position/base"
)
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"`
eub.Basic
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
}
+6 -2
View File
@@ -3,6 +3,7 @@ package unit
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ei "simrs-vx/internal/domain/main-entities/installation"
eipb "simrs-vx/internal/domain/main-entities/unit-position/base"
)
type CreateDto struct {
@@ -29,6 +30,7 @@ type ReadDetailDto struct {
Id uint16 `json:"id"`
Installation_Id *uint16 `json:"installation_id"`
Code *string `json:"code"`
Includes string `json:"includes"`
}
type UpdateDto struct {
@@ -50,8 +52,9 @@ type ResponseDto struct {
ecore.SmallMain
Installation_Id *uint16 `json:"installation_id"`
Installation *ei.Installation
Code string `json:"code"`
Name string `json:"name"`
Code string `json:"code"`
Name string `json:"name"`
UnitPositions []eipb.Basic `json:"unitPositions,omitempty"`
}
func (d Unit) ToResponse() ResponseDto {
@@ -59,6 +62,7 @@ func (d Unit) ToResponse() ResponseDto {
Installation_Id: d.Installation_Id,
Code: d.Code,
Name: d.Name,
UnitPositions: d.UnitPositions,
}
resp.SmallMain = d.SmallMain
if d.Installation != nil {
@@ -3,6 +3,7 @@ package unit
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ei "simrs-vx/internal/domain/main-entities/installation"
eub "simrs-vx/internal/domain/main-entities/unit-position/base"
ero "simrs-vx/internal/domain/references/organization"
)
@@ -13,4 +14,5 @@ type Unit struct {
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Type_Code *ero.UnitTypeCode `json:"type_code"`
UnitPositions []eub.Basic `json:"unitPositions,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
}
@@ -11,7 +11,7 @@ import (
e "simrs-vx/internal/domain/main-entities/adime"
u "simrs-vx/internal/use-case/main-use-case/adime"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -10,7 +10,7 @@ import (
m "simrs-vx/internal/domain/main-entities/user"
s "simrs-vx/internal/use-case/main-use-case/authentication"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
)
func Login(w http.ResponseWriter, r *http.Request) {
@@ -14,7 +14,7 @@ import (
u "simrs-vx/internal/use-case/main-use-case/chemo"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -11,7 +11,7 @@ import (
e "simrs-vx/internal/domain/main-entities/consultation"
u "simrs-vx/internal/use-case/main-use-case/consultation"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -9,7 +9,7 @@ import (
e "simrs-vx/internal/domain/main-entities/device-order"
u "simrs-vx/internal/use-case/main-use-case/device-order"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -37,7 +37,9 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
if id <= 0 {
return
}
dto := e.ReadDetailDto{}
sf.UrlQueryParam(&dto, *r.URL)
dto.Id = uint16(id)
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
@@ -12,7 +12,7 @@ import (
u "simrs-vx/internal/use-case/main-use-case/encounter"
erc "simrs-vx/internal/domain/references/common"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -36,7 +36,12 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
}
func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
authInfo, err := pa.GetAuthInfo(r)
if err != nil {
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
}
dto := e.ReadListDto{}
dto.AuthInfo = *authInfo
sf.UrlQueryParam(&dto, *r.URL)
res, err := u.ReadList(dto)
rw.DataResponse(w, res, err)
@@ -38,6 +38,8 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
return
}
dto := e.ReadDetailDto{}
sf.UrlQueryParam(&dto, *r.URL)
dto.Id = uint16(id)
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
+20 -19
View File
@@ -5,6 +5,7 @@ import (
/******************** main / transaction ********************/
adime "simrs-vx/internal/interface/main-handler/adime"
admemployeehist "simrs-vx/internal/interface/main-handler/adm-employee-hist"
ambulancetransportrequest "simrs-vx/internal/interface/main-handler/ambulance-transport-req"
auth "simrs-vx/internal/interface/main-handler/authentication"
chemo "simrs-vx/internal/interface/main-handler/chemo"
@@ -27,11 +28,11 @@ import (
practiceschedule "simrs-vx/internal/interface/main-handler/practice-schedule"
prescription "simrs-vx/internal/interface/main-handler/prescription"
prescriptionitem "simrs-vx/internal/interface/main-handler/prescription-item"
responsibledoctorhist "simrs-vx/internal/interface/main-handler/responsible-doctor-hist"
sbar "simrs-vx/internal/interface/main-handler/sbar"
soapi "simrs-vx/internal/interface/main-handler/soapi"
/******************** actor ********************/
admemployeehist "simrs-vx/internal/interface/main-handler/adm-employee-hist"
doctor "simrs-vx/internal/interface/main-handler/doctor"
employee "simrs-vx/internal/interface/main-handler/employee"
nurse "simrs-vx/internal/interface/main-handler/nurse"
@@ -42,7 +43,6 @@ import (
personcontact "simrs-vx/internal/interface/main-handler/person-contact"
personinsurance "simrs-vx/internal/interface/main-handler/person-insurance"
pharmacist "simrs-vx/internal/interface/main-handler/pharmacist"
responsibledoctorhist "simrs-vx/internal/interface/main-handler/responsible-doctor-hist"
user "simrs-vx/internal/interface/main-handler/user"
/******************** external ********************/
@@ -137,6 +137,20 @@ func SetRoutes() http.Handler {
hc.RegCrud(r, "/v1/prescription-item", prescriptionitem.O)
hc.RegCrud(r, "/v1/device-order-item", deviceorderitem.O)
hc.RegCrud(r, "/v1/material-order-item", materialorderitem.O)
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": encounter.O.GetList,
"GET /{id}": encounter.O.GetDetail,
"POST /": encounter.O.Create,
"PATCH /{id}": encounter.O.Update,
"DELETE /{id}": encounter.O.Delete,
"PATCH /{id}/check-out": encounter.O.CheckOut,
"PATCH /{id}/check-in": encounter.O.CheckIn,
"PATCH /{id}/proccess": encounter.O.Process,
"PATCH /{id}/cancel": encounter.O.Cancel,
"PATCH /{id}/reject": encounter.O.Reject,
"PATCH /{id}/skip": encounter.O.Skip,
})
hk.GroupRoutes("/v1/mcu-order", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": mcuorder.O.GetList,
"GET /{id}": mcuorder.O.GetDetail,
@@ -155,7 +169,7 @@ func SetRoutes() http.Handler {
"PATCH /{id}/complete": mcuorderitem.O.Complete,
"PATCH /{id}/set-schedule": mcuorderitem.O.SetSchedule,
})
hk.GroupRoutes("/v1/prescription", r, hk.MapHandlerFunc{
hk.GroupRoutes("/v1/prescription", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": prescription.O.GetList,
"GET /{id}": prescription.O.GetDetail,
"POST /": prescription.O.Create,
@@ -163,7 +177,7 @@ func SetRoutes() http.Handler {
"DELETE /{id}": prescription.O.Delete,
"PATCH /{id}/approve": prescription.O.Approve,
})
hk.GroupRoutes("/v1/mcu-order-sub-item", r, hk.MapHandlerFunc{
hk.GroupRoutes("/v1/mcu-order-sub-item", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": mcuordersubitem.O.GetList,
"GET /{id}": mcuordersubitem.O.GetDetail,
"POST /": mcuordersubitem.O.Create,
@@ -171,19 +185,6 @@ func SetRoutes() http.Handler {
"DELETE /{id}": mcuordersubitem.O.Delete,
"PATCH /{id}/complete": mcuordersubitem.O.Complete,
})
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": encounter.O.GetList,
"GET /{id}": encounter.O.GetDetail,
"POST /": encounter.O.Create,
"PATCH /{id}": encounter.O.Update,
"DELETE /{id}": encounter.O.Delete,
"PATCH /{id}/check-out": encounter.O.CheckOut,
"PATCH /{id}/check-in": encounter.O.CheckIn,
"PATCH /{id}/proccess": encounter.O.Process,
"PATCH /{id}/cancel": encounter.O.Cancel,
"PATCH /{id}/reject": encounter.O.Reject,
"PATCH /{id}/skip": encounter.O.Skip,
})
hk.GroupRoutes("/v1/medication", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": medication.O.GetList,
"GET /{id}": medication.O.GetDetail,
@@ -193,7 +194,7 @@ func SetRoutes() http.Handler {
"PATCH /{id}/complete": medication.O.Complete,
})
hk.GroupRoutes("/v1/medication-item", r, hk.MapHandlerFunc{
hk.GroupRoutes("/v1/medication-item", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": medicationitem.O.GetList,
"GET /{id}": medicationitem.O.GetDetail,
"POST /": medicationitem.O.Create,
@@ -279,7 +280,7 @@ func SetRoutes() http.Handler {
"PATCH /{id}": patient.O.Update,
"DELETE /{id}": patient.O.Delete,
"GET /search/{keyword}": patient.O.Search,
"GET /by-resident-identity": patient.O.SearchByResidentIdentity,
"GET /by-resident-identity": patient.O.SearchByResidentIdentityNumber,
"POST /{id}/upload": patient.O.Upload,
})
@@ -11,7 +11,7 @@ import (
e "simrs-vx/internal/domain/main-entities/material-order"
u "simrs-vx/internal/use-case/main-use-case/material-order"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -11,7 +11,7 @@ import (
e "simrs-vx/internal/domain/main-entities/mcu-order"
u "simrs-vx/internal/use-case/main-use-case/mcu-order"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -6,7 +6,7 @@ import (
rw "github.com/karincake/risoles"
sf "github.com/karincake/semprit"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
e "simrs-vx/internal/domain/main-entities/medication-item-dist"
u "simrs-vx/internal/use-case/main-use-case/medication-item-dist"
@@ -6,7 +6,7 @@ import (
rw "github.com/karincake/risoles"
sf "github.com/karincake/semprit"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
e "simrs-vx/internal/domain/main-entities/medication"
u "simrs-vx/internal/use-case/main-use-case/medication"
@@ -76,21 +76,22 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
func (obj myBase) Search(w http.ResponseWriter, r *http.Request) {
dto := e.SearchDto{}
sf.UrlQueryParam(&dto, *r.URL)
keyword := rw.ValidateString(w, "keyword", r.PathValue("keyword"))
if keyword == "" {
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "keyword is required"}, nil)
}
dto.Mode = e.SMIdent
dto.Search = keyword
res, err := u.Search(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) SearchByResidentIdentity(w http.ResponseWriter, r *http.Request) {
func (obj myBase) SearchByResidentIdentityNumber(w http.ResponseWriter, r *http.Request) {
dto := e.SearchDto{}
sf.UrlQueryParam(&dto, *r.URL)
dto.Mode = e.SMNik
res, err := u.Search(dto)
res, err := u.SearchByResidentIdentityNumber(dto)
rw.DataResponse(w, res, err)
}
@@ -7,6 +7,9 @@ import (
sf "github.com/karincake/semprit"
// ua "github.com/karincake/tumpeng/auth/svc"
d "github.com/karincake/dodol"
pa "simrs-vx/internal/lib/auth"
e "simrs-vx/internal/domain/main-entities/prescription"
u "simrs-vx/internal/use-case/main-use-case/prescription"
@@ -21,6 +24,11 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
authInfo, err := pa.GetAuthInfo(r)
if err != nil {
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
}
dto.AuthInfo = *authInfo
res, err := u.Create(dto)
rw.DataResponse(w, res, err)
}
@@ -11,7 +11,7 @@ import (
e "simrs-vx/internal/domain/main-entities/sbar"
u "simrs-vx/internal/use-case/main-use-case/sbar"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -11,7 +11,7 @@ import (
e "simrs-vx/internal/domain/main-entities/soapi"
u "simrs-vx/internal/use-case/main-use-case/soapi"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
d "github.com/karincake/dodol"
)
@@ -38,6 +38,8 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
return
}
dto := e.ReadDetailDto{}
sf.UrlQueryParam(&dto, *r.URL)
dto.Id = uint16(id)
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
@@ -38,6 +38,8 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
return
}
dto := e.ReadDetailDto{}
sf.UrlQueryParam(&dto, *r.URL)
dto.Id = uint16(id)
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
@@ -38,6 +38,8 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
return
}
dto := e.ReadDetailDto{}
sf.UrlQueryParam(&dto, *r.URL)
dto.Id = uint16(id)
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
View File
@@ -6,16 +6,23 @@ import (
type AuthKey struct{}
// const AuthKey = struct{}{}
type AuthInfo struct {
Uuid string
User_Id uint
User_Name string
User_ContractPosition_code string
Employee_Position_Code *string
Employee_Id *int
Doctor_Id *int
Nurse_Id *int
Midwife_Id *int
Nutritionist_Id *int
Laborant_Id *int
Pharmachist_Id *int
Intern_Position_Code *string
User_DivisionPositions []DivisionPosition
// User_DivisionPositions []DivisionPosition
// User_Position_Code string
Roles []string
// User_DivisionPositions []DivisionPosition
}
type DivisionPosition struct {
@@ -13,12 +13,13 @@ import (
"simrs-vx/internal/domain/main-entities/intern"
eu "simrs-vx/internal/domain/main-entities/user"
pa "simrs-vx/pkg/auth-helper"
pa "simrs-vx/internal/lib/auth"
el "simrs-vx/pkg/logger"
p "simrs-vx/pkg/password"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/employee"
em "simrs-vx/internal/domain/main-entities/midwife"
en "simrs-vx/internal/domain/main-entities/nurse"
erc "simrs-vx/internal/domain/references/common"
erg "simrs-vx/internal/domain/references/organization"
@@ -120,10 +121,10 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
outputData["employee_id"] = employee.Id
role = append(role, "emp-"+string(*employee.Position_Code))
if employee.Division_Code != nil {
atClaims["employee_division_code"] = employee.Division_Code
outputData["employee_division_code"] = employee.Division_Code
}
//if employee.Division_Code != nil {
// atClaims["employee_division_code"] = employee.Division_Code
// outputData["employee_division_code"] = employee.Division_Code
//}
// employee position
if employee.Id > 0 && employee.Position_Code != nil {
@@ -147,19 +148,27 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
outputData["subspecialist_id"] = doctor.Subspecialist_Id
}
case erg.EPCNur:
nurse := en.Nurse{}
dg.I.Where("\"Employee_Id\" = ?", employee.Id).First(&nurse)
if nurse.Id == 0 {
empData := en.Nurse{}
dg.I.Where("\"Employee_Id\" = ?", employee.Id).First(&empData)
if empData.Id == 0 {
return nil, d.FieldErrors{"authentication": d.FieldError{Code: "auth-noNurse", Message: el.GenMessage("auth-noNurse")}}
}
atClaims["nurse_id"] = nurse.Id
outputData["nurse_id"] = nurse.Id
atClaims["nurse_id"] = empData.Id
outputData["nurse_id"] = empData.Id
case erg.EPCMwi:
empData := em.Midwife{}
dg.I.Where("\"Employee_Id\" = ?", employee.Id).First(&empData)
if empData.Id == 0 {
return nil, d.FieldErrors{"authentication": d.FieldError{Code: "auth-noNurse", Message: el.GenMessage("auth-noNurse")}}
}
atClaims["nurse_id"] = empData.Id
outputData["nurse_id"] = empData.Id
}
errorGetPosition := d.FieldErrors{"authentication": d.FieldError{Code: "auth-getData-failed", Message: el.GenMessage("auth-getData-failed")}}
// division position
divsionPositions, err := getDivisionPosition(employee.Id)
divisionPositions, err := getDivisionPosition(employee.Id)
if err != nil {
return nil, errorGetPosition
}
@@ -188,7 +197,7 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
return nil, errorGetPosition
}
role = append(role, divsionPositions...)
role = append(role, divisionPositions...)
role = append(role, installationPositions...)
role = append(role, unitPositions...)
role = append(role, specialistPositions...)
@@ -200,6 +209,8 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
intern := intern.Intern{}
dg.I.Where("\"User_Id\" = ?", user.Id).First(&intern)
role = append(role, "int-"+string(*intern.Position_Code))
case erg.CSCSys:
role = append(role, "system")
}
atClaims["roles"] = role
outputData["roles"] = role
@@ -287,43 +298,22 @@ func ExtractToken(r *http.Request, tokenType TokenType) (data *pa.AuthInfo, err
if accessUuidRedis.String() == "" {
return nil, d.FieldError{Code: "token-unidentified", Message: el.GenMessage("token-unidentified")}
}
user_name := fmt.Sprintf("%v", claims["user_name"])
// user_email := ""
// if v, exist := claims["user_email"]; exist && v != nil {
// user_email = v.(string)
// }
// ref_id := 0
// if v, exist := claims["user_ref_id"]; exist && v != nil {
// tmp := v.(float64)
// ref_id = int(tmp)
// }
// position_code := ""
// if v, exist := claims["user_position_code"]; exist && v != nil {
// position_code = v.(string)
// }
// data = &AuthInfo{
// Uuid: accessUuid,
// User_Id: int(user_id),
// User_Name: user_name,
// User_Email: user_email,
// User_Ref_Id: ref_id,
// User_Position_Code: position_code,
contractPosition_code := ""
if v, exist := claims["contractPosition_code"]; exist && v != nil {
contractPosition_code = v.(string)
}
employee_position_code := ""
if v, exist := claims["employee_position_code"]; exist && v != nil {
employee_position_code = v.(string)
}
data = &pa.AuthInfo{
Uuid: accessUuid,
User_Id: uint(user_id),
User_Name: user_name,
User_ContractPosition_code: contractPosition_code,
Employee_Position_Code: &employee_position_code,
Uuid: accessUuid,
User_Id: uint(user_id),
User_Name: fmt.Sprintf("%v", claims["user_name"]),
}
data.User_ContractPosition_code = checkStrClaims(claims, "contractPosition_code")
data.Employee_Position_Code = checkStrPtrClaims(claims, "employee_position_code")
data.Doctor_Id = checkIntPtrClaims(claims, "doctor_id")
data.Nurse_Id = checkIntPtrClaims(claims, "nurse_id")
data.Midwife_Id = checkIntPtrClaims(claims, "midwife_id")
data.Nutritionist_Id = checkIntPtrClaims(claims, "nutritionist_id")
data.Laborant_Id = checkIntPtrClaims(claims, "laborant_id")
data.Pharmachist_Id = checkIntPtrClaims(claims, "pharmachist_id")
data.Intern_Position_Code = checkStrPtrClaims(claims, "intern_position_code")
return
}
return nil, d.FieldError{Code: "token", Message: "token-invalid"}
@@ -332,3 +322,33 @@ func ExtractToken(r *http.Request, tokenType TokenType) (data *pa.AuthInfo, err
func GetConfig() {
a.ParseCfg(&authCfg)
}
func checkStrClaims(claim map[string]interface{}, key string) string {
if v, exist := claim[key]; exist && v != nil {
return v.(string)
}
return ""
}
func checkStrPtrClaims(claim map[string]interface{}, key string) *string {
if v, exist := claim[key]; exist && v != nil {
val := v.(string)
return &val
}
return nil
}
func checkIntClaims(claim map[string]interface{}, key string) int {
if v, exist := claim[key]; exist && v != nil {
return v.(int)
}
return 0
}
func checkIntPtrClaims(claim map[string]interface{}, key string) *int {
if v, exist := claim[key]; exist && v != nil {
val := int(v.(float64))
return &val
}
return nil
}
@@ -28,10 +28,6 @@ func getAndCheck(input, condition any) (eCode string) {
return ""
}
func getDocName(id uint) string {
return "authentication"
}
func getDivisionPosition(employee_id uint) ([]string, error) {
var result []string
@@ -91,7 +91,9 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if err := tx.First(&data, input.Id).Error; err != nil {
if err := tx.
Scopes(gh.Preload(input.Includes)).
First(&data, input.Id).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
@@ -19,7 +19,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Employee) {
data.User_Id = inputSrc.User_Id
data.Person_Id = inputSrc.Person_Id
data.Division_Code = inputSrc.Division_Code
data.Number = inputSrc.Number
data.Status_Code = inputSrc.Status_Code
data.Position_Code = inputSrc.Position_Code
@@ -1,15 +1,21 @@
package encounter
import (
e "simrs-vx/internal/domain/main-entities/encounter"
// std
"errors"
// external
dg "github.com/karincake/apem/db-gorm-pg"
gh "github.com/karincake/getuk"
"gorm.io/gorm"
// pkg
plh "simrs-vx/pkg/lib-helper"
pl "simrs-vx/pkg/logger"
pu "simrs-vx/pkg/use-case-helper"
dg "github.com/karincake/apem/db-gorm-pg"
gh "github.com/karincake/getuk"
"gorm.io/gorm"
// internal
e "simrs-vx/internal/domain/main-entities/encounter"
)
func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.Encounter, error) {
@@ -34,6 +40,10 @@ func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.Encount
}
func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Encounter, *e.MetaDto, error) {
if input.AuthInfo.User_Id == 0 {
return nil, nil, plh.HandleListError(input, event, errors.New("user_id is required"))
}
pl.SetLogInfo(event, input, "started", "DBReadList")
data := []e.Encounter{}
pagination := gh.Pagination{}
@@ -46,10 +56,13 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.En
} else {
tx = dg.I
}
tx = tx.Model(&e.Encounter{})
tx = tx.
Model(&e.Encounter{}).
Scopes(gh.Preload(input.Includes)).
if input.AuthInfo.Doctor_Id != nil {
tx.Where("\"Responsible_Doctor_Id\" = ?", *input.AuthInfo.Doctor_Id)
}
tx.Scopes(gh.Preload(input.Includes)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
@@ -81,7 +81,9 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if err := tx.First(&data, input.Id).Error; err != nil {
if err := tx.
Scopes(gh.Preload(input.Includes)).
First(&data, input.Id).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
@@ -352,18 +352,18 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
}
func Search(input e.SearchDto) (*d.Data, error) {
func SearchByResidentIdentityNumber(input e.SearchDto) (*d.Data, error) {
var data *e.Patient
var err error
event := pl.Event{
Feature: "Search",
Feature: "Search By Resident Identity Number",
Source: source,
}
// Start log
pl.SetLogInfo(&event, input, "started", "search")
if data, err = SearchData(input, &event); err != nil {
if data, err = SearchDataByRIN(input, &event); err != nil {
return nil, err
}
@@ -377,6 +377,46 @@ func Search(input e.SearchDto) (*d.Data, error) {
}, nil
}
func Search(input e.SearchDto) (*d.Data, error) {
var dataList []e.Patient
var metaList *e.MetaDto
var err error
event := pl.Event{
Feature: "Search",
Source: source,
}
// Start log
pl.SetLogInfo(&event, input, "started", "readList")
err = dg.I.Transaction(func(tx *gorm.DB) error {
if dataList, metaList, err = SearchData(input, &event, tx); err != nil {
return err
}
return nil
})
if err != nil {
return nil, err
}
return &d.Data{
Meta: d.IS{
"source": source,
"structure": "list-data",
"status": "fetched",
"page_number": strconv.Itoa(metaList.PageNumber),
"page_size": strconv.Itoa(metaList.PageSize),
"record_totalCount": strconv.Itoa(metaList.Count),
"record_currentCount": strconv.Itoa(len(dataList)),
},
Data: e.ToResponseList(dataList),
}, nil
}
func Upload(input e.UploadDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
var data *e.Patient
+52 -19
View File
@@ -154,11 +154,11 @@ func DeleteData(data *e.Patient, event *pl.Event, dbx ...*gorm.DB) error {
return nil
}
func SearchData(input e.SearchDto, event *pl.Event, dbx ...*gorm.DB) (*e.Patient, error) {
// Search By Resident Identity Number
func SearchDataByRIN(input e.SearchDto, event *pl.Event, dbx ...*gorm.DB) (*e.Patient, error) {
pl.SetLogInfo(event, input, "started", "DBSearch")
var patient e.Patient
var err error
var data e.Patient
var tx *gorm.DB
if len(dbx) > 0 {
@@ -174,27 +174,60 @@ func SearchData(input e.SearchDto, event *pl.Event, dbx ...*gorm.DB) (*e.Patient
Preload("Person.Relatives").
Preload("Person.Insurances")
switch input.Mode {
case e.SMIdent:
// Search by patient number OR person's resident identity number (exact match) OR person's name (partial match)
err = tx.Joins("JOIN \"Person\" ON \"Patient\".\"Person_Id\" = \"Person\".\"Id\"").
Where("\"Patient\".\"Number\" = ? OR \"Person\".\"ResidentIdentityNumber\" = ? OR \"Person\".\"Name\" ILIKE ?",
input.Search, input.Search, "%"+input.Search+"%").
First(&patient).Error
case e.SMNik:
// Search by patient person's resident identity number (exact match)
err = tx.Joins("JOIN \"Person\" ON \"Patient\".\"Person_Id\" = \"Person\".\"Id\"").
Where("\"Person\".\"ResidentIdentityNumber\" = ?",
input.Search).
First(&patient).Error
}
// Search by patient person's resident identity number (exact match)
err := tx.Joins("JOIN \"Person\" ON \"Patient\".\"Person_Id\" = \"Person\".\"Id\"").
Where("\"Person\".\"ResidentIdentityNumber\" = ?",
input.Search).
First(&data).Error
if err != nil {
if processedErr := pu.HandleSearchError(err, event, source, input.Search, patient); processedErr != nil {
if processedErr := pu.HandleSearchError(err, event, source, input.Search, data); processedErr != nil {
return nil, processedErr
}
}
pl.SetLogInfo(event, nil, "complete")
return &patient, nil
return &data, nil
}
func SearchData(input e.SearchDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Patient, *e.MetaDto, error) {
pl.SetLogInfo(event, input, "started", "DBSearch")
var data []e.Patient
pagination := gh.Pagination{}
count := int64(0)
meta := e.MetaDto{}
var tx *gorm.DB
if len(dbx) > 0 {
tx = dbx[0]
} else {
tx = dg.I
}
// Preload associations for complete data
tx = tx.Preload(clause.Associations)
tx = tx.Preload("Person.Addresses").
Preload("Person.Contacts").
Preload("Person.Relatives").
Preload("Person.Insurances")
// Search by patient number OR person's resident identity number (exact match) OR person's name (partial match)
tx = tx.Joins("JOIN \"Person\" ON \"Patient\".\"Person_Id\" = \"Person\".\"Id\"").
Where("\"Patient\".\"Number\" ILIKE ? OR \"Person\".\"ResidentIdentityNumber\" ILIKE ? OR \"Person\".\"Name\" ILIKE ?",
"%"+input.Search+"%", "%"+input.Search+"%", "%"+input.Search+"%")
err := tx.Scopes(gh.Paginate(input, &pagination)).Find(&data).Error
if err != nil {
if processedErr := pu.HandleSearchError(err, event, source, input.Search, data); processedErr != nil {
return nil, nil, processedErr
}
}
meta.Count = int(count)
meta.PageNumber = pagination.PageNumber
meta.PageSize = pagination.PageSize
pl.SetLogInfo(event, nil, "complete")
return data, &meta, nil
}
@@ -81,7 +81,9 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if err := tx.First(&data, input.Id).Error; err != nil {
if err := tx.
Scopes(gh.Preload(input.Includes)).
First(&data, input.Id).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
@@ -81,7 +81,9 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if err := tx.First(&data, input.Id).Error; err != nil {
if err := tx.
Scopes(gh.Preload(input.Includes)).
First(&data, input.Id).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
+3 -1
View File
@@ -81,7 +81,9 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if err := tx.First(&data, input.Id).Error; err != nil {
if err := tx.
Scopes(gh.Preload(input.Includes)).
First(&data, input.Id).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
@@ -46,7 +46,6 @@ func setDataEmployeeUpdate(src e.EmployeUpdateDto) ee.UpdateDto {
CreateDto: ee.CreateDto{
User_Id: src.User_Id,
Person_Id: src.Person_Id,
Division_Code: src.Division_Code,
Number: src.Number,
Status_Code: src.Status_Code,
Position_Code: &src.Position_Code,