In [1]:
import pprint
In [2]:
# Updating Patient Information
patient_data = {
"patient_id": 12345,
"name": "John Doe",
"age": 30,
"conditions": ["hypertension"]
}
update_data = {
"age": 31,
"conditions": ["hypertension", "diabetes"]
}
patient_data.update(update_data)
pprint.pp(patient_data)
{''''patient_id'''': 12345, ''''name'''': ''''John Doe'''', ''''age'''': 31, ''''conditions'''': [''''hypertension'''', ''''diabetes'''']}
In [3]:
# Adding New Patient Records
patient_records = {
12345: {"name": "John Doe", "age": 30, "conditions": ["hypertension"]},
67890: {"name": "Jane Smith", "age": 25, "conditions": ["asthma"]}
}
new_patient = {
11223: {"name": "Alice Brown", "age": 40, "conditions": ["arthritis"]}
}
patient_records.update(new_patient)
pprint.pp(patient_records)
{12345: {''''name'''': ''''John Doe'''', ''''age'''': 30, ''''conditions'''': [''''hypertension'''']}, 67890: {''''name'''': ''''Jane Smith'''', ''''age'''': 25, ''''conditions'''': [''''asthma'''']}, 11223: {''''name'''': ''''Alice Brown'''', ''''age'''': 40, ''''conditions'''': [''''arthritis'''']}}
In [4]:
# Updating Multiple Records
patient_records = {
12345: {"name": "John Doe", "age": 30, "conditions": ["hypertension"]},
67890: {"name": "Jane Smith", "age": 25, "conditions": ["asthma"]}
}
update_records = {
12345: {"age": 31, "conditions": ["hypertension", "diabetes"]},
67890: {"age": 26, "conditions": ["asthma", "allergy"]}
}
patient_records.update(update_records)
pprint.pp(patient_records)
{12345: {''''age'''': 31, ''''conditions'''': [''''hypertension'''', ''''diabetes'''']}, 67890: {''''age'''': 26, ''''conditions'''': [''''asthma'''', ''''allergy'''']}}