mml-ruby 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. data/LICENSE +199 -10
  2. data/lib/mml.rb +288 -5
  3. data/lib/mml/common.rb +26 -268
  4. data/lib/mml/version.rb +1 -1
  5. data/lib/xml/address.xml.builder +12 -0
  6. data/lib/xml/baseclinic.xml.builder +36 -0
  7. data/lib/xml/creatorinfo.xml.builder +6 -0
  8. data/lib/xml/creatorlicense.xml.builder +3 -0
  9. data/lib/xml/department.xml.builder +8 -0
  10. data/lib/xml/extref.xml.builder +5 -0
  11. data/lib/xml/facility.xml.builder +8 -0
  12. data/lib/xml/firstclinic.xml.builder +47 -0
  13. data/lib/xml/id.xml.builder +4 -0
  14. data/lib/xml/insurance.xml.builder +82 -0
  15. data/lib/xml/lifestyle.xml.builder +6 -0
  16. data/lib/xml/name.xml.builder +10 -0
  17. data/lib/xml/patientinfo.xml.builder +51 -0
  18. data/lib/xml/personalizedinfo.xml.builder +25 -0
  19. data/lib/xml/phone.xml.builder +10 -0
  20. data/lib/xml/progresscourse.xml.builder +89 -0
  21. data/lib/xml/registereddiagnosis.xml.builder +27 -0
  22. data/lib/xml/staffinfo.xml.builder +6 -0
  23. data/lib/xml/summary.xml.builder +125 -0
  24. data/lib/xml/surgery.xml.builder +81 -0
  25. data/spec/mml/admission_spec.rb +45 -0
  26. data/spec/mml/allergy_item_spec.rb +35 -0
  27. data/spec/mml/anesthesia_procedure_spec.rb +15 -0
  28. data/spec/mml/anesthesiologist_spec.rb +22 -0
  29. data/spec/mml/base_clinic_module_spec.rb +58 -0
  30. data/spec/mml/birth_info_spec.rb +90 -0
  31. data/spec/mml/blood_type_spec.rb +40 -0
  32. data/spec/mml/clinical_record_spec.rb +37 -0
  33. data/spec/mml/creator_info_spec.rb +3 -3
  34. data/spec/mml/creator_license_spec.rb +7 -0
  35. data/spec/mml/death_flag_spec.rb +11 -0
  36. data/spec/mml/death_info_spec.rb +19 -0
  37. data/spec/mml/department_spec.rb +3 -3
  38. data/spec/mml/diagnostic_category_spec.rb +23 -0
  39. data/spec/mml/discharge_spec.rb +29 -0
  40. data/spec/mml/dx_item_spec.rb +19 -0
  41. data/spec/mml/family_history_item_spec.rb +36 -0
  42. data/spec/mml/first_clinic_module_spec.rb +105 -0
  43. data/spec/mml/infection_item_spec.rb +39 -0
  44. data/spec/mml/inpatient_item_spec.rb +49 -0
  45. data/spec/mml/insurance_class_spec.rb +24 -0
  46. data/spec/mml/insurance_client_spec.rb +36 -0
  47. data/spec/mml/insurance_spec.rb +182 -0
  48. data/spec/mml/lifestyle_module_spec.rb +50 -0
  49. data/spec/mml/nationality_spec.rb +19 -0
  50. data/spec/mml/objective_spec.rb +51 -0
  51. data/spec/mml/operation_element_item_spec.rb +31 -0
  52. data/spec/mml/organization_info_spec.rb +35 -0
  53. data/spec/mml/other_blood_type_spec.rb +31 -0
  54. data/spec/mml/outpatient_item_spec.rb +48 -0
  55. data/spec/mml/past_history_item_spec.rb +23 -0
  56. data/spec/mml/past_history_spec.rb +17 -0
  57. data/spec/mml/patient_info_spec.rb +126 -0
  58. data/spec/mml/phone_spec.rb +5 -1
  59. data/spec/mml/physical_exam_item_spec.rb +40 -0
  60. data/spec/mml/plan_spec.rb +45 -0
  61. data/spec/mml/problem_item_spec.rb +35 -0
  62. data/spec/mml/procedure_item_spec.rb +44 -0
  63. data/spec/mml/progress_course_module_spec.rb +79 -0
  64. data/spec/mml/public_insurance_item_spec.rb +64 -0
  65. data/spec/mml/race_spec.rb +19 -0
  66. data/spec/mml/registered_diagnosis_spec.rb +124 -0
  67. data/spec/mml/related_doc_spec.rb +15 -0
  68. data/spec/mml/service_history_spec.rb +53 -0
  69. data/spec/mml/staff_info_spec.rb +31 -0
  70. data/spec/mml/subject_spec.rb +16 -0
  71. data/spec/mml/subjective_item_spec.rb +23 -0
  72. data/spec/mml/summary_module_spec.rb +239 -0
  73. data/spec/mml/surgery_item_spec.rb +132 -0
  74. data/spec/mml/surgery_module_spec.rb +90 -0
  75. data/spec/mml/surgical_staff_spec.rb +34 -0
  76. data/spec/mml/test_result_spec.rb +24 -0
  77. data/spec/mml/vaccination_item_spec.rb +38 -0
  78. data/spec/mml/value_with_link_spec.rb +15 -0
  79. data/spec/spec_helper.rb +1 -1
  80. metadata +137 -5
  81. checksums.yaml +0 -7
