Skip to content

Commit

Permalink
CCDA Validator v3 functionality part 2 (#68)
Browse files Browse the repository at this point in the history
* Functionality for CCDA-V3 Validator

* Add .env

* Validator results continuation

* Minor adjustments for Validator results

* Styling enhancements  (#66)

* ui: reformat result total cards

* ui: replace avatar with chips in dialog menu

* ui: make uploaded file a chip and deletable

* ui: move helpertext within validation indicator

* fix: duplicate content

---------

Co-authored-by: Matthew Stankiewicz <[email protected]>

* CCDA Validator error handling and menu

* Remove unused imports

* Rearrange and rename some validator components

* ui: add theme over error display and reformat error pop-up

* fix: overlap in xpath & ccda. Plus alter colors & format for summary

* Some more changes for Validator

* Validator totals display

* ui: reformat total row to include grid. Add padding on subheaders

* fix: take out overflow

* fix: z-index for close button on  error display

* Validator minor changes

* ui: add helpertext for save results

* ui: replace static helpertext with tooltip for save button

* Add Details component and handle error scenario

* ui: add breakpoints

* ui: add scroll breakpoint on dialogTemplate

* ui: add padding on loading results title

* fix: reduce chip size

* fix: reduce accordion min height

* fix: take out scrollToTop and use anchor link method

* ui: add padding bottom to c-cda content

* ui: speed up indicator

* Clean up for ValidatorV3

* ui: add styles for back to top button, hover and visted puesdo classes

* fix: take out unused code

---------

Co-authored-by: mattystank <[email protected]>
Co-authored-by: Matthew Stankiewicz <[email protected]>
  • Loading branch information
3 people authored and ebrockainq committed Jul 30, 2024
1 parent 9eefbac commit 5ad77d6
Show file tree
Hide file tree
Showing 22 changed files with 969 additions and 494 deletions.
12 changes: 11 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"react-dom": "^18",
"react-dropzone": "^14.2.3",
"react-joyride": "^2.7.4",
"react-multi-carousel": "^2.8.5"
"react-multi-carousel": "^2.8.5",
"react-to-print": "^2.15.1"
},
"devDependencies": {
"@types/dompurify": "^3.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Typography,
} from '@mui/material'
import { useEffect, useState } from 'react'
import ValidationComponent from '../ValidatorLoadingCard'
import ValidationComponent from './results/ValidationResultsComponent'
import _ from 'lodash'
import { getScenarioOptions, submitForm } from './actions'
import palette from '@/styles/palette'
Expand Down Expand Up @@ -56,6 +56,7 @@ export default function V3ValidatorForm({
const [disableValidate, setDisableValidate] = useState(true)
const [data, submitAction] = useFormState(submitForm, { response: {} })
const [estimatedValidationTime, setEstimatedValidationTime] = useState(5)
const [fileName, setFileName] = useState('')
useEffect(() => {
if (_.isEqual(system, 'Sender')) {
setCriteriaOptions(senderCriteriaOptions)
Expand All @@ -66,6 +67,9 @@ export default function V3ValidatorForm({
if (!_.isEmpty(system) && !_.isEmpty(criteriaOption) && !_.isEmpty(scenarioOption)) {
setDisableValidate(false)
}
if (_.isEqual(criteriaOption, 'C-CDA_IG_Only') || _.isEqual(criteriaOption, 'C-CDA_IG_Plus_Vocab')) {
setScenarioOption('Readme.txt')
}
if (criteriaOption.includes('IG_Only')) {
setEstimatedValidationTime(5)
} else if (criteriaOption.includes('IG_Plus_Vocab')) {
Expand Down Expand Up @@ -96,6 +100,12 @@ export default function V3ValidatorForm({
setScenarioOption('')
setDisableValidate(true)
}
const getFileName = (data: File[]) => {
//console.log(data[0]?.name)
if (data !== undefined) {
setFileName(data[0]?.name)
}
}

return (
<Container>
Expand Down Expand Up @@ -172,21 +182,19 @@ export default function V3ValidatorForm({
<Box sx={{ pt: 3 }}>
<FormControl fullWidth>
<FormLabel sx={{ pb: 1 }}>Upload your generated C-CDA file and submit for validation</FormLabel>
<DragDropFileUpload maxFiles={1} name="ccdaFile" />
<DragDropFileUpload maxFiles={1} name="ccdaFile" fileName={getFileName} />
{/** <input type="file" name="ccdaFile" />*/}
</FormControl>
</Box>

{/* Buttons */}
<Box display="flex" flexDirection="row" justifyContent="space-between" sx={{ pt: 4 }}>
<ValidationComponent
response={data.response}
response={data?.response}
estimatedValidationTime={estimatedValidationTime}
disabled={disableValidate}
fileName={fileName}
></ValidationComponent>
{/* <Button variant="contained" type="submit" disabled={pending}>
VALIDATE
</Button> */}
<Box>
<Link href={downloadScenario} passHref style={{ textDecoration: 'none' }} target="_blank">
<Button variant="outlined" sx={{ color: palette.primary }} disabled={disableDownloadSceario}>
Expand Down
125 changes: 0 additions & 125 deletions src/components/c-cda/validation/ValidatorLoadingCard.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use server'
import https from 'https'
import axios from 'axios'
import { revalidatePath } from 'next/cache'
export async function getScenarioOptions(criteriaUrl: string) {
const res = await fetch(criteriaUrl)
if (!res.ok) {
Expand All @@ -27,12 +26,16 @@ async function getToken() {
})
return response.data
} catch (error) {
console.log(error)
throw new Error('failed to fetch token from keycloak')
if (axios.isAxiosError(error)) {
console.error(error.response?.data)
return { response: { error: 'Failed to fetch token from keycloak', errorStatus: error.response?.status } }
} else {
console.error(error)
}
}
}

export async function submitForm(prevState: object, formData: FormData) {
export async function submitForm(prevState: object | undefined, formData: FormData) {
const ccdaValidatorUrl = process.env.CCDA_VALIDATOR_URL
const token = await getToken()
const uploadFile = formData.get('ccdaFile')
Expand All @@ -53,10 +56,19 @@ export async function submitForm(prevState: object, formData: FormData) {
try {
const response = await axios.request(config)
//console.log(JSON.stringify(response.data))
console.log('Response status', response.status)
return { response: response.data }
// revalidatePath('/c-cda/uscdi-v3')
} catch (error) {
console.error(error)
throw new Error('failed to get validator results')
if (axios.isAxiosError(error)) {
console.error(error.response?.data)
return {
response: {
error: 'Validator Service had an issue, Please try again later!',
errorStatus: error.response?.status,
},
}
} else {
console.error(error)
}
}
}
71 changes: 71 additions & 0 deletions src/components/c-cda/validation/results/ErrorDisplay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react'
import { Box, Dialog, DialogTitle, IconButton, DialogContent, Typography } from '@mui/material'
import CloseIcon from '@mui/icons-material/Close'
import { ErrorOutline } from '@mui/icons-material'
import palette from '@/styles/palette'
import ONCLogo from '@public/shared/ONCLogo-backgroundImage.png'
import Image from 'next/image'

interface ErrorDisplayCardProps {
open: boolean
handleClose: () => void
response: { error?: string | null; errorStatus?: number }
}
const ErrorDisplayCard = ({ open, handleClose, response }: ErrorDisplayCardProps) => {
return (
<>
{response ? (
<Dialog open={open} maxWidth="sm" onClose={handleClose}>
<IconButton
aria-label="Close Dialog"
sx={{ zIndex: '1000', position: 'absolute', right: 8, top: 8 }}
onClick={handleClose}
>
<CloseIcon htmlColor={palette.white} />
</IconButton>
<Box px={4} py={3} alignItems={'flex-start'} display={'flex'} flexDirection={'row'} bgcolor={palette.warning}>
<Image
style={{
backgroundSize: 'contain',
backgroundRepeat: 'no-repeat',
top: -80,
left: -1,
position: 'absolute',
overflow: 'clip',
width: '100%',
height: '100%',
objectFit: 'none',
}}
src={ONCLogo}
alt="ONC Logo"
/>
<ErrorOutline sx={{ mb: -1 }} fontSize={'large'} htmlColor={palette.white} />
<Box>
<DialogTitle
textAlign={'left'}
color={palette.white}
sx={{ fontWeight: '600', px: 2, py: 1 }}
id="validating-dialog-title"
variant="h3"
>
Oh no!
<br />
Looks like there was an error.
</DialogTitle>
{response.errorStatus ? (
<Typography sx={{ px: 2 }} textAlign={'left'} color={palette.white}>
Error Type: {response.errorStatus!}
</Typography>
) : null}
</Box>
</Box>
<DialogContent sx={{ padding: '32px' }}>
<Typography>{response.error}</Typography>
</DialogContent>
</Dialog>
) : null}
</>
)
}

export default ErrorDisplayCard
30 changes: 25 additions & 5 deletions src/components/c-cda/validation/results/OriginalCCDAResult.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
import { Box } from '@mui/material'
import palette from '@/styles/palette'
import { Accordion, AccordionDetails, AccordionSummary, Box, Typography } from '@mui/material'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
interface OriginalCCDAResultProps {
xmlData: string
xmlData: { ccdaFileContents: string }
}

const OriginalCCDAResult = ({ xmlData }: OriginalCCDAResultProps) => {
return (
<Box>
<pre>{xmlData}</pre>
</Box>
<Accordion
sx={{
py: 0,
'&:before': {
display: 'none',
},
borderLeft: `4px solid ${palette.greyDark}`,
}}
disableGutters
elevation={1}
>
<AccordionSummary sx={{ borderBottom: `1px solid ${palette.divider}` }} expandIcon={<ExpandMoreIcon />}>
<Typography sx={{ fontWeight: 'bold', border: `` }}>C-CDA</Typography>
</AccordionSummary>

<AccordionDetails sx={{ p: 2 }}>
<Box sx={{ marginBottom: 1, width: '100%', overflow: 'auto' }} p={2}>
<pre style={{ whiteSpace: 'pre-line', wordWrap: 'break-word' }}>{xmlData.ccdaFileContents}</pre>
</Box>
</AccordionDetails>
</Accordion>
)
}
export default OriginalCCDAResult
Loading

0 comments on commit 5ad77d6

Please sign in to comment.