An implantable medical device (IMD) is provided. The IMD includes a medical procedure performing unit configured to perform a medical procedure inside a body of a user, a code generating unit configured to detect a motion state of the user, and to generate a motion code that represents a user's intention based on the detected motion state, and a control unit configured to control the medical procedure of the medical procedure performing unit based on the generated motion code.