def createProcedure(): json = request.json db = DBConnector() results = [] for procedure in json: name = abort(400) if not procedure.get('name') else procedure.get( 'name') note = abort(400) if not procedure.get('note') else procedure.get( 'note') price = abort(400) if not procedure.get('price') else procedure.get( 'price') date = abort(400) if not procedure.get('date') else procedure.get( 'date') storageID = abort(400) if not procedure.get( 'storageID') else procedure.get('storageID') patientID = abort(400) if not procedure.get( 'patientID') else procedure.get('patientID') procedure = { 'name': name, 'note': note, 'price': price, 'date': date, 'storageID': storageID, 'patientID': patientID } result = db.createProcedure(procedure) results.append(result) db.close() return jsonify({'procedures': results}), 201
def createPatient(): ''' Create a new patient through a POST method. Takes a JSON object Returns: The newly created patient. ''' json = request.json if not json or not 'firstName' in json: abort(400) lastName = '' if not json.get('lastName') else json.get('lastName') mobile = '' if not json.get('mobile') else json.get('mobile') gender = '' if not json.get('gender') else json.get('gender') email = '' if not json.get('email') else json.get('email') note = '' if not json.get('note') else json.get('note') storageID = '' if not json.get('storageID') else json.get('storageID') date = '' if not json.get('date') else json.get('date') age = 0 if not json.get('age') else json.get('age') patient = { 'firstName': request.json['firstName'], 'lastName': lastName, 'mobile': mobile, 'gender': gender, 'email': email, 'note': note, 'storageID': storageID, 'date': date, 'age': age } db = DBConnector() result = db.createPatient(patient) db.close() return jsonify({'patient': result}), 201
def getProcedureType(typeID): db = DBConnector() result = db.getProcedureType(typeID) if len(result) == 0: abort(404) db.close() return jsonify({'type': result})
def getProcedureByPatient(patientID): db = DBConnector() result = db.getProcedureByPatient(patientID) if len(result) == 0: abort(404) db.close() return jsonify({'procedures': result})
def getPatients(): ''' Get all the patients Returns: a list of patient objects ''' db = DBConnector() result = db.getPatients() db.close() return jsonify( {'patients': [make_public_patient(patient) for patient in result]})
def getPatient(patientID): ''' Get a patient by ID Parameter: - patientID: the ID of the patient Returns: a patient object ''' db = DBConnector() result = db.getPatient(patientID) if len(result) == 0: abort(404) db.close() return jsonify({'patient': make_public_patient(result)})
def getProcedureTypes(): db = DBConnector() result = db.getProcedureTypes() db.close() return jsonify({'types': result})