The pharmaceutical supply chain, which ensures that drugs are accessible to patients in a trusted process, is a complex arrangement in the healthcare industry. For that, a secure pharmachain framework is proposed. Primarily, the users register their details. Then, the details are converted into cipher text and stored in the blockchain. If a user requests an order, the manufacturer receives the request, and the order is handed to the distributor. Labeling is performed through Hypergeometric Distribution Centroid Selection K-Medoids Clustering (HDCS-KMC) to track the drugs. The healthcare Pharmachain architecture uses IoT to control the supply chain and provide safe medication tracking. The framework includes security with a classifier and block mining consensus method, boosts performance with a decision controller, and protects user and medication information with encryption mechanisms. After that, the drugs are assigned to vehicles, where the vehicle ID and Internet of Things (IoT) sensor data are collected and pre-processed. Afterward, the pre-processed data is analyzed in the fog node by utilizing a decision controller. Now, the status ID is generated based on vehicle id and location. The generated status ID is meant for fragmentation, encryption, and block mining processes. If a user requests to view the drug’s status ID, then the user needs to get authentication. The user’s forking behavior and request activities were extracted and given to the classifier present in the block-mining consensus algorithm for authentication purposes. Block mining happens after authentication, thereby providing the status ID. Furthermore, the framework demonstrates an efficaciousness in identifying assaults with a low False Positive Rate (FPR) of 0.022483% and a low False Negative Rate (FNR) of 1.996008%. Additionally, compared to traditional methods, the suggested strategy exhibits good precision (97.869%), recall (97.0039%), accuracy (98%), and F-measure (97.999%).