IoT-based insulin pumps are used to deliver precise quantities of insulin to diabetic patients to regulate blood glucose levels. Generally, these levels correspond to the dietary patterns observed at time intervals that vary between patients. However, any misrepresentation in insulin levels may lead to fatal consequences. As a result, most IoT-based insulin pumps are rejected due to the possibility of external threats, which include software and hardware attacks. However, IoT-based insulin pumps are extremely useful in real-time patient monitoring, and for controlled insulin delivery to the patient based on their current glucose level. We propose a blockchain-based method to protect against the above-mentioned attacks. The system creates a patient-specific private blockchain wherein the dosage information is added as a new block by obtaining the approval of the doctor, chief doctor, nurse, and caretaker of the patient who are authorized blockchain miners. Secondly, it securely transfers prescription data, such as dosage quantity and time of delivery, to the IoT insulin pump, which ensures the dosage information is not modified during transit before insulin administration to the patient. The proposed approach uses a state-behavior-based solution that detects anomalies in the behavior of the insulin pump via temporal data analysis and immutable ledger verification, which are designed to eliminate fatal dosages in case of anomalies. The system is designed to work within binary outcome conditions, i.e., it verifies and delivers dosage or halts. There is no middle ground that an attacker can exploit, resulting in accountability for the system.