Я создаю веб-систему электронного здравоохранения 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
Ошибка преобразования массива в строку в php при получении записей из Ganache ⇐ Php
Кемеровские программисты php общаются здесь
1732546734
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;
}
}
Контроллер администратора
Подробнее здесь: [url]https://stackoverflow.com/questions/79223543/array-to-string-conversion-error-in-php-when-retriving-records-from-ganache[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия