-
Notifications
You must be signed in to change notification settings - Fork 1
/
resource_gallery.py
53 lines (41 loc) · 1.87 KB
/
resource_gallery.py
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
import json
from alphanum import alphanum
from mds.core.models import Encounter, Observation, Concept
from resource import ImageResource, VideoResource, AudioResource, ChartResource
class ResourceGallery():
"""A representation of all resources associated with an encounter
"""
def __init__(self, encounter_id):
self.__encounter_id = encounter_id
def get_info(self):
encounterObservations = list(Observation.objects.filter(encounter=self.__encounter_id))
encounterObservations.sort(key=lambda observation: observation.node, cmp=alphanum)
content = []
for observation in encounterObservations:
if bool(observation.value_complex):
resource_type = ''
if(AudioResource.is_valid_observation(observation)):
resource_type = 'audio'
elif(VideoResource.is_valid_observation(observation)):
resource_type = 'video'
elif(ImageResource.is_valid_observation(observation)):
resource_type = 'image'
elif(ChartResource.is_valid_observation(observation)):
resource_type = 'chart'
content.append(
{
'name': observation.concept.name,
'type': resource_type,
'date': str(observation.modified.day) +'/' + str(observation.modified.month) + '/' + str(observation.modified.year),
'id': observation.uuid
}
)
return content
def get_content(self):
# TODO: return image data
pass
def get_type(self):
return "image"
def generate_thumbnail(self):
# TODO: Generate thumbnail and return binary
pass