Skip to content

Commit

Permalink
Merge branch 'dev' into dependabot/npm_and_yarn/adobe/css-tools-4.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Virgulto committed Sep 5, 2023
2 parents 3c85b18 + 85219f4 commit 7d25f5f
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Development URLS

REACT_APP_REMS_ADMIN_SERVER_BASE = http://localhost:8090
REACT_APP_REMS_HOOKS_PATH = /cds-services/rems-order-sign
REACT_APP_REMS_HOOKS_PATH = /cds-services/rems-order-select
REACT_APP_PHARMACY_SERVER_BASE = http://localhost:5051
REACT_APP_ETASU_STATUS_ENABLED = true
REACT_APP_PHARMACY_STATUS_ENABLED = true
Expand Down
1 change: 1 addition & 0 deletions logs/installer.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*** Logs for continuous installer ***
19 changes: 19 additions & 0 deletions logs/runner.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

> [email protected] start /home/node/app/rems-smart-on-fhir
> react-app-rewired start

override
Starting the development server...

Compiled successfully!

You can now view rems-smart-on-fhir in the browser.

Local: http://localhost:4040
On Your Network: http://192.168.32.2:4040

Note that the development build is not optimized.
To create a production build, use npm run build.

webpack compiled successfully
No issues found.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 20 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ interface AppProps {
interface SmartTab {
element: ReactElement;
name: string;
groupName?: string;
id: string;
closeable: boolean;
}
function App(props: AppProps) {
Expand All @@ -32,12 +34,17 @@ function App(props: AppProps) {
const [tabs, setTabs] = useState<SmartTab[]>([]);
const [staticContent, setStaticContent] = useState<ReactElement>();
const handleChange = (event: React.SyntheticEvent, newValue: number) => {
setValue(tabs[newValue].name);
setValue(tabs[newValue].id);
};
const addTab = (element: ReactElement, tabName: string) => {
setTabs(oldTabs => [...oldTabs, { element: element, name: tabName, closeable: true }]);
setValue(tabName);
const addTab = (element: ReactElement, tabName: string, groupName: string, tabIndex = 0) => {
const tabId = `${tabName}-${tabIndex}`;
setTabs(oldTabs => [
...oldTabs,
{ element: element, name: tabName, id: tabId, closeable: true, groupName: groupName }
]);
setValue(tabId);
};

useEffect(() => {
const homeName = 'Home';
let appContext: AppContext | null = null;
Expand All @@ -52,6 +59,7 @@ function App(props: AppProps) {
standalone={false}
appContext={appContext}
patientId={client.getPatientId() || ''}
tabIndex={0}
/>
);
setStaticContent(smartApp);
Expand All @@ -60,6 +68,7 @@ function App(props: AppProps) {
{
element: <Patient client={client} tabCallback={addTab} />,
name: homeName,
id: homeName,
closeable: false
}
]);
Expand All @@ -71,10 +80,10 @@ function App(props: AppProps) {
(event: MouseEvent, tabToDelete: SmartTab) => {
event.stopPropagation();
const tabToDeleteIndex = tabs.findIndex(tab => {
return tab.name === tabToDelete.name;
return tab.id === tabToDelete.id;
});
if (tabToDeleteIndex > 0 && value === tabToDelete.name) {
setValue(tabs[tabToDeleteIndex - 1].name);
if (tabToDeleteIndex > 0 && value === tabToDelete.id) {
setValue(tabs[tabToDeleteIndex - 1].id);
}
const newTabs = tabs.filter((tab, index) => {
return index !== tabToDeleteIndex;
Expand Down Expand Up @@ -104,19 +113,19 @@ function App(props: AppProps) {
orientation="horizontal"
variant="scrollable"
value={tabs.findIndex(tab => {
return tab.name === value;
return tab.id === value;
})}
onChange={handleChange}
aria-label="tabs"
>
{tabs.map((tab, i) => {
return (
<Tab
style={{ maxWidth: '500px' }}
label={
typeof tab.name === 'string' ? (
<span>
{' '}
{tab.name}
{tab.groupName ? <span> {tab.groupName} </span> : null} {tab.name}
{tab.closeable && (
<IconButton
component="div"
Expand All @@ -143,7 +152,7 @@ function App(props: AppProps) {
return (
<MemoizedTabPanel
value={tabs.findIndex(tab => {
return tab.name === value;
return tab.id === value;
})}
index={i}
key={i}
Expand Down
2 changes: 1 addition & 1 deletion src/cds-hooks
48 changes: 32 additions & 16 deletions src/views/Patient/MedReqDropDown/MedReqDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 OrderSign from '../../../cds-hooks/resources/OrderSign';
import OrderSelect from '../../../cds-hooks/resources/OrderSelect';
import './MedReqDropDown.css';
import * as env from 'env-var';

Expand All @@ -38,7 +38,7 @@ interface MedicationBundle {
}

interface MedReqDropDownProps {
tabCallback: (n: ReactElement, m: string) => void;
tabCallback: (n: ReactElement, m: string, o: string) => void;
client: Client;
}
function MedReqDropDown(props: MedReqDropDownProps) {
Expand Down Expand Up @@ -168,7 +168,8 @@ function MedReqDropDown(props: MedReqDropDownProps) {
useState<BundleEntry<MedicationRequest>>();

const [selectedMedicationCard, setselectedMedicationCard] = useState<MedicationRequest>();

const [medicationName, setMedicationName] = useState<string>('');
const [tabIndex, setTabIndex] = useState<number>(1);
useEffect(() => {
if (selectedOption != '') {
setselectedMedicationCard(
Expand All @@ -179,17 +180,28 @@ function MedReqDropDown(props: MedReqDropDownProps) {

useEffect(() => {
if (selectedMedicationCard) {
const medName =
selectedMedicationCard?.medicationCodeableConcept?.coding?.[0].display?.split(' ')[0];
if (medName) {
setMedicationName(medName);
}
setselectedMedicationCardBundle({ resource: selectedMedicationCard });
}
}, [selectedMedicationCard]);

useEffect(() => {
if (patient && patient.id && user && selectedMedicationCardBundle) {
const hook = new OrderSign(patient.id, user, {
resourceType: 'Bundle',
type: 'batch',
entry: [selectedMedicationCardBundle]
});
const resourceId = `${selectedMedicationCardBundle.resource?.resourceType}/${selectedMedicationCardBundle.resource?.id}`;
const hook = new OrderSelect(
patient.id,
user,
{
resourceType: 'Bundle',
type: 'batch',
entry: [selectedMedicationCardBundle]
},
[resourceId]
);
const tempHook = hook.generate();

hydrate(getFhirResource, example.prefetch, tempHook).then(() => {
Expand Down Expand Up @@ -223,8 +235,12 @@ function MedReqDropDown(props: MedReqDropDownProps) {
p: 4
};

const etasu_status_enabled: boolean = env.get('REACT_APP_ETASU_STATUS_ENABLED').asBool() ? true : false;
const pharmacy_status_enabled: boolean = env.get('REACT_APP_PHARMACY_STATUS_ENABLED').asBool() ? true : false;
const etasu_status_enabled: boolean = env.get('REACT_APP_ETASU_STATUS_ENABLED').asBool()
? true
: false;
const pharmacy_status_enabled: boolean = env.get('REACT_APP_PHARMACY_STATUS_ENABLED').asBool()
? true
: false;

return (
<div>
Expand All @@ -233,7 +249,8 @@ function MedReqDropDown(props: MedReqDropDownProps) {
marginTop: 8,
display: 'flex',
flexDirection: 'column',
alignItems: 'center'
alignItems: 'center',
maxWidth: '800px'
}}
>
<div className="MedReqDropDown">
Expand Down Expand Up @@ -286,11 +303,7 @@ function MedReqDropDown(props: MedReqDropDownProps) {
fontSize: 24
}}
>
{
selectedMedicationCard?.medicationCodeableConcept?.coding?.[0].display?.split(
' '
)[0]
}
{medicationName}
</Typography>
<Typography
variant="h6"
Expand Down Expand Up @@ -324,6 +337,9 @@ function MedReqDropDown(props: MedReqDropDownProps) {
<CdsHooksCards
cards={hooksCards}
client={client}
name={medicationName}
tabIndex={tabIndex}
setTabIndex={setTabIndex}
tabCallback={props.tabCallback}
></CdsHooksCards>
</CardContent>
Expand Down
Loading

0 comments on commit 7d25f5f

Please sign in to comment.