Skip to content

Commit

Permalink
Merge pull request #83 from chronic-care/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
swmuir authored Jul 29, 2024
2 parents fceeaad + 8121bb7 commit b4042cd
Show file tree
Hide file tree
Showing 31 changed files with 65,485 additions and 30,029 deletions.
11 changes: 8 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ GENERATE_SOURCEMAP=false
# REACT_APP_SHARED_DATA_AUTH_ENDPOINT=
# REACT_APP_SHARED_DATA_SCOPE="launch/patient openid fhirUser patient/*.read patient/*.write"

REACT_APP_SHARED_DATA_ENDPOINT=http://localhost:8080/fhir
REACT_APP_SHARED_DATA_AUTH_ENDPOINT=https://gw.interop.community/MCCDevelopment/data
REACT_APP_SHARED_DATA_SCOPE="launch/patient openid fhirUser patient/* user/*.cruds patient/*.cruds"


# These 2 parameters are only used when Shared Data is a separate FHIR server with its own SMART launch flow.
REACT_APP_SHARED_DATA_CLIENT_ID=
REACT_APP_SHARED_DATA_REDIRECT_URI="./index.html"


REACT_APP_MELD_SANDBOX_NAME=MCCDevelopment
REACT_APP_MELD_SANDBOX_CLIENT_ID=<...>
REACT_APP_MELD_SANDBOX_CLIENT_ID=5fa54c47-ed80-405b-a0b7-611eee5d0159

# Logica sandbox
REACT_APP_CLIENT_ID_logica=<...>
Expand Down Expand Up @@ -89,6 +94,6 @@ REACT_APP_LOG_ENABLED=false
REACT_APP_LOG_API_KEY=<...>
REACT_APP_LOG_ENDPOINT_URI="http://localhost:8085"

REACT_APP_VERSION="version - 2.2.2"
REACT_APP_VERSION="version - 2.2.3"
# Set to have HHS Banner
REACT_APP_HHS_BANNER=false
REACT_APP_HHS_BANNER=false
46 changes: 0 additions & 46 deletions dev-data-files/mcc-provenance-pnoelle-hypertension.json

This file was deleted.

46 changes: 0 additions & 46 deletions dev-data-files/mcc-provenance-pnoelle-lipids.json

