improve upload done
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
eem "simrs-vx/internal/domain/main-entities/emergency"
|
||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
||||
efa "simrs-vx/internal/domain/main-entities/file-attachment"
|
||||
eip "simrs-vx/internal/domain/main-entities/inpatient"
|
||||
ei "simrs-vx/internal/domain/main-entities/insurance-company"
|
||||
eir "simrs-vx/internal/domain/main-entities/internal-reference"
|
||||
@@ -70,6 +71,7 @@ type Encounter struct {
|
||||
Inpatient *eip.Inpatient `json:"inpatient,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Rehab *er.Basic `json:"rehab,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
RehabChildren *[]er.Basic `json:"rehabChildren,omitempty" gorm:"foreignKey:Parent_Encounter_Id;references:Id"`
|
||||
FileAttachments *[]efa.FileAttachment `json:"fileAttachments,omitempty" gorm:"foreignKey:Ref_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d Encounter) IsDone() bool {
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package file_attachment
|
||||
|
||||
import (
|
||||
"mime/multipart"
|
||||
eru "simrs-vx/internal/domain/references/upload"
|
||||
|
||||
// internal - domain - base-entities
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
|
||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
EntityType_Code eru.EntityTypeCode `form:"entityType_code" validate:"required"`
|
||||
Ref_Id *uint `form:"ref_id" validate:"required"`
|
||||
Type_Code eru.UploadCode `form:"type_code" validate:"required"`
|
||||
Name string `form:"name"`
|
||||
Upload_Employee_Id *string `form:"upload_employee_id"`
|
||||
FilePath string `json:"-"`
|
||||
|
||||
File multipart.File `json:"-"`
|
||||
FileHeader *multipart.FileHeader `json:"-"`
|
||||
Filename string `json:"-"`
|
||||
Size int64 `json:"-"`
|
||||
MimeType string `json:"-"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
EntityType_Code eru.EntityTypeCode `json:"entityType-code"`
|
||||
Ref_Id *uint `json:"ref-id"`
|
||||
Type_Code eru.UploadCode `json:"type-code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
Upload_Employee_Id *string `json:"upload-employee-id"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
EntityType_Code eru.EntityTypeCode `json:"entityType_code"`
|
||||
Ref_Id *uint `json:"ref_id"`
|
||||
Type_Code eru.UploadCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
Upload_Employee_Id *string `json:"upload_employee_id"`
|
||||
Upload_Employee *ee.Employee `json:"upload_employee,omitempty"`
|
||||
}
|
||||
|
||||
func (d FileAttachment) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
EntityType_Code: d.EntityType_Code,
|
||||
Ref_Id: d.Ref_Id,
|
||||
Type_Code: d.Type_Code,
|
||||
Name: d.Name,
|
||||
FilePath: d.FilePath,
|
||||
FileName: d.FileName,
|
||||
Upload_Employee_Id: d.Upload_Employee_Id,
|
||||
Upload_Employee: d.Upload_Employee,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []FileAttachment) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package file_attachment
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
||||
eru "simrs-vx/internal/domain/references/upload"
|
||||
)
|
||||
|
||||
type FileAttachment struct {
|
||||
ecore.Main
|
||||
EntityType_Code eru.EntityTypeCode `json:"entityType_code"`
|
||||
Ref_Id *uint `json:"ref_id"`
|
||||
Type_Code eru.UploadCode `json:"type_code"`
|
||||
Name string `json:"name"`
|
||||
FilePath *string `json:"filePath"`
|
||||
FileName *string `json:"fileName"`
|
||||
Upload_Employee_Id *string `json:"upload_employee_id"`
|
||||
Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"`
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
epr "simrs-vx/internal/domain/main-entities/person-relative"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
eru "simrs-vx/internal/domain/references/upload"
|
||||
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
)
|
||||
@@ -68,7 +68,7 @@ type SearchDto struct {
|
||||
|
||||
type UploadDto struct {
|
||||
Id uint `json:"-"`
|
||||
Code ere.UploadCode `json:"-"`
|
||||
Code eru.UploadCode `json:"-"`
|
||||
File multipart.File `json:"-"`
|
||||
FileHeader *multipart.FileHeader `json:"-"`
|
||||
Filename string `json:"-"`
|
||||
|
||||
@@ -10,7 +10,6 @@ type (
|
||||
OutpatientClassCode string
|
||||
AmbulatoryClassCode string
|
||||
InpatientClassCode string
|
||||
UploadCode string
|
||||
ChemoClassCode string
|
||||
AmbulanceFacilityCode string
|
||||
AmbulanceNeedsCode string
|
||||
@@ -78,12 +77,6 @@ const (
|
||||
ICCHCU InpatientClassCode = "hcu" // HCU
|
||||
ICCVK InpatientClassCode = "vk" // Verlos kamer
|
||||
|
||||
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
|
||||
|
||||
CCCAdm ChemoClassCode = "adm" // Administrasi
|
||||
CCCAct ChemoClassCode = "act" // Tindakan
|
||||
|
||||
@@ -125,12 +118,3 @@ func (ec EncounterClassCode) Code() string {
|
||||
return "UNKNOWN"
|
||||
}
|
||||
}
|
||||
|
||||
func IsValidUploadCode(code UploadCode) bool {
|
||||
switch UploadCode(code) {
|
||||
case UCPRN, UCPDL, UCPP, UCPFC, UCMIR:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package upload
|
||||
|
||||
type (
|
||||
UploadCode 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
|
||||
UCSEP UploadCode = "vclaim-sep" // SEP
|
||||
UCSIPP UploadCode = "vclaim-sipp" // SIPP
|
||||
|
||||
ETCPerson EntityTypeCode = "person"
|
||||
ETCEncounter EntityTypeCode = "encounter"
|
||||
)
|
||||
|
||||
var validUploadCodesByEntity = map[EntityTypeCode][]UploadCode{
|
||||
ETCPerson: {
|
||||
UCPRN, UCPDL, UCPP, UCPFC, UCMIR,
|
||||
},
|
||||
ETCEncounter: {
|
||||
UCSEP, UCSIPP,
|
||||
},
|
||||
}
|
||||
|
||||
func IsValidUploadCode(entity EntityTypeCode, code UploadCode) bool {
|
||||
for _, c := range validUploadCodesByEntity[entity] {
|
||||
if c == code {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user