@@ -1,25 +1,9 @@
1
1
  require 'builder'
2
2
 
3
3
  module MML
4
- class BaseName
5
- attr_reader :value, :repCode
6
- attr_accessor :tableId
7
-
8
- def initialize(args ={})
9
- %W(value repCode tableId).each do |item|
10
- self.send("#{item}=", args[item.to_sym])
11
- end
12
- end
13
-
14
- def value=(value)
15
- raise ArgumentError, 'value is mandatory' if value.nil?
16
- @value = value
17
- end
18
-
19
- def repCode=(repCode)
20
- raise ArgumentError, 'repCode is mandatory' if repCode.nil?
21
- @repCode = repCode
22
- end
4
+ class BaseName < Base
5
+ mandatory_attribute :value, :repCode
6
+ optional_attribute :tableId
23
7
  end
24
8
 
25
9
  class FacilityName < BaseName
@@ -31,276 +15,50 @@ module MML
31
15
  end
32
16
 
33
17
  class Name < BaseName
34
- attr_accessor :family, :given, :middle, :fullname, :prefix, :degree
35
-
36
- def initialize(args = {})
37
- %W(family given middle fullname prefix degree repCode tableId).each do |item|
38
- self.send("#{item}=", args[item.to_sym])
39
- end
40
- end
18
+ optional_attribute :family, :given, :middle, :fullname, :prefix, :degree
41
19
 
42
20
  undef value=
43
-
44
- def to_xml
45
- xb = Builder::XmlMarkup.new
46
- xb.mmlNm(:Name, {'mmlNm:repCode' => @repCode, 'mmlNm:tableId' => @tableId}) do
47
- xb.mmlNm :family, @family if @family
48
- xb.mmlNm :middle, @middle if @middle
49
- xb.mmlNm :given, @given if @given
50
- xb.mmlNm :fullname, @fullname if @fullname
51
- xb.mmlNm :prefix, @prefix if @prefix
52
- xb.mmlNm :degree, @degree if @degree
53
- end
54
- end
55
21
  end
56
22
 
