first commit
This commit is contained in:
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package specimen
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TODO: Sesuaikan dengan payload internal API Specimen
|
||||
func MapToInternalAPI(dbData *SpecimenDB, orgID string) map[string]interface{} {
|
||||
waktu := time.Now()
|
||||
if dbData.TglAmbil.Valid {
|
||||
waktu = dbData.TglAmbil.Time
|
||||
}
|
||||
payload := map[string]interface{}{
|
||||
"specimen_id": fmt.Sprintf("%d", dbData.IdxSpesimen),
|
||||
"encounter_id": fmt.Sprintf("%d", dbData.IdxDaftar),
|
||||
"patient_id": dbData.NoMR.String,
|
||||
"specimen_type": dbData.JenisSpesimen.String,
|
||||
"collected_date": waktu.Format(time.RFC3339),
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
func MapToSyncLog(idx int64, fhirID string, reqPayload interface{}, respBody []byte, status string, errMsg string) SpecimenSyncLog {
|
||||
reqBytes, _ := json.MarshalIndent(reqPayload, "", " ")
|
||||
return SpecimenSyncLog{
|
||||
IdxSpesimen: idx,
|
||||
SpecimenID: fhirID,
|
||||
RequestPayload: string(reqBytes),
|
||||
ResponsePayload: string(respBody),
|
||||
Status: status,
|
||||
ErrorMessage: errMsg,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user