Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KeeyanGhoreshi committed Nov 8, 2023
1 parent 2aa5235 commit e54de98
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/views/Patient/MedReqDropDown/MedReqDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function MedReqDropDown(props: MedReqDropDownProps) {
[resourceId]
);
let tempHook: OrderSelectHook;
if(env.get('REACT_APP_SEND_FHIR_AUTH_ENABLED').asBool()){
if (env.get('REACT_APP_SEND_FHIR_AUTH_ENABLED').asBool()) {
tempHook = hook.generate(client);
} else {
tempHook = hook.generate();
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

0 comments on commit e54de98

Please sign in to comment.