package episodeofcare

import (
	"encoding/json"
	"fmt"
)

// TODO: Sesuaikan dengan payload internal API EpisodeOfCare
func MapToInternalAPI(dbData *EpisodeOfCareDB, orgID string) map[string]interface{} {
	payload := map[string]interface{}{
		"episode_id": fmt.Sprintf("%d", dbData.IdxEpisode),
		"patient_id": dbData.NoMR.String,
	}
	return payload
}

func MapToSyncLog(idx int64, fhirID string, reqPayload interface{}, respBody []byte, status string, errMsg string) EpisodeOfCareSyncLog {
	reqBytes, _ := json.MarshalIndent(reqPayload, "", "  ")
	return EpisodeOfCareSyncLog{
		IdxEpisode:      idx,
		EpisodeOfCareID: fhirID,
		RequestPayload:  string(reqBytes),
		ResponsePayload: string(respBody),
		Status:          status,
		ErrorMessage:    errMsg,
	}
}