57
- class Id
58
- attr_reader :value, :type, :tableId
59
- attr_accessor :checkDigit, :checkDigitSchema
60
-
61
- def initialize(args = {})
62
- self.value = args[:value]
63
- self.type = args[:type]
64
- self.tableId = args[:tableId]
65
- self.checkDigit = args[:checkDigit]
66
- self.checkDigitSchema = args[:checkDigitSchema]
67
- end
68
-
69
- def value=(value)
70
- raise ArgumentError, 'value should not be nil' if value.nil? or value.empty?
71
- @value = value
72
- end
73
-
74
- def type=(type)
75
- raise ArgumentError, 'type should no be nil' if type.nil? or type.empty?
76
- @type = type
77
- end
78
-
79
- def tableId=(tableId)
80
- raise ArgumentError, 'table id is required' if tableId.nil? or type.empty?
81
- @tableId = tableId
82
- end
83
-
84
- def to_xml
85
- xb = Builder::XmlMarkup.new
86
- attributes = {'mmlCm:type' => type, 'mmlCm:tableId' => tableId }
87
- attributes['mmlCm:checkDigit'] = checkDigit if checkDigit
88
- attributes['mmlCm:checkDigitSchema'] = checkDigitSchema if checkDigitSchema
89
- xb.mmlCm :Id, value, attributes
90
- end
23
+ class Id < Base
24
+ mandatory_attribute :value, :type, :tableId
25
+ optional_attribute :checkDigit, :checkDigitSchema
91
26
  end
92
27
 
93
- class ExtRef
94
- attr_accessor :contentType, :medicalRole, :title
95
- attr_reader :href
96
-
97
- def initialize(args = {})
98
- self.contentType = args[:contentType]
99
- self.medicalRole = args[:medicalRole]
100
- self.title = args[:title]
101
- self.href = args[:href]
102
- end
103
-
104
- def href=(href)
105
- raise ArgumentError, 'href is mandatory' if href.nil?
106
- @href = href
107
- end
108
-
109
- def to_xml
110
- xb = Builder::XmlMarkup.new
111
- attributes = { 'mmlCm:href' => href }
112
- attributes['mmlCm:contentType'] = contentType if contentType
113
- attributes['mmlCm:medicalRole'] = medicalRole if medicalRole
114
- attributes['mmlCm:title'] = title if title
115
- xb.mmlCm :extRef, attributes
116
- end
28
+ class ExtRef < Base
29
+ mandatory_attribute :href
30
+ optional_attribute :contentType, :medicalRole, :title
117
31
  end
118
32
 
119
- class Address
120
- attr_reader :repCode
121
- attr_accessor :addressClass, :tableId, :homeNumber, :town, :city, :prefecture, :full, :zip, :countryCode
122
-
123
- def initialize(args = {})
124
- %W(repCode addressClass tableId full homeNumber town city prefecture zip countryCode).each do |item|
125
- self.send("#{item}=", args[item.to_sym])
126
- end
127
- end
128
-
129
- def repCode=(repCode)
130
- raise ArgumentError, 'repCode is mandatory' if repCode.nil?
131
- @repCode = repCode
132
- end
133
-
134
- def to_xml
135
- xb = Builder::XmlMarkup.new
136
- attributes = { 'mmlAd:repCode' => repCode }
137
- attributes['mmlAd:addressClass'] = addressClass
138
- attributes['mmlAd:tableId'] = tableId
139
- xb.mmlAd :Address, attributes do
140
- xb.mmlAd :homeNumber, homeNumber if homeNumber
141
- xb.mmlAd :town, town if town
142
- xb.mmlAd :city, city if city
143
- xb.mmlAd :prefecture, prefecture if prefecture
144
- xb.mmlAd :full, full if full
145
- xb.mmlAd :zip, zip if zip
146
- xb.mmlAd :countryCode, countryCode if countryCode
147
- end
148
- end
33
+ class Address < Base
34
+ mandatory_attribute :repCode
35
+ optional_attribute :addressClass, :tableId, :homeNumber, :town, :city, :prefecture, :full, :zip, :countryCode
149
36
  end
150
37
 
151
- class Phone
152
- attr_accessor :telEquipType, :area, :city, :number, :extension, :country, :memo
153
-
154
- def initialize(args = {})
155
- %W(telEquipType area city number extension country memo).each do |item|
156
- self.send("#{item}=", args[item.to_sym])
157
- end
158
- end
159
-
160
- def to_xml
161
- xb = Builder::XmlMarkup.new
162
- attributes = {'mmlPh:telEquipType' => telEquipType} if telEquipType
163
- xb.mmlPh :Phone, attributes do
164
- xb.mmlPh :area, area if area
165
- xb.mmlPh :city, city if city
166
- xb.mmlPh :number, number if number
167
- xb.mmlPh :extension, extension if extension
168
- xb.mmlPh :country, country if country
169
- xb.mmlPh :memo, memo if memo
170
- end
171
- end
38
+ class Phone < Base
39
+ optional_attribute :telEquipType, :area, :city, :number, :extension, :full, :country, :memo
172
40
  end
