28 lines
863 B
Go
28 lines
863 B
Go
package allergyintolerance
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// TODO: Sesuaikan dengan payload internal API AllergyIntolerance
|
|
func MapToInternalAPI(dbData *AllergyIntoleranceDB, orgID string) map[string]interface{} {
|
|
payload := map[string]interface{}{
|
|
"allergy_id": fmt.Sprintf("%d", dbData.IdxAlergi),
|
|
"patient_id": dbData.NoMR.String, // Sebaiknya mapping ke IHS Number di service
|
|
}
|
|
return payload
|
|
}
|
|
|
|
func MapToSyncLog(idx int64, fhirID string, reqPayload interface{}, respBody []byte, status string, errMsg string) AllergyIntoleranceSyncLog {
|
|
reqBytes, _ := json.MarshalIndent(reqPayload, "", " ")
|
|
return AllergyIntoleranceSyncLog{
|
|
IdxAlergi: idx,
|
|
AllergyIntoleranceID: fhirID,
|
|
RequestPayload: string(reqBytes),
|
|
ResponsePayload: string(respBody),
|
|
Status: status,
|
|
ErrorMessage: errMsg,
|
|
}
|
|
}
|