first commit
This commit is contained in:
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package medication
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TODO: Sesuaikan dengan payload internal API Medication
|
||||
func MapToInternalAPI(dbData *MedicationDB, orgID string) map[string]interface{} {
|
||||
payload := map[string]interface{}{
|
||||
"status_code": "active",
|
||||
"kfa_code": dbData.KodeKFA.String,
|
||||
"kfa_display": dbData.NamaKFA.String,
|
||||
"form_code": dbData.KodeBentuk.String,
|
||||
"form_display": dbData.NamaBentuk.String,
|
||||
"manufacturer_id": orgID, // Bisa disesuaikan menjadi dbData.ManufacturerID.String jika beda pabrik
|
||||
"batch_number": dbData.NoBatch.String,
|
||||
}
|
||||
if dbData.TglKadaluarsa.Valid {
|
||||
payload["expiration_date"] = dbData.TglKadaluarsa.Time.Format(time.RFC3339)
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
func MapToSyncLog(idx int64, fhirID string, reqPayload interface{}, respBody []byte, status string, errMsg string) MedicationSyncLog {
|
||||
reqBytes, _ := json.MarshalIndent(reqPayload, "", " ")
|
||||
return MedicationSyncLog{
|
||||
IdxObat: idx,
|
||||
MedicationID: fhirID,
|
||||
RequestPayload: string(reqBytes),
|
||||
ResponsePayload: string(respBody),
|
||||
Status: status,
|
||||
ErrorMessage: errMsg,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user