I have to extract patient information from a bunch of XML files for further data analysis.
I have multiple Patients that can have multiple Diseases . For each Diseases there may or may not have been a Treatment or several. Each Treatment may or may not have TreatmentDetails. The TreatmentDetails are often duplicated in files (ie. files with different names, but the same TreatmentDetails for a Diseases or just a small change).
I think that a data structure of the type Patient[i].Disease[j].Treatment[k]
might be useful for this problem. Unfortunately, I am not very good with Classes or OOP.
How can I achieve this type of data structure Patient[i].Disease[j].Treatment[k]
?
Below is my code:
class PatientClass(object):
def __init__(self):
self.patient = []
def addPatient(self, PatientID, casVersion):
self.patient.append((False, PatientID, casVersion))
def patient_count(self):
return(len(self.patient))
def printPatient(self):
print(self.patient)
def printpatientN(self,n):
print(self.patient[n])
def __str__(self,n):
return(self.patient[n])
class Disease(PatientClass):
def __init__(self):
PatientClass.__init__(self)
self.disease = []
def addDisease(self, datetime_Start, datetime_End):
self.disease.append((False, datetime_Start, datetime_End))
def printDiseaseN(self,n):
print(self.disease[n])
def __str__(self,n):
return "%s has disease %s" % (self.patient[n], self.disease[n])