feat (encounter): create and checkout + checking soapi done

This commit is contained in:
dpurbosakti
2025-09-09 13:41:06 +07:00
parent cc226b8034
commit e4358034d9
15 changed files with 225 additions and 71 deletions
+15
View File
@@ -0,0 +1,15 @@
package authhelper
import (
"errors"
"net/http"
)
func GetAuthInfo(r *http.Request) (*AuthInfo, error) {
ctxVal := r.Context().Value(AuthKey{})
if ctxVal == nil {
return nil, errors.New("can't get auth info")
}
authInfo := ctxVal.(*AuthInfo)
return authInfo, nil
}
+52
View File
@@ -0,0 +1,52 @@
package authhelper
import (
ero "simrs-vx/internal/domain/references/organization"
)
type AuthKey struct{}
type AuthInfo struct {
Uuid string
User_Id uint
User_Name string
// User_Email string
// User_Ref_Id int
User_Position_Code string
}
func (a AuthInfo) IsDoctor() bool {
return a.User_Position_Code == string(ero.UPCDoc)
}
func (a AuthInfo) IsNurse() bool {
return a.User_Position_Code == string(ero.UPCNur)
}
func (a AuthInfo) IsNutritionist() bool {
return a.User_Position_Code == string(ero.UPCNut)
}
func (a AuthInfo) IsLaborant() bool {
return a.User_Position_Code == string(ero.UPCLab)
}
func (a AuthInfo) IsPharmacist() bool {
return a.User_Position_Code == string(ero.UPCPha)
}
func (a AuthInfo) IsPayment() bool {
return a.User_Position_Code == string(ero.UPCPay)
}
func (a AuthInfo) IsPaymentVerificator() bool {
return a.User_Position_Code == string(ero.UPCPav)
}
func (a AuthInfo) IsManagement() bool {
return a.User_Position_Code == string(ero.UPCMan)
}
func (a AuthInfo) IsSpecialistIntern() bool {
return a.User_Position_Code == string(ero.UPCInt)
}