Complete Exam
Complete Exam
Example data:
Answer 1:
A well-structured prompt would be:
Create a hospital management system with these specifications:
1. Data Management:
- Patient registration system
- Room allocation tracker
- Medical records database
- Treatment scheduling
2. Core Functionalities:
- Admission processing
* Validate patient information
* Check room availability
* Record initial diagnosis
- Medical record updates
* Track treatments
* Store test results
* Monitor medications
- Discharge management
* Generate summary
* Update room status
* Process billing
3. Technical Requirements:
- Input validation for all fields
- Data encryption for patient records
- Audit trail for all changes
- Error handling and logging
- Data backup procedures
4. Implementation Details:
- Use object-oriented design
- Implement data access layers
- Include documentation
- Add unit tests
- Support multiple user roles
self.patients[patient_id] = {
"name": name,
"room": room
}
self.rooms[room] = {
"occupied": True,
"patient": patient_id
}
def main():
hospital = Hospital()
while True:
print("1. Admit Patient")
print("2. Discharge Patient")
print("3. Exit")
if choice == 1:
id = input("Patient ID: ")
name = input("Name: ")
room = input("Room: ")
hospital.admit_patient(id, name, room)
Answer 2:
Bugs and Fixes:
1. Menu Choice Bug:
# Original
if choice == 1:
# Fix
if choice == "1":
self.patients[patient_id] = {
"name": name,
"room": room
}
self.rooms[room] = {
"occupied": True,
"patient": patient_id
}
return True # Add return value
3. Error Handling:
4. Input Validation:
def admit_patient(self, patient_id, name, room):
if not all([patient_id, name, room]):
return False
if patient_id in self.patients:
return False
Answer 3:
from datetime import datetime
from typing import List, Dict, Optional
class Medication:
def __init__(self, code: str, name: str, standard_dosage: float):
self._code = code
self._name = name
self._standard_dosage = standard_dosage
self._interactions: List[str] = [] # List of medication codes
class Prescription:
def __init__(self, patient_id: str, medication_code: str,
dosage: float, duration: int):
self._patient_id = patient_id
self._medication_code = medication_code
self._dosage = dosage
self._duration = duration
self._issue_date = datetime.now()
class PrescriptionManager:
def __init__(self):
self._medications: Dict[str, Medication] = {}
self._prescriptions: Dict[str, List[Prescription]] = {}
current_meds = set(p._medication_code
for p in self._prescriptions[patient_id])
if med_code in self._medications:
return [code for code in current_meds
if code in self._medications[med_code]._interactions]
return []
self._prescriptions[prescription._patient_id].append(prescription)
return True
Answer 4:
1. Work Division:
Developer 1:
Medication management
Interaction checking
Database design
Developer 2:
Prescription processing
Patient records
Reporting system
2. Repository Structure:
/prescription-system
/src
/models
medication.py
prescription.py
/services
interaction_checker.py
prescription_manager.py
/utils
validators.py
/tests
/unit
/integration
/docs
API.md
setup.md
3. Development Process:
4. Testing Strategy:
Would you like me to explain any part of the solutions in more detail or provide additional practice questions?