Merge branch 'migration' of https://github.com/dikstub-rssa/simrs-be into feat/sync-source
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- Modify "GeneralConsent" table
|
||||
ALTER TABLE "public"."GeneralConsent" ADD COLUMN "FileUrl" character varying(1024) NULL;
|
||||
@@ -1,4 +1,4 @@
|
||||
h1:fNeqUpbdIqGDiH68u1bwwMgHTEOmmEWeI+IIYEq6pto=
|
||||
h1:2JitBq/ClDO+w/9iPRmvv946fDfbSDFoHbpHL20aqNI=
|
||||
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
||||
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
||||
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
||||
@@ -118,4 +118,5 @@ h1:fNeqUpbdIqGDiH68u1bwwMgHTEOmmEWeI+IIYEq6pto=
|
||||
20251113101344.sql h1:xaOZvAUP1fFfnO+syEFOzJUIg5lTfBe5AWHPbBWuCLA=
|
||||
20251113120533.sql h1:f3/U1Ve2yF2zSMhkt+xtwF8wUYfUKYwgbNeGfE37EW4=
|
||||
20251114062746.sql h1:FInLaEFQByESEwFJKuKnuUSTKmcDpi3ZXaxkKwz2+D8=
|
||||
20251117005942.sql h1:mW/TC8GgFgPLZ7PBVQnn9mChEekAcwfQMCbzXnoaw9w=
|
||||
20251117005942.sql h1:wD3BWrUSmo1HlW16V3lkaBkJvbAZ0fNk77te7J9NhOc=
|
||||
20251117075427.sql h1:/PZovLaMdWILT6y1uNuBo9EyMHyxp3vQ7BwndRpQriY=
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Type_Code eru.UploadCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath string `json:"filePath"`
|
||||
Filename string `json:"-"`
|
||||
Upload_Employee_Id *uint `form:"upload_employee_id"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Type_Code eru.DocTypeCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath string `json:"filePath"`
|
||||
Filename string `json:"-"`
|
||||
Upload_Employee_Id *uint `form:"upload_employee_id"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -24,9 +24,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Type_Code eru.UploadCode `json:"type-code"`
|
||||
Upload_Employee_Id *string `json:"encounter-document-employee-id"`
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Type_Code eru.DocTypeCode `json:"type-code"`
|
||||
Upload_Employee_Id *string `json:"encounter-document-employee-id"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
@@ -51,13 +51,13 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Type_Code eru.UploadCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
Upload_Employee_Id *uint `json:"upload_employee_id"`
|
||||
Upload_Employee *ee.Employee `json:"upload_employee,omitempty"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Type_Code eru.DocTypeCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
Upload_Employee_Id *uint `json:"upload_employee_id"`
|
||||
Upload_Employee *ee.Employee `json:"upload_employee,omitempty"`
|
||||
}
|
||||
|
||||
func (d EncounterDocument) ToResponse() ResponseDto {
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
|
||||
type EncounterDocument struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Type_Code eru.UploadCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
Upload_Employee_Id *uint `json:"upload_employee_id"`
|
||||
Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Type_Code eru.DocTypeCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
Upload_Employee_Id *uint `json:"upload_employee_id"`
|
||||
Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"`
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ type GeneralConsent struct {
|
||||
Encounter_Id *uint `json:"encounter_id" gorm:"not null"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Value *string `json:"value"`
|
||||
FileUrl *string `json:"fileUrl" gorm:"size:1024"`
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ type SearchDto struct {
|
||||
|
||||
type UploadDto struct {
|
||||
Id uint `json:"-"`
|
||||
Code eru.UploadCode `json:"-"`
|
||||
Code eru.DocTypeCode `json:"-"`
|
||||
File multipart.File `json:"-"`
|
||||
FileHeader *multipart.FileHeader `json:"-"`
|
||||
Filename string `json:"-"`
|
||||
|
||||
@@ -3,6 +3,7 @@ package upload
|
||||
import (
|
||||
"mime/multipart"
|
||||
eru "simrs-vx/internal/domain/references/upload"
|
||||
|
||||
// internal - domain - base-entities
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
type CreateDto struct {
|
||||
EntityType_Code eru.EntityTypeCode `form:"entityType_code"`
|
||||
Ref_Id *uint `form:"ref_id"`
|
||||
Type_Code eru.UploadCode `form:"type_code"`
|
||||
Type_Code eru.DocTypeCode `form:"type_code"`
|
||||
Name string `form:"name"`
|
||||
Upload_Employee_Id *uint `form:"upload_employee_id"`
|
||||
FilePath string `json:"-"`
|
||||
@@ -31,7 +32,7 @@ type ReadListDto struct {
|
||||
type FilterDto struct {
|
||||
EntityType_Code eru.EntityTypeCode `json:"entityType-code"`
|
||||
Ref_Id *uint `json:"ref-id"`
|
||||
Type_Code eru.UploadCode `json:"type-code"`
|
||||
Type_Code eru.DocTypeCode `json:"type-code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
@@ -61,7 +62,7 @@ type MetaDto struct {
|
||||
type ResponseDto struct {
|
||||
EntityType_Code eru.EntityTypeCode `json:"entityType_code"`
|
||||
Ref_Id *uint `json:"ref_id"`
|
||||
Type_Code eru.UploadCode `json:"type_code"`
|
||||
Type_Code eru.DocTypeCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
Upload_Employee_Id *uint `json:"upload_employee_id"`
|
||||
FilePath string `json:"filePath"`
|
||||
|
||||
@@ -3,40 +3,41 @@ package upload
|
||||
import "fmt"
|
||||
|
||||
type (
|
||||
UploadCode string
|
||||
DocTypeCode string
|
||||
EntityTypeCode string
|
||||
)
|
||||
|
||||
const (
|
||||
UCPRN UploadCode = "person-resident-number" // Person Resident Number
|
||||
UCPDL UploadCode = "person-driver-license" // Person Driver License
|
||||
UCPP UploadCode = "person-passport" // Person Passport
|
||||
UCPFC UploadCode = "person-family-card" // Person Family Card
|
||||
UCMIR UploadCode = "mcu-item-result" // Mcu Item Result
|
||||
UCEnPatient UploadCode = "encounter-patient"
|
||||
UCEnSupport UploadCode = "encounter-support"
|
||||
UcEnOther UploadCode = "encounter-other"
|
||||
UCSEP UploadCode = "vclaim-sep" // SEP
|
||||
UCSIPP UploadCode = "vclaim-sipp" // SIPP
|
||||
DTCPRN DocTypeCode = "person-resident-number" // Person Resident Number
|
||||
DTCPDL DocTypeCode = "person-driver-license" // Person Driver License
|
||||
DTCPP DocTypeCode = "person-passport" // Person Passport
|
||||
DTCPFC DocTypeCode = "person-family-card" // Person Family Card
|
||||
DTCMIR DocTypeCode = "mcu-item-result" // Mcu Item Result
|
||||
DTCEnPatient DocTypeCode = "encounter-patient"
|
||||
DTCEnSupport DocTypeCode = "encounter-support"
|
||||
DTCEnOther DocTypeCode = "encounter-other"
|
||||
DTCSEP DocTypeCode = "vclaim-sep" // SEP
|
||||
DTCSIPP DocTypeCode = "vclaim-sipp" // SIPP
|
||||
DTCGC DocTypeCode = "general-consent"
|
||||
|
||||
ETCPerson EntityTypeCode = "person"
|
||||
ETCEncounter EntityTypeCode = "encounter"
|
||||
ETCMCU EntityTypeCode = "mcu"
|
||||
)
|
||||
|
||||
var validUploadCodesByEntity = map[EntityTypeCode][]UploadCode{
|
||||
var validUploadCodesByEntity = map[EntityTypeCode][]DocTypeCode{
|
||||
ETCPerson: {
|
||||
UCPRN, UCPDL, UCPP, UCPFC,
|
||||
DTCPRN, DTCPDL, DTCPP, DTCPFC,
|
||||
},
|
||||
ETCEncounter: {
|
||||
UCSEP, UCSIPP, UCEnPatient, UCEnSupport, UcEnOther,
|
||||
DTCSEP, DTCSIPP, DTCEnPatient, DTCEnSupport, DTCEnOther,
|
||||
},
|
||||
ETCMCU: {
|
||||
UCMIR,
|
||||
DTCMIR,
|
||||
},
|
||||
}
|
||||
|
||||
func IsValidUploadCode(entity EntityTypeCode, code UploadCode) (bool, string) {
|
||||
func IsValidUploadCode(entity EntityTypeCode, code DocTypeCode) (bool, string) {
|
||||
allowedCodes, ok := validUploadCodesByEntity[entity]
|
||||
if !ok {
|
||||
return false, fmt.Sprintf("unknown entityType_code: %s", entity)
|
||||
@@ -48,5 +49,5 @@ func IsValidUploadCode(entity EntityTypeCode, code UploadCode) (bool, string) {
|
||||
}
|
||||
}
|
||||
|
||||
return false, fmt.Sprintf("invalid upload_code '%s' for entityType_code '%s'", code, entity)
|
||||
return false, fmt.Sprintf("invalid doctype_code '%s' for entityType_code '%s'", code, entity)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{
|
||||
EntityType_Code: eru.EntityTypeCode(r.FormValue("entityType_code")),
|
||||
Ref_Id: refID,
|
||||
Type_Code: eru.UploadCode(r.FormValue("type_code")),
|
||||
Type_Code: eru.DocTypeCode(r.FormValue("type_code")),
|
||||
Name: r.FormValue("name"),
|
||||
Upload_Employee_Id: employeeId,
|
||||
File: file,
|
||||
|
||||
@@ -106,22 +106,22 @@ func setPersonAttachment(input e.CreateDto, event *pl.Event, tx *gorm.DB) (*ep.P
|
||||
|
||||
var removeUrl string
|
||||
switch input.Type_Code {
|
||||
case eru.UCPRN:
|
||||
case eru.DTCPRN:
|
||||
if dataPerson.ResidentIdentityFileUrl != nil {
|
||||
removeUrl = *dataPerson.ResidentIdentityFileUrl
|
||||
}
|
||||
dataPerson.ResidentIdentityFileUrl = &input.FilePath
|
||||
case eru.UCPDL:
|
||||
case eru.DTCPDL:
|
||||
if dataPerson.DrivingLicenseFileUrl != nil {
|
||||
removeUrl = *dataPerson.DrivingLicenseFileUrl
|
||||
}
|
||||
dataPerson.DrivingLicenseFileUrl = &input.FilePath
|
||||
case eru.UCPP:
|
||||
case eru.DTCPP:
|
||||
if dataPerson.PassportFileUrl != nil {
|
||||
removeUrl = *dataPerson.PassportFileUrl
|
||||
}
|
||||
dataPerson.PassportFileUrl = &input.FilePath
|
||||
case eru.UCPFC:
|
||||
case eru.DTCPFC:
|
||||
if dataPerson.FamilyIdentityFileUrl != nil {
|
||||
removeUrl = *dataPerson.FamilyIdentityFileUrl
|
||||
}
|
||||
@@ -164,7 +164,7 @@ func setEncounterDocument(input e.CreateDto, event *pl.Event, tx *gorm.DB) (*ee.
|
||||
Upload_Employee_Id: input.Upload_Employee_Id,
|
||||
}
|
||||
|
||||
if input.Type_Code == eru.UCSEP || input.Type_Code == eru.UCSIPP {
|
||||
if input.Type_Code == eru.DTCSEP || input.Type_Code == eru.DTCSIPP {
|
||||
if len(dataUpload) > 0 {
|
||||
data = dataUpload[0]
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@ import (
|
||||
func getBucketForType(docType string) (string, error) {
|
||||
switch strings.ToLower(docType) {
|
||||
case "resident", "resident-number", "ktp":
|
||||
return string(ere.UCPRN), nil
|
||||
return string(ere.DTCPRN), nil
|
||||
case "driver-license", "sim", "license":
|
||||
return string(ere.UCPDL), nil
|
||||
return string(ere.DTCPDL), nil
|
||||
case "passport", "paspor":
|
||||
return string(ere.UCPP), nil
|
||||
return string(ere.DTCPP), nil
|
||||
case "family-card", "kk", "family":
|
||||
return string(ere.UCPFC), nil
|
||||
return string(ere.DTCPFC), nil
|
||||
case "mcu", "medical", "mcu-result":
|
||||
return string(ere.UCMIR), nil
|
||||
return string(ere.DTCMIR), nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown document type: %s", docType)
|
||||
}
|
||||
@@ -28,9 +28,9 @@ func getBucketForType(docType string) (string, error) {
|
||||
// getValidFileTypesForBucket returns allowed file types for each bucket
|
||||
func getValidFileTypesForBucket(bucketName string) []string {
|
||||
switch bucketName {
|
||||
case string(ere.UCPRN), string(ere.UCPDL), string(ere.UCPP), string(ere.UCPFC):
|
||||
case string(ere.DTCPRN), string(ere.DTCPDL), string(ere.DTCPP), string(ere.DTCPFC):
|
||||
return []string{".jpg", ".jpeg", ".png", ".pdf", ".gif"}
|
||||
case string(ere.UCMIR):
|
||||
case string(ere.DTCMIR):
|
||||
return []string{".jpg", ".jpeg", ".png", ".pdf", ".gif", ".doc", ".docx", ".xls", ".xlsx"}
|
||||
default:
|
||||
return []string{".jpg", ".jpeg", ".png", ".pdf"}
|
||||
|
||||
Reference in New Issue
Block a user