-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatientRecordFactory.sol
More file actions
27 lines (22 loc) · 1.13 KB
/
PatientRecordFactory.sol
File metadata and controls
27 lines (22 loc) · 1.13 KB
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
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.24;
import "./PatientRecord.sol";
/// @title PatientRecordFactory - deploys one PatientRecord per caller
contract PatientRecordFactory {
/// @dev Maps each patient address to their deployed PatientRecord contract address.
/// Public mapping gives you an auto-generated getter: recordOf(patient) -> record address.
mapping(address => address) public recordOf;
event RecordCreated(address indexed patient, address indexed record);
/// @notice Create your PatientRecord (one per address). Reverts if it already exists.
/// @return record The address of your newly deployed PatientRecord
function createRecord() external returns (address record) {
require(recordOf[msg.sender] == address(0), "record exists");
record = address(new PatientRecord(msg.sender));
recordOf[msg.sender] = record;
emit RecordCreated(msg.sender, record);
}
/// @notice Check if a record exists for a given patient address.
function hasRecord(address patient) external view returns (bool) {
return recordOf[patient] != address(0);
}
}