End-user development is a new trend to provide tailored services to dynamic environments such as hospitals. These services not only facilitate daily work for pharmacy personnel but also improve self-care in elder people that are still related to hospital, such as discharged patients. This paper presents an ambient intelligence (AmI) environment for End-user service provisioning in the pharmacy department of Gregorio Maranon Hospital in Madrid, composed of a drug traceability infrastructure (DP-TraIN) and a ubiquitous application for enabling the pharmacy staff to create and execute their own services for facilitating drug management and dispensing. The authors carried out a case study with various experiments where different roles from the pharmacy department of Gregorio Maranon Hospital were involved in activities such as drug identification, dispensing and medication administering. The authors analyzed the effort required to create services by pharmacy staff, the discharged patients' perception of the AmI environment and the quantifiable benefits in reducing patient waiting time for drug dispensing.