I have a smart contract which contains information about patients.
Patient struct
struct patient {
uint256 recordid;
bytes32 name;
bytes32 regNo;
bytes32 address;
int contactno;
}
mapping(uint256=>patient ) patients;
Now I want to search the patient by name or by contact no. Currently, I am searching the record by recordid, which is unique.
Search function
function getpatientbyrecordid(uint256 id) view public returns (bytes32 ,bytes32 , bytes32, int ) {
return (patients[id].name,
patients[id].regNo,
patients[id].address,
patients[id].contactno,);
}
I am stuck in searching the record by name and contact no.
Any help will be appreciated.