173
41
 
174
- class Facility
175
- attr_reader :name
176
- attr_accessor :id
177
-
178
- def initialize(args = {})
179
- %W(name id).each do |item|
180
- self.send("#{item}=", args[item.to_sym])
181
- end
182
- end
183
-
184
- def name=(name)
185
- raise ArgumentError, 'name is mandatory' if name.nil? or name.empty?
186
- @name = name
187
- end
188
-
189
- def to_xml
190
- xb = Builder::XmlMarkup.new
191
- xb.mmlFc :Facility do
192
- name.each do |n|
193
- attributes = {'mmlFc:repCode' => n.repCode}
194
- attributes['mmlFc:tableId'] = n.tableId if n.tableId
195
- xb.mmlFc :name, n.value, attributes
196
- end
197
- xb << id.to_xml if id
198
- end
199
- end
42
+ class Facility < Base
43
+ mandatory_attribute :name
44
+ optional_attribute :id
200
45
  end
201
46
 
202
47
  class Department < Facility
203
- def initialize(args = {})
204
- super
205
- end
206
48
 
207
- def to_xml
208
- xb = Builder::XmlMarkup.new
209
- xb.mmlDp :Department do
210
- name.each do |n|
211
- attributes = { 'mmlDp:repCode' => n.repCode}
212
- attributes['mmlDp:tableId'] = n.tableId if n.tableId
213
- xb.mmlDp :name, n.value, attributes
214
- end
215
- xb << id.to_xml if id
216
- end
217
- end
218
49
  end
219
50
 
220
- class PersonalizedInfo
221
- attr_reader :id, :personName
222
- attr_accessor :facility, :department, :addresses, :emailAddresses, :phones
223
-
224
- def initialize(args = {})
225
- %W(id personName facility department addresses emailAddresses phones).each do |item|
226
- send "#{item}=", args[item.to_sym]
227
- end
228
- end
229
-
230
- def id=(id)
231
- @id = id
232
- end
233
-
234
- def personName=(personName)
235
- @personName = personName
236
- end
237
-
238
- def to_xml
239
- xb = Builder::XmlMarkup.new
240
- xb.mmlPsi :PersonalizedInfo do
241
- xb << id.to_xml
242
- xb.mmlPsi :personName do
243
- personName.each do |n|
244
- xb << n.to_xml
245
- end
246
- end
247
- xb << facility.to_xml if facility
248
- xb << department.to_xml if department
249
- xb.mmlPsi :addresses do
250
- addresses.each do |address|
251
- xb << address.to_xml
252
- end
253
- end if addresses
254
- xb.mmlPsi :emailAddresses do
255
- emailAddresses.each do |email|
256
- xb.mmlCm :email, email
257
- end
258
- end if emailAddresses
259
- xb.mmlPsi :phones do
260
- phones.each do |phone|
261
- xb << phone.to_xml
262
- end
263
- end if phones
264
- end
265
- end
51
+ class PersonalizedInfo < Base
52
+ mandatory_attribute :id, :personName
53
+ optional_attribute :facility, :department, :addresses, :emailAddresses, :phones
266
54
  end
267
55
 
268
- class CreatorLicense
269
- attr_accessor :tableId, :value
270
-
271
- def initialize(args = {})
272
- @tableId = args[:tableId]
273
- @value = args[:value]
274
- end
56
+ class CreatorLicense < Base
57
+ optional_attribute :tableId, :value
275
58
  end
276
59
 
