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

Test Data and Sample Input payload for the API #168

Closed saravanakumargs closed 3 years ago

saravanakumargs commented 3 years ago

Can you provide the Test Data available in the Sandbox environment and sample Input for all the API calls.

We are successfully able to authenticate and get the token to call the API.

Can you please share the test data for all the API calls like, Providers available, Slot , Appointment etc.,

AjeetYadav07 commented 3 years ago

To get a specific resource data make a get for that resource like Patient -- if you need patient specific data [GET]https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/Patient -- will list top 20 record In response body you can find the patient Id and provider/Practitioner details. based on patient or provider you can make API calls. for example [GET]https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/RelatedPerson?patient=1902008249235680 Most of the API calls are supporting 'patient' as a search parameter. please look at the https://mydata.athenahealth.com/fhirapidoc for supported search parameter for specific API's. I have provide one sample payload to create a patient. [POST]https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/Patient Patient.txt

To get the data for all the API calls like, Providers available, Slot , Appointment etc., Please make get call for corresponding API and do some analysis on response body.

saravanakumargs commented 3 years ago

HI,

After login with personal account, I am trying to get the schedule of the Practitioner. But getting unauthorized error.

Steps: 1) Login with the url - https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/oauth2/authorize?state=defaultState&scope=openid%20profile%20patient/*.*%20launch/patient&response_type=code%20id_token&redirect_uri=https://localhost:8080/emrlogin/athenaLoginSuccess&aud=https%3A%2F%2Fcpsapisandbox.virenceaz.com%3A9443%2FdemoAPIServer&client_id={client_id}

2) Get the Bearer Token using the URL - https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/oauth2/token 

3) Got the belo response:
        a) Bearer token
        b) Scope: patient/BasicPosting.read patient/Medication.read patient/Immunization.read patient/OperationDefinition.read patient/DocumentReference.read patient/Procedure.read patient/ValueSet.read patient/BasicAccount.read patient/Slot.read patient/MedicationAdministration.read patient/Condition.read patient/CarePlan.read patient/Practitioner.read launch/patient patient/Coverage.read openid profile patient/Appointment.read patient/Goal.read patient/AllergyIntolerance.read patient/Schedule.read patient/MedicationOrder.read patient/ProcedureRequest.read patient/RelatedPerson.read patient/FamilyMemberHistory.read patient/NamingSystem.read patient/Device.read patient/Patient.read patient/Location.read patient/DiagnosticOrder.read patient/ConceptMap.read patient/Observation.read patient/MedicationStatement.read patient/Organization.read patient/Encounter.read patient/Binary.read patient/ReferralRequest.read patient/BasicAdvanceDirective.read

4) Got the patient Information:
   https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/Patient?_format=json using the Bearer Token.
   In the patient response got the practitioner id - {
                    "url": "http://hl7.org/fhir/StructureDefinition/ge-patient-extension-RESPPROVID",
                    "valueReference": {
                        "reference": "Practitioner/1225652472001060"
                    }
                },

5) Calling Schedule with the Parctitioner -https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/Schedule?actor=Practitioner/1225652472001060&_format=json

    Getting the error as Unauthorized. (Tried refreshing the token many times)
     "issue": [
    {
        "severity": "error",
        "code": "processing",
        "diagnostics": "Not authorized"
    }
]

Can you please let me know if I am doing anything wrong.

Thanks, Saravana

AjeetYadav07 commented 3 years ago

Please check the scope of the bearer token which you have generated and also look at the gihub issue #167 to create an access token which will valid for 1hrs. Try to generate the access token from provider workflow https://mydata.athenahealth.com/access-the-apis.

saravanakumargs commented 3 years ago

In the Bearer Token scope - I see the patient/Schedule.read available.

We are developing the Patient Flow to get the Schedule of the Provider and Display to Patient and they will select the slot and book the appointment

saravanakumargs commented 3 years ago

I have tried with the provider flow also,

I am able to call the below method https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/Patient?_format=json

But when calling the below method getting the 401. https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/Schedule?_format=json&actor=Practitioner%2F1225652472001060.

Can you please provide all the API example in the Sandbox or any demo app available to try all the api in sandbox.

saravanakumargs commented 3 years ago

Do you have any update on this??

ARCSIndia commented 3 years ago

@AjeetYadav07 Please suggest an Patient/Location/Practitioner Id for I can get appointment records. I tried with multiple Patient/Location/Practitioner, but the response is same as "total": 0, { "resourceType": "Bundle", "id": "1.2.840.113619.21.1.8899560752578716278.10.1614580669844.131229", "meta": { "lastUpdated": "2021-03-01T06:37:49.844Z" }, "type": "searchset", "total": 0, "link": [ { "relation": "self", "url": "https://cpsapisandbox.virenceaz.com:9443/demoAPIServer/fhir/Appointment?_format=json&patient=1902008249235680" } ] }

Also Suggest the Billing/Invoice API End Points.

AjeetYadav07 commented 3 years ago

Appointment without any search parameters will return OperationOutcome indicating Appointment resource requires location parameter to be able to search across patients. The location ids can be discovered by querying Location resource.

Location resource can be searched across patients without any search parameters. Location?_count=50

Extract location ids with prefix “FAC-“ for facilities.

Query Appointment by a list of facilities Appointment?location=FAC-403,FAC-404,FAC-405,FAC-406. Please look at github issue #140 and #136

Supported resources are listed here at https://mydata.athenahealth.com/fhirapidoc

Torin-Shepard-athena commented 3 years ago

@saravanakumargs FHIR Schedule resources can be read with user scope but not with patient scope. This is working as designed. Access tokens with patient scope are not allowed to access Schedule resource because patient scope should not be allowed to access user schedules. Patient scope would be allowed to access appointments related to the patient but not to access the definition of a Schedule for a Practitioner.

This has been put on the list for fixing in a future release. Access tokens with patient scope should not include patient/Schedule.read.

Research and discussion is needed to determine if/how patient-facing app could allow patients to schedule appointments. Most customers would not want to allow patients to schedule appointments directly. Instead, there would need to be some interaction with clinic staff to schedule appointments when responding to requests from patients.

Torin-Shepard-athena commented 3 years ago

@ARCSIndia Account and Posting are the only Practice Management APIs supported for billing, and these are supported for only CPS and athenaPractice but not for CEMR or athenaFlow.

GET [base]/fhir/$Account GET [base]/fhir/$Posting

Both of these APIs are extensions of the Basic Resource because FHIR DSTU2 does not have any resource types that could be mapped.

The Posting API documentation page mentions APIs for creating and deleting payments from a patient account. POST [base]/fhir/$PostPayment DELETE [base]/fhir/$deletePayment

Issue #141 has details about these APIs. https://github.com/athenahealth/apiserver-athenaFlex/issues/141#issuecomment-652323513 has sample resource ids that can be used with our API sandbox server.