0
pragma solidity ^ 0.4 .18;

import "./ConvertLib.sol";


contract MetaCoin {

    struct hospital {
        uint index;
        uint record;
        address patientdata;

        mapping(address => uint) _patientrecord;
        bytes32[] record;



    }
    // mapping the address to the previous report  


    function Metacoin() {

        patient = msg.sender;
        doctor = msg.sender;



    }




    event verify(patientPublicKey, doctorPublicKey, timestamp, uint8 consentCode); // verification process

    function verify(bytes32 hash, uint8 v, bytes32 r, bytes32 s) constant returns(bool) {
        return ecrecover(hash, v, r, s, address) == address;



    }

    function isSigned(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns(bool) {
        return ecrecover(hash, v, r, s) == address;

    }

    function Time_call() returns(uint256) {
        return block.number;
    }

    modifier onlypatient() {
        if (msg.sender != patient) throw;
        _;
    }

    modifier onlydoctor() {
        if (msg.sender != doctor) throw;
        _;
    }

    function getAddressfromPublicKey(bytes _publickey) returns(address signer) { // getting address from the public key
        bytes32 keyHash = keccak256(_publickey);
        uint result = 0;
        for (uint i = keyHash.length - 1; i + 1 > 2; i--) {
            uint c = uint(keyHash[i]);
            uint to_inc = c * (16 ** ((keyHash.length - i - 1) * 2));
            result += to_inc;
        }
        result record;
    }
}




contract Signagreement { // signing the agreement by both patient and doctor
    address patient;
    address doctor;

    function patient(address _patient) {
        patient = _patient;
    }

    function doctor(address _doctor) {
        doctor = _doctor;

    }


    modifier onlyPatient() {
        require(msg.sender == patient);
        _;

    }
    modifier onlydoctor() {
        require(msg.sender == doctor);
        _;

    }

    function data() {
        patient = msg.sender;
        doctor = msg.sender;
    }


    struct recordstructs {
        bool approvedBypatient;
        bool approvedBydoctor;

    }
    // this agreement is all publicly explorable
    mapping(bytes32 => recordstruct) public recordstructs;
    bytes32[] public DataList; //all
    bytes32[] public approvedData; //approved

    event LogproposedData(address _patient, bytes32 docHash);
    event ApprovedproposedData(address _doctor, bytes32 docHash);
    // constructor
    function agreement(string timestamp_patient, address _patientdata, string timestamp_doctor) {
        patient = block.timestamp_patient && address_patient && Identification_patient;
        doctor = block.timestamp_doctor && address_doctor && Identification_doctor;
    }


    // for convenient iteration 
    function getDataCount() public constant returns(uint docCount) {
        return DataList.length;

    }

    function getApprovedCount() public constant returns(uint docCount) {
        return DataList.length;
    }



    // approve the agreement
    function agreeDoc(bytes32 Hash) public returns(bool success) {
        if (msg.sender != patient && msg.sender != doctor) throw; //abort the session//unknown person
        if (msg.sender == patient) recordstructs[hash].approvedBypatient = true;
        if (msg.sender == doctor) recordstructs[hash].approvedBypatient = true;
        if (block.number(patient) == block.number(doctor)) recordstructs[hash].approvedBypatient = true; {
            if (msg.sender(patient) == msg.sender(doctor)) recordstructs[hash].approvedBypatient = true;
        }
        if (recordstructs[hash].approvedBypatient == true) {
            uint docCount = DataList.push(hash);
            LogApprovedData(msg.sender, hash);


        } else {
            uint apprCount = approvedData.push(hash);
            LogProposedData(msg.sender, hash);
        }
        return true;
    }
}

// permissions to P2P network
contract permissionsP2P is Enabled {

    struct consentedPatientDataTuple {
        bytes32 verificationmessage;
        address patientdata;


    }

    function records(address _patientdata) {
        records = _patientdata;

    }
    struct consentPatientCode {

        uint8 consentCode;
        // 0 no permission
        // 1 for retrieve the data
        // 2 for add the data
        // 3 for update the data
        // 4 for append the data

    }


    mapping(address => uint8) public permissions;
    mapping(address_patientdata => consentPatientcode) public patientconsent;
    mapping(address_patientdata => consentedPatientDataTuple) public patientdoctorconsent;


    function retrieveData(address _patientdata, uint8 index) returns(bytes32) {

        mapping(uint => address) _patientdata;
        address _patientdata = msg.sender;
        uint retrievedData = address _patientdata && consentpatientCode;
        var cons = consentpatientCode(address _patientdata, consentCode);

        if (consentCode = 1 && msg.sender == doctor || msg.sender == patient) {
            if (DataList[address _patientdata].init == false) {
                return 0;

            } else {
                DataList[address _patientdata].record[index];
                return record(result);

            }
        }

    }

    function addData(address _data, bytes32 record) returns(uint result) {
        var cons = consentpatientCode(address _patientdata, consentCode);

        if (consentCode = 2 && DataList.[address _patientdata].init == false) {
            return 0;
        } else if (data == 0) {
            return 1;
        } else {
            DataList[address _patientdata].record[index].push(record);
            DataList[address _patientdata].responsible.push(resp);
            return 2; // means data added to the patientdatabase

        }
    }

    function confirmData(address _data, bytes32 report) returns(bool) {
        if (address _record != 0x0) {
            // ensure the caller is patient or doctor
            address _doctor = address _data.Identification _doctor;
            address _patient = address _data.Identification _patient;
            if (msg.sender == doctor || msg.sender == patient) {
                if (DataList[address _data].init == false || record == 0) {
                    return false;
                }
            }
        }
    }

    function updateData(address _patientdata, bytes32 record) returns(bool) {
        var cons = consentpatientCode(address _patientdata, consentCode);

        if (consentCode = 3 && DataList.[address _patientdata].init == false) {

            address_ patientdata.record[index] = record;
        }
    }
}

function appendData(address _patientdata, bytes32 record) returns(bool) {
    var cons = consentpatientCode(address _patientdata, consentCode);

    if (consentCode = 4 && DataList.[address _patientdata].init == false) {

        bytes(record).push(record);
    }

    function set(DataList[address _patientdata], bytes32 record) {
        DataList[address _patientdata].record[index] = record;
    }


}
}
}
  • your code was not legible. Even formatting it still contains a block that is wrong. The code from appendData has a wrong scope. Please try to check your code first and explain what's your issue – mirg Apr 12 '18 at 10:42
  • as am trying to modify the code. Can you please explain what is wrong in the code? – aarthi Apr 12 '18 at 10:46
1

You have several errors in your contract. For example in this snippet

event verify(patientPublicKey, doctorPublicKey, timestamp, uint8 consentCode);

function verify(bytes32 hash, uint8 v, bytes32 r, bytes32 s) constant returns(bool) {
    return ecrecover(hash, v, r, s, address) == address;
}
  • An event and a function with the same name
  • Event parameters are declared without the type
  • The function ecrecover receives 4 parameters and you pass 5 parameters
  • You are using address as a variable but it is a type

For small contracts you can use remix.ethereum.org to verify the correct syntax of your contract. It will indicate the line causing the error, and a description of the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.