I have created a struct patient as follows, and a mapping of uint->patient.
struct patient {
uint pId;
string name;
string phone;
address payable owner;
uint numRecords;
uint[] cost;
address[] uploader;
string[] procedure;
uint[] hospId;
string[] doctorName;
bool[] treated;
string[] image;
}
mapping(uint => patient) public patients;
I am have created functions to insert data into the mapping. However, when i try to read the data in reactjs using web3,
//REACTJS
for (var i = 1; i <= patientCount; i++) {
const patient = await container.methods.patients(i).call()
}
the patient variable only contains the non array parts of the struct. i.e, only pId, name, phone, owner and numRecords is returned.
The value returned is
{0: BigNumber, 1: "Name", 2: "1234567890", 3: "0x771D3a7C2d6C59D9030731a48D60D8296303fC06", 4: BigNumber, pId: BigNumber, name: "Name", phone: "1234567890", owner: "0x771D3a7C2d6C59D9030731a48D60D8296303fC06", numRecords: BigNumber}
0: BigNumber {_hex: "0x01", _ethersType: "BigNumber"}
1: "NAme"
2: "1234567890"
3: "0x771D3a7C2d6C59D9030731a48D60D8296303fC06"
4: BigNumber {_hex: "0x01", _ethersType: "BigNumber"}
name: "Name"
numRecords: BigNumber {_hex: "0x01", _ethersType: "BigNumber"}
owner: "0x771D3a7C2d6C59D9030731a48D60D8296303fC06"
pId: BigNumber {_hex: "0x01", _ethersType: "BigNumber"}
phone: "1234567890"
__proto__: Object