1 |
|
---|
2 | module OpenEHR
|
---|
3 | module RM
|
---|
4 | module Support
|
---|
5 | module Terminology
|
---|
6 | class CodeSetAccess
|
---|
7 | def all_codes
|
---|
8 | raise NotImplementedError, "all_codes must be implemented"
|
---|
9 | end
|
---|
10 |
|
---|
11 | def has_code(a_code)
|
---|
12 | raise NotImplementedError, "has_code must be implemented"
|
---|
13 | end
|
---|
14 |
|
---|
15 | def has_lang(a_lang)
|
---|
16 | raise NotImplementedError, "has_lang must be implemented"
|
---|
17 | end
|
---|
18 |
|
---|
19 | def id
|
---|
20 | raise NotImplementedError, "id must be returned"
|
---|
21 | end
|
---|
22 | end
|
---|
23 |
|
---|
24 | module OpenEHRCodeSetIdentifier
|
---|
25 | CODE_SET_ID_CHARACER_SETS = "character sets".freeze
|
---|
26 | CODE_SET_ID_COMPRESSION_ALGORITHMS = "compression algorithms".freeze
|
---|
27 | CODE_SET_ID_COUNTRIES = "countries".freeze
|
---|
28 | CODE_SET_ID_INTEGRITY_CHECK_ALGORITHMS = "integrity check algorithms".freeze
|
---|
29 | CODE_SET_ID_LANGUAGES = "languages".freeze
|
---|
30 | CODE_SET_ID_MEDIA_TYPES = "media types".freeze
|
---|
31 | def valid_code_set_id(an_id)
|
---|
32 | !@an_id.nil?
|
---|
33 | end
|
---|
34 | end
|
---|
35 |
|
---|
36 | module OpenEHRTerminologyGroupIdentifiers
|
---|
37 | GROUP_ID_ATTESTATION_REASON = "attestation reason".freeze
|
---|
38 | GROUP_ID_AUDIT_CHANGE_TYPE = "audit change type".freeze
|
---|
39 | GROUP_ID_COMPOSITION_CATEGORY = "composition category".freeze
|
---|
40 | GROUP_ID_MATH_FUNCTION = "event math function".freeze
|
---|
41 | GROUP_ID_INSTRUCTION_STATES = "instruction states".freeze
|
---|
42 | GROUP_ID_INSTRUCTION_TRANSITIONS = "instruction transitions".freeze
|
---|
43 | GROUP_ID_NULL_FLAVOURS = "null flavours".freeze
|
---|
44 | GROUP_ID_PARTICIPATION_FUNCTION = "participation function".freeze
|
---|
45 | GROUP_ID_PARTICIPATION_MODE = "participation mode".freeze
|
---|
46 | GROUP_ID_PROPERTY = "property".freeze
|
---|
47 | GROUP_ID_SETTING = "setting".freeze.freeze
|
---|
48 | GROUP_ID_SUBJECT_RELATIONSHIP = "subject relationship".freeze
|
---|
49 | GROUP_ID_TERM_MAPPING_PURPOSE = "term mapping purpose".freeze
|
---|
50 | GROUP_ID_VERSION_LIFECYCLE_STATE = "version lifecycle state".freeze
|
---|
51 | TERMINOLOGY_ID = "openehr".freeze
|
---|
52 | end
|
---|
53 |
|
---|
54 | class TerminologyAccess
|
---|
55 | attr_reader :id
|
---|
56 |
|
---|
57 | def initialize(args = {})
|
---|
58 | self.id = args[:id]
|
---|
59 | end
|
---|
60 |
|
---|
61 | def all_codes
|
---|
62 | raise NotImplementedError, "all_codes is not implemented"
|
---|
63 | end
|
---|
64 |
|
---|
65 | def codes_for_group_id(group_id)
|
---|
66 | raise NotImplementedError, "codes_for_group_id is not implemented"
|
---|
67 | end
|
---|
68 |
|
---|
69 | def codes_for_group_name(name, lang)
|
---|
70 | raise NotImplementedError, "codes_for_group_name is not implemented"
|
---|
71 | end
|
---|
72 |
|
---|
73 | def has_code_for_group_id(group_id, a_code)
|
---|
74 |
|
---|
75 | end
|
---|
76 |
|
---|
77 | def id=(id)
|
---|
78 | @terminology = Terminology.find_all_by_name(id)
|
---|
79 | @id = id
|
---|
80 | end
|
---|
81 |
|
---|
82 | def rubric_for_code(code, lang)
|
---|
83 | return Terminology.find(:first, :conditions => {:code => code,
|
---|
84 | :lang => lang})
|
---|
85 | end
|
---|
86 |
|
---|
87 | private
|
---|
88 | def id_exists
|
---|
89 | if id.nil?
|
---|
90 | raise ArgumentError, "id must not be nil"
|
---|
91 | elsif id.empty?
|
---|
92 | raise ArgumentError, "id must not be empty"
|
---|
93 | end
|
---|
94 | end
|
---|
95 | end
|
---|
96 |
|
---|
97 | class TerminologyService
|
---|
98 | include OpenEHRCodeSetIdentifier, OpenEHRTerminologyGroupIdentifiers
|
---|
99 |
|
---|
100 | def code_set(name)
|
---|
101 | raise NotImplementedError, "code_set is not implemented"
|
---|
102 | end
|
---|
103 |
|
---|
104 | def code_set_for_id(id)
|
---|
105 | raise NotImplementedError, "code_set_for_id is not implemented"
|
---|
106 | end
|
---|
107 |
|
---|
108 | def code_set_identifiers
|
---|
109 | raise NotImplementedError, "code_set_for_identifiers is not implemented"
|
---|
110 | end
|
---|
111 |
|
---|
112 | def has_code_set(name)
|
---|
113 | raise NotImplementedError, "has_code_set is not implemented"
|
---|
114 | end
|
---|
115 |
|
---|
116 | def has_terminology?(name)
|
---|
117 | raise NotImplementedError, "has_terminology is not implemented"
|
---|
118 | end
|
---|
119 |
|
---|
120 | def openehr_code_sets
|
---|
121 | raise NotImplementedError, "openehr_code_set is not implemented"
|
---|
122 | end
|
---|
123 |
|
---|
124 | def terminology(name)
|
---|
125 | return TerminologyAccess.new(:id => name)
|
---|
126 | end
|
---|
127 |
|
---|
128 | def terminology_identifiers
|
---|
129 | raise NotImplementedError, "terminology_identiferes is not implemented"
|
---|
130 | end
|
---|
131 | end
|
---|
132 | end # of Terminology
|
---|
133 | end # of Support
|
---|
134 | end # of RM
|
---|
135 | end # of OpenEHR
|
---|