def get_patients_with_severity(self, doctor_id=None): json_data = {} if doctor_id != None: patients_with_severity = Patient.objects( assigned_doctor=doctor_id, severity__gt=0).order_by('-severity') json_data = json.loads(patients_with_severity.to_json()) return json_data else: patients_with_severity = Patient.objects( severity__gt=0).order_by('-severity') json_data = json.loads(patients_with_severity.to_json()) return json_data
def test_add(self): doctor1 = Doctor(doctor_id="yo111", password="******", first_name="yotsaphon", second_name="sutweha", contact_number="0868441277", room_number="d1", ward="north1", access_rights={ "view": True }).save() patient1 = Patient(assigned_doctor=doctor1, first_name="yooooooo", second_name="bbb", address="53 Abbey street Dublin 1", contact_number="8776544", next_of_kin1_first_name="gggg", next_of_kin1_second_name="bbb", next_of_kin2_first_name="ddd", next_of_kin2_second_name="aaa", severity=1, medical_data={ "diagnosed": False }).save()
def delete_patient(self, patient_id): patient = None try: patient = Patient.objects(id=patient_id).get() return patient.delete() except: patient = None return "No patient exist"
def update_patient_details(self, patient_id, first_name, second_name, address, contact_number, next_of_kin1_first_name, next_of_kin1_second_name, next_of_kin2_first_name, next_of_kin2_second_name): return Patient.objects(id=patient_id).update( first_name=first_name, second_name=second_name, address=address, contact_number=contact_number, next_of_kin1_first_name=next_of_kin1_first_name, next_of_kin1_second_name=next_of_kin1_second_name, next_of_kin2_first_name=next_of_kin2_first_name, next_of_kin2_second_name=next_of_kin2_second_name)
def add_patient(self, current_doctor, first_name, second_name, address, contact_number, assigned_doctor_name, next_of_kin1_first_name, next_of_kin1_second_name, next_of_kin2_first_name, next_of_kin2_second_name, severity, medical_data): return Patient(assigned_doctor=current_doctor, first_name=first_name, second_name=second_name, address=address, contact_number=contact_number, assigned_doctor_name=assigned_doctor_name, next_of_kin1_first_name=next_of_kin1_first_name, next_of_kin1_second_name=next_of_kin1_second_name, next_of_kin2_first_name=next_of_kin2_first_name, next_of_kin2_second_name=next_of_kin2_second_name, severity=severity, medical_data=medical_data).save()
def get_every_patients(self): patients = Patient.objects() json_data = json.loads(patients.to_json()) return json_data
def get_patients_based_on_doctor(self, doctor_id): patients = Patient.objects(assigned_doctor=doctor_id) json_data = json.loads(patients.to_json()) return json_data
def assign_severity(self, patient_id, severity): return Patient.objects(id=patient_id).update(severity=severity)
def get_patient_based_on_patient_id(self, patient_id): patient = Patient.objects(id=patient_id).get() json_data = json.loads(patient.to_json()) return json_data