To add or update the avatar, you can use a png or jpg image saved to disk. Issue the following command:
curl -X PUT \ https://ua.ap.painchek.com/api/patients/e4142bf3-65d4-4862-b813-8359c0783bac/image/ \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F image=@image.jpg
Note
-
The image "image.jpg" is assumed to exist in the current working directory
-
The uuid of the patient record whose avatar is being set is included in the URL - "e4142bf3-65d4-4862-b813-8359c0783bac" in this case.
Sample return data:
{ "image": "https://ua.ap.painchek.com/media/patients/e4142bf3-65d4-4862-b813-8359c0783bac.jpeg" }
Adding/Updating the Avatar using Base64 Encoded data
To add or update the avatar, you can also use a base64 encoded version of a png or jpg image. Issue the following command:
curl -X PUT \ https://ua.ap.painchek.com/api/patients/e4142bf3-65d4-4862-b813-8359c0783bac/image/ \ -H 'Content-Type: application/json' \ -d '{"image_encoded": "data:image/<file_type>;base64,<base64 encoded png>"}'
Note
-
The file must be smaller than 2MB
-
<file_type> must be jpg, jpeg or png
-
<base64 encoded png> is the base64 encoded version of the image
-
The uuid of the patient record whose avatar is being set is included in the URL - "e4142bf3-65d4-4862-b813-8359c0783bac" in this case
-
The return data from this call is the same as when calling the endpoint with a file
The following sample shows the payload with a real base64 encoded png image:
curl -X PUT 'https://ua.ap.painchek.com/api/patients/aa8bfa08-7b25-49df-8695-33ee499b99c3/image/' \ -H 'Content-Type: application/json' \ -d '{"image_encoded": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAEGWlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPrtzZyMkzlNsNIV0qD8NJQ2TVjShtLp/3d02bpZJNtoi6GT27s6Yyc44M7v9oU9FUHwx6psUxL+3gCAo9Q/bPrQvlQol2tQgKD60+INQ6Ium65k7M5lpurHeZe58853vnnvuuWfvBei5qliWkRQBFpquLRcy4nOHj4g9K5CEh6AXBqFXUR0rXalMAjZPC3e1W99Dwntf2dXd/p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Uh8C+DU9+z2v/oyeH791OncxHOs5y2AtTc7nb/f73TWPkD/qwBnjX8BoJ98VQNcC+8AAAA4ZVhJZk1NACoAAAAIAAGHaQAEAAAAAQAAABoAAAAAAAKgAgAEAAAAAQAAABCgAwAEAAAAAQAAABAAAAAAF51TyAAAAXBJREFUOBGlUr9Lw1AQ/vKSIAgZXIqLiIKog4pkcxOqm0WHIoLgksFd8I9wFnRwEBVUpIgFB6Xo5FgEHXRSFzdBcAz5Ye7aeybkDQUP2nt3774v3909K80M/zAVRVFPcFNdGIawTArmp0c06f3TOygmbzJlSrpuH+zzOsgv+hOwlcNldKZf3phA5B3u7aK6tYDkpAbcfWDsOIDnecDpCgMp//P9xXjBFFoQdipU600uZLK1SybBwSMQzCJevdAtdbR1Nd22X1kBhcnZMhAlfKNSC3za9HWuC4GeAQ2q+rLNX+DLeqMDzpQwGUX7ba2ML7M/RasQI9npwyfG0wri5G+9vjsMd+MaQ/2DIJWykdIaZQZUREaKiDSJYyjbZrB8THxhiJIUzy1lQWtyR1IlzwS0kqW5GQQDlVKBKdFwFI6ubuA4TvElUgvN0SkTRudqb8+FVkot5J+xRuUOMkBJlQjoQl4ZSRSjXD6WOiOBgHrxv8N+rAn4jyITAAAAAElFTkSuQmCC"}'
Removing the Avatar
To remove the existing avatar (if any), issue the following command:
curl -X DELETE https://ua.ap.painchek.com/api/patients/e4142bf3-65d4-4862-b813-8359c0783bac/image/
Note
-
If there is no existing avatar, this call still returns a successful result (200)
-
Note the uuid of the patient record whose avatar is being removed is included in the URL - "e4142bf3-65d4-4862-b813-8359c0783bac" in this case.
Sample return data:
{ "image": null }
To obtain the URL for an avatar of a patient record, issue the following command:
curl https://ua.ap.painchek.com/api/patients/e4142bf3-65d4-4862-b813-8359c0783bac/image/
Note
Note the uuid of the patient record whose avatar is being sought is included in the URL - "e4142bf3-65d4-4862-b813-8359c0783bac" in this case.
Sample return data:
{ "image": "https://ua.ap.painchek.com/media/patients/e4142bf3-65d4-4862-b813-8359c0783bac.jpeg" }
Note also that the image URL for an avatar can be obtained by looking for the "image" field returned in the response from these requests:
a) adding/updating an avatar (a PUT to api/patients/{patient_uuid}/image/)
b) fetching patient details (a GET to .../api/patients/ or .../api/patients/{patient_uuid}/ )