Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content creation in Treatment Notes failing #362

Open
staverton opened this issue Apr 6, 2022 · 12 comments
Open

Content creation in Treatment Notes failing #362

staverton opened this issue Apr 6, 2022 · 12 comments

Comments

@staverton
Copy link

Hi there,

I'm struggling to get the treatment_notes endpoint to accept treatment notes content. I can create the notes ok, but am struggling to actually update the notes - example of the data I'm feeding into 'content' below:
{"sections": [{"name": "Section 1", "questions": [{"name": "Patient progress report", "type": "paragraph", "answer": "hello world"} ] } ] }

...and getting a 500 error:

image

Any help gratefully received.

@JohnColvin
Copy link
Member

JohnColvin commented Apr 6, 2022 via email

@staverton
Copy link
Author

Thanks for getting back so quickly John!

I'm now up against a validation failure... (please be patient!). Message body as follows:
{ "body": { "patient_id": xxx, "treatment_note_template_id": xxx, "draft": true, "content": { "sections": [ { "name": "Section 1", "questions": [ { "name": "Patient progress report", "type": "paragraph", "answer": "Hello world" } ] } ] } } }

And a response of:
{ "errors": { "patient": "can’t be blank", "title": "can’t be blank" }, "message": "Validation Failed" }

...which is kinda odd because I couldn't see 'title' or 'patient' in the api docs?!

Thanks again for your help on this.

@hagen
Copy link
Contributor

hagen commented Apr 6, 2022

Almost there!
body is just the content of the request. Not a property in the JSON object.

You're posting to treatment notes, to create the treatment note:
POST /v1/treatment_notes

Your JSON will be:

{
  "patient_id": "xxx", 
  "treatment_note_template_id": "xxx", 
  "draft": true, 
  "content": { 
    "sections": [ 
      { 
        "name": "Section 1", 
        "questions": [ 
          {
            "name": "Patient progress report", 
            "type": "paragraph",
            "answer": "Hello world"
          }
        ]
      }
    ]
  }
}

To update a treatment note, you make a PUT request instead.

You can only update treatment notes that are still in a draft state. Once a treatment note has been updated with draft: false, you cannot make any further changes to the treatment note record.

PUT /v1/treatment_notes/xxx

Your JSON will be same as above, with the changes you require. For example, your update may just be finalising the treatment note with:

{
  "draft": false
}

@staverton
Copy link
Author

PS - this worked using Postman, but I got the above error using Power Automate.

@staverton
Copy link
Author

staverton commented Apr 6, 2022

Ah - yup, sorry I had excluded 'body' from the body 😂 - just copied the code wrong, so I'm afraid I am still having issues.

image

I will definitely follow up a post with the put as you say to mark as final - nice touch. I wonder if you're able to 'fix' the date the note was taken as well?

@hagen
Copy link
Contributor

hagen commented Apr 6, 2022

I don't use Power Automate, sorry!
The request body looks fine to me. Maybe it needs to be stringified before sending?
If you can see the response text from that 422 response, that might help identify what's wrong?
We send 422s when the content of your request is invalid in some way (missing params, wrongly typed params, invalid content, etc.)

@staverton
Copy link
Author

I don't blame you! 😂
I'm getting the validation failure below - is this something you can see on your end?
{ "errors": { "draft": "is not included in the list", "patient": "can’t be blank", "title": "can’t be blank" }, "message": "Validation Failed" }

@staverton
Copy link
Author

The above was what I got with a stringified version - the below is what I get with a JSON body:

{ "errors": { "patient": "can’t be blank" }, "message": "Validation Failed" }

@JohnColvin
Copy link
Member

JohnColvin commented Apr 7, 2022 via email

@staverton
Copy link
Author

staverton commented Apr 7, 2022 via email

@JohnColvin
Copy link
Member

JohnColvin commented Apr 8, 2022 via email

@JohnColvin
Copy link
Member

JohnColvin commented Apr 8, 2022

I think for us to be able to help, we'll need to be using the same tool. Which unfortunately means CURL. Below is the simplest POST that will work for a treatment note. Once that's working with your params, add your content to make sure it's working. If CURL works then we'll know there's a problem somewhere in the other tool you're using.

curl https://api.au1.cliniko.com/v1/treatment_notes \
  -u YOURAPIKEY-au1: \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'User-Agent: CURL ***@***.***)' \
  -d '{ "draft": true, "patient_id": 835505263451571861, "title": "Test" }' \
  -X POST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants