-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatientclass1.py
76 lines (50 loc) · 2.06 KB
/
patientclass1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import random
class Patient:
user = []
id= 0
def __init__(self):
pass
def autoId(self):
global id
startId = 1
idInterval = 1
if(id == 0):
id = startId
else:
id = id + idInterval
return id
def registerPatient(self, name, age, nextOfkin, contact):
self.id = Patient
self.name = name
self.age = age
self.nextOfkin = nextOfkin
self.contact = contact
Patient.user.append({'id':id(self.id),'name':self.name,'age':self.age,'nextOfkin':self.nextOfkin,"contact":self.contact})
class Person(Patient):
def searchPersonByName(self,name):
self.name = name
search_status = 0
for i in range(len(Patient.user)):
if self.name in Patient.user[i]["name"]:
print("%d %s %d %s %s" %(Patient.user[i]["id"],Patient.user[i]["name"],Patient.user[i]["age"],Patient.user[i]["contact"],Patient.user[i]["nextOfkin"]))
search_status = 1
if search_status == 0 and i == len(Patient.user)-1:
print("Not Found")
def searchPersonById(self, id):
self.id = id
search_status = 0
for i in range(len(Patient.user)):
if self.name in Patient.user[i]["name"]:
print(" %s %d %s %s" %(Patient.user[i]["name"],Patient.user[i]["age"],Patient.user[i]["contact"],Patient.user[i]["nextOfkin"]))
search_status = 1
if search_status == 0 and i == len(Patient.user)-1:
print("Not Found")
def displayPatient(self):
for i in range(len(Patient.user)):
print(" %s %d %s %s" %(Patient.user[i]["name"],Patient.user[i]["age"],Patient.user[i]["contact"],Patient.user[i]["nextOfkin"]))
ptn1 = Person()
ptn1.registerPatient("steve andoh",22,"Stephanie Andoh","0241443624")
ptn1.registerPatient("Michael Okorie",16,"Richard Obiri","0202552663")
ptn1.registerPatient("Michael Okyere",16,"Richard Obiri","0202552663")
#ptn1.displayPatient()
ptn1.searchPersonByName("Michael")