277
- class CreatorInfo
278
- attr_reader :personalizedInfo, :creatorLicense
279
-
280
- def initialize(args = {})
281
- self.personalizedInfo = args[:personalizedInfo]
282
- self.creatorLicense = args[:creatorLicense]
283
- end
284
-
285
- def personalizedInfo=(personalizedInfo)
286
- raise ArgumentError, 'personalizedInfo is mandatory' if personalizedInfo.nil?
287
- @personalizedInfo = personalizedInfo
288
- end
289
-
290
- def creatorLicense=(creatorLicense)
291
- raise ArgumentError, 'creatorLicense is mandatory' if creatorLicense.nil? or creatorLicense.empty?
292
- @creatorLicense = creatorLicense
293
- end
294
-
295
- def to_xml
296
- xb= Builder::XmlMarkup.new
297
- xb.mmlCi :CreatorInfo do
298
- xb << personalizedInfo.to_xml
299
- creatorLicense.each do |license|
300
- attributes = {'mmlCi:tableId' => license.tableId} if license.tableId
301
- xb.mmlCi :creatorLicense, license.value, attributes
302
- end
303
- end
304
- end
60
+ class CreatorInfo < Base
61
+ mandatory_attribute :personalizedInfo, :creatorLicense
305
62
  end
63
+
306
64
  end
