From baf8bd83bcffe7e9eab7f49526f6cb14cdbdea9f Mon Sep 17 00:00:00 2001
From: Savy011 <106910589+Savy011@users.noreply.github.com>
Date: Mon, 29 May 2023 09:35:34 +0530
Subject: [PATCH] Finished Ex 9.23
---
.../components/PatientListPage/EntryData.tsx | 17 +++++++
.../components/PatientListPage/GenderIcon.tsx | 16 +++++++
.../src/components/PatientPage/index.tsx | 37 ++++++++-------
Part_9/patientor-frontend/src/types.ts | 47 ++++++++++++++++++-
4 files changed, 98 insertions(+), 19 deletions(-)
create mode 100644 Part_9/patientor-frontend/src/components/PatientListPage/EntryData.tsx
create mode 100644 Part_9/patientor-frontend/src/components/PatientListPage/GenderIcon.tsx
diff --git a/Part_9/patientor-frontend/src/components/PatientListPage/EntryData.tsx b/Part_9/patientor-frontend/src/components/PatientListPage/EntryData.tsx
new file mode 100644
index 0000000..3bb16d5
--- /dev/null
+++ b/Part_9/patientor-frontend/src/components/PatientListPage/EntryData.tsx
@@ -0,0 +1,17 @@
+import { Entry } from '../../types';
+import { Typography } from '@mui/material';
+
+const EntryData = ({ entry }: { entry: Entry }) => {
+ return (
+ <>
+ {entry.date} {entry.description}
+
+ {entry.diagnosisCodes?.map(code => (
+ - {code}
+ ))}
+
+ >
+ )
+}
+
+export default EntryData
diff --git a/Part_9/patientor-frontend/src/components/PatientListPage/GenderIcon.tsx b/Part_9/patientor-frontend/src/components/PatientListPage/GenderIcon.tsx
new file mode 100644
index 0000000..6a29278
--- /dev/null
+++ b/Part_9/patientor-frontend/src/components/PatientListPage/GenderIcon.tsx
@@ -0,0 +1,16 @@
+import { Female, Male, Transgender } from '@mui/icons-material';
+import { Gender } from '../../types';
+
+const GenderIcon = ({ gender }: { gender: Gender}): JSX.Element | null => {
+ if (gender === Gender.Male) {
+ return
+ } else if (gender === Gender.Female) {
+ return
+ } else if (gender === Gender.Other) {
+ return
+ } else {
+ return null
+ }
+}
+
+export default GenderIcon
diff --git a/Part_9/patientor-frontend/src/components/PatientPage/index.tsx b/Part_9/patientor-frontend/src/components/PatientPage/index.tsx
index 9848761..31dc129 100644
--- a/Part_9/patientor-frontend/src/components/PatientPage/index.tsx
+++ b/Part_9/patientor-frontend/src/components/PatientPage/index.tsx
@@ -2,22 +2,10 @@ import { Typography } from '@mui/material';
import axios from 'axios';
import { useState, useEffect } from 'react';
import { useParams } from 'react-router-dom';
+import GenderIcon from '../PatientListPage/GenderIcon';
+import EntryData from '../PatientListPage/EntryData';
import { apiBaseUrl } from '../../constants';
import { Patient } from '../../types';
-import { Female, Male, Transgender } from '@mui/icons-material';
-import { Gender } from '../../types';
-
-const GenderIcon = ({ gender }: { gender: Gender}): JSX.Element | null => {
- if (gender === Gender.Male) {
- return
- } else if (gender === Gender.Female) {
- return
- } else if (gender === Gender.Other) {
- return
- } else {
- return null
- }
-}
const PatientPage = () => {
const [patient, setPatient] = useState(null)
@@ -26,6 +14,7 @@ const PatientPage = () => {
useEffect(() => {
axios.get(`${apiBaseUrl}/patients/${id}`).then(patient => {
setPatient(patient?.data)
+ console.log(patient?.data)
})
}, [id])
@@ -33,10 +22,22 @@ const PatientPage = () => {
return (
- {patient.name}
- Date of Birth: {patient.dateOfBirth}
- SSN: {patient.ssn}
- Occupation: {patient.occupation}
+
+ {patient.name}
+
+
+ Date of Birth: {patient.dateOfBirth}
+
+
+ SSN: {patient.ssn}
+
+
+ Occupation: {patient.occupation}
+
+ Entries
+ {patient.entries.length !== 0 ? (patient.entries.map(entry => (
+
+ ))) : (No Entries Available for Patient...)}
)
diff --git a/Part_9/patientor-frontend/src/types.ts b/Part_9/patientor-frontend/src/types.ts
index aba3c72..17334c7 100644
--- a/Part_9/patientor-frontend/src/types.ts
+++ b/Part_9/patientor-frontend/src/types.ts
@@ -1,4 +1,4 @@
-export interface Diagnosis {
+export interface Diagnose {
code: string;
name: string;
latin?: string;
@@ -10,6 +10,50 @@ export enum Gender {
Other = "other"
}
+export enum HealthCheckRating {
+ "Healthy" = 0,
+ "LowRisk" = 1,
+ "HighRisk" = 2,
+ "CriticalRisk" = 3
+}
+
+interface Discharge {
+ date: string;
+ criteria: string;
+}
+
+interface SickLeave {
+ startDate: string;
+ endDate: string;
+}
+
+interface BaseEntry {
+ id: string;
+ description: string;
+ date: string;
+ specialist: string;
+ diagnosisCodes?: Array;
+}
+
+export interface HealthCheckEntry extends BaseEntry {
+ type: "HealthCheck";
+ healthCheckRating: HealthCheckRating;
+}
+
+export interface HospitalEntry extends BaseEntry {
+ type: "Hospital";
+ discharge: Discharge;
+}
+
+export interface OccupationalHealthcareEntry extends BaseEntry {
+ type: "OccupationalHealthcare";
+ employerName: string;
+ sickLeave?: SickLeave;
+}
+
+export type Entry = HospitalEntry | HealthCheckEntry | OccupationalHealthcareEntry
+
+
export interface Patient {
id: string;
name: string;
@@ -17,6 +61,7 @@ export interface Patient {
gender: Gender;
ssn?: string;
dateOfBirth?: string;
+ entries: Entry[]
}
export type PatientFormValues = Omit;
--
2.51.2