Using username from m_pasien.nip
This commit is contained in:
@@ -35,7 +35,7 @@ func Create(input e.Patient) (*d.Data, error) {
|
||||
}
|
||||
reqBody := bytes.NewBuffer(jsonPatient)
|
||||
// send data to main-api
|
||||
resp, err := send(http.MethodPost, path, reqBody)
|
||||
resp, err := send(http.MethodPost, path, reqBody, *input.RegisteredBy_User_Name)
|
||||
if err != nil {
|
||||
return nil, pl.SetLogError(&evt, input)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func Update(input e.Patient) (*d.Data, error) {
|
||||
}
|
||||
|
||||
// get data patient from main-api
|
||||
resp, err := send(http.MethodGet, fmt.Sprintf("%s%v", "patient/", patientLink.Simx_Id), nil)
|
||||
resp, err := send(http.MethodGet, fmt.Sprintf("%s%v", "patient/", patientLink.Simx_Id), nil, *input.RegisteredBy_User_Name)
|
||||
if err != nil {
|
||||
return nil, pl.SetLogError(&evt, input)
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func Update(input e.Patient) (*d.Data, error) {
|
||||
// send data to main api
|
||||
url := fmt.Sprintf("%s%v", "patient/", simxPatient.Id)
|
||||
reqBody := bytes.NewBuffer(jsonPatient)
|
||||
_, err = send(http.MethodPatch, url, reqBody)
|
||||
_, err = send(http.MethodPatch, url, reqBody, *input.RegisteredBy_User_Name)
|
||||
if err != nil {
|
||||
return nil, pl.SetLogError(&evt, input)
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func Delete(input e.Patient) (*d.Data, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = send(http.MethodDelete, fmt.Sprintf("%s%v", "patient/", patientLink.Simx_Id), nil)
|
||||
_, err = send(http.MethodDelete, fmt.Sprintf("%s%v", "patient/", patientLink.Simx_Id), nil, *input.RegisteredBy_User_Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func Delete(input e.Patient) (*d.Data, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func send(method string, endpoint string, body *bytes.Buffer) ([]byte, error) {
|
||||
func send(method string, endpoint string, body *bytes.Buffer, username string) ([]byte, error) {
|
||||
var url string = cfg.O.NewHost + endpoint
|
||||
var reader io.Reader = nil
|
||||
if body != nil {
|
||||
@@ -154,8 +154,7 @@ func send(method string, endpoint string, body *bytes.Buffer) ([]byte, error) {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("X-Sync-Source", cfg.O.OldSource)
|
||||
req.Header.Set("X-Sync-SecretKey", cfg.O.NewSecretKey)
|
||||
// TODO get use username from patient, migreate database first
|
||||
req.Header.Set("X-Sync-UserName", "dave")
|
||||
req.Header.Set("X-Sync-UserName", username)
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user