127 lines
4.5 KiB
Go
127 lines
4.5 KiB
Go
package kfr
|
|
|
|
import (
|
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
|
erc "simrs-vx/internal/domain/references/common"
|
|
ere "simrs-vx/internal/domain/references/encounter"
|
|
|
|
eem "simrs-vx/internal/domain/main-entities/employee"
|
|
ee "simrs-vx/internal/domain/main-entities/encounter"
|
|
|
|
pa "simrs-vx/internal/lib/auth"
|
|
|
|
pu "simrs-vx/pkg/use-case-helper"
|
|
)
|
|
|
|
type CreateDto struct {
|
|
Encounter_Id *uint `json:"encounter_id"`
|
|
CreatedBy_Employee_Id *uint `json:"createdBy_employee_id"`
|
|
Type ere.KFRTypeCode `json:"type" gorm:"size:15"`
|
|
Subjective string `json:"subjective"`
|
|
Objective string `json:"objective"`
|
|
Assessment string `json:"assessment"`
|
|
TreatmentGoals string `json:"treatmentGoals"`
|
|
Education string `json:"education"`
|
|
Action string `json:"action"`
|
|
Frequency *uint `json:"frequency"`
|
|
IntervalUnit_Code *erc.TimeUnitCode `json:"intervalUnit_code" gorm:"size:10"`
|
|
FollowUpType ere.KFRFollowUpTypeCode `json:"followUpType" gorm:"size:10"`
|
|
FollowUpNote string `json:"followUpNote"`
|
|
Status_Code erc.DataVerifiedCode `json:"status_code" gorm:"not null;size:10"`
|
|
|
|
pa.AuthInfo
|
|
}
|
|
|
|
type ReadListDto struct {
|
|
FilterDto
|
|
Includes string `json:"includes"`
|
|
Pagination ecore.Pagination
|
|
}
|
|
|
|
type FilterDto struct {
|
|
Encounter_Id *uint `json:"encounter-id"`
|
|
CreatedBy_Employee_Id *uint `json:"createdBy_employee-id"`
|
|
Type ere.KFRTypeCode `json:"type" gorm:"size:15"`
|
|
}
|
|
|
|
type ReadDetailDto struct {
|
|
Id uint `json:"id"`
|
|
Includes string `json:"includes"`
|
|
}
|
|
|
|
type UpdateDto struct {
|
|
Id uint `json:"id"`
|
|
CreateDto
|
|
}
|
|
|
|
type DeleteDto struct {
|
|
Id uint `json:"id"`
|
|
|
|
pa.AuthInfo
|
|
}
|
|
|
|
type MetaDto struct {
|
|
PageNumber int `json:"page_number"`
|
|
PageSize int `json:"page_size"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
type ResponseDto struct {
|
|
ecore.Main
|
|
Encounter_Id *uint `json:"encounter_id"`
|
|
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
|
CreatedBy_Employee_Id *uint `json:"createdBy_employee_id"`
|
|
CreatedBy_Employee *eem.Employee `json:"createdBy_employee,omitempty" gorm:"foreignKey:CreatedBy_Employee_Id;references:Id"`
|
|
Type ere.KFRTypeCode `json:"type" gorm:"size:15"`
|
|
Subjective string `json:"subjective"`
|
|
Objective string `json:"objective"`
|
|
Assessment string `json:"assessment"`
|
|
TreatmentGoals string `json:"treatmentGoals"`
|
|
Education string `json:"education"`
|
|
Action string `json:"action"`
|
|
Frequency *uint `json:"frequency"`
|
|
IntervalUnit_Code *erc.TimeUnitCode `json:"intervalUnit_code" gorm:"size:10"`
|
|
FollowUpType ere.KFRFollowUpTypeCode `json:"followUpType" gorm:"size:10"`
|
|
FollowUpNote string `json:"followUpNote"`
|
|
Status_Code erc.DataVerifiedCode `json:"status_code" gorm:"not null;size:10"`
|
|
}
|
|
|
|
func (d KFR) ToResponse() ResponseDto {
|
|
resp := ResponseDto{
|
|
Encounter_Id: d.Encounter_Id,
|
|
Encounter: d.Encounter,
|
|
CreatedBy_Employee_Id: d.CreatedBy_Employee_Id,
|
|
CreatedBy_Employee: d.CreatedBy_Employee,
|
|
Type: d.Type,
|
|
Subjective: d.Subjective,
|
|
Objective: d.Objective,
|
|
Assessment: d.Assessment,
|
|
TreatmentGoals: d.TreatmentGoals,
|
|
Education: d.Education,
|
|
Action: d.Action,
|
|
Frequency: d.Frequency,
|
|
IntervalUnit_Code: d.IntervalUnit_Code,
|
|
FollowUpType: d.FollowUpType,
|
|
FollowUpNote: d.FollowUpNote,
|
|
Status_Code: d.Status_Code,
|
|
}
|
|
resp.Main = d.Main
|
|
return resp
|
|
}
|
|
|
|
func ToResponseList(data []KFR) []ResponseDto {
|
|
resp := make([]ResponseDto, len(data))
|
|
for i, u := range data {
|
|
resp[i] = u.ToResponse()
|
|
}
|
|
return resp
|
|
}
|
|
|
|
func (c CreateDto) IsCorrectType() bool {
|
|
return pu.Contains([]ere.KFRTypeCode{ere.KFRAssessment, ere.KFRTherapy, ere.KFRReAssessment}, c.Type)
|
|
}
|
|
|
|
func (c CreateDto) IsCorrectFollowUpType() bool {
|
|
return pu.Contains([]ere.KFRFollowUpTypeCode{ere.KFUTCEva, ere.KFUTCRef, ere.KFUTCFin}, c.FollowUpType)
|
|
}
|