Python Code
Python Code
class CustomJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, date):
return obj.isoformat()
return super().default(obj)
def get_patient_details():
"""
This function collects the details of the patient where the user can
enter the name, gender, birthdate, and telephone number.
And afterwards the return value for the funtion is the patient record.
The function gets invoked using the entry point if __name__ where the
main function is called.
Returns:
_type_: patient record
"""
patient = Patient()
patient.telecom = []
add_tele_info = True
while add_tele_info:
telecom_system = input(
"Enter telecom system (e.g., phone number system, email system): "
)
telecom_value = input("Enter telecom value of the telecon system
above: ")
patient.telecom.append({"system": telecom_system, "value":
telecom_value})
add_more = input(
"Add another telecom? Enter Y for yes, N for no (y/n): "
).lower()
if add_more != "y":
add_tele_info = False
patient_address = {
"use": "home",
"line": [input("Enter address line: ")],
"city": input("Enter city: "),
"state": input("Enter state: "),
"postalCode": input("Enter postal code: "),
"country": input("Enter country: "),
}
patient.address = [patient_address]
return patient
def main():
patient_record = get_patient_details()
patient_dict = patient_record.dict()
if __name__ == "__main__":
main()
class CustomJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, date):
return obj.isoformat()
return super().default(obj)
def get_patient_details():
"""
This function collects the details of the patient where the user can
enter the name, gender, birthdate, and telephone number.
And afterwards the return value for the funtion is the patient record.
The function gets invoked using the entry point if __name__ where the
main function is called.
Returns:
_type_: patient record
"""
patient = Patient()
patient.telecom = []
add_tele_info = True
while add_tele_info:
telecom_system = input(
"Enter telecom system (e.g., phone number system, email system): "
)
telecom_value = input("Enter telecom value of the telecon system
above: ")
patient.telecom.append({"system": telecom_system, "value":
telecom_value})
add_more = input(
"Add another telecom? Enter Y for yes, N for no (y/n): "
).lower()
if add_more != "y":
add_tele_info = False
patient_address = {
"use": "home",
"line": [input("Enter address line: ")],
"city": input("Enter city: "),
"state": input("Enter state: "),
"postalCode": input("Enter postal code: "),
"country": input("Enter country: "),
}
patient.address = [patient_address]
return patient
def main():
patient_record = get_patient_details()
patient_dict = patient_record.dict()
if __name__ == "__main__":
main()
class CustomJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, date):
return obj.isoformat()
return super().default(obj)
def get_patient_details():
"""
This function collects the details of the patient where the user can
enter the name, gender, birthdate, and telephone number.
And afterwards the return value for the funtion is the patient record.
The function gets invoked using the entry point if __name__ where the
main function is called.
Returns:
_type_: patient record
"""
patient = Patient()
patient.telecom = []
add_tele_info = True
while add_tele_info:
telecom_system = input(
"Enter telecom system (e.g., phone number system, email system): "
)
telecom_value = input("Enter telecom value of the telecon system
above: ")
patient.telecom.append({"system": telecom_system, "value":
telecom_value})
add_more = input(
"Add another telecom? Enter Y for yes, N for no (y/n): "
).lower()
if add_more != "y":
add_tele_info = False
patient_address = {
"use": "home",
"line": [input("Enter address line: ")],
"city": input("Enter city: "),
"state": input("Enter state: "),
"postalCode": input("Enter postal code: "),
"country": input("Enter country: "),
}
patient.address = [patient_address]
return patient
def main():
patient_record = get_patient_details()
patient_dict = patient_record.dict()
if __name__ == "__main__":
main()