first commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package imagingstudy
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// MapToInternalAPI memetakan data gabungan ke payload API Internal SatuSehat
|
||||
func MapToInternalAPI(dbData *ImagingStudyData, orgID string) map[string]interface{} {
|
||||
waktu := time.Now()
|
||||
if dbData.StartedDate.Valid {
|
||||
waktu = dbData.StartedDate.Time
|
||||
}
|
||||
payload := map[string]interface{}{
|
||||
"request_id": dbData.RequestID,
|
||||
"servicerequest_id": dbData.ServiceRequestID.String,
|
||||
"encounter_id": dbData.EncounterID.String,
|
||||
"patient_id": dbData.PatientID.String,
|
||||
"accession_number": dbData.NoRegister.String, // Digunakan sebagai Identifier SATUSEHAT
|
||||
"modality": dbData.Modality.String,
|
||||
"started_date": waktu.Format(time.RFC3339),
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
func MapToSyncLog(reqID string, fhirID string, reqPayload interface{}, respBody []byte, status string, errMsg string) ImagingStudySyncLog {
|
||||
reqBytes, _ := json.MarshalIndent(reqPayload, "", " ")
|
||||
return ImagingStudySyncLog{
|
||||
RequestID: reqID,
|
||||
ImagingStudyID: fhirID,
|
||||
RequestPayload: string(reqBytes),
|
||||
ResponsePayload: string(respBody),
|
||||
Status: status,
|
||||
ErrorMessage: errMsg,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user