diff --git a/app.py b/app.py index 8a5d833..d9f087a 100644 --- a/app.py +++ b/app.py @@ -110,6 +110,26 @@ def get_patient(patient_id): except Exception as e: return jsonify({'success': False, 'error': str(e)}), 500 +@app.route('/api/patients/search', methods=['GET']) +def search_patients(): + """환자 검색 (이름으로)""" + try: + name = request.args.get('name', '') + + with get_db() as conn: + cursor = conn.cursor() + cursor.execute(""" + SELECT patient_id, name, phone, gender, birth_date, notes, + mileage_balance, total_mileage_earned, total_mileage_used + FROM patients + WHERE name LIKE ? AND is_active = 1 + ORDER BY name + """, (f'%{name}%',)) + patients = [dict(row) for row in cursor.fetchall()] + return jsonify({'success': True, 'data': patients}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}), 500 + @app.route('/api/patients', methods=['POST']) def create_patient(): """새 환자 등록""" diff --git a/static/app.js b/static/app.js index e1da7e4..228fff7 100644 --- a/static/app.js +++ b/static/app.js @@ -1380,6 +1380,7 @@ $(document).ready(function() {