Ошибка преобразования массива в строку в php при получении записей из GanachePhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Ошибка преобразования массива в строку в php при получении записей из Ganache

Сообщение Anonymous »

Я создаю веб-систему электронного здравоохранения Blockchain, используя Laravel для внешнего и внутреннего интерфейса, Solidity & Truffle для создания смарт-контрактов и Ganache для развертывания смарт-контрактов. Я могу создавать записи пациентов и передавать их в свою сеть блокчейна, но я не могу получить все записи пациентов из блокчейна и отобразить их в таблице.
Преобразование массива в строку ошибка
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.17;

contract PatientRecords {

// Structure to store patient details
struct Patient {
uint patientId; // Unique identifier for the patient
string fullNames; // Full names of the patient
uint phone; // Phone number
string email; // Email address
string insuranceDetails; // Insurance details
string gender; // Gender of the patient
uint dob; // Date of birth (as a Unix timestamp)
string addressDetails; // Physical address of the patient
}

// Mapping to store patients by their ID
mapping(uint => Patient) private patients;

// Array to store all patient IDs for enumeration
uint[] private patientIds;

// Event to notify when a new patient is added
event PatientAdded(uint patientId, string fullNames, string email);

// Function to add a new patient
function addPatient(
uint _patientId,
string memory _fullNames,
uint _phone,
string memory _email,
string memory _insuranceDetails,
string memory _gender,
uint _dob,
string memory _addressDetails
) public {
require(patients[_patientId].patientId == 0, "Patient with this ID already exists.");

// Add patient details
patients[_patientId] = Patient(
_patientId,
_fullNames,
_phone,
_email,
_insuranceDetails,
_gender,
_dob,
_addressDetails
);

// Track the patient ID
patientIds.push(_patientId);

// Emit the event
emit PatientAdded(_patientId, _fullNames, _email);
}

// Function to get a patient's details by ID
function getPatient(uint _patientId) public view returns (
uint,
string memory,
uint,
string memory,
string memory,
string memory,
uint,
string memory
) {
require(patients[_patientId].patientId != 0, "Patient not found.");

Patient memory patient = patients[_patientId];
return (
patient.patientId,
patient.fullNames,
patient.phone,
patient.email,
patient.insuranceDetails,
patient.gender,
patient.dob,
patient.addressDetails
);
}

// Function to get all patient IDs
function getAllPatientIds() public view returns (uint[] memory) {
return patientIds;
}

// Function to check if a patient exists by ID
function patientExists(uint _patientId) public view returns (bool) {
return patients[_patientId].patientId != 0;
}
}

Контроллер администратора


Подробнее здесь: https://stackoverflow.com/questions/792 ... om-ganache
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»