first commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package medicationstatement
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TODO: Sesuaikan dengan payload internal API MedicationStatement
|
||||
func MapToInternalAPI(dbData *MedicationStatementDB, orgID string) map[string]interface{} {
|
||||
waktu := time.Now()
|
||||
if dbData.TglDicatat.Valid {
|
||||
waktu = dbData.TglDicatat.Time
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"medicationstatement_id": fmt.Sprintf("%d", dbData.IdxRiwayatObat),
|
||||
"encounter_id": fmt.Sprintf("%d", dbData.IdxDaftar),
|
||||
"patient_id": dbData.NoMR.String,
|
||||
"medication_code": dbData.KFA.String,
|
||||
"date_asserted": waktu.Format(time.RFC3339),
|
||||
"dosage_text": dbData.Instruksi.String,
|
||||
}
|
||||
}
|
||||
|
||||
func MapToSyncLog(idx int64, fhirID string, reqPayload interface{}, respBody []byte, status string, errMsg string) MedicationStatementSyncLog {
|
||||
reqBytes, _ := json.MarshalIndent(reqPayload, "", " ")
|
||||
return MedicationStatementSyncLog{
|
||||
IdxRiwayatObat: idx,
|
||||
MedicationStatementID: fhirID,
|
||||
RequestPayload: string(reqBytes),
|
||||
ResponsePayload: string(respBody),
|
||||
Status: status,
|
||||
ErrorMessage: errMsg,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user