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

ECR Viwer Demo Site #31

Merged
merged 18 commits into from
Dec 26, 2023
25 changes: 25 additions & 0 deletions front-end/app/view_ecr/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use client'
import {Button} from '@trussworks/react-uswds'
import ECRTable from '@/components/ECRTable';
import React from "react";
import {useData} from '@/utils/DataContext';

export default function ViewECR() {
const {data} = useData()

if (!data) {
return <div>No data available.</div>
}

return (
<div className="margin-3">
<h1 className={'font-sans-xl text-bold'}>View your eCR</h1>
<p>
You can view your data below or download it as a FHIR bundle (JSON file).
</p>
<ECRTable ecrData={data}></ECRTable>
<Button type="button" outline>Upload new eCR</Button>
<Button type="button">Download FHIR bundle</Button>
</div>
)
}
72 changes: 34 additions & 38 deletions front-end/components/ECRTable.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
import {
Table
} from '@trussworks/react-uswds'
import {Table} from '@trussworks/react-uswds'
import _ from 'lodash';

export default function ECRTable({ ecrData }) {
const options = ['patient_id', 'first_name', 'last_name', 'gender', 'birth_date']
export default function ECRTable({ecrData}) {
const options = ['patient_id', 'first_name', 'last_name', 'gender', 'birth_date']


const getTableBody = (data: any) => {
return (
<tbody>
{options.map(function (option) {
return (
<tr key={option}>
<th scope="row">{_.startCase(option)}</th>
<td>{data[option]}</td>
</tr>
);
})}
const getTableBody = (data: any) => {
return (
<tbody>
{options.map(function (option) {
return (
<tr key={option}>
<th scope="row">{_.startCase(option)}</th>
<td>{data[option]}</td>
</tr>
);
})}

</tbody>
)
}
</tbody>
)
}

return (
<div className='margin-3'>
<h1>eCR Viewer</h1>
<div>
<Table
bordered
caption="This table uses the fullWidth prop to increase to 100% width"
fullWidth>
<thead>
<tr>
<th scope="col">Field Name</th>
<th scope="col">Field Value</th>
</tr>
</thead>
{getTableBody(ecrData.processed_values.parsed_values)}
</Table>
</div>
</div>
)
return (
<div className='margin-3'>
<div>
<Table
bordered
fullWidth>
<thead>
<tr>
<th scope="col">Field Name</th>
<th scope="col">Field Value</th>
</tr>
</thead>
{getTableBody(ecrData.processed_values.parsed_values)}
</Table>
</div>
</div>
)
}
Loading