Description
In UserSide.sol, the takeUserHistory function initializes a PatientHistory struct using the global counter totalUsers as the userId field instead of the _userId parameter passed to the function.
As a result, the userId stored inside the struct does not correspond to the actual patient whose history is being recorded.
Location
MedETH/foundry/src/UserSide.sol
Function: takeUserHistory(...)
Current Code
function takeUserHistory(uint256 _userId, ...) public {
PatientHistory memory pt1 = PatientHistory(
totalUsers, // wrong userId
_isHandicap,
_isBp,
_isDiabetes,
_userExp
);
userIdtoPatientHistory[_userId] = pt1;
}
Expected Behavior
The userId field inside PatientHistory should store the _userId argument passed to the function.
Actual Behavior
The struct stores totalUsers instead of _userId.
This causes the embedded userId field to contain the wrong value, potentially misleading frontend applications or future contract logic that reads patientHistory.userId.
Description
In
UserSide.sol, thetakeUserHistoryfunction initializes aPatientHistorystruct using the global countertotalUsersas theuserIdfield instead of the_userIdparameter passed to the function.As a result, the
userIdstored inside the struct does not correspond to the actual patient whose history is being recorded.Location
MedETH/foundry/src/UserSide.solFunction:
takeUserHistory(...)Current Code
Expected Behavior
The
userIdfield insidePatientHistoryshould store the_userIdargument passed to the function.Actual Behavior
The struct stores
totalUsersinstead of_userId.This causes the embedded
userIdfield to contain the wrong value, potentially misleading frontend applications or future contract logic that readspatientHistory.userId.