mml-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,15 @@
1
+ describe MML::RelatedDoc do
2
+ let(:related_doc) {MML::RelatedDoc.new(value: '11D1AC5400A0C94A814796045F768ED5', relation: 'detail')}
3
+
4
+ it 'is an instance of MML::RelatedDoc' do
5
+ expect(related_doc).to be_an_instance_of MML::RelatedDoc
6
+ end
7
+
8
+ it 'value should be assigned properly' do
9
+ expect(related_doc.value).to eq '11D1AC5400A0C94A814796045F768ED5'
10
+ end
11
+
12
+ it 'relation should be assigned properly' do
13
+ expect(related_doc.relation).to eq 'detail'
14
+ end
15
+ end
@@ -0,0 +1,53 @@
1
+ describe MML::ServiceHistory do
2
+ let(:out_staff_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '00123')}
3
+ let(:out_staff_name) {MML::Name.new(repCode: 'A', fullname: 'Hiroyuki Yoshihara')}
4
+ let(:out_staff_personalized_info) {MML::PersonalizedInfo.new(id: id, personName: [out_staff_name])}
5
+ let(:out_staff_creator_license) { MML::CreatorLicense.new(tableId: 'MML0026', value: 'doctor')}
6
+ let(:out_staff_info) {MML::StaffInfo.new(personalizedInfo: out_staff_personalized_info, creatorLicense: [out_staff_creator_license])}
7
+ let(:outpatient_item) {MML::OutpatientItem.new(date: '2013-08-25', first: true, emergency: true, outPatientCondition: '10A.M.the patient was put into the ambulance on a stretcher and driven to our hospital.', staffs: [out_staff_info])}
8
+ let(:referer_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '23234567')}
9
+ let(:referer_name) {MML::Name.new(repCode: 'A', tableId: 'MML0025', family: 'Ono', given: 'Yoko', degree: 'M.D.')}
10
+ let(:referer_facility_name) {MML::FacilityName.new(repCode: 'A', tableId: 'MML0025', value: 'New Millenium Medical College Hospital')}
11
+ let(:referer_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '801.006.3')}
12
+ let(:referer_facility) {MML::Facility.new(id: referer_facility_id, name: [referer_facility_name])}
13
+ let(:referer) {MML::PersonalizedInfo.new(id: referer_id, personName: [referer_name], facility: referer_facility)}
14
+ let(:admission) {MML::Admission.new(date: '2013-12-08', admissionCondition: 'Emergency admission by ambulance', emergency: true, referFrom: referer)}
15
+
16
+ let(:refer_to_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '55234567')}
17
+ let(:refer_to_name) {MML::Name.new(repCode: 'A', tableId: 'MML0025', family: 'Tanaka', given: 'Fujiko', degree: 'M.D.')}
18
+ let(:refer_to_facility_name) {MML::FacilityName.new(repCode: 'A', tableId: 'MML0025', value: 'New Millenium Heisei Hospital')}
19
+ let(:refer_to_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '32354678')}
20
+ let(:refer_to_facility) {MML::Facility.new(id: refer_to_facility_id, name: [refer_to_facility_name])}
21
+ let(:refer_to) {MML::PersonalizedInfo.new(id: refer_to_id, personName: [refer_to_name], facility: refer_to_facility)}
22
+ let(:discharge) {MML::Discharge.new(date: '2013-08-31', dischargeCondition: '4 P.O.D, the patient was transferred to the chronic hospital.', outcome: 'transferChronic', referTo: refer_to)}
23
+
24
+ let(:id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '23456789')}
25
+ let(:name) {MML::Name.new(repCode: 'A', fullname: 'Kenji Araki')}
26
+ let(:personalized_info) {MML::PersonalizedInfo.new(id: id, personName: [name])}
27
+ let(:creator_license) { MML::CreatorLicense.new(tableId: 'MML0026', value: 'doctor')}
28
+ let(:staff_info) {MML::StaffInfo.new(personalizedInfo: personalized_info, creatorLicense: [creator_license])}
29
+
30
+ let(:inpatient_item) {MML::InpatientItem.new(admission: admission, discharge: discharge, staffs: [staff_info])}
31
+
32
+ let(:service_history) {MML::ServiceHistory.new(start: '2013-08-25', end: '2013-08-31', outPatient: [outpatient_item], inPatient: [inpatient_item])}
33
+
34
+ it 'is an instance of MML::ServiceHistory' do
35
+ expect(service_history).to be_an_instance_of MML::ServiceHistory
36
+ end
37
+
38
+ it 'start is assigned properly' do
39
+ expect(service_history.start).to eq '2013-08-25'
40
+ end
41
+
42
+ it 'end is assigned properly' do
43
+ expect(service_history.end).to eq '2013-08-31'
44
+ end
45
+
46
+ it 'outPatient should be assigned properly' do
47
+ expect(service_history.outPatient[0].date).to eq '2013-08-25'
48
+ end
49
+
50
+ it 'inPatient should be assigned properly' do
51
+ expect(service_history.inPatient[0].admission.date).to eq '2013-12-08'
52
+ end
53
+ end
@@ -0,0 +1,31 @@
1
+ describe MML::StaffInfo do
2
+ let(:id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '00123')}
3
+ let(:name) {MML::Name.new(repCode: 'A', fullname: 'Hiroyuki Yoshihara')}
4
+ let(:personalized_info) {MML::PersonalizedInfo.new(id: id, personName: [name])}
5
+ let(:creator_license) { MML::CreatorLicense.new(tableId: 'MML0026', value: 'doctor')}
6
+ let(:staff_info) {MML::StaffInfo.new(personalizedInfo: personalized_info, creatorLicense: [creator_license])}
7
+
8
+ it 'is an instance of MML::StaffInfo' do
9
+ expect(staff_info).to be_an_instance_of MML::StaffInfo
10
+ end
11
+
12
+ it 'personalizedInfo should be assigned properly' do
13
+ expect(staff_info.personalizedInfo.id.value).to eq '00123'
14
+ end
15
+
16
+ it 'personalizedInfo is mandatory' do
17
+ expect {staff_info.personalizedInfo = nil}.to raise_error ArgumentError
18
+ end
19
+
20
+ it 'creatorLicense should be assigned properly' do
21
+ expect(staff_info.creatorLicense[0].value).to eq 'doctor'
22
+ end
23
+
24
+ it 'creatorLicense is mandatory' do
25
+ expect {staff_info.creatorLicense = nil}.to raise_error ArgumentError
26
+ end
27
+
28
+ describe "to_xml" do
29
+
30
+ end
31
+ end
@@ -0,0 +1,16 @@
1
+ describe MML::Subjective do
2
+ let(:subjective_item) {MML::SubjectiveItem.new(timeExpression: '5 years ago', eventExpression: ['headache'])}
3
+ let(:subjective) {MML::Subjective.new(freeNotes: 'headache from 5 years ago', subjectiveItem: [subjective_item])}
4
+
5
+ it 'is an instance of MML::Subjective' do
6
+ expect(subjective).to be_an_instance_of MML::Subjective
7
+ end
8
+
9
+ it 'freeNotes should be assigned properly' do
10
+ expect(subjective.freeNotes).to eq 'headache from 5 years ago'
11
+ end
12
+
13
+ it 'subjectiveItem should be assigned properly' do
14
+ expect(subjective.subjectiveItem[0].timeExpression).to eq '5 years ago'
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ describe MML::SubjectiveItem do
2
+ let(:subjective_item) {MML::SubjectiveItem.new(timeExpression: '5 years ago', eventExpression: ['headache'])}
3
+
4
+ it 'is an instance of MML::SubjectiveItem' do
5
+ expect(subjective_item).to be_an_instance_of MML::SubjectiveItem
6
+ end
7
+
8
+ it 'timeExpression should be assigned properly' do
9
+ expect(subjective_item.timeExpression).to eq '5 years ago'
10
+ end
11
+
12
+ it 'timeExpression is mandatory' do
13
+ expect {subjective_item.timeExpression = nil}.to raise_error ArgumentError
14
+ end
15
+
16
+ it 'eventExpression should be assigned properly' do
17
+ expect(subjective_item.eventExpression).to eq ['headache']
18
+ end
19
+
20
+ it 'eventExpression is mandatory' do
21
+ expect {subjective_item.timeExpression = nil}.to raise_error ArgumentError
22
+ end
23
+ end
@@ -0,0 +1,239 @@
1
+ describe MML::Summary do
2
+ let(:out_staff_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '00123')}
3
+ let(:out_staff_name) {MML::Name.new(repCode: 'A', fullname: 'Hiroyuki Yoshihara')}
4
+ let(:out_staff_personalized_info) {MML::PersonalizedInfo.new(id: id, personName: [out_staff_name])}
5
+ let(:out_staff_creator_license) { MML::CreatorLicense.new(tableId: 'MML0026', value: 'doctor')}
6
+ let(:out_staff_info) {MML::StaffInfo.new(personalizedInfo: out_staff_personalized_info, creatorLicense: [out_staff_creator_license])}
7
+ let(:outpatient_item) {MML::OutpatientItem.new(date: '2013-08-25', first: true, emergency: true, outPatientCondition: '10A.M.the patient was put into the ambulance on a stretcher and driven to our hospital.', staffs: [out_staff_info])}
8
+ let(:referer_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '23234567')}
9
+ let(:referer_name) {MML::Name.new(repCode: 'A', tableId: 'MML0025', family: 'Ono', given: 'Yoko', degree: 'M.D.')}
10
+ let(:referer_facility_name) {MML::FacilityName.new(repCode: 'A', tableId: 'MML0025', value: 'New Millenium Medical College Hospital')}
11
+ let(:referer_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '801.006.3')}
12
+ let(:referer_facility) {MML::Facility.new(id: referer_facility_id, name: [referer_facility_name])}
13
+ let(:referer) {MML::PersonalizedInfo.new(id: referer_id, personName: [referer_name], facility: referer_facility)}
14
+ let(:admission) {MML::Admission.new(date: '2013-12-08', admissionCondition: 'Emergency admission by ambulance', emergency: true, referFrom: referer)}
15
+
16
+ let(:refer_to_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '55234567')}
17
+ let(:refer_to_name) {MML::Name.new(repCode: 'A', tableId: 'MML0025', family: 'Tanaka', given: 'Fujiko', degree: 'M.D.')}
18
+ let(:refer_to_facility_name) {MML::FacilityName.new(repCode: 'A', tableId: 'MML0025', value: 'New Millenium Heisei Hospital')}
19
+ let(:refer_to_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '32354678')}
20
+ let(:refer_to_facility) {MML::Facility.new(id: refer_to_facility_id, name: [refer_to_facility_name])}
21
+ let(:refer_to) {MML::PersonalizedInfo.new(id: refer_to_id, personName: [refer_to_name], facility: refer_to_facility)}
22
+ let(:discharge) {MML::Discharge.new(date: '2013-08-31', dischargeCondition: '4 P.O.D, the patient was transferred to the chronic hospital.', outcome: 'transferChronic', referTo: refer_to)}
23
+
24
+ let(:id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '23456789')}
25
+ let(:name) {MML::Name.new(repCode: 'A', fullname: 'Kenji Araki')}
26
+ let(:personalized_info) {MML::PersonalizedInfo.new(id: id, personName: [name])}
27
+ let(:creator_license) { MML::CreatorLicense.new(tableId: 'MML0026', value: 'doctor')}
28
+ let(:staff_info) {MML::StaffInfo.new(personalizedInfo: personalized_info, creatorLicense: [creator_license])}
29
+
30
+ let(:inpatient_item) {MML::InpatientItem.new(admission: admission, discharge: discharge, staffs: [staff_info])}
31
+
32
+ let(:service_history) {MML::ServiceHistory.new(start: '2013-08-25', end: '2013-08-31', outPatient: [outpatient_item], inPatient: [inpatient_item])}
33
+
34
+ let(:registered_diagnosis) {MML::RegisteredDiagnosis.new(diagnosis: 'right tibial fracture')}
35
+
36
+ let(:death_info) {MML::DeathInfo.new(date: '2013-08-31', autopsy: true, value: 'The patient died of gastric cancer.')}
37
+
38
+ let(:surgical_diagnosis) {MML::RegisteredDiagnosis.new(diagnosis: 'Lung cancer')}
39
+ let(:procedure_item) {MML::ProcedureItem.new(operation: 'right lobectomy')}
40
+ let(:surgery_item) {MML::SurgeryItem.new(date: '2013-12-10', surgicalDiagnosis: [surgical_diagnosis], surgicalProcedure: [procedure_item])}
41
+ let(:surgery) {MML::Surgery.new(surgeryItem: [surgery_item])}
42
+
43
+ let(:physicalExamRef) {MML::ExtRef.new(href: 'http://chest/auscultation')}
44
+ let(:physicalExam) {MML::ValueWithLink.new(value: 'Heart sounds were clear', link: [physicalExamRef])}
45
+
46
+ let(:doc_ref) {MML::ExtRef.new(href: 'img://file/angio/')}
47
+ let(:related_doc) {MML::RelatedDoc.new(value: '11D1AC5400A0C94A814796045F768ED5', relation: 'detail')}
48
+ let(:clinical_record) {MML::ClinicalRecord.new(value: 'Emergency coronary angiography was carried out.', date: '2013-12-20', extRef: [doc_ref], relatedDoc: [related_doc])}
49
+
50
+ let(:discharge_ref) {MML::ExtRef.new(href: 'ext:/summary/discharge')}
51
+ let(:discharge_findings) {MML::ValueWithLink.new(value: 'Symptoms free, no wound infection.', link: [discharge_ref])}
52
+
53
+ let(:medication_ref) {MML::ExtRef.new(href: 'patient1234/prescription003.HL7')}
54
+ let(:medication) {MML::ValueWithLink.new(value: 'Prescription on discharge', link: [medication_ref])}
55
+
56
+ let(:test_ref) {MML::ExtRef.new(href: 'patient1234/prescription004.HL7')}
57
+ let(:test_result) {MML::TestResult.new(date: '2013-12-22', value: 'Labo findings on discharge', link: [test_ref])}
58
+
59
+ let(:plan_ref) {MML::ExtRef.new(href: 'patient1234/rehabilitationplan')}
60
+ let(:plan) {MML::ValueWithLink.new(value: 'Rehabilitation program and wound care will continue in the chronic hospital.', link: [plan_ref])}
61
+ let(:summary) {MML::Summary.new(serviceHistory: service_history, registeredDiagnosis: [registered_diagnosis], deathInfo: death_info, surgeryModule: [surgery], chiefComplaints: 'Severe chest pain', patientProfile: 'The patient is a 40-year-old married forester.', history: 'On a background of good health, (snip)', physicalExam: physicalExam, clinicalCourse: [clinical_record], dischargeFindings: discharge_findings, medication: medication, testResults: [test_result], plan: plan, remarks: 'Patient education: good. Appointment in outpatient department in 2 weeks.')}
62
+
63
+ it 'is an instance of MML::Summary' do
64
+ expect(summary).to be_an_instance_of MML::Summary
65
+ end
66
+
67
+ it 'serviceHistory should be assigned properly' do
68
+ expect(summary.serviceHistory.start).to eq '2013-08-25'
69
+ end
70
+
71
+ it 'registeredDiagnosis should be assigned properly' do
72
+ expect(summary.registeredDiagnosis[0].diagnosis).to eq 'right tibial fracture'
73
+ end
74
+
75
+ it 'registeredDiagnosis is optional' do
76
+ expect {summary.registeredDiagnosis = nil}.not_to raise_error
77
+ end
78
+
79
+ it 'deathInfo should be assigned properly' do
80
+ expect(summary.deathInfo.value).to eq 'The patient died of gastric cancer.'
81
+ end
82
+
83
+ it 'deathInfo is optional' do
84
+ expect {summary.deathInfo = nil}.not_to raise_error
85
+ end
86
+
87
+ it 'surgeryModule should be assigned properly' do
88
+ expect(summary.surgeryModule[0].surgeryItem[0].date).to eq '2013-12-10'
89
+ end
90
+
91
+ it 'surgeryModule is optional' do
92
+ expect {summary.surgeryModule = nil}.not_to raise_error
93
+ end
94
+
95
+ it 'chiefComplaint should be assigned properly' do
96
+ expect(summary.chiefComplaints).to eq 'Severe chest pain'
97
+ end
98
+
99
+ it 'chiefComplaints is optional' do
100
+ expect {summary.chiefComplaints = nil}.not_to raise_error
101
+ end
102
+
103
+ it 'patientProfile should be assigned properly' do
104
+ expect(summary.patientProfile).to eq 'The patient is a 40-year-old married forester.'
105
+ end
106
+
107
+ it 'patientProfile is optional' do
108
+ expect {summary.patientProfile}.not_to raise_error
109
+ end
110
+
111
+ it 'hitory should be assigned properly' do
112
+ expect(summary.history).to eq 'On a background of good health, (snip)'
113
+ end
114
+
115
+ it 'history is optional' do
116
+ expect {summary.history = nil}.not_to raise_error
117
+ end
118
+
119
+ it 'physicalExam should be assigned properly' do
120
+ expect(summary.physicalExam.value).to eq 'Heart sounds were clear'
121
+ end
122
+
123
+ it 'physicalExam is optional' do
124
+ expect {summary.physicalExam = nil}.not_to raise_error
125
+ end
126
+
127
+ it 'clinicalCourse should be assigned properly' do
128
+ expect(summary.clinicalCourse[0].date).to eq '2013-12-20'
129
+ end
130
+
131
+ it 'clinicalCourse is optional' do
132
+ expect {summary.clinicalCourse = nil}.not_to raise_error
133
+ end
134
+
135
+ it 'dischargeFindings should be assigned properly' do
136
+ expect(summary.dischargeFindings.value).to eq 'Symptoms free, no wound infection.'
137
+ end
138
+
139
+ it 'dischargeFindings is optional' do
140
+ expect {summary.dischargeFindings = nil}.not_to raise_error
141
+ end
142
+
143
+ it 'medication should be assigned properly' do
144
+ expect(summary.medication.value).to eq 'Prescription on discharge'
145
+ end
146
+
147
+ it 'medication is optional' do
148
+ expect {summary.medication = nil}.not_to raise_error
149
+ end
150
+
151
+ it 'testResults should be assigned properly' do
152
+ expect(summary.testResults[0].value).to eq 'Labo findings on discharge'
153
+ end
154
+
155
+ it 'plan should be assigned properly' do
156
+ expect(summary.plan.value).to eq 'Rehabilitation program and wound care will continue in the chronic hospital.'
157
+ end
158
+
159
+ it 'remarks should be assigned properly' do
160
+ expect(summary.remarks).to eq 'Patient education: good. Appointment in outpatient department in 2 weeks.'
161
+ end
162
+
163
+ describe '#to_xml' do
164
+ subject {summary.to_xml}
165
+
166
+ it {should match '<mmlSm:SummaryModule>'}
167
+ it {should match '<mmlSm:serviceHistory'}
168
+ it {should match 'mmlSm:start="2013-08-25"'}
169
+ it {should match 'mmlSm:end="2013-08-31"'}
170
+ it {should match '<mmlSm:outPatient><mmlSm:outPatientItem>'}
171
+ it {should match '<mmlSm:date>2013-08-25</mmlSm:date>'}
172
+ it {should match '<mmlSm:outPatientCondition'}
173
+ it {should match 'mmlSm:first="true"'}
174
+ it {should match 'mmlSm:emergency="true"'}
175
+ it {should match '10A.M.the patient was put into the ambulance on a stretcher and driven to our hospital.</mmlSm:outPatientCondition>'}
176
+ it {should match '<mmlSm:staffs><mmlSm:staffInfo>'}
177
+ it {should match '<mmlPsi:PersonalizedInfo>'}
178
+ it {should match '<mmlNm:fullname>Hiroyuki Yoshihara</mmlNm:fullname>'}
179
+ it {should match '</mmlPsi:PersonalizedInfo>'}
180
+ it {should match '<mmlCi:creatorLicense mmlCi:tableId="MML0026">doctor</mmlCi:creatorLicense></mmlSm:staffInfo></mmlSm:staffs>'}
181
+ it {should match '</mmlSm:outPatientItem></mmlSm:outPatient>'}
182
+ it {should match '<mmlSm:inPatient>'}
183
+ it {should match '<mmlSm:inPatientItem>'}
184
+ it {should match '<mmlSm:admission>'}
185
+ it {should match '<mmlSm:date>2013-12-08</mmlSm:date>'}
186
+ it {should match '<mmlSm:admissionCondition mmlSm:emergency="true">Emergency admission by ambulance</mmlSm:admissionCondition>'}
187
+ it {should match '<mmlSm:referFrom><mmlPsi:PersonalizedInfo'}
188
+ it {should match '<mmlNm:given>Yoko</mmlNm:given>'}
189
+ it {should match '</mmlPsi:PersonalizedInfo></mmlSm:referFrom>'}
190
+ it {should match '</mmlSm:admission><mmlSm:discharge><mmlSm:date>2013-08-31</mmlSm:date>'}
191
+ it {should match '<mmlSm:dischargeCondition mmlSm:outcome="transferChronic">4 P.O.D, the patient was transferred to the chronic hospital.</mmlSm:dischargeCondition>'}
192
+ it {should match '<mmlSm:referTo><mmlPsi:PersonalizedInfo>'}
193
+ it {should match '<mmlNm:family>Tanaka</mmlNm:family>'}
194
+ it {should match '</mmlPsi:PersonalizedInfo></mmlSm:referTo></mmlSm:discharge>'}
195
+ it {should match '<mmlSm:staffs>'}
196
+ it {should match '<mmlSm:staffInfo><mmlPsi:PersonalizedInfo>'}
197
+ it {should match '<mmlNm:fullname>Kenji Araki</mmlNm:fullname>'}
198
+ it {should match '</mmlCi:creatorLicense></mmlSm:staffInfo></mmlSm:staffs></mmlSm:inPatientItem>'}
199
+ it {should match '</mmlSm:inPatient>'}
200
+ it {should match '</mmlSm:serviceHistory>'}
201
+ it {should match '<mmlRd:RegisteredDiagnosisModule>'}
202
+ it {should match '<mmlRd:diagnosis>right tibial fracture</mmlRd:diagnosis>'}
203
+ it {should match '</mmlRd:RegisteredDiagnosisModule>'}
204
+ it {should match '<mmlSm:deathInfo'}
205
+ it {should match 'mmlSm:date="2013-08-31"'}
206
+ it {should match 'mmlSm:autopsy="true"'}
207
+ it {should match '>The patient died of gastric cancer.</mmlSm:deathInfo>'}
208
+ it {should match '<mmlSg:SurgeryModule>'}
209
+ it {should match '<mmlSg:surgeryItem>'}
210
+ it {should match '<mmlSg:operation>right lobectomy</mmlSg:operation>'}
211
+ it {should match '</mmlSg:surgeryItem>'}
212
+ it {should match '</mmlSg:SurgeryModule>'}
213
+ it {should match '<mmlSm:chiefComplaints>Severe chest pain</mmlSm:chiefComplaints>'}
214
+ it {should match '<mmlSm:patientProfile>The patient is a 40-year-old married forester.</mmlSm:patientProfile>'}
215
+ it {should match '<mmlSm:history>On a background of good health, \(snip\)</mmlSm:history>'}
216
+ it {should match '<mmlSm:physicalExam>Heart sounds were clear'}
217
+ it {should match '<mmlCm:extRef mmlCm:href="http://chest/auscultation"/>'}
218
+ it {should match '</mmlSm:physicalExam>'}
219
+ it {should match '<mmlSm:clinicalCourse>'}
220
+ it {should match '<mmlSm:clinicalRecord mmlSm:date="2013-12-20">Emergency coronary angiography was carried out.'}
221
+ it {should match '<mmlCm:extRef mmlCm:href="img://file/angio/"/>'}
222
+ it {should match '</mmlSm:clinicalRecord>'}
223
+ it {should match '</mmlSm:clinicalCourse>'}
224
+ it {should match '<mmlSm:dischargeFindings>Symptoms free, no wound infection.'}
225
+ it {should match '<mmlCm:extRef mmlCm:href="ext:/summary/discharge"/>'}
226
+ it {should match '</mmlSm:dischargeFindings>'}
227
+ it {should match '<mmlSm:medication>Prescription on discharge'}
228
+ it {should match '<mmlCm:extRef mmlCm:href="patient1234/prescription003.HL7"/>'}
229
+ it {should match '</mmlSm:medication>'}
230
+ it {should match '<mmlSm:testResults>'}
231
+ it {should match '<mmlSm:testResult mmlSm:date="2013-12-22">Labo findings on discharge'}
232
+ it {should match '<mmlCm:extRef mmlCm:href="patient1234/prescription004.HL7"/>'}
233
+ it {should match '</mmlSm:testResult></mmlSm:testResults>'}
234
+ it {should match '<mmlSm:plan>Rehabilitation program and wound care will continue in the chronic hospital.'}
235
+ it {should match '<mmlCm:extRef mmlCm:href="patient1234/rehabilitationplan"/></mmlSm:plan>'}
236
+ it {should match '<mmlSm:remarks>Patient education: good. Appointment in outpatient department in 2 weeks.</mmlSm:remarks>'}
237
+ it {should match '</mmlSm:SummaryModule>'}
238
+ end
239
+ end
@@ -0,0 +1,132 @@
1
+ describe MML::SurgeryItem do
2
+ let(:surgical_department_name) {MML::DepartmentName.new(repCode: 'A', tableId: 'MML0025', value: 'Cardiovascular surgery')}
3
+ let(:surgical_department) {MML::Department.new(name: [surgical_department_name])}
4
+ let(:patient_department_name) {MML::DepartmentName.new(repCode: 'A', tableId: 'MML0025', value: 'Internal medicine')}
5
+ let(:patient_department) {MML::Department.new(name: [patient_department_name])}
6
+ let(:registered_diagnosis) {MML::RegisteredDiagnosis.new(diagnosis: 'Lung cancer')}
7
+ let(:operation_element_item) {MML::OperationElementItem.new(title: 'coronary artery bipass grafting', code: 'K552', system: 'MHLW')}
8
+ let(:procedure_item) {MML::ProcedureItem.new(operation: 'right lobectomy', code: 'K511', system: 'MHLW', operationElement: [operation_element_item], procedureMemo: 'off pump')}
9
+ let(:staff_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '00123')}
10
+ let(:staff_name) {MML::Name.new(repCode: 'A', fullname: 'Hiroyuki Yoshihara')}
11
+ let(:staff_info) {MML::PersonalizedInfo.new(id: staff_id, personName: [staff_name])}
12
+ let(:staff) {MML::SurgicalStaff.new(staffClass: 'assistant', superiority: 1, staffInfo: staff_info)}
13
+ let(:anesthesia_procedure){MML::AnesthesiaProcedure.new(title: 'general anesthesia', code: 'L002', system: 'MHLW')}
14
+ let(:anesthesiologist_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '00123')}
15
+ let(:anesthesiologist_name) {MML::Name.new(repCode: 'A', fullname: 'Kenji ARAKI')}
16
+ let(:anesthesiologist_info) {MML::PersonalizedInfo.new(id: staff_id, personName: [anesthesiologist_name])}
17
+ let(:anesthesiologist) {MML::Anesthesiologist.new(staffClass: 'main anesthesiologist', superiority: 1, staffInfo: anesthesiologist_info)}
18
+ let(:ext_ref) {MML::ExtRef.new(contentType: 'image/gif', medicalRole: 'surgicalFigure', title: 'skin incision', href: 'patient001/surgicalFigure001.gif')}
19
+ let(:surgery_item) {MML::SurgeryItem.new(type: 'elective', date: '2013-12-10', startTime: '08:30', duration: 'PT5H25M', surgicalDepartment: surgical_department, patientDepartment: patient_department, surgicalDiagnosis: [registered_diagnosis], surgicalProcedure: [procedure_item], surgicalStaffs: [staff],anesthesiaProcedure: [anesthesia_procedure], anesthesiologists: [anesthesiologist], anesthesiaDuration: 'PT6H25M', operativeNotes: 'Total bleeding: 380ml', referenceInfo: [ext_ref], memo: 'This operation was well performed.')}
20
+
21
+ it 'is an instance of MML::SurgicalItem' do
22
+ expect(surgery_item).to be_an_instance_of MML::SurgeryItem
23
+ end
24
+
25
+ it 'type should be assigned properly' do
26
+ expect(surgery_item.type).to eq 'elective'
27
+ end
28
+
29
+ it 'type is optional' do
30
+ expect {surgery_item.type = nil}.not_to raise_error
31
+ end
32
+
33
+ it 'date should be assigned properly' do
34
+ expect(surgery_item.date).to eq '2013-12-10'
35
+ end
36
+
37
+ it 'data is mandatory' do
38
+ expect{surgery_item.date = nil}.to raise_error ArgumentError
39
+ end
40
+
41
+ it 'startTime should be assigned properly' do
42
+ expect(surgery_item.startTime).to eq '08:30'
43
+ end
44
+
45
+ it 'startTime should be assigned properly' do
46
+ expect {surgery_item.startTime = nil}.not_to raise_error
47
+ end
48
+
49
+ it 'duration should be assigned properly' do
50
+ expect(surgery_item.duration).to eq 'PT5H25M'
51
+ end
52
+
53
+ it 'duration is optional' do
54
+ expect {surgery_item.duration = nil}.not_to raise_error
55
+ end
56
+
57
+ it 'surgicalDepartment should be assigned properly' do
58
+ expect(surgery_item.surgicalDepartment.name[0].value).to eq 'Cardiovascular surgery'
59
+ end
60
+
61
+ it 'surgicalDepartment is optional' do
62
+ expect {surgery_item.surgicalDepartment = nil}.not_to raise_error
63
+ end
64
+
65
+ it 'patientDepartment should be assigned properly' do
66
+ expect(surgery_item.patientDepartment.name[0].value).to eq 'Internal medicine'
67
+ end
68
+
69
+ it 'patientDepartment is optional' do
70
+ expect {surgery_item.patientDepartment = nil}.not_to raise_error
71
+ end
72
+
73
+ it 'surgicalDiagnosis should be assigned properly' do
74
+ expect(surgery_item.surgicalDiagnosis[0].diagnosis).to eq 'Lung cancer'
75
+ end
76
+
77
+ it 'surgicalDiagnosis is mandatory' do
78
+ expect {surgery_item.surgicalDiagnosis = nil}.to raise_error ArgumentError
79
+ end
80
+
81
+ it 'surgicalProcedure is properly assigned' do
82
+ expect(surgery_item.surgicalProcedure[0].operation).to eq 'right lobectomy'
83
+ end
84
+
85
+ it 'surgicalStaffs should be assigned properly' do
86
+ expect(surgery_item.surgicalStaffs[0].staffClass).to eq 'assistant'
87
+ end
88
+
89
+ it 'anesthesiaProcedure should be assigned properly' do
90
+ expect(surgery_item.anesthesiaProcedure[0].title).to eq 'general anesthesia'
91
+ end
92
+
93
+ it 'anesthesiologists should be assigned properly' do
94
+ expect(surgery_item.anesthesiologists[0].staffInfo.personName[0].fullname).to eq 'Kenji ARAKI'
95
+ end
96
+
97
+ it 'anesthesiologists is optional' do
98
+ expect {surgery_item.anesthesiologists = nil}.not_to raise_error
99
+ end
100
+
101
+ it 'anesthesiaDuration should be assigned properly' do
102
+ expect(surgery_item.anesthesiaDuration).to eq 'PT6H25M'
103
+ end
104
+
105
+ it 'anesthesiaDuration is optional' do
106
+ expect {surgery_item.anesthesiaDuration}.not_to raise_error
107
+ end
108
+
109
+ it 'operativeNotes should be assigned properly' do
110
+ expect(surgery_item.operativeNotes).to eq 'Total bleeding: 380ml'
111
+ end
112
+
113
+ it 'operativeNotes is optional' do
114
+ expect {surgery_item.operativeNotes = nil}.not_to raise_error
115
+ end
116
+
117
+ it 'referenceInfo should be assigned properly' do
118
+ expect(surgery_item.referenceInfo[0].title).to eq 'skin incision'
119
+ end
120
+
121
+ it 'referenceInfo is optional' do
122
+ expect {surgery_item.referenceInfo = nil}.not_to raise_error
123
+ end
124
+
125
+ it 'memo should be assigned properly' do
126
+ expect(surgery_item.memo).to eq 'This operation was well performed.'
127
+ end
128
+
129
+ it 'memo is optional' do
130
+ expect {surgery_item.memo = nil}.not_to raise_error
131
+ end
132
+ end