1+ $ ( document ) . ready ( function ( ) {
2+ $ ( '#navbar-placeholder' ) . load ( 'nav.html' ) ;
3+
4+ const patients = getPatients ( ) ;
5+
6+ function renderPatientsTable ( patients ) {
7+ const tbody = $ ( '#patients-table tbody' ) ;
8+ tbody . empty ( ) ; // Clear any existing rows
9+
10+ patients . forEach ( patient => {
11+ const row = `
12+ <tr>
13+ <td>${ patient . id } </td>
14+ <td>${ patient . name } </td>
15+ <td>${ patient . sex } </td>
16+ <td>${ patient . birthData } </td>
17+ <td><button class="view-button" data-id="${ patient . id } ">View Status</button></td>
18+ <td><button class="edit-button" data-id="${ patient . id } ">Edit</button></td>
19+ </tr>
20+ ` ;
21+ tbody . append ( row ) ;
22+ } ) ;
23+
24+ // Add event listeners to the edit buttons
25+ $ ( '#edit-button' ) . on ( 'click' , function ( ) {
26+ const patientId = $ ( this ) . data ( 'id' ) ;
27+ editPatient ( patientId ) ;
28+ } ) ;
29+
30+ $ ( '#view-button' ) . on ( 'click' , function ( ) {
31+ const patientId = $ ( this ) . data ( 'id' ) ;
32+ viewPatient ( patientId ) ;
33+ } )
34+
35+ $ ( '#add-patient' ) . on ( 'click' , function ( ) {
36+ addPatient ( ) ;
37+ } )
38+ }
39+
40+ // Render the table on page load
41+ renderPatientsTable ( patients ) ;
42+
43+ } ) ;
44+
45+
46+ function getPatients ( ) {
47+
48+ const savePath = localStorage . getItem ( "path" ) ;
49+ const patients = [
50+ { id : 1 , name : 'John Doe' , sex : 'Male' , birthDate : '1900-1-1' } ,
51+ { id : 2 , name : 'Jane Smith' , sex : 'Female' , birthDate : '1900-1-1' } ,
52+ // Add more patient data here
53+ ] ;
54+
55+ return patients ;
56+
57+ }
58+
59+ function savePatients ( patients ) {
60+
61+ const savePath = localStorage . getItem ( "path" ) ;
62+
63+
64+ }
65+
66+ function editPatient ( id ) {
67+ console . log ( `Edit patient with ID: ${ id } ` ) ;
68+ // Add your edit logic here
69+ }
70+
71+ function viewPatient ( id ) {
72+ console . log ( `View patient: ${ id } ` ) ;
73+ }
74+
75+ function addPatient ( ) {
76+ console . log ( 'add patient' )
77+ window . location . href = 'add_patient.html' ;
78+ }
0 commit comments