This file was deleted.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mycareplanner",
"version": "2.0.0",
"version": "2.2.3",
"private": true,
"homepage": "https://chronic-care.github.io/mycareplanner",
"dependencies": {
Expand Down Expand Up @@ -53,7 +53,9 @@
"cors": "^2.8.5",
"express": "^4.17.1",
"gh-pages": "^3.1.0",
"typescript": "^3.8.3"
"typescript": "^3.8.3",
"cql-exec-vsac": "^1.2.2",
"temp": "^0.9.1"
},
"scripts": {
"start": "rescripts start",
Expand Down
121 changes: 77 additions & 44 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import { getPatientSummaries, executeScreenings } from './data-services/mpcCqlSe
import { ScreeningDecision } from "./components/decision/ScreeningDecision";

import { GoalSummary, ConditionSummary, MedicationSummary, ObservationSummary } from './data-services/models/cqlSummary';
import { isEndpointStillAuthorized, getSelectedEndpoints, deleteSelectedEndpoints, isSavedTokenStillValid, getLauncherData } from './data-services/persistenceService'
import {
isEndpointStillAuthorized, getSelectedEndpoints, deleteSelectedEndpoints,
isSavedTokenStillValid, getLauncherData, deleteAllDataFromLocalForage, saveSessionId, isSessionId, getSessionId, deleteSessionId
} from './data-services/persistenceService'
import {
getGoalSummaries, getLabResultSummaries, getConditionSummaries,
getMedicationSummaries, getVitalSignSummaries
Expand All @@ -32,7 +35,7 @@ import {
getMatchingProviderEndpointsFromUrl
} from './data-services/providerEndpointService'

import { doLog, LogRequest } from './log/log-service'
import { clearSession, doLog, initializeSession, LogRequest } from './log/log-service'
import { GoalList } from "./components/summaries/GoalList";
import { ConditionList } from "./components/summaries/ConditionList";
import { MedicationList } from "./components/summaries/MedicationList";
Expand Down Expand Up @@ -90,6 +93,7 @@ interface AppState {

isActiveSession: boolean,
isLogout: boolean,
sessionId: string | undefined,
}

type SummaryFunctionType = (fhirData?: FHIRData[]) =>
Expand Down Expand Up @@ -139,6 +143,7 @@ class App extends React.Component<AppProps, AppState> {

isActiveSession: true,
isLogout: false,
sessionId: undefined,
}

this.initializeSummaries()
Expand All @@ -156,6 +161,19 @@ class App extends React.Component<AppProps, AppState> {
// await this.setSupplementalDataClient('somePatientId')

try {
if(await isSessionId()){
const retrievedSessionId = await getSessionId();
if(retrievedSessionId){
this.setState({ sessionId : retrievedSessionId });
}
console.log("I am in Retrieving the sessionID block ----------->",retrievedSessionId);
}
else{
const sessionId = await initializeSession(); // Initialize session when the application is launched
this.setState({ sessionId });
saveSessionId(sessionId);
console.log("I am in Creating the sessionID block ----------------->", sessionId)
}
console.log("Checking if this is a multi-select, single, or a loader...")
const selectedEndpoints: string[] | undefined = await getSelectedEndpoints()
if (selectedEndpoints && selectedEndpoints.length > 0) {
Expand Down Expand Up @@ -339,7 +357,7 @@ class App extends React.Component<AppProps, AppState> {
// TODO: convert this to use multi login code?

// Configure the SDS client to get FHIR Data
console.log('We can connect to the SDS, so, add it to loader (read) SDS data')
console.log('We can connect to the SDS, so, add it to launcher (read) SDS data')
const serverUrl = this.state.supplementalDataClient.state.serverUrl
const serverUrlFromEnvVar = process.env.REACT_APP_SHARED_DATA_ENDPOINT
console.log(`Dynamic SDS serverUrl (using this for now...): ${serverUrl}`)
Expand All @@ -352,7 +370,7 @@ class App extends React.Component<AppProps, AppState> {
this.resetErrorMessageState()

try {
// Use the SDS client to get FHIR Data
// Use the SDS client to get FHIR Data
const sdsData: FHIRData = await getFHIRData(true, serverUrl, this.state.supplementalDataClient,
this.setAndLogProgressState, this.setResourcesLoadedCountState, this.setAndLogErrorMessageState)
console.log('SDS data: ', sdsData)
Expand Down Expand Up @@ -540,6 +558,7 @@ class App extends React.Component<AppProps, AppState> {
event: 'Summaries Loading',
message: `Resource Count for ${key}: ${length}`,
resourceCount: length,
sessionId: this.state.sessionId,
};
doLog(request)
}
Expand Down Expand Up @@ -606,6 +625,16 @@ class App extends React.Component<AppProps, AppState> {
console.log('setSupplementalDataClient()')
let client = await getSupplementalDataClient(patientId)

// wait for client to get online to fix refresh issue
var attempts = 0
while (!client) {
client = await getSupplementalDataClient(patientId);
attempts++;
if (attempts < 10) {
break;
}
}

if (client) {
// We have a valid client for the SDS, but, we don't know if it has any data yet
// (or a valid patient / patient with data)
Expand All @@ -617,43 +646,43 @@ class App extends React.Component<AppProps, AppState> {
// If we want to go further, and we get back a Patient, we can check that: "id": "patient-name",
// If either of those fail, we don't load the SDS...

const sdsMessageSuffix = "The SDS client will not be used."
let isSDSReadError = false
let sdsPatient: Patient | undefined
if (client.patient.id !== null) {
console.log("client.patient.id !== null, using client.patient.read()")
try {
sdsPatient = await client.patient.read() as Patient
console.log("Valid ")
} catch (err) {
console.warn("Warning: SDS Patient cannot be read via client.patient.read(): " + sdsMessageSuffix)
isSDSReadError = true
}
} else {
console.log("client.patient.id === null, using client.user.read() isntead of client.patient.read()")
try {
sdsPatient = await client.user.read() as Patient
} catch (err) {
console.warn("Warning: SDS Patient cannot be read via client.user.read(): " + sdsMessageSuffix)
isSDSReadError = true
}
}

if (!isSDSReadError) {
console.log("Valid SDS patient read: Using SDS client", sdsPatient ? sdsPatient : "unknown")

const stillValid = await isSavedTokenStillValid(client.state)
// const sdsMessageSuffix = "The SDS client will not be used."
// let isSDSReadError = false
// let sdsPatient: Patient | undefined
// if (client.patient.id !== null) {
// console.error("setSupplementalDataClient client.patient.id !== null, using client.patient.read()")
// try {
// sdsPatient = await client.patient.read() as Patient
// console.log("Valid ")
// } catch (err) {
// console.warn("Warning: SDS Patient cannot be read via client.patient.read(): " + sdsMessageSuffix)
// isSDSReadError = true
// }
// } else {
// console.log("client.patient.id === null, using client.user.read() isntead of client.patient.read()")
// try {
// sdsPatient = await client.user.read() as Patient
// } catch (err) {
// console.warn("Warning: SDS Patient cannot be read via client.user.read(): " + sdsMessageSuffix)
// isSDSReadError = true
// }
// }

// if (!isSDSReadError) {
// console.log("Valid SDS patient read: Using SDS client", sdsPatient ? sdsPatient : "unknown")

// const stillValid = await isSavedTokenStillValid(client.state)
this.setState({ supplementalDataClient: client })
this.setState({ canShareData: stillValid })
this.setState({ canShareData: true })

console.log("***** PatientID = " + client.getPatientId() ?? "")
console.log("***** User ID = " + client.getUserId() ?? "")
console.log("***** Can share data = " + stillValid ?? "?")
} else {
console.warn(`Warning: Invalid SDS patient read: Overriding valid client to undefined
and not setting state for supplementalDataClient or canShareData`)
client = undefined
}
// console.log("***** PatientID = " + client.getPatientId() ?? "")
// console.log("***** User ID = " + client.getUserId() ?? "")
// console.log("***** Can share data = " + stillValid ?? "?")
// } else {
// console.warn(`Warning: Invalid SDS patient read: Overriding valid client to undefined
// and not setting state for supplementalDataClient or canShareData`)
// client = undefined
// }

}
return client
Expand All @@ -668,6 +697,7 @@ class App extends React.Component<AppProps, AppState> {
event: 'Patient information loading',
page: 'Home',
message: logMessage,
sessionId: this.state.sessionId,
}
doLog(request)
this.setState({ progressMessage: message })
Expand Down Expand Up @@ -720,13 +750,13 @@ class App extends React.Component<AppProps, AppState> {
this.setState({ userErrorMessage: undefined })
}

private handleLogout = () => {
private handleLogout = async () => {
if (!this.state.isLogout) {
this.setState({ isLogout: true })
sessionStorage.clear();
this.props.history.push('/logout');
sessionStorage.clear()
await deleteAllDataFromLocalForage()
this.props.history.push('/logout')
}

}

updateLogMainTab = async (event: any, value: any) => {
Expand All @@ -741,6 +771,7 @@ class App extends React.Component<AppProps, AppState> {
event: 'Clicked',
page: tab,
message,
sessionId: this.state.sessionId,
}
doLog(request)
}
Expand All @@ -758,6 +789,7 @@ class App extends React.Component<AppProps, AppState> {
event: 'Clicked',
page: tab,
message,
sessionId: this.state.sessionId,
}

doLog(request)
Expand All @@ -775,6 +807,7 @@ class App extends React.Component<AppProps, AppState> {
event: 'Clicked',
page: tab,
message,
sessionId: this.state.sessionId,
}
doLog(request)

Expand Down Expand Up @@ -893,7 +926,7 @@ class App extends React.Component<AppProps, AppState> {
<Home fhirDataCollection={this.state.fhirDataCollection} patientSummaries={this.state.patientSummaries} screenings={this.state.screenings}
progressMessage={this.state.progressMessage} progressValue={this.state.progressValue} resourcesLoadedCount={this.state.resourcesLoadedCount}
errorType={this.state.errorType} userErrorMessage={this.state.userErrorMessage} developerErrorMessage={this.state.developerErrorMessage} errorCaught={this.state.errorCaught}
canShareData={this.state.canShareData}
canShareData={this.state.canShareData} isLogout={this.state.isLogout}
/>
</TabPanel>
<TabPanel value="2" sx={{ padding: '0px 0px 100px' }}>
Expand Down
Loading

0 comments on commit b4042cd

Please sign in to comment.