[86] | 1 | # This module is based on the UML,
|
---|
| 2 | # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_76d0249_1118674798473_6021_0Report.html
|
---|
| 3 | # Ticket refs #45
|
---|
[6] | 4 | module OpenEHR
|
---|
| 5 | module RM
|
---|
| 6 | module Demogrphic
|
---|
[306] | 7 | class Address < OpenEhr::RM::Common::Archetyped::Locatable
|
---|
[87] | 8 | attr_reader :details
|
---|
| 9 |
|
---|
| 10 | def as_string
|
---|
| 11 |
|
---|
| 12 | end
|
---|
| 13 |
|
---|
| 14 | def type
|
---|
| 15 |
|
---|
| 16 | end
|
---|
| 17 | end
|
---|
| 18 |
|
---|
[306] | 19 | class Capability < OpenEhr::RM::Common::Archetyped::Locatable
|
---|
[87] | 20 | attr_reader :credentials, :time_validity
|
---|
| 21 |
|
---|
| 22 | end
|
---|
| 23 |
|
---|
[306] | 24 | class Party < OpenEhr::RM::Common::Archetyped::Locatable
|
---|
[7] | 25 | attr_reader :details, :reverse_relationships, :uid
|
---|
| 26 | attr_reader :idetities, :contacts, :relationships
|
---|
[8] | 27 | def initialize(uid, archetype_node_id, name, archetype_details,
|
---|
[9] | 28 | feeder_audit, links, identities, contacts,
|
---|
| 29 | relationships, reverse_relationships, details)
|
---|
[8] | 30 | super(uid, archetype_node_id, name, archetype_details,
|
---|
| 31 | feeder_audit, links, nil)
|
---|
| 32 | uid_valid(uid)
|
---|
| 33 | @uid = uid
|
---|
[9] | 34 | identities_vaild(identities)
|
---|
| 35 | @identities = identities
|
---|
| 36 | contacts_valid(contacts)
|
---|
| 37 | @contacts = contacts
|
---|
| 38 | relationships_valid(relationships)
|
---|
[8] | 39 | end
|
---|
[306] | 40 |
|
---|
[7] | 41 | def type
|
---|
[306] | 42 | name
|
---|
[7] | 43 | end
|
---|
[306] | 44 |
|
---|
[9] | 45 | def uid=(uid)
|
---|
| 46 | uid_valid(uid)
|
---|
| 47 | @uid = uid
|
---|
| 48 | end
|
---|
[306] | 49 |
|
---|
[9] | 50 | def identities=(identities)
|
---|
| 51 | identities_vaild(identities)
|
---|
| 52 | @identities = identities
|
---|
[306] | 53 | end
|
---|
| 54 |
|
---|
[9] | 55 | def contacts=(contacts)
|
---|
| 56 | contacts_valid(contacts)
|
---|
| 57 | @contacts = contacts
|
---|
| 58 | end
|
---|
[306] | 59 |
|
---|
[8] | 60 | def parent=(parent)
|
---|
| 61 | @parent = nil
|
---|
| 62 | end
|
---|
[306] | 63 |
|
---|
[8] | 64 | private
|
---|
[306] | 65 |
|
---|
[8] | 66 | def uid_valid(uid)
|
---|
| 67 | raise ArgumentError, "uid is not valid" if uid.nil?
|
---|
| 68 | end
|
---|
[306] | 69 |
|
---|
[9] | 70 | def identities_vaild(identities)
|
---|
| 71 | if identities.nil?
|
---|
| 72 | raise ArgumentError, "identities must not be nil"
|
---|
| 73 | elsif identities.empty?
|
---|
| 74 | raise ArgumentError, "identities must not be empty"
|
---|
| 75 | end
|
---|
| 76 | end
|
---|
[306] | 77 |
|
---|
[9] | 78 | def contacts_valid(contacts)
|
---|
| 79 | if contacs.nil?
|
---|
| 80 | raise ArgumentError, "contacts must not be nil"
|
---|
| 81 | elsif contacts.empty?
|
---|
| 82 | raise ArgumentError, "contacts must not be empty"
|
---|
[306] | 83 | end
|
---|
[9] | 84 | end
|
---|
[7] | 85 | end
|
---|
[87] | 86 |
|
---|
[306] | 87 | class PartyIdentity < OpenEhr::RM::Common::Archetyped::Locatable
|
---|
[87] | 88 | attr_reader :details
|
---|
| 89 |
|
---|
| 90 | end
|
---|
| 91 |
|
---|
[306] | 92 | class PartyRelationship < OpenEhr::RM::Common::Archetyped::Locatable
|
---|
[87] | 93 |
|
---|
| 94 | end
|
---|
| 95 |
|
---|
[306] | 96 | class Versioned_Party < OpenEhr::RM::Common::Archetyped::Locatable
|
---|
[87] | 97 |
|
---|
| 98 | end
|
---|
| 99 |
|
---|
| 100 | class Role < Party
|
---|
| 101 |
|
---|
| 102 | end
|
---|
| 103 |
|
---|
[86] | 104 | class Actor < Party
|
---|
[51] | 105 | LEAGAL_IDENTITY = 'leagal identity'
|
---|
| 106 | attr_reader :languages, :rules
|
---|
| 107 | def initialize(uid, archetype_node_id, name, archetype_details,
|
---|
| 108 | feeder_audit, links, identities, contacts,
|
---|
| 109 | relationships, reverse_relationships, details,
|
---|
| 110 | languages, rules)
|
---|
| 111 | super(uid, archetype_node_id, name, archetype_details,
|
---|
| 112 | feeder_audit, links, relationships, reverse_relationships,
|
---|
| 113 | details)
|
---|
| 114 | has_legal_identity?
|
---|
| 115 | set_languages(languages)
|
---|
| 116 | set_rules(rules)
|
---|
| 117 | end
|
---|
| 118 | def has_legal_identity?
|
---|
| 119 | @identities.each {|identity|
|
---|
| 120 | if (identity.purpose.value == LEAGAL_IDENTITY)
|
---|
| 121 | return true
|
---|
| 122 | end
|
---|
| 123 | }
|
---|
| 124 | false
|
---|
| 125 | end
|
---|
| 126 | def languages=(languages)
|
---|
| 127 | set_languages(languages)
|
---|
| 128 | end
|
---|
| 129 | def values=(values)
|
---|
| 130 | set_values(values)
|
---|
| 131 | end
|
---|
| 132 | private
|
---|
| 133 | def set_languages(languages)
|
---|
| 134 | if languages.nil?
|
---|
| 135 | raise ArgumentError, "languages should not be nil."
|
---|
| 136 | elsif languages.empty?
|
---|
| 137 | raise ArgumentError, "languages shouldnot be empty."
|
---|
| 138 | end
|
---|
| 139 | @languages = languages
|
---|
| 140 | end
|
---|
| 141 | def set_values(values)
|
---|
| 142 | if values.nil?
|
---|
| 143 | raise ArgumentError, "values should not be nil."
|
---|
| 144 | elsif values.empty?
|
---|
| 145 | raise ArgumentError, "values should not be nil."
|
---|
| 146 | end
|
---|
| 147 | @values = values
|
---|
[306] | 148 | end
|
---|
[10] | 149 | end
|
---|
[306] | 150 |
|
---|
| 151 | class Contact < OpenEhr::RM::Common::Archetyped::Locatable
|
---|
[51] | 152 | attr_accessor :time_validity
|
---|
| 153 | attr_reader :addresses
|
---|
[306] | 154 |
|
---|
[51] | 155 | def initialize(uid, archetype_node_id, name, archetype_details,
|
---|
| 156 | feeder_audit, links, parent, time_validity, addresses)
|
---|
| 157 | super(uid, archetype_node_id, name, archetype_details,
|
---|
| 158 | feeder_audit, links, parent)
|
---|
| 159 | address_exists?(addresses)
|
---|
| 160 | @addresses = addresses
|
---|
| 161 | @time_validity = time_validity
|
---|
| 162 | end
|
---|
[306] | 163 |
|
---|
[51] | 164 | def purpose
|
---|
| 165 | @name
|
---|
| 166 | end
|
---|
[306] | 167 |
|
---|
[51] | 168 | def purpose=(purpose)
|
---|
| 169 | @name = purpose
|
---|
| 170 | end
|
---|
[306] | 171 |
|
---|
[51] | 172 | def addresses=(addresses)
|
---|
| 173 | address_exists?(addresses)
|
---|
| 174 | @addresses = addresses
|
---|
| 175 | end
|
---|
[306] | 176 |
|
---|
[51] | 177 | private
|
---|
[306] | 178 |
|
---|
[51] | 179 | def address_exists?(addresses)
|
---|
| 180 | if addresses.nil?
|
---|
| 181 | raise ArgumentError, "address must not be nil"
|
---|
| 182 | elsif addresses.empty?
|
---|
| 183 | raise ArgumentError, "address must not be empty"
|
---|
| 184 | end
|
---|
| 185 | end
|
---|
| 186 | end
|
---|
[86] | 187 |
|
---|
| 188 | class Agent < Actor
|
---|
| 189 |
|
---|
| 190 | end
|
---|
| 191 |
|
---|
| 192 | class Organisation < Actor
|
---|
| 193 |
|
---|
| 194 | end
|
---|
| 195 |
|
---|
| 196 | class Person < Actor
|
---|
| 197 |
|
---|
| 198 | end
|
---|
| 199 |
|
---|
| 200 | class Group < Actor
|
---|
| 201 |
|
---|
| 202 | end
|
---|
[6] | 203 | end # of Demographic
|
---|
| 204 | end # of RM
|
---|
| 205 | end # of OpenEHR
|
---|