-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontract.sol
92 lines (80 loc) · 2.39 KB
/
contract.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<<<<<<< HEAD
pragma solidity ^0.6.0;
contract PrivateData{
uint numberParents = 0;
uint numberPatients = 0;
struct Patient{
uint id;
string name;
string familyName;
string birthdate;
}
struct Parent{
address id;
string name;
string familyName;
string email;
string telephone;
string password;
uint numberPatients;
mapping(uint => uint) patients;
}
mapping(address => uint) parents;
function public getParent(address _id) view returns (Parent){
for(uint i=0; i < numberParents; i++){
if(parents[i].id == _id){
return parents[i];
}
}
return null;
}
function public createParent(struct Parent memory parent){
parents[numberParents] = parent;
numberParents++;
}
constructor public(){
}
=======
pragma solidity ^0.8;
contract PrivateData{
uint256 numberPatients = 0;
struct Patient{
uint256 id;
string name;
string familyName;
string birthdate;
string school;
uint256 parentId;
}
mapping(uint256 => Patient) public patients;
uint256[] public patientsIds;
function createPatient(uint256 id, string memory name, string memory familyName, string memory birthdate,
string memory school, uint256 parentId) public{
patients[id] = Patient(id, name, familyName, birthdate, school, parentId);
patientsIds.push(id);
}
function getPatientById(uint256 id) public view returns(Patient memory){
return patients[id];
}
function deletePatient(uint256 id) public returns (bool){
delete patients[id];
for(uint256 i = 0; i < numberPatients; i++){
if(patientsIds[i] == id){
patientsIds[i] = patientsIds[patientsIds.length -1];
delete patientsIds[patientsIds.length - 1];
return true;
}
}
return false;
}
function updatePatient(uint256 id, string memory name, string memory familyName, string memory birthdate,
string memory school) public{
Patient memory patient = patients[id];
patient.name = name;
patient.familyName = familyName;
patient.birthdate = birthdate;
patient.school = school;
patients[id] = patient;
}
>>>>>>> origin/main
}