Error: CompileError: InternalCompilerError: Stack too deep, try removing local variables

by LSCodeSchool   Last Updated June 29, 2020 22:28 PM - source

Hello everyone please kindly help me out. I have researched on the error above associated with this block of code. But please is there a way to revise this code so that i can get all the data of a patient from a single struct. How would you advice I approach this

pragma solidity >=0.4.21 <0.7.0;

contract Patients {
    uint256 public count = 0;
    struct Patient {
        bytes16 patientID;
        bytes16 title;
        bytes16 fullName;
        bytes16 dob;
        bytes16 gender;
        bytes16 contact;
        bytes16 residentialAddress;
        bytes16 relativeNumber;
        uint256 NHIS;
        uint256 temperature;
        uint256 bloodPressure;
        uint256 pulse;
        uint256 respiration;
        uint256 weight;
        uint256 bmi;
        bool appointment;

event created(string message);

mapping(uint256 => Patient) public patient;

  function setBio(bytes16  patientID, bytes16  title, bytes16  fullName, bytes16  dob, bytes16  gender, bytes16  contact, bytes16  residentialAddress, bytes16  relativeNumber, uint256 NHIS) public {
    patient[count].patientID = patientID;
    patient[count].title = title;
    patient[count].fullName = fullName;
    patient[count].dob = dob;
    patient[count].gender = gender;
    patient[count].contact = contact;
    patient[count].residentialAddress = residentialAddress;
    patient[count].relativeNumber = relativeNumber;
    patient[count].NHIS = NHIS;
    emit created('New Patient folder created');

  function getBio(uint256 index) public view returns(bytes16  patientID, bytes16  title, bytes16  fullName, bytes16  dob,bytes16  gender, bytes16  contact, bytes16  residentialAddress,bytes16  relativeNumber, uint256 NHIS){
    Patient memory p = patient[index];
    return(p.patientID, p.title, p.fullName, p.dob, p.gender,, p.residentialAddress, p.relativeNumber, p.NHIS);

  function setVitalSigns(uint _id, uint256 temperature, uint256 bloodPressure, uint256 pulse, uint256 respiration, uint256 weight, uint256 bmi, bool)public {
    Patient memory _patient = patient[_id];
    _patient.temperature = temperature;
    _patient.bloodPressure = bloodPressure;
    _patient.pulse = pulse;
    _patient.respiration = respiration;
    _patient.weight = weight;
    _patient.bmi = bmi;
    _patient.appointment = !_patient.appointment;
    emit created('Vital Signs Checked');
Tags : solidity evm

Related Questions

How to map an address with a string array in solidity?

Updated October 09, 2018 12:28 PM

How to handle dynamic size string array in solidity?

Updated November 28, 2018 04:28 AM

What is the status of forbidden call in constructor?

Updated December 12, 2018 08:28 AM

How can I pass struct from one contract to another?

Updated January 10, 2019 23:28 PM

How to transfer Ether to ERC20 token contract?

Updated July 23, 2018 00:28 AM