athenahealth / apiserver-athenaFlex

Software developers can use sample code and documentation to use athenahealth's athenaPractice/athenaFlow FHIR API Server.
https://mydata.athenahealth.com/home
17 stars 7 forks source link

Getting "No schedule found for given resource id." on Appointment Create #238

Closed ahsankcg closed 2 years ago

ahsankcg commented 2 years ago

Hi I am trying to create new appointment with the payload:

{
    "resourceType": "Appointment",
    "status": "booked",
    "participant": [
        {
            "actor": {
                "reference": "Location/FAC-3",
                "type": "Location",
                "display": "Orlando Childrens Clinic"
            },
            "status": "tentative"
        },
        {
            "actor": {
                "reference": "Patient/1972198803383290",
                "type": "Patient",
                "display": "Ahsan James"
            },
            "status": "tentative"
        },
        {
            "actor": {
                "reference": "Practitioner/1968652949366960",
                "type": "Practioner",
                "display": "Amanda Assigned"
            },
            "status": "tentative"
        }
    ],
    "start": "2022-07-01T11:45:00+00:00",
    "end": "2022-07-01T12:00:00+00:00",
    "minutesDuration": 15
}

And using standard sandbox URL: https://ap22sandbox.fhirapi.athenahealth.com/demoAPIServer/fhir/Appointment

But, I am getting this error with 400 Bad Request status code:

{
    "resourceType": "OperationOutcome",
    "text": {
        "status": "generated",
        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><table width=\"100%\"><tbody><tr><td width=\"25%\"><span class=\"text-muted\">Outcome null</span></td><td width=\"42%\"><span class=\"text-muted\"><table><thead><tr><th>#</th><th>Severity</th><th>Type</th><th>Detail</th></tr></thead><tbody><tr><td>1</td><td>ERROR</td><td>PROCESSING</td><td>No schedule found for given resource id.</td></tr></tbody></table></span></td></tr></tbody></table></div>"
    },
    "issue": [
        {
            "severity": "error",
            "code": "processing",
            "diagnostics": "No schedule found for given resource id."
        }
    ]
}

Can anyone please help me out solve this issue?

Thanks

AjeetYadav07 commented 2 years ago

@ahsankcg Sorry for delay in response. To create an Appointment, generate correct access token with user/*.write scope otherwise you will get 403 not authorized. This scope is providing permission to read and write operation of APIs. Use attached payload to create appointment because all provider does not have a schedule to create appointment. Appt_ap22sandbox.txt

ahsankcg commented 2 years ago

Hi @AjeetYadav07, Thanks for your response. I get this with my redirect url If I put user/*.write in the scope: /?error=invalid_scope&error_description=Cannot%20have%20scopes%20with%20patient/%20and%20user/

AjeetYadav07 commented 2 years ago

Please use the detailed scopes :

User scope(PROVIDER WORKFLOW) : For all read and Write operation : https://ap22sandbox.fhirapi.athenahealth.com/demoAPIServer/oauth2/authorize?state=defaultState&scope=openid%20profile%20user/*.*%20launch/patient&response_type=code&redirect_uri=[REDIRECT_URL]&aud=https%3A%2F%2Fap22sandbox.fhirapi.athenahealth.com%2FdemoAPIServer&client_id=[CLIENTID]

Patient workflow : for all read and write operation : https://ap22sandbox.fhirapi.athenahealth.com/demoAPIServer/oauth2/authorize?state=defaultState&scope=openid%20profile%20patient/*.*%20launch/patient&response_type=code&redirect_uri=[REDIRECT_URL]&aud=https%3A%2F%2Fap22sandbox.fhirapi.athenahealth.com%2FdemoAPIServer&client_id=[CLIENTID]

Read only access of APIs in user scope : openid%20profile%20user/.read%20launch/patient Write only access of APIs in user scope : openid%20profile%20user/.write%20launch/patient

Read only access of APIs in Patient workflow scope : openid%20profile%20patient/.read%20launch/patient Write only access of APIs in patient workflow scope : openid%20profile%20patient/.write%20launch/patient

ahsankcg commented 2 years ago

@AjeetYadav07 Hi I successfully generated access token with user read write scope but now I am getting this error from create appointment API:

{
    "resourceType": "OperationOutcome",
    "text": {
        "status": "generated",
        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><table width=\"100%\"><tbody><tr><td width=\"25%\"><span class=\"text-muted\">Outcome null</span></td><td width=\"42%\"><span class=\"text-muted\"><table><thead><tr><th>#</th><th>Severity</th><th>Type</th><th>Detail</th></tr></thead><tbody><tr><td>1</td><td>FATAL</td><td>EXCEPTION</td><td>No slot found for given details to create appointment.</td></tr></tbody></table></span></td></tr></tbody></table></div>"
    },
    "issue": [
        {
            "severity": "fatal",
            "code": "exception",
            "diagnostics": "No slot found for given details to create appointment."
        }
    ]
}

My payload is:

{
    "resourceType": "Appointment",
    "status": "pending",
    "start": "2022-06-27T16:44:00.000Z",
    "end": "2022-06-27T17:00:00.000Z",
    "minutesDuration": "16",
    "participant": [
        {
            "actor": {
                "reference": "Patient/1442678384850620"
            }
        },
        {
            "type": {
                "coding": {
                    "system": "http://hl7.org/fhir/v3/ParticipationType",
                    "code": "PPRF",
                    "display": "primary performer"
                },
                "text": "primary performer"
            },
            "actor": {
                "reference": "Practitioner/1225652472001060"
            }
        },
        {
            "actor": {
                "reference": "Location/FAC-404"
            }
        },
        {
            "type": {
                "coding": {
                    "system": "http://www.gehealthcare.com/fhir/cpsemr/codesystem/PARTICIPANTTYPECPS",
                    "code": "Resource",
                    "display": "Resource"
                },
                "text": "Resource"
            },
            "actor": {
                "reference": "Practitioner/1225652472001060"
            }
        }
    ]
}
ahsankcg commented 2 years ago

Hi @AjeetYadav07 as mentioned in your comment here https://github.com/athenahealth/apiserver-athenaFlex/issues/147#issuecomment-704260251

You said create a schedule for appointment in client..

My question is how can we create a schedule. Because we don't have access to any client app. Can we get access to Sandbox Client?

Thank you

AjeetYadav07 commented 2 years ago

Hi @ahsankcg,

Created schedule and slots for booking appointments. Slots are available to book from start date 2022-07-06 to end date 2022-07-31. All available slots for 15 min duration. Slots can be created only from our client application(AthenaFlow). there is no fhir end point to create Slots. reference payload is attached for the same. Appt_ap22sandbox_v22.txt

ahsankcg commented 2 years ago

@AjeetYadav07 Hi

I successfully created appointment after you created the slots. Thanks much really appreciate your efforts and cooperation.