@@ -8,8 +8,14 @@ export type EOBRecord = {
88 amount : number
99}
1010
11- export default function Records ( ) {
11+ export type ErrorResponse = {
12+ type : string ,
13+ content : string ,
14+ }
15+
16+ export default function Records ( { } ) {
1217 const [ records , setRecords ] = useState < EOBRecord [ ] > ( [ ] ) ;
18+ const [ message , setMessage ] = useState < ErrorResponse > ( ) ;
1319 /*
1420 * DEVELOPER NOTES:
1521 * Here we are parsing through the different PDE Claim records
@@ -31,7 +37,7 @@ export default function Records() {
3137 . then ( res => {
3238 return res . json ( ) ;
3339 } ) . then ( eobData => {
34- if ( eobData && eobData . entry ) {
40+ if ( eobData . hasOwnProperty ( ' entry' ) ) {
3541 const records : EOBRecord [ ] = eobData . entry . map ( ( resourceData : any ) => {
3642 const resource = resourceData . resource ;
3743 return {
@@ -43,40 +49,67 @@ export default function Records() {
4349 } ) ;
4450 setRecords ( records ) ;
4551 }
52+ else {
53+ setMessage ( { "type" : "error" , "content" : eobData ?. detail || "Unknown" } )
54+ }
4655 } ) ;
4756 } , [ ] )
4857
49- // TODO: add page navigation for bundle
50- return (
51- < div className = 'full-width-card' >
52- < Table className = "ds-u-margin-top--2" stackable stackableBreakpoint = "md" >
53- < TableCaption > Medicare Prescription Drug Claims Data</ TableCaption >
54- < TableHead >
55- < TableRow >
56- < TableCell id = "column_1" > NDC Code</ TableCell >
57- < TableCell id = "column_2" > Prescription Drug Name</ TableCell >
58- < TableCell id = "column_3" > Cost</ TableCell >
59- </ TableRow >
60- </ TableHead >
61- < TableBody >
62-
63- { records . map ( record => {
64- return (
65- < TableRow key = { record . id } >
66- < TableCell stackedTitle = "NDC Code" headers = "column_1" >
67- { record . code }
68- </ TableCell >
69- < TableCell stackedTitle = "Prescription Drug Name" headers = "column_2" >
70- { record . display }
71- </ TableCell >
72- < TableCell stackedTitle = "Cost" headers = "column_3" >
73- ${ record . amount } .00
74- </ TableCell >
75- </ TableRow >
76- )
77- } ) }
78- </ TableBody >
79- </ Table >
80- </ div >
81- ) ;
58+ if ( message ) {
59+ return (
60+ < div className = 'full-width-card' >
61+ < Table className = "ds-u-margin-top--2" stackable stackableBreakpoint = "md" >
62+ < TableCaption > Error Response</ TableCaption >
63+ < TableHead >
64+ < TableRow >
65+ < TableCell id = "column_1" > Type</ TableCell >
66+ < TableCell id = "column_2" > Content</ TableCell >
67+ </ TableRow >
68+ </ TableHead >
69+ < TableBody >
70+ < TableRow >
71+ < TableCell stackedTitle = "Type" headers = "column_1" >
72+ { message . type }
73+ </ TableCell >
74+ < TableCell stackedTitle = "Content" headers = "column_2" >
75+ { message . content }
76+ </ TableCell >
77+ </ TableRow >
78+ </ TableBody >
79+ </ Table >
80+ </ div >
81+ ) ;
82+ } else {
83+ return (
84+ < div className = 'full-width-card' >
85+ < Table className = "ds-u-margin-top--2" stackable stackableBreakpoint = "md" >
86+ < TableCaption > Medicare Prescription Drug Claims Data</ TableCaption >
87+ < TableHead >
88+ < TableRow >
89+ < TableCell id = "column_1" > NDC Code</ TableCell >
90+ < TableCell id = "column_2" > Prescription Drug Name</ TableCell >
91+ < TableCell id = "column_3" > Cost</ TableCell >
92+ </ TableRow >
93+ </ TableHead >
94+ < TableBody >
95+ { records . map ( record => {
96+ return (
97+ < TableRow key = { record . id } >
98+ < TableCell stackedTitle = "NDC Code" headers = "column_1" >
99+ { record . code }
100+ </ TableCell >
101+ < TableCell stackedTitle = "Prescription Drug Name" headers = "column_2" >
102+ { record . display }
103+ </ TableCell >
104+ < TableCell stackedTitle = "Cost" headers = "column_3" >
105+ ${ record . amount } .00
106+ </ TableCell >
107+ </ TableRow >
108+ )
109+ } ) }
110+ </ TableBody >
111+ </ Table >
112+ </ div >
113+ ) ;
114+ }
82115} ;
0 commit comments