I am trying to build a Dapp for healthcare where I must be able to allow patients(users) to enter their details after creating (say an account) by a password and next time they are able to view their data by entering the password they created.
All data on the Blockchain is public. So you can not use the Blockchain to store and verify passwords, and you can not hide information on the Blockchain behind a password.
At best, you would need to encrypt the data offchain and you can store the encrypted data on the Blockchain.
You could assign a unique identifier for each user so that it points the their data, such as an address
mapping(address => EncryptedPatientDataStruct).
After doing something like this to retrieve the user’s encrypted data, the data would have to be decrypted offchain.
After Noushads comment about him wanting to store the password on the chain:
If you want to store a password hash on the blockchain and grant access to your Dapp only if the user can correctly enter a password that produces a matching hash, it might work - but I am not seeing how you are benefiting from storing the password on the blockchain. There is no reason to store it in a publicly accessible database, if you are just using it for authentication against your frontend application.
If you want to use the password to encrypt data on the chain, and only allow decryption in the dapp if the user knows the right password, this would be a way to make the public data inaccessible to third parties. Please remember that nothing prevents third parties from loading the encrypted data from the chain and trying to bruteforce them, locally.