package auth

import (
	ero "simrs-vx/internal/domain/references/organization"
)

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                *uint
	Doctor_Code                *string
	Nurse_Code                 *string
	Midwife_Code               *string
	Nutritionist_Code          *string
	Laborant_Code              *string
	Pharmachist_Code           *string
	Intern_Position_Code       *string
	Roles                      []string
	// User_DivisionPositions     []DivisionPosition
}

type DivisionPosition struct {
	Division_Code         string `json:"division_code"`
	DivisionPosition_Code string `json:"divisionPosition_code"`
}

func (a AuthInfo) IsDoctor() bool {
	if a.Employee_Position_Code == nil {
		return false
	}
	return *a.Employee_Position_Code == string(ero.EPCDoc)
}

func (a AuthInfo) IsNurse() bool {
	if a.Employee_Position_Code == nil {
		return false
	}
	return *a.Employee_Position_Code == string(ero.EPCNur)
}

func (a AuthInfo) IsNutritionist() bool {
	if a.Employee_Position_Code == nil {
		return false
	}
	return *a.Employee_Position_Code == string(ero.EPCNut)
}

func (a AuthInfo) IsLaborant() bool {
	if a.Employee_Position_Code == nil {
		return false
	}
	return *a.Employee_Position_Code == string(ero.EPCLab)
}

func (a AuthInfo) IsPharmacist() bool {
	if a.Employee_Position_Code == nil {
		return false
	}
	return *a.Employee_Position_Code == string(ero.EPCPha)
}

func (a AuthInfo) IsScreener() bool { // MPP, petugas skrining
	if a.Employee_Position_Code == nil {
		return false
	}
	return *a.Employee_Position_Code == string(ero.EPCScr)
}

// func (a AuthInfo) IsPayment() bool {
// 	if a.Employee_Position_Code == nil {
// 		return false
// 	}
// 	return *a.Employee_Position_Code == string(ero.EPCPay)
// }

// func (a AuthInfo) IsManagement() bool {
// 	if a.Employee_Position_Code == nil {
// 		return false
// 	}
// 	return *a.Employee_Position_Code == string(ero.EPCMan)
// }

func (a AuthInfo) IsSpecialistIntern() bool {
	if a.Intern_Position_Code == nil {
		return false
	}
	return *a.Intern_Position_Code == string(ero.IPCSpecialist)
}

func (a AuthInfo) IsNurseIntern() bool {
	if a.Intern_Position_Code == nil {
		return false
	}
	return *a.Intern_Position_Code == string(ero.IPCNurse)
}

func (a AuthInfo) HasEmployeePosition() bool {
	return a.Employee_Position_Code != nil
}
