/
PatientDocumentCreateCCDAEvent.php
299 lines (256 loc) · 6.69 KB
/
PatientDocumentCreateCCDAEvent.php
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<?php
/**
* PatientDocumentCreateCCDAEvent is fired when the dispatcher wants to generate a ccda document in the system for a patient.
*
* @package openemr
* @link http://www.open-emr.org
* @author Stephen Nielson <snielson@discoverandchange.com>
* @copyright Copyright (c) 2022 Discover and Change <snielson@discoverandchange.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
namespace OpenEMR\Events\PatientDocuments;
use OpenEMR\Services\Search\DateSearchField;
use DateTime;
class PatientDocumentCreateCCDAEvent
{
const EVENT_NAME_CCDA_CREATE = "patient.ccda.create";
/**
* @var int
*/
private $pid;
/**
* @var string[] The individual components to include in the ccda, empty if all components are to be generated
*/
private $components;
/**
* @var string[] The sections to include in the ccda, empty if all sections are to be generated
*/
private $sections;
/**
* The output format
* @var xml|html|zip
*/
private $format;
/**
* @var string The recipient of the CCDA
*/
private $recipient;
/**
* @var int The database primary key to the ccda that was generated in the system.
*/
private $ccdaId;
/**
* @var string the URL to the file that was generated.
*/
private $fileUrl;
/**
* @var DateTime The start date from which to include clinically relevant data for the generated CCDA. Null if all data from the start of the system is relevant.
*/
private $dateFrom;
/**
* If a dateFromSearchField is populated it will take precedence over the dateFrom field
* @var DateSearchField Complex date search field - The start date from which to include clinically relevant data for the generated CCDA. Null if all data from the start of the system is relevant.
*/
private $dateFromSearchField;
/**
* @var DateTime The end date to include clinically relevant data for the generated CCDA. Null if there is no end date.
*/
private $dateTo;
/**
* @var "ccd"|"referral"|"careplan"|"toc"
*/
private $documentType;
public function __construct($pid)
{
$this->setPid($pid);
$this->setComponents(array());
$this->setFormat("xml");
$this->setRecipient("self");
$this->dateFrom = null;
$this->dateTo = null;
$this->documentType = "ccd";
}
/**
* @return int
*/
public function getPid(): int
{
return $this->pid;
}
/**
* @param int $pid
* @return PatientDocumentCreateCCDAEvent
*/
public function setPid(int $pid): PatientDocumentCreateCCDAEvent
{
$this->pid = $pid;
return $this;
}
/**
* @param string $component
*/
public function addComponent(string $component)
{
$this->components[] = $component;
}
/**
* @return string[]
*/
public function getComponents(): array
{
return $this->components;
}
/**
* @param string[] $components
* @return PatientDocumentCreateCCDAEvent
*/
public function setComponents(array $components): PatientDocumentCreateCCDAEvent
{
$this->components = array_filter($components, 'is_string');
return $this;
}
/**
* @return html|xml|zip
*/
public function getFormat()
{
return $this->format;
}
/**
* @param html|xml|zip $format
* @return PatientDocumentCreateCCDAEvent
*/
public function setFormat($format)
{
$this->format = $format;
return $this;
}
/**
* @return string
*/
public function getRecipient(): string
{
return $this->recipient;
}
/**
* @param string $recipient
* @return PatientDocumentCreateCCDAEvent
*/
public function setRecipient(string $recipient): PatientDocumentCreateCCDAEvent
{
$this->recipient = $recipient;
return $this;
}
/**
* @return int|null
*/
public function getCcdaId(): ?int
{
return $this->ccdaId;
}
/**
* @param int $ccdaId
* @return PatientDocumentCreateCCDAEvent
*/
public function setCcdaId(int $ccdaId): PatientDocumentCreateCCDAEvent
{
$this->ccdaId = $ccdaId;
return $this;
}
/**
* @return string
*/
public function getFileUrl(): string
{
return $this->fileUrl;
}
/**
* @param string $fileUrl
* @return PatientDocumentCreateCCDAEvent
*/
public function setFileUrl(string $fileUrl): PatientDocumentCreateCCDAEvent
{
$this->fileUrl = $fileUrl;
return $this;
}
/**
* @return DateTime|null
*/
public function getDateFrom(): ?DateTime
{
return $this->dateFrom;
}
/**
* @param DateTime $dateFrom
* @return PatientDocumentCreateCCDAEvent
*/
public function setDateFrom(?DateTime $dateFrom): PatientDocumentCreateCCDAEvent
{
$this->dateFrom = $dateFrom;
return $this;
}
/**
* @return DateTime|null
*/
public function getDateTo(): ?DateTime
{
return $this->dateTo;
}
/**
* @param DateTime|null $dateTo
* @return PatientDocumentCreateCCDAEvent
*/
public function setDateTo(?DateTime $dateTo): PatientDocumentCreateCCDAEvent
{
$this->dateTo = $dateTo;
return $this;
}
/**
* @return string[]
*/
public function getSections(): array
{
return $this->sections;
}
/**
* @param string[] $sections
* @return PatientDocumentCreateCCDAEvent
*/
public function setSections(array $sections): PatientDocumentCreateCCDAEvent
{
$this->sections = $sections;
return $this;
}
public function addSection(string $section)
{
$this->sections[] = $section;
}
public function getSectionsAsString(): string
{
return $this->getCcdaStringFormat($this->sections ?? []);
}
public function getComponentsAsString(): string
{
return $this->getCcdaStringFormat($this->components ?? []);
}
private function getCcdaStringFormat(array $arr)
{
return implode("|", $arr);
}
/**
* @return string
*/
public function getDocumentType()
{
return $this->documentType;
}
/**
* @param string $documentType The c-cda document type to generate options are "ccd", "careplan", "toc", "referral"
* @return PatientDocumentCreateCCDAEvent
*/
public function setDocumentType($documentType)
{
$this->documentType = $documentType;
return $this;
}
}