smart-on-fhir / growth-chart-app

Other
67 stars 98 forks source link

How to use a new FIHR server? #51

Open sohrabhejazi opened 5 years ago

sohrabhejazi commented 5 years ago

Hi,

I created an FHIR server and I want to connect to this server through your app and use my own data. Is it possible? If yes, could you please guide me and tell me how?

LG Sohrab

vlad-ignatov commented 5 years ago

Yes, it should be possible. The simplest way would be to:

  1. Host the PGC app somewhere. For example npm start will start small http server and then the app will be available at http://127.0.0.1:9000/
  2. In the launch.html file at https://github.com/smart-on-fhir/growth-chart-app/blob/master/launch.html#L10-L11 add a patientId option. The value should be the ID of the patient (on your FHIR server) that you want to launch with.
  3. Then load your launch.html file and pass a fhirServiceUrl parameter like so: http://127.0.0.1:9000/launch.html?fhirServiceUrl=http://my.fhir.server
usmanbahadur commented 5 years ago

@vlad-ignatov hi that works fine as long as you testing hapi fhir servers but if your fhir server requires Oauth Porcess i can get a token and patient data using POSTMAN, my next step is that i want to plugin my FHIR Server to test Growth Chart App but for that i need to get access token first within your app.?

vlad-ignatov commented 5 years ago

Hi @usmanbahadur,

That was just an example of how to work-around SMART/Oauth. If you have an Oauth server, then you can register a client there and use the client_id in the launch.html file and launch as usual.

usmanbahadur commented 5 years ago

hi @vlad-ignatov so i have done the following this autheitcates the app against fhir server but how do we actually search a patient? image

vlad-ignatov commented 5 years ago

It is a responsibility of the server to offer you a patient selection UI if you have stated that you need it using the launch/patient scope. You can also bypass that by adding a patientId option to the authorize call in your launch.html, but that will "fix" your app to always use that patient.

usmanbahadur commented 5 years ago

hi @vlad-ignatov

i have tried by providing static patientId when launching as stand alone patient app, the error is patient not found.
image

image

image

vlad-ignatov commented 5 years ago

Does that patient exist on the server you are launching against?

BTW, the scope looks weird. Try "patient/*.read launch/patient".

usmanbahadur commented 5 years ago

@vlad-ignatov the patient exist in server, Azure FHIR Server does not like "patientId : smart-77777703" so i had to convert patient id var launchContext = {patient: patientId}; var launchContextString = encodeURIComponent(btoa(JSON.stringify(launchContext)));

https://github.com/microsoft/fhir-server-samples/blob/master/src/FhirDashboardJS/js/PatientModule.js

hexicalsystems commented 2 years ago

Hello, I'm trying to connect to our FHIR server as well. Did you finish using the growth chart app with your own FHIR server ? I could use any help or samples to get started in this. Please let me know.

usmanbahadur commented 2 years ago

@hexicalsystems Use the following in launch.html file of the project, you would need client_id, patientid etc from your fhir service provider, a redirect_uri is also very important this is where you will see the patient data pulled out of your fhir service. BW FHIR.oauth2.authorize({ "scope": "patient$*.read", "iss": "https://name-of-your-fhir-server.com", "patientId": "patient-id-that-exist-in-your-fhir-server", "client_id": "id-given-by-your-server", "redirect_url": "uri-where-you-want-to-redirect-this-app" )}