def insertMedSuppliesJson(self, json): Medsupply_price = json['Medsupply_price'] Medsupply_date = json['Medsupply_date'] Medsupply_quantity = json['Medsupply_quantity'] if Medsupply_price and Medsupply_quantity and Medsupply_date: dao = MedSuppliesDAO() result = dao.insert(Medsupply_price, Medsupply_quantity, Medsupply_date) return jsonify(Med_Supply=result), 201 else: return jsonify(Error="Unexpected attributes in post request"), 400
def searchMedSupplies(self, args): if len(args) > 1: return jsonify(Error="Malformed search string."), 400 else: date = args.get("date") price = args.get("price") if date: dao = MedSuppliesDAO() result_list = dao.getMedSupplyByDate(date) return jsonify(MedSupplies=result_list) elif price: dao = MedSuppliesDAO() result_list = dao.getMedSupplyByPrice(price) return jsonify(MedSupplies=result_list) else: return jsonify(Error="Malformed search string."), 400
def getMedById(self, mid): dao = MedSuppliesDAO() result = dao.getMedDevById(mid) return jsonify(MedSupplies=result)
def getAllMedSupplies(self): dao = MedSuppliesDAO() result_list = dao.getAllMedSupplies() return jsonify(MedSupplies=result_list)