if(hasattr(i, "new") and callable(i.new)):
if(hasattr(i, "input") and callable(i.input)):
i.input(self.input())
- message=i.new(prescription)
+ prescription_copy=copy.deepcopy(prescription)
+ message=i.new(prescription_copy)
+ prescription.set_data_from_copy(prescription_copy)
if(message):
self.showMessage(message)
except Exception as e:
if(hasattr(i, "open") and callable(i.open)):
if(hasattr(i, "input") and callable(i.input)):
i.input(self.input())
- message=i.open(prescription)
+ prescription_copy=copy.deepcopy(prescription)
+ message=i.open(prescription_copy)
+ prescription.set_data_from_copy(prescription_copy)
if(message):
self.showMessage(message)
except Exception as e:
if(hasattr(i, "save") and callable(i.save)):
if(hasattr(i, "input") and callable(i.input)):
i.input(self.input())
- message=i.save(prescription)
+ prescription_copy=copy.deepcopy(prescription)
+ message=i.save(prescription_copy)
+ prescription.set_data_from_copy(prescription_copy)
if(message):
self.showMessage(message)
except Exception as e:
if(hasattr(i, "refresh") and callable(i.refresh)):
if(hasattr(i, "input") and callable(i.input)):
i.input(self.input())
- message=i.refresh(prescription)
+ prescription_copy=copy.deepcopy(prescription)
+ message=i.refresh(prescription_copy)
+ prescription.set_data_from_copy(prescription_copy)
if(message):
self.showMessage(message)
except Exception as e:
if(hasattr(module, "web") and callable(module.web)):
self.webapp=WebApp()
self.webapp.done.connect(lambda: self.update.emit())
- url, data=module.web(prescription)
+ prescription_copy=copy.deepcopy(prescription)
+ url, data=module.web(prescription_copy)
+ prescription.set_data_from_copy(prescription_copy)
self.webapp.load(module, QUrl(url), prescription, data)
self.webapp.show()
elif(hasattr(module, "run") and callable(module.run)):
self.workers[index].pluginComplete.connect(self.showMessage)
self.workers[index].start()
else:
- message=module.run(prescription)
+ prescription_copy=copy.deepcopy(prescription)
+ message=module.run(prescription_copy)
+ prescription.set_data_from_copy(prescription_copy)
if(message):
self.showMessage(message)
except Exception as e:
@pyqtSlot(str)
def run(self, result):
try:
- message=self.module.run(self.prescription, result)
+ prescription_copy=copy.deepcopy(self.prescription)
+ message=self.module.run(prescription_copy, result)
+ self.prescription.set_data_from_copy(prescription_copy)
if(message):
QMessageBox.information(None, "Information", message)
self.done.emit()
else:
self.read_from(file)
- def set_data(self, name="", qualification="", registration="", address="", contact="", extra="", properties=None):
+ def set_data(self, name="", qualification="", registration="", address="", contact="", extra="", properties={}):
self.name = name
self.qualification = qualification
self.registration = registration
self.address = data["address"]
self.contact = data["contact"]
self.extra = data["extra"]
- if("properties" in data):
+ if("properties" in data and type(properties) is dict):
self.properties = data["properties"]
else:
- self.properties = None
+ self.properties = {}
except Exception as e:
logging.exception(e)
self.address = ""
self.contact = ""
self.extra = ""
- self.properties = ""
+ self.properties = {}
class Prescription:
file=""
- def __init__(self, date="", id="", pid="", name="", dob="", age="", sex="", address="", contact="", extra="", mode="", daw="", diagnosis="", note="", report="", advice="", investigation="", medication="", additional="", certificate="", custom=None, properties=None, prescriber=None):
+ def __init__(self, date="", id="", pid="", name="", dob="", age="", sex="", address="", contact="", extra="", mode="", daw="", diagnosis="", note="", report="", advice="", investigation="", medication="", additional="", certificate="", custom=None, properties={}, prescriber=None):
self.set_data(date, name, dob, age, sex, address, contact, extra, mode, daw, diagnosis, note, report, advice, investigation, medication, additional, certificate, custom, properties)
if prescriber is None:
self.prescriber = Prescriber()
else:
self.prescriber = prescriber
- def set_data(self, date="", id="", pid="", name="", dob="", age="", sex="", address="", contact="", extra="", mode="", daw="", diagnosis="", note="", report="", advice="", investigation="", medication="", additional="", certificate="", custom=None, properties=None):
+ def set_data(self, date="", id="", pid="", name="", dob="", age="", sex="", address="", contact="", extra="", mode="", daw="", diagnosis="", note="", report="", advice="", investigation="", medication="", additional="", certificate="", custom=None, properties={}):
self.date = date
self.id = id
self.pid = pid
self.prescriber.set_data_from_json(data.get("prescriber"))
self.date = data.get("date")
self.id = data.get("id")
- self.id = data.get("pid")
+ self.pid = data.get("pid")
self.name = data.get("name")
self.dob = data.get("dob")
self.age = data.get("age")
if("properties" in data):
self.properties = data["properties"]
else:
- self.properties = None
+ self.properties = {}
except Exception as e:
logging.exception(e)
+ def set_data_from_copy(self, prescription_copy):
+ try:
+ self.date = prescription_copy.date
+ self.id = prescription_copy.id
+ self.pid = prescription_copy.pid
+ self.name = prescription_copy.name
+ self.dob = prescription_copy.dob
+ self.age = prescription_copy.age
+ self.sex = prescription_copy.sex
+ self.address = prescription_copy.address
+ self.contact = prescription_copy.contact
+ self.extra = prescription_copy.extra
+ self.mode = prescription_copy.mode
+ self.daw = prescription_copy.daw
+ self.diagnosis = prescription_copy.diagnosis
+ self.note = prescription_copy.note
+ self.report = prescription_copy.report
+ self.advice = prescription_copy.advice
+ self.investigation = prescription_copy.investigation
+ self.medication = prescription_copy.medication
+ self.additional = prescription_copy.additional
+ self.certificate = prescription_copy.certificate
+ self.custom = prescription_copy.custom
+ if(type(prescription_copy.properties) is dict):
+ self.properties = prescription_copy.properties
+ else:
+ self.properties = {}
+ self.prescriber = prescription_copy.prescriber
+ except Exception as e:
+ logging.exception(e)
+
+
def get_json(self):
return(json.dumps(self, default=lambda o: o.__dict__, indent=4))