@@ -1,3 +1,3 @@
1
1
  module MML
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,12 @@
1
+ attributes = { 'mmlAd:repCode' => repCode }
2
+ attributes['mmlAd:addressClass'] = addressClass
3
+ attributes['mmlAd:tableId'] = tableId
4
+ xml.mmlAd :Address, attributes do
5
+ xml.mmlAd :homeNumber, homeNumber if homeNumber
6
+ xml.mmlAd :town, town if town
7
+ xml.mmlAd :city, city if city
8
+ xml.mmlAd :prefecture, prefecture if prefecture
9
+ xml.mmlAd :full, full if full
10
+ xml.mmlAd :zip, zip if zip
11
+ xml.mmlAd :countryCode, countryCode if countryCode
12
+ end
@@ -0,0 +1,36 @@
1
+ xml.mmlBc :BaseClinicModule do
2
+ xml.mmlBc :allergy do
3
+ allergy.each do |item|
4
+ xml.mmlBc :allergyItem do
5
+ xml.mmlBc :factor, item.factor
6
+ xml.mmlBc :severity, item.severity if item.severity
7
+ xml.mmlBc :identifiedDate, item.identifiedDate if item.identifiedDate
8
+ xml.mmlBc :memo, item.memo if item.memo
9
+ end
10
+ end
11
+ end if allergy
12
+ xml.mmlBc :bloodtype do
13
+ xml.mmlBc :abo, bloodtype.abo
14
+ xml.mmlBc :rh, bloodtype.rh if bloodtype.rh
15
+ xml.mmlBc :others do
16
+ bloodtype.others.each do |other|
17
+ xml.mmlBc :other do
18
+ xml.mmlBc :typeName, other.typeName
19
+ xml.mmlBc :typeJudgement, other.typeJudgement
20
+ xml.mmlBc :description, other.description if other.description
21
+ end
22
+ end
23
+ end if bloodtype.others
24
+ xml.mmlBc :memo, bloodtype.memo if bloodtype.memo
25
+ end if bloodtype
26
+ xml.mmlBc :infection do
27
+ infection.each do |item|
28
+ xml.mmlBc :infectionItem do
29
+ xml.mmlBc :factor, item.factor
30
+ xml.mmlBc :examValue, item.examValue
31
+ xml.mmlBc :identifiedDate, item.identifiedDate if item.identifiedDate
32
+ xml.mmlBc :memo, item.memo if item.memo
33
+ end
34
+ end
35
+ end if infection
36
+ end
@@ -0,0 +1,6 @@
1
+ xml.mmlCi :CreatorInfo do
2
+ xml << personalizedInfo.to_xml
3
+ creatorLicense.each do |license|
4
+ xml << license.to_xml
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ attributes = Hash.new
2
+ attributes['mmlCi:tableId'] = tableId if tableId
3
+ xml.mmlCi :creatorLicense, value, attributes
@@ -0,0 +1,8 @@
1
+ xml.mmlDp :Department do
2
+ name.each do |n|
3
+ attributes = { 'mmlDp:repCode' => n.repCode}
4
+ attributes['mmlDp:tableId'] = n.tableId if n.tableId
5
+ xml.mmlDp :name, n.value, attributes
6
+ end
7
+ xml << id.to_xml if id
8
+ end
@@ -0,0 +1,5 @@
1
+ attributes = { 'mmlCm:href' => href }
2
+ attributes['mmlCm:contentType'] = contentType if contentType
3
+ attributes['mmlCm:medicalRole'] = medicalRole if medicalRole
4
+ attributes['mmlCm:title'] = title if title
5
+ xml.mmlCm :extRef, attributes
@@ -0,0 +1,8 @@
1
+ xml.mmlFc :Facility do
2
+ name.each do |n|
3
+ attributes = {'mmlFc:repCode' => n.repCode}
4
+ attributes['mmlFc:tableId'] = n.tableId if n.tableId
5
+ xml.mmlFc :name, n.value, attributes
6
+ end
7
+ xml << id.to_xml if id
8
+ end
@@ -0,0 +1,47 @@
1
+ xml.mmlFcl :FirstClinicModule do
2
+ xml.mmlFcl :familyHistory do
3
+ familyHistory.each do |item|
4
+ xml.mmlFcl :familyHistoryItem do
5
+ xml.mmlFcl :relation, item.relation
6
+ xml << item.registeredDiagnosis.to_xml
7
+ xml.mmlFcl :age, item.age
8
+ xml.mmlFcl :memo, item.memo
9
+ end
10
+ end
11
+ end if familyHistory
12
+ xml.mmlFcl :childhood do
13
+ xml.mmlFcl :birthInfo do
14
+ xml << birthInfo.facility.to_xml if birthInfo.facility
15
+ xml.mmlFcl :deliveryWeeks, birthInfo.deliveryWeeks if birthInfo.deliveryWeeks
16
+ xml.mmlFcl :deliveryMethod, birthInfo.deliveryMethod if birthInfo.deliveryMethod
17
+ xml.mmlFcl :bodyWeight, birthInfo.bodyWeight, {'mmlFcl:unit' => birthInfo.bodyWeightUnit} if birthInfo.bodyWeight
18
+ xml.mmlFcl :bodyHeight, birthInfo.bodyHeight, {'mmlFcl:unit' => birthInfo.bodyHeightUnit} if birthInfo.bodyHeight
19
+ xml.mmlFcl :chestCircumference, birthInfo.chestCircumference, {'mmlFcl:unit' => birthInfo.chestCircumferenceUnit} if birthInfo.chestCircumference
20
+ xml.mmlFcl :headCircumference, birthInfo.headCircumference, {'mmlFcl:unit' => birthInfo.headCircumferenceUnit} if birthInfo.headCircumference
21
+ xml.mmlFcl :memo, birthInfo.memo if birthInfo.memo
22
+ end if birthInfo
23
+ xml.mmlFcl :vaccination do
24
+ vaccination.each do |item|
25
+ xml.mmlFcl :vaccinationItem do
26
+ xml.mmlFcl :vaccine, item.vaccine
27
+ xml.mmlFcl :injected, item.injected
28
+ xml.mmlFcl :age, item.age if item.age
29
+ xml.mmlFcl :memo, item.memo if item.memo
30
+ end
31
+ end
32
+ end if vaccination
33
+ end if birthInfo or vaccination
34
+ xml.mmlFcl :pastHistory do
35
+ xml.mmlFcl :freeNote, pastHistory.freeNote if pastHistory.freeNote
36
+ pastHistory.pastHistoryItem.each do |item|
37
+ xml.mmlFcl :pastHistoryItem do
38
+ xml.mmlFcl :timeExpression, item.timeExpression
39
+ item.eventExpression.each do |event|
40
+ xml.mmlFcl :eventExpression, event
41
+ end if item.eventExpression
42
+ end
43
+ end if pastHistory.pastHistoryItem
44
+ end if pastHistory
45
+ xml.mmlFcl :chiefComplaints, chiefComplaints if chiefComplaints
46
+ xml.mmlFcl :presentIllnessNotes, presentIllnessNotes if presentIllnessNotes
47
+ end