chronic-care / mcc-project

MCC eCare Plan project planning and documentation
Apache License 2.0
0 stars 1 forks source link

Explore persisting data to enable aggregation #191

Closed kbertodatti closed 1 year ago

kbertodatti commented 2 years ago

Enable persisting OAuth2.0 tokens. Using tokens to load all the data.

Reference #173

drdavec commented 2 years ago

fhirService.ts includes code to log the OAuth2 client JSON to console. I attached here results from logging authentication to both MELD and Epic sandboxes. I think that we can persist the client.state object and use all persisted states to re-connect to all endpoints that have unexpired tokens and aggregate their results in the app. Have not examined How to invoke JS Client connection with an existing token, bypassing authentication flow.

console.log('Client JSON: ') console.log(console.log(JSON.stringify(client)))

drdavec commented 2 years ago

Client JSON from Epic sandbox:

{ "units": {}, "state": { "clientId": "821ea3c1-011f-4f70-a8ae-299043b7e0be", "scope": "launch launch/patient openid fhirUser patient/Patient.read patient/Practitioner.read patient/RelatedPerson.read patient/Condition.read patient/DiagnosticReport.read patient/Observation.read patient/Procedure.read patient/CarePlan.read patient/CareTeam.read patient/Goal.read patient/Immunization.read patient/MedicationRequest.read patient/Medication.read patient/ServiceRequest.read patient/Provenance.read patient/Organization.read", "redirectUri": "http://localhost:8000/mycareplanner/index.html", "serverUrl": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "tokenResponse": { "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ1cm46b2lkOmZoaXIiLCJjbGllbnRfaWQiOiI4MjFlYTNjMS0wMTFmLTRmNzAtYThhZS0yOTkwNDNiN2UwYmUiLCJlcGljLmVjaSI6InVybjplcGljOk9wZW4uRXBpYy1jdXJyZW50IiwiZXBpYy5tZXRhZGF0YSI6ImI3TDRkWGZXZERpcEhwd21xOTRCUFdpMG5fWWs3WmtKWkM1T3BOUHoyakY5cmZpb1pYVlpMTzhjZ3hNOE9fcGs0QTR1V0p2UkVpczA3cmJyZGZBUVRaQktKM3FmRTkzNGdzRDhQSTFJTTNaNjVqYURGSTBMSktxaFB6Y1gxSldyIiwiZXBpYy50b2tlbnR5cGUiOiJhY2Nlc3MiLCJleHAiOjE2NjYyODg0NzEsImlhdCI6MTY2NjI4NDg3MSwiaXNzIjoidXJuOm9pZDpmaGlyIiwianRpIjoiNjViZDA4NzMtNGY2MC00M2M4LTg3NGItMWU4ZjU0MjkyZDUxIiwibmJmIjoxNjY2Mjg0ODcxLCJzdWIiOiJlaWFWSm0yakFCVHJ1OU1SbnR2YW1iUTMifQ.Z8MpLZfRA2S_78T1oE7nI-aCtq-9kE2JplIRxhLQwt-oPA1k0AjmWSv7VXfQ1lnq7lUYGCBiU5X-ggGB6ajVUkL0qFsLG3Wly1KyCCLA3xWI29QRV3zMhWhowrUD0Sfc1yPRVzzwaVqqTFl2MxGr-gf3xZHO82ZUIX_dGh0UEGRYor2WeApGULhP9dXQDT4i_0mdCz_Eqa5ZyNCLDCtqOqQH0xJ4nhx52QI6KKZqLkA6mENoe96n9WOWGgbqM_RNYhr9JOkUSYdlAi21lJzlfspLMYvif7AlmrL_p_YHUdzAdUT5RL0fzSCDYGZ3akQa2UotolqQCIqeyD-vyc4g9A", "token_type": "Bearer", "expires_in": 3600, "scope": "patient/CarePlan.read patient/CareTeam.read patient/Condition.read patient/Encounter.read patient/Goal.read patient/Immunization.read patient/Location.read patient/Medication.read patient/MedicationRequest.read patient/Observation.read patient/Organization.read patient/Patient.read patient/Practitioner.read patient/PractitionerRole.read patient/Procedure.read patient/Provenance.read patient/RelatedPerson.Read fhirUser launch/patient openid", "state": "ErSez9yhiKF0myUx", "__epic.dstu2.patient": "Tw1NlvLjU9fJ3smxYc.DP2IYIruy10jgl8uyBEyuh4ykB", "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InRvVzlqTVVTTi81L0wzaXdhUUdkVG1ORHVodnAvSmNBWlZIL2NPSjZPckU9IiwidHlwIjoiSldUIn0.eyJhdWQiOiI4MjFlYTNjMS0wMTFmLTRmNzAtYThhZS0yOTkwNDNiN2UwYmUiLCJleHAiOjE2NjYyODUxNzEsImZoaXJVc2VyIjoiaHR0cHM6Ly9maGlyLmVwaWMuY29tL2ludGVyY29ubmVjdC1maGlyLW9hdXRoL2FwaS9GSElSL1I0L1BhdGllbnQvZTJTUFA1aHY3OU9VUGJ4LUhqcHJ6bUEzIiwiaWF0IjoxNjY2Mjg0ODcxLCJpc3MiOiJodHRwczovL2ZoaXIuZXBpYy5jb20vaW50ZXJjb25uZWN0LWZoaXItb2F1dGgvb2F1dGgyIiwic3ViIjoiZTJTUFA1aHY3OU9VUGJ4LUhqcHJ6bUEzIn0.WKEe_hTo4iSmrIwmAkr9jPXi6jpi1v-KH1S2aAslYKWfna59tw3t33kNN6-xrsKIW7mbNZTmdQAWO7uCTzBjW53f4k-VqR9jP-Voj9-NND-1wUGWeuCgTBOkTACBa7FcqLvsKgytK87-S04dfSGXlCXARBVI_ebY88Too0ZL04wCEVhqfV-yUlel5aEjqlFmDa5CX94ymUSyVwo8hNOxfeMzyMZ6_X6bk2ZfHqOBripcISLOP6uBrQ8H3Ty7Pz665mEhWxhkmdl-dlm6ejkbxpYnk2Y98XPu5-y_O0uBYQW--Dwu-dUBtOEMyxTB5gpqCouiwDiBhIj25V1pPO8pvw", "patient": "e2SPP5hv79OUPbx-HjprzmA3" }, "key": "ErSez9yhiKF0myUx", "registrationUri": "", "authorizeUri": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize", "tokenUri": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token", "expiresAt": 1666288471 }, "environment": { "_url": "http://localhost:8000/mycareplanner/index.html", "_storage": {}, "options": { "replaceBrowserHistory": true, "fullSessionStorageSupport": true, "refreshTokenWithCredentials": "same-origin" } }, "_refreshTask": null, "patient": { "id": "e2SPP5hv79OUPbx-HjprzmA3" }, "encounter": { "id": null }, "user": { "fhirUser": "Patient/e2SPP5hv79OUPbx-HjprzmA3", "id": "e2SPP5hv79OUPbx-HjprzmA3", "resourceType": "Patient" } }

