0% found this document useful (0 votes)
8 views8 pages

Complete Exam

Uploaded by

arshia.heravi5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views8 pages

Complete Exam

Uploaded by

arshia.heravi5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Software Development Exam

Question 1: GPT Prompt Engineering


Create a GPT prompt for generating code for a hospital patient management system. The system should handle patient
admissions, room assignments, medical records, and discharge processes.

Example data:

Patient: John Doe (ID: P123)


Admitted: 2024-03-15
Room: 301
Diagnosis: Pneumonia
Treatment: Antibiotics 500mg/day

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

Provide complete class definitions and example usage.

Question 2: Code Analysis and Debugging


Review this hospital records code and identify/fix all bugs:
class Hospital:
def __init__(self):
self.patients = {}
self.rooms = {}

def admit_patient(self, patient_id, name, room):


if room in self.rooms and self.rooms[room]["occupied"]:
return False

self.patients[patient_id] = {
"name": name,
"room": room
}
self.rooms[room] = {
"occupied": True,
"patient": patient_id
}

def discharge_patient(self, patient_id):


if patient_id in self.patients:
room = self.patients[patient_id]["room"]
del self.patients[patient_id]
self.rooms[room]["occupied"] = False

def main():
hospital = Hospital()
while True:
print("1. Admit Patient")
print("2. Discharge Patient")
print("3. Exit")

choice = input("> ")

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":

2. Missing Return Values:

def admit_patient(self, patient_id, name, room):


if room in self.rooms and self.rooms[room]["occupied"]:
return False

# Add room validation


if not room.strip():
return False

self.patients[patient_id] = {
"name": name,
"room": room
}
self.rooms[room] = {
"occupied": True,
"patient": patient_id
}
return True # Add return value

3. Error Handling:

def discharge_patient(self, patient_id):


try:
if patient_id in self.patients:
room = self.patients[patient_id]["room"]
del self.patients[patient_id]
self.rooms[room]["occupied"] = False
self.rooms[room]["patient"] = None
return True
return False
except KeyError:
return False

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

# Rest of the function...

Question 3: Program Design


Design a system for handling medical prescriptions. Include medication tracking, dosage calculations, and interaction
checks.

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]] = {}

def add_medication(self, med: Medication) -> bool:


"""Add new medication to formulary"""
if med._code in self._medications:
return False
self._medications[med._code] = med
return True

def check_interactions(self, patient_id: str,


med_code: str) -> List[str]:
"""Check for medication interactions"""
if patient_id not in self._prescriptions:
return []

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 []

def prescribe(self, prescription: Prescription) -> bool:


"""Create new prescription"""
interactions = self.check_interactions(
prescription._patient_id,
prescription._medication_code
)
if interactions:
return False

if prescription._patient_id not in self._prescriptions:


self._prescriptions[prescription._patient_id] = []

self._prescriptions[prescription._patient_id].append(prescription)
return True

Question 4: Collaborative Development


How would you implement this prescription system with a partner using version control?

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:

Feature branches for each component


Code review requirements
Automated testing
Regular integration
Documentation updates

4. Testing Strategy:

Unit tests for each class


Integration tests for workflows
Mock objects for external services
Performance testing
Security testing

Would you like me to explain any part of the solutions in more detail or provide additional practice questions?

You might also like