/*
DESCRIPTION:
Any functions that are used internally by the use-case
*/
package subspecialist

import (
	"encoding/json"
	erc "simrs-vx/internal/domain/references/common"
	//esimgos "simrs-vx/internal/domain/simgos-entities/specialist"
	esyncLog "simrs-vx/internal/domain/sync-entities/log"
	esync "simrs-vx/internal/domain/sync-entities/specialist"
)

//func setDataSimgos[T *e.CreateDto | *e.UpdateDto](input T) (data esimgos.MPolihfis) {
//	var inputSrc *e.CreateDto
//	if inputT, ok := any(input).(*e.CreateDto); ok {
//		inputSrc = inputT
//	} else {
//		inputTemp := any(input).(*e.UpdateDto)
//		inputSrc = &inputTemp.CreateDto
//	}
//
//	data.Code = inputSrc.Code
//	data.Poliklinik = inputSrc.Name
//	data.CodePolirs = *inputSrc.Unit_Code
//	data.Active = 1
//	data.Status = 1
//
//	return
//}

func setDataSimxLog(input *esyncLog.SimxLogDto) (data esync.SpecialistSimxLog) {
	// encode to JSON
	jsonData, _ := json.MarshalIndent(input.Payload, "", "  ")
	jsonString := string(jsonData)

	var status erc.ProcessStatusCode
	if input.IsSuccess {
		status = erc.PSCSuccess
	} else {
		status = erc.PSCFailed
		if input.ErrMessage != nil {
			data.ErrMessage = input.ErrMessage
		}
	}

	data.Value = &jsonString
	data.Date = &now
	data.Status = status

	return
}

func setDataSimxLink(simxId, simgosId uint) (data esync.SpecialistLink) {
	data.Simx_Id = simxId
	data.Simgos_Id = simgosId
	return
}
