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
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
2 changes: 1 addition & 1 deletion front-end/app/export/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import ECRTable from '@/components/ECRTable';
import ECRTable from '@/components/ECRTable/ECRTable';
import { useData } from '@/utils/DataContext';
import { Button } from '@trussworks/react-uswds'

Expand Down
5 changes: 5 additions & 0 deletions front-end/app/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@
background: #162e51;
color: white !important;
min-height: 84px;

a {
color: white !important;
}
}

.usa_footer-trademark {
font-family:
Source Sans Pro Web,
Expand Down Expand Up @@ -99,6 +101,7 @@
margin-top: 1rem;
margin-bottom: 1rem;
//styleName: H1;

h1 {
font-family:
Source Sans Pro Web,
Expand All @@ -118,8 +121,10 @@
width: 100%;
max-width: 100%;
}

.usa-button--outline {
background-color: white !important;

&:hover {
background-color: #005ea2 !important;
color: white;
Expand Down
36 changes: 36 additions & 0 deletions front-end/app/view_ecr/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use client'
import {Button} from '@trussworks/react-uswds'
import ECRTable from '@/components/ECRTable/ECRTable';
import React from "react";
import { useRouter } from 'next/navigation';
import {useData} from "@/utils/DataContext";


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

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

const handleUploadClick = () => {
router.push('/upload_tutorial')
}

const handleDownloadClick = () => {
router.push('/export')
}

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 onClick={handleUploadClick}>Upload new eCR</Button>
<Button type="button" onClick={handleDownloadClick}>Download FHIR bundle</Button>
</div>
)
}
45 changes: 0 additions & 45 deletions front-end/components/ECRTable.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions front-end/components/ECRTable/ECRTable.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.usa-table {
max-width: 512px;
}
37 changes: 37 additions & 0 deletions front-end/components/ECRTable/ECRTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Table} from '@trussworks/react-uswds'
import _ from 'lodash';

export default function ECRTable({ecrData}: any) {

const options = ['patient_id', 'first_name', 'last_name', 'gender', 'birth_date']


const getTableBody = (data: any) => {
return (
<tbody>
{data && options.map(function (option) {
return (
<tr key={option}>
<th scope="row">{_.startCase(option)}</th>
<td>{data[option]}</td>
</tr>
);
})}
</tbody>
)
}
return (
<Table className={'usa-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>
)
}
7 changes: 3 additions & 4 deletions front-end/tests/components/ECRTable.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import {render, screen} from '@testing-library/react';
import "@testing-library/jest-dom";
import ECRTable from '../../components/ECRTable'; // Adjust the import path as per your project structure
import ECRTable from '../../components/ECRTable/ECRTable'; // Adjust the import path as per your project structure

describe('ECRTable', () => {
it('renders ECRTable component with provided data', () => {
Expand All @@ -19,11 +19,10 @@ describe('ECRTable', () => {
}
};

render(<ECRTable ecrData={ecrData} />);
render(<ECRTable ecrData={ecrData}/>);

// You can add more specific assertions here
// For example, checking if the table headers and data are rendered
expect(screen.getByText('eCR Viewer')).toBeInTheDocument();
expect(screen.getByText('Field Name')).toBeInTheDocument();
expect(screen.getByText('Field Value')).toBeInTheDocument();
expect(screen.getByText('Patient Id')).toBeInTheDocument();
Expand Down
Loading