Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill fhir auth #55

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ REACT_APP_PHARMACY_SERVER_BASE = http://localhost:5051
REACT_APP_ETASU_STATUS_ENABLED = true
REACT_APP_PHARMACY_STATUS_ENABLED = true
REACT_APP_SEND_RX_ENABLED = true
REACT_APP_SEND_FHIR_AUTH_ENABLED = false
PORT=4040
REACT_APP_CLIENT_ID = app-login
REACT_APP_CLIENT_SCOPES = launch openid profile user/Patient.read patient/Patient.read user/Practitioner.read
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Following are a list of modifiable paths:
| REACT_APP_PHARMACY_STATUS_ENABLED | `true` |
| REACT_APP_DEVELOPER_MODE | `true` |
| REACT_APP_SEND_RX_ENABLED | `true` |
| REACT_APP_SEND_FHIR_AUTH_ENABLED | `false` |
| PORT | `4040`|

*Note that .env values can only be accessed by react app starting with `REACT_APP_`*
Expand Down
2 changes: 1 addition & 1 deletion src/cds-hooks
10 changes: 7 additions & 3 deletions src/views/Patient/MedReqDropDown/MedReqDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Client from 'fhirclient/lib/Client';
import { ReactElement, useEffect, useState } from 'react';
import example from '../../../cds-hooks/prefetch/exampleHookService.json'; // TODO: Replace with request to CDS service
import { hydrate } from '../../../cds-hooks/prefetch/PrefetchHydrator';
import { Hook, Card as HooksCard } from '../../../cds-hooks/resources/HookTypes';
import { Hook, Card as HooksCard, OrderSelectHook } from '../../../cds-hooks/resources/HookTypes';
import OrderSelect from '../../../cds-hooks/resources/OrderSelect';
import './MedReqDropDown.css';
import * as env from 'env-var';
Expand Down Expand Up @@ -206,8 +206,12 @@ function MedReqDropDown(props: MedReqDropDownProps) {
},
[resourceId]
);
const tempHook = hook.generate();

let tempHook: OrderSelectHook;
if (env.get('REACT_APP_SEND_FHIR_AUTH_ENABLED').asBool()) {
tempHook = hook.generate(client);
} else {
tempHook = hook.generate();
}
hydrate(getFhirResource, example.prefetch, tempHook).then(() => {
setCDSHook(tempHook);
});
Expand Down
50 changes: 31 additions & 19 deletions src/views/Questionnaire/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
}
});
const loadAndMergeForms = (newResponse: QuestionnaireResponse | null) => {

let lform = LForms.Util.convertFHIRQuestionnaireToLForms(
props.qform,
props.fhirVersion.toUpperCase()
Expand All @@ -212,7 +211,6 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
);
}


LForms.Util.addFormToPage(lform, questionnaireFormId);
const specificForm = document.getElementById(questionnaireFormId);
if (specificForm) {
Expand Down Expand Up @@ -1022,9 +1020,11 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
return true;
} else {
// check if form is fully filled out based on required fields
const requiredFieldErrors = formValidationErrors ? formValidationErrors.filter((error) => {
return error.includes('requires a value');
}) : [];
const requiredFieldErrors = formValidationErrors
? formValidationErrors.filter(error => {
return error.includes('requires a value');
})
: [];
return !(formValidationErrors && requiredFieldErrors.length);
}
};
Expand All @@ -1035,14 +1035,16 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
return <Typography fontSize={16}>{tooltip}</Typography>;
};

