|
25 | 25 | ) |
26 | 26 | from care.emr.reports.context_builder.data_points.patient import ( |
27 | 27 | IdentifiersContextBuilder, |
28 | | - PatientMinimumContextBuilder, |
| 28 | + PatientContextBuilder, |
29 | 29 | PatientTagContextBuilder, |
30 | 30 | TagFilter, |
31 | 31 | ) |
@@ -226,7 +226,24 @@ def get_context(self): |
226 | 226 | ) |
227 | 227 |
|
228 | 228 |
|
229 | | -class BaseEncounterReportContext(SingleObjectContextBuilder): |
| 229 | +class PatientFacilityIdentifiersContextBuilder(IdentifiersContextBuilder): |
| 230 | + def get_context(self): |
| 231 | + return self.parent_context.patient.facility_identifiers.get( |
| 232 | + str(self.parent_context.facility.id), [] |
| 233 | + ) |
| 234 | + |
| 235 | + |
| 236 | +class EncounterReportContext(SingleObjectContextBuilder): |
| 237 | + standalone_context = True |
| 238 | + __slug__ = "encounter_base" |
| 239 | + __associating_model__ = Encounter |
| 240 | + __display_name__ = "Encounter Report" |
| 241 | + __description__ = "Report context for encounter-based reports" |
| 242 | + context_key = "encounter" |
| 243 | + |
| 244 | + def get_context(self): |
| 245 | + return getattr(self.parent_context, self.parent_attribute) |
| 246 | + |
230 | 247 | status = Field( |
231 | 248 | display="Encounter Status", |
232 | 249 | mapping=lambda e: STATUS_DISPLAY.get( |
@@ -284,12 +301,6 @@ class BaseEncounterReportContext(SingleObjectContextBuilder): |
284 | 301 | preview_value="Patient is advised to follow up in 2 weeks.", |
285 | 302 | description="Discharge summary advice for the encounter", |
286 | 303 | ) |
287 | | - patient_facility_tags = Field( |
288 | | - target_context=EncounterPatientFacilityTagContextBuilder, |
289 | | - display="Patient Facility Tags", |
290 | | - preview_value="", |
291 | | - description="Facility-specific tags associated with the patient for the encounter", |
292 | | - ) |
293 | 304 | encounter_tags = Field( |
294 | 305 | target_context=EncounterTagContextBuilder, |
295 | 306 | display="Encounter Tags", |
@@ -327,30 +338,9 @@ class BaseEncounterReportContext(SingleObjectContextBuilder): |
327 | 338 | description="Encounter extensions as JSON (e.g. encounter.extensions.encounter_attender)", |
328 | 339 | ) |
329 | 340 |
|
330 | | - |
331 | | -class MinimumEncounterReportContext(BaseEncounterReportContext): |
332 | | - def get_context(self): |
333 | | - return getattr(self.parent_context, self.parent_attribute) |
334 | | - |
335 | | - |
336 | | -class PatientFacilityIdentifiersContextBuilder(IdentifiersContextBuilder): |
337 | | - def get_context(self): |
338 | | - return self.parent_context.patient.facility_identifiers.get( |
339 | | - str(self.parent_context.facility.id), [] |
340 | | - ) |
341 | | - |
342 | | - |
343 | | -class EncounterReportContext(BaseEncounterReportContext): |
344 | | - standalone_context = True |
345 | | - __slug__ = "encounter_base" |
346 | | - __associating_model__ = Encounter |
347 | | - __display_name__ = "Encounter Report" |
348 | | - __description__ = "Report context for encounter-based reports" |
349 | | - context_key = "encounter" |
350 | | - |
351 | 341 | patient = Field( |
352 | 342 | display="Patient Details", |
353 | | - target_context=PatientMinimumContextBuilder, |
| 343 | + target_context=PatientContextBuilder, |
354 | 344 | preview_value="", |
355 | 345 | description="Details of the patient associated with the encounter", |
356 | 346 | ) |
@@ -414,6 +404,12 @@ class EncounterReportContext(BaseEncounterReportContext): |
414 | 404 | preview_value="", |
415 | 405 | description="Facility identifiers associated with the encounter", |
416 | 406 | ) |
| 407 | + patient_facility_tags = Field( |
| 408 | + target_context=EncounterPatientFacilityTagContextBuilder, |
| 409 | + display="Patient Facility Tags", |
| 410 | + preview_value="", |
| 411 | + description="Facility-specific tags associated with the patient for the encounter", |
| 412 | + ) |
417 | 413 |
|
418 | 414 |
|
419 | 415 | DataPointRegistry.register(EncounterReportContext) |
0 commit comments