drdavec commented 2 years ago

Client JSON from MELD sandbox:

{ "units": {}, "state": { "clientId": "2dbe1620-7232-4ab7-a5e5-4ee85112a74e", "scope": "launch launch/patient openid fhirUser patient/Patient.read patient/Practitioner.read patient/RelatedPerson.read patient/Condition.read patient/DiagnosticReport.read patient/Observation.read patient/Procedure.read patient/CarePlan.read patient/CareTeam.read patient/Goal.read patient/Immunization.read patient/MedicationRequest.read patient/ServiceRequest.read patient/Task.read patient/Questionnaire.read patient/QuestionnaireResponse.write patient/Goal.write patient/MedicationRequest.write patient/Condition.write", "redirectUri": "http://localhost:8000/mycareplanner/index.html", "serverUrl": "https://gw.interop.community/CarePlanning/data", "tokenResponse": { "access_token": "eyJqa3UiOiJodHRwczpcL1wvaW9sMmF1dGguaW50ZXJvcC5jb21tdW5pdHlqd2siLCJraWQiOiJyc2ExIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJhdWQiOiIyZGJlMTYyMC03MjMyLTRhYjctYTVlNS00ZWU4NTExMmE3NGUiLCJpc3MiOiJodHRwczpcL1wvaW9sMmF1dGguaW50ZXJvcC5jb21tdW5pdHkiLCJleHAiOjE2NjYyODgxOTksImlhdCI6MTY2NjI4NDU5OSwianRpIjoiOWU5YTdkOGQtY2UwZS00NDBjLWIwMGMtZjg2M2JhYmE2ODQ4In0.FM8AuQMqCUAhZAmtI2n0ShtQ08AAkJik3OHxPp0WC4ZIr3Lg1CKum2V3dCm-zuSmTTW1IduhBxIBJOBRRl9T-zGra1Vd0hyzVlQN-umkY_yGXbmkrSqFxd23UYNiTD1sDWlWa5Op0IwlSSGo_FRGi_vM1n-p42Zg8WwBO3rjnQ-HYKSdzz8RVijanQ5t3UhRPY7vpjQnZb78PXk4Q3BIQ6sroA8SlksEJtRAd6At_Ipf8Aj73gvTGHILL4n_UdcP08HFPmsClfqFeMpAYEtEVjlrYGZKswcnFdX24DMWmopipSrgwRtlTi_ARdP264LViUGgUg3V6oi9HZoTQ_vhJA", "token_type": "Bearer", "expires_in": 3599, "scope": "patient/Goal.write patient/CareTeam.read patient/Practitioner.read launch/patient openid patient/Questionnaire.read patient/Goal.read patient/Immunization.read launch patient/ServiceRequest.read fhirUser patient/Procedure.read patient/RelatedPerson.read patient/MedicationRequest.read patient/Task.read patient/Condition.write patient/DiagnosticReport.read patient/Patient.read patient/Condition.read patient/MedicationRequest.write patient/QuestionnaireResponse.write patient/Observation.read patient/CarePlan.read", "patient": "mcc-pat-pnoelle", "id_token": "eyJraWQiOiJyc2ExIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJwbm9lbGxlQENhcmVQbGFubmluZyIsImF1ZCI6IjJkYmUxNjIwLTcyMzItNGFiNy1hNWU1LTRlZTg1MTEyYTc0ZSIsImRpc3BsYXlOYW1lIjoiUGF0cmljaWEgTm9lbGxlIiwicHJvZmlsZSI6IlBhdGllbnRcL21jYy1wYXQtcG5vZWxsZSIsImtpZCI6InJzYTEiLCJpc3MiOiJodHRwczpcL1wvaW9sMmF1dGguaW50ZXJvcC5jb21tdW5pdHkiLCJleHAiOjE2NjYyODgxOTksImZoaXJVc2VyIjoiUGF0aWVudFwvbWNjLXBhdC1wbm9lbGxlIiwiaWF0IjoxNjY2Mjg0NTk5LCJlbWFpbCI6InBub2VsbGVAQ2FyZVBsYW5uaW5nIn0.TTBplL-0rAN1RHfZwp_8eK3otZ4AUQ6hYCk2BczOQfaQLr95Lv0cZ4NdZkKRK-ZNdmZB-OkxySMkgXBXIERufoQpMtEH-qv3taPBQ04Q3DdPH_1N42OjaOTsDYLqUGZiZOWN_3W-RTq5o8dki39XlOiAOwnHIQ_vkHR5eOCq6Jb18R4vvG9IqPUpDwr-crVhNXn6qRgRk8oEKJMC-4hyqy8NIjPZzQ3hyi4xmIfyObVayX9pT3XGNMFsM_BK7Vbzqu4S1mHKdNQykwcUgYuKcVoaUZG11_7x81gWm0H0L_CU0K82Xs0CwNBqmB6XxlUifajN2eI-GIuLh-OHP4LP4Q" }, "key": "IVEJWYt7bjDbi6AG", "registrationUri": "https://iol2auth.interop.community/register", "authorizeUri": "https://iol2auth.interop.community/authorize", "tokenUri": "https://iol2auth.interop.community/token", "expiresAt": 1666288198 }, "environment": { "_url": "http://localhost:8000/mycareplanner/index.html", "_storage": {}, "options": { "replaceBrowserHistory": true, "fullSessionStorageSupport": true, "refreshTokenWithCredentials": "same-origin" } }, "_refreshTask": null, "patient": { "id": "mcc-pat-pnoelle" }, "encounter": { "id": null }, "user": { "fhirUser": "Patient/mcc-pat-pnoelle", "id": "mcc-pat-pnoelle", "resourceType": "Patient" } }

drdavec commented 2 years ago

The SMART JavaScript docs are here:

http://docs.smarthealthit.org/client-js/api#authorizeoptions-promisenever