// Get missing fields to display
// Get missing fields to display
const getMissingFields = () => {
const fields: string[] = [];
const requiredFieldErrors = formValidationErrors ? formValidationErrors.filter((error) => {
return error.includes('requires a value');
}) : [];
const requiredFieldErrors = formValidationErrors
? formValidationErrors.filter(error => {
return error.includes('requires a value');
})
: [];
if (requiredFieldErrors.length) {
requiredFieldErrors.forEach((err) => {
requiredFieldErrors.forEach(err => {
const name = err.split(' requires a value')[0];
fields.push(name);
});
Expand All @@ -1053,12 +1055,13 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
const getDisplayButtons = () => {
if (!isAdaptiveForm()) {
return (
<div className='submit-button-panel'>
<div className="submit-button-panel">
<div className="btn-row">
<Button variant="outlined" onClick={() => loadPreviousForm()}>
Load Previous Form
</Button>
<Button variant="outlined"
<Button
variant="outlined"
onClick={() => {
outputResponse('in-progress');
}}
Expand All @@ -1067,7 +1070,9 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
</Button>
<Tooltip title={getMissingFieldsTooltip()}>
<span>
<Button variant="outlined" disabled={!isFilledOut()}
<Button
variant="outlined"
disabled={!isFilledOut()}
onClick={() => {
outputResponse('completed');
}}
Expand All @@ -1077,15 +1082,21 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
</span>
</Tooltip>
</div>
{!isFilledOut() ? <p className='error-text'>You must include a value for {getMissingFields()}</p> : <></>}
{!isFilledOut() ? (
<p className="error-text">You must include a value for {getMissingFields()}</p>
) : (
<></>
)}
</div>
);
} else {
if (props.adFormCompleted) {
return (
<div className="submit-button-panel">
<Tooltip title={getMissingFieldsTooltip()}>
<Button variant="outlined" disabled={!isFilledOut()}
<Button
variant="outlined"
disabled={!isFilledOut()}
onClick={() => {
outputResponse('completed');
}}
Expand All @@ -1104,7 +1115,8 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
</Button>
) : null}
{isAdaptiveFormWithItem() ? (
<Button variant="outlined"
<Button
variant="outlined"
onClick={() => {
outputResponse('in-progress');
}}
Expand Down Expand Up @@ -1663,15 +1675,15 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
{!props.adFormCompleted ? (
<div>
{' '}
<Button variant='outlined' onClick={loadNextQuestions}>
<Button variant="outlined" onClick={loadNextQuestions}>
Next Question
</Button>
</div>
) : null}
</div>
) : null}
<div style={{display: 'flex', justifyContent: 'space-between'}}>
{!isAdaptive ? <div className="status-panel">Form Loaded: {formLoaded}</div> : <div/>}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
{!isAdaptive ? <div className="status-panel">Form Loaded: {formLoaded}</div> : <div />}
{getDisplayButtons()}
</div>
</div>
Expand Down
30 changes: 19 additions & 11 deletions src/views/Questionnaire/SmartApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ export function SmartApp(props: SmartAppProps) {
// update the ignore required checkbox
const updateRequired = (defaultFilter: boolean) => {
let checked: boolean, requiredCheckbox: HTMLInputElement;
if (!defaultFilter) {
requiredCheckbox = document.getElementById('required-fields-checkbox') as HTMLInputElement;
checked = requiredCheckbox ? requiredCheckbox.checked : false;
} else {
checked = true;
}
setIgnoreRequiredCheckbox(checked);
if (!defaultFilter) {
requiredCheckbox = document.getElementById('required-fields-checkbox') as HTMLInputElement;
checked = requiredCheckbox ? requiredCheckbox.checked : false;
} else {
checked = true;
}
setIgnoreRequiredCheckbox(checked);
};

const fetchResourcesAndExecuteCql = (
Expand Down Expand Up @@ -593,7 +593,9 @@ export function SmartApp(props: SmartAppProps) {

// update required checkbox ref
const onRequiredCheckboxRefChange = () => {
const requiredCheckbox = document.getElementById(questionnaire ? `required-fields-checkbox-${questionnaire.id}` : 'required-fields-checkbox') as HTMLInputElement;
const requiredCheckbox = document.getElementById(
questionnaire ? `required-fields-checkbox-${questionnaire.id}` : 'required-fields-checkbox'
) as HTMLInputElement;
if (requiredCheckbox != null) {
requiredCheckbox.checked = ignoreRequiredCheckbox;
}
Expand Down Expand Up @@ -640,19 +642,25 @@ export function SmartApp(props: SmartAppProps) {
ref={onFilterCheckboxRefChange}
></input>
</div>
{ showRequiredCheckbox ?
{showRequiredCheckbox ? (
<div className="task-button">
<label>Ignore required fields</label>{' '}
<input
type="checkbox"
onChange={() => {
updateRequired(false);
}}
id={questionnaire ? `required-fields-checkbox-${questionnaire.id}` : 'required-fields-checkbox'}
id={
questionnaire
? `required-fields-checkbox-${questionnaire.id}`
: 'required-fields-checkbox'
}
ref={onRequiredCheckboxRefChange}
></input>
</div>
: <div/>}
) : (
<div />
)}
</div>
</div>
);
Expand Down
Loading