[4] | 1 |
|
---|
[216] | 2 | module OpenEHR
|
---|
[4] | 3 | module RM
|
---|
| 4 | module Support
|
---|
| 5 | module Terminology
|
---|
[167] | 6 | class CodeSetAccess
|
---|
[4] | 7 | def all_codes
|
---|
| 8 | raise NotImplementedError, "all_codes must be implemented"
|
---|
| 9 | end
|
---|
[226] | 10 |
|
---|
[4] | 11 | def has_code(a_code)
|
---|
| 12 | raise NotImplementedError, "has_code must be implemented"
|
---|
| 13 | end
|
---|
[226] | 14 |
|
---|
[4] | 15 | def has_lang(a_lang)
|
---|
| 16 | raise NotImplementedError, "has_lang must be implemented"
|
---|
| 17 | end
|
---|
[226] | 18 |
|
---|
[4] | 19 | def id
|
---|
| 20 | raise NotImplementedError, "id must be returned"
|
---|
| 21 | end
|
---|
| 22 | end
|
---|
[226] | 23 |
|
---|
[216] | 24 | module OpenEHRCodeSetIdentifier
|
---|
[4] | 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
|
---|
[226] | 35 |
|
---|
[216] | 36 | module OpenEHRTerminologyGroupIdentifiers
|
---|
[4] | 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
|
---|
[226] | 53 |
|
---|
[167] | 54 | class TerminologyAccess
|
---|
[226] | 55 | attr_reader :id
|
---|
| 56 |
|
---|
| 57 | def initialize(args = {})
|
---|
| 58 | self.id = args[:id]
|
---|
| 59 | end
|
---|
| 60 |
|
---|
[4] | 61 | def all_codes
|
---|
| 62 | raise NotImplementedError, "all_codes is not implemented"
|
---|
| 63 | end
|
---|
[226] | 64 |
|
---|
[4] | 65 | def codes_for_group_id(group_id)
|
---|
| 66 | raise NotImplementedError, "codes_for_group_id is not implemented"
|
---|
| 67 | end
|
---|
[226] | 68 |
|
---|
[4] | 69 | def codes_for_group_name(name, lang)
|
---|
| 70 | raise NotImplementedError, "codes_for_group_name is not implemented"
|
---|
| 71 | end
|
---|
[226] | 72 |
|
---|
[4] | 73 | def has_code_for_group_id(group_id, a_code)
|
---|
[226] | 74 |
|
---|
[4] | 75 | end
|
---|
[226] | 76 |
|
---|
| 77 | def id=(id)
|
---|
| 78 | @terminology = Terminology.find_all_by_name(id)
|
---|
| 79 | @id = id
|
---|
[4] | 80 | end
|
---|
[226] | 81 |
|
---|
[4] | 82 | def rubric_for_code(code, lang)
|
---|
[226] | 83 | return Terminology.find(:first, :conditions => {:code => code,
|
---|
| 84 | :lang => lang})
|
---|
[4] | 85 | end
|
---|
[226] | 86 |
|
---|
[4] | 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
|
---|
[226] | 96 |
|
---|
[167] | 97 | class TerminologyService
|
---|
[216] | 98 | include OpenEHRCodeSetIdentifier, OpenEHRTerminologyGroupIdentifiers
|
---|
[226] | 99 |
|
---|
[4] | 100 | def code_set(name)
|
---|
| 101 | raise NotImplementedError, "code_set is not implemented"
|
---|
| 102 | end
|
---|
[226] | 103 |
|
---|
[4] | 104 | def code_set_for_id(id)
|
---|
| 105 | raise NotImplementedError, "code_set_for_id is not implemented"
|
---|
| 106 | end
|
---|
[226] | 107 |
|
---|
[4] | 108 | def code_set_identifiers
|
---|
| 109 | raise NotImplementedError, "code_set_for_identifiers is not implemented"
|
---|
| 110 | end
|
---|
[226] | 111 |
|
---|
[4] | 112 | def has_code_set(name)
|
---|
| 113 | raise NotImplementedError, "has_code_set is not implemented"
|
---|
| 114 | end
|
---|
[226] | 115 |
|
---|
[4] | 116 | def has_terminology?(name)
|
---|
| 117 | raise NotImplementedError, "has_terminology is not implemented"
|
---|
| 118 | end
|
---|
[226] | 119 |
|
---|
[4] | 120 | def openehr_code_sets
|
---|
| 121 | raise NotImplementedError, "openehr_code_set is not implemented"
|
---|
| 122 | end
|
---|
[226] | 123 |
|
---|
[4] | 124 | def terminology(name)
|
---|
[226] | 125 | return TerminologyAccess.new(:id => name)
|
---|
[4] | 126 | end
|
---|
[226] | 127 |
|
---|
[4] | 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
|
---|