package specimen

import (
	"service/internal/interfaces/satusehat"
	"time"
)

func MapRequestToFHIR(req SpecimenRequest) satusehat.FHIRPayload {
	return satusehat.NewFHIRPayload("Specimen").
		Set("status", req.Status).
		Set("type", map[string]interface{}{
			"coding": []map[string]interface{}{
				{"system": "http://snomed.info/sct", "code": req.TypeCode, "display": req.TypeDisplay},
			},
		}).
		Set("subject", map[string]interface{}{
			"reference": "Patient/" + req.PatientID,
			"display":   req.PatientName,
		}).
		Set("collection", map[string]interface{}{
			"collectedDateTime": req.CollectedDateTime.Format(time.RFC3339),
			"collector": map[string]interface{}{
				"reference": "Practitioner/" + req.CollectorID,
				"display":   req.CollectorName,
			},
		})
}
