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

import (
	e "simrs-vx/internal/domain/main-entities/encounter"
	ir "simrs-vx/internal/domain/main-entities/internal-reference"
	erc "simrs-vx/internal/domain/references/common"
)

func setDataCreate(input *ir.CreateDto, data *ir.InternalReference) {
	data.Encounter_Id = input.Encounter_Id
	data.Unit_Code = input.Unit_Code

	data.Doctor_Code = input.Doctor_Code
	data.SrcDoctor_Code = input.SrcDoctor_Code

	data.Nurse_Code = input.Nurse_Code
	data.SrcNurse_Code = input.SrcNurse_Code
	data.Status_Code = &input.Status_Code
}

func setDataUpdate(input *ir.UpdateDto, data *ir.InternalReference) {
	data.Doctor_Code = input.Doctor_Code
	data.Nurse_Code = input.Nurse_Code
	data.Status_Code = &input.Status_Code
}

func setBulkData(input *e.SwitchUnitDto) []ir.InternalReference {
	var data []ir.InternalReference

	for _, v := range *input.InternalReferences {
		statusCode := erc.DACNew
		data = append(data, ir.InternalReference{
			Encounter_Id:   &input.Id,
			Unit_Code:      v.Unit_Code,
			Doctor_Code:    v.Doctor_Code,
			Status_Code:    &statusCode,
			SrcDoctor_Code: input.Src_Doctor_Code,
			SrcNurse_Code:  input.Src_Nurse_Code,
		})
	}

	return data
}
