Skip to content

Commit

Permalink
fillbot fills out form 8500-8
Browse files Browse the repository at this point in the history
  • Loading branch information
awatson1978 committed Apr 27, 2024
1 parent fa3385a commit 423849b
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ symptomatic:data-importer
symptomatic:data-relay
symptomatic:timelines
awatson:space-situational-awareness
mitre:fhir-side
symptomatic:structured-data-capture
mitre:sphr-record-analyzer
mitre:fhir-side
4 changes: 2 additions & 2 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ [email protected]
clinical:[email protected]
clinical:[email protected]
clinical:[email protected]
clinical:[email protected].2
clinical:[email protected].3
clinical:[email protected]
clinical:[email protected]
clinical:[email protected]
Expand Down Expand Up @@ -106,7 +106,7 @@ [email protected]
symptomatic:[email protected]
symptomatic:[email protected]
symptomatic:[email protected]
symptomatic:[email protected].0
symptomatic:[email protected].1
[email protected]
tmeasday:[email protected]
[email protected]
Expand Down
107 changes: 107 additions & 0 deletions app/SmartOnFhirHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import _ from 'lodash';
let get = _.get;
let set = _.set;
let has = _.has;
let uniq = _.uniq;

import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { Session } from 'meteor/session';


export const SmartOnFhirHelpers = {
fetchCapabilityStatement(){
console.log('fetchCapabilityStatement');

HTTP.get(get(Meteor, 'settings.public.smartOnFhir[0].fhirServiceUrl', '') + "/metadata?_format=json", {}, function(error, result){
if(error){
console.error('HTTP.get /metadata error', error)
}
if(result){
console.log('HTTP.get /metadata result', result)
let parsedData;
if(get(result, 'data')){
setServerCapabilityStatement(result.data);
fetchWellKnownSmartConfig();
} else if (get(result, 'content')) {
setServerCapabilityStatement(JSON.parse(get(result, 'content')));
SmartOnFhirHelpers.fetchWellKnownSmartConfig();
}
}
});
},
fetchWellKnownSmartConfig(callback){
console.log('fetchWellKnownSmartConfig');

HTTP.get(get(Meteor, 'settings.public.smartOnFhir[0].fhirServiceUrl', '') + "/.well-known/smart-configuration", {}, function(error, result){
if(error){
console.error('HTTP.get /.well-known/smart-configuration error', error)
}
if(result){
console.log('HTTP.get /.well-known/smart-configuration result', result)
setWellKnownSmartConfig(get(result, 'data'));
SmartOnFhirHelpers.exchangeCodeForAccessToken(get(result, 'data'));
}
});
},
exchangeCodeForAccessToken(wellKnownSmartConfig){

console.log('exchangeCodeForAccessToken')
console.log('exchangeCodeForAccessToken.url', get(wellKnownSmartConfig, 'token_endpoint'))

let stringEncodedData = "grant_type=authorization_code&code=" + searchParams.get('code') + '&redirect_uri=' + encodeURIComponent(get(Meteor, 'settings.public.smartOnFhir[0].redirect_uri', '')) + '&client_id=' + get(Meteor, 'settings.public.smartOnFhir[0].client_id', '')
console.log('exchangeCodeForAccessToken.stringEncodedData', stringEncodedData);
let payload = {
code: searchParams.get('code'),
grant_type: 'authorization_code',
redirect_uri: encodeURIComponent(get(Meteor, 'settings.public.smartOnFhir[0].redirect_uri', '')),
client_id: get(Meteor, 'settings.public.smartOnFhir[0].client_id', '')
}
console.log('exchangeCodeForAccessToken.code', searchParams.get('code'))
console.log('exchangeCodeForAccessToken.code', payload)

HTTP.post(get(wellKnownSmartConfig, 'token_endpoint'), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
content: stringEncodedData
}, function(error, result){
if(error){
console.error('HTTP.post /token error', error)
}
if(result){
console.log('HTTP.post /token result', result)
setSmartAccessToken(get(result, 'data'));

SmartOnFhirHelpers.fetchPatient(get(result, 'data.patient'), get(result, 'data.access_token'));
}
});

return returnQuery
},
fetchPatient(patientId, accessToken){
console.log('fetchPatient')
console.log('fetchPatient.url', get(Meteor, 'settings.public.smartOnFhir[0].fhirServiceUrl', '') + "/Patient")
console.log('fetchPatient.url', accessToken)

HTTP.get(get(Meteor, 'settings.public.smartOnFhir[0].fhirServiceUrl', '') + "/Patient/" + patientId + "?_format=json", {
headers: {
'Authorization': 'Bearer ' + accessToken
}
}, function(error, result){
if(error){
console.error('HTTP.get /Patient error', error)
}
if(result){
console.log('HTTP.get /Patient result', result)
if(get(result, 'data')){
setFhirPatient(get(result, 'data'));
} else if (get(result, 'content')) {
setFhirPatient(JSON.parse(get(result, 'content')));
}
}
});
}
}

export default FhirUtilities;
16 changes: 8 additions & 8 deletions app/layout/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,19 +431,19 @@ export function App(props) {
document.getElementById("reactCanvas").setAttribute("style", "bottom: 0px; background: " + defaultCanvasColor + ";");
document.getElementById("reactCanvas").setAttribute("background", defaultCanvasColor);
}
}, [])
}, [props])

// ------------------------------------------------------------------
// Trackers (Auto Update Variables)

const absoluteUrl = useTracker(function(){
console.log('App is checking that Meteor is loaded and fetching the absolute URL.')
return Meteor.absoluteUrl();
}, []);
// const absoluteUrl = useTracker(function(){
// console.log('App is checking that Meteor is loaded and fetching the absolute URL.')
// return Meteor.absoluteUrl();
// }, []);

const selectedPatient = useTracker(function(){
return Session.get('selectedPatient')
}, []);
// const selectedPatient = useTracker(function(){
// return Session.get('selectedPatient')
// }, []);


// const canvasBackgroundColor = useTracker(function(){
Expand Down

0 comments on commit 423849b

Please sign in to comment.