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
@@ -13,4 +13,11 @@ describe MML::CreatorLicense do
13
13
  it 'value should be doctor' do
14
14
  expect(creator_license.value).to eq 'doctor'
15
15
  end
16
+
17
+ describe "#to_xml" do
18
+ subject {creator_license.to_xml}
19
+
20
+ it {should match '<mmlCi:creatorLicense mmlCi:tableId="MML0026">'}
21
+ it {should match '>doctor</mmlCi:creatorLicense>'}
22
+ end
16
23
  end
@@ -0,0 +1,11 @@
1
+ describe MML::Death do
2
+ let(:death) {MML::Death.new(flag: true, date: '2013-11-21')}
3
+
4
+ it 'flag should be assigned properly' do
5
+ expect(death.flag).to be_true
6
+ end
7
+
8
+ it 'date should be assigned properly' do
9
+ expect(death.date).to eq '2013-11-21'
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ describe MML::DeathInfo do
2
+ let(:death_info) {MML::DeathInfo.new(date: '2013-08-31', autopsy: true, value: 'The patient died of gastric cancer.')}
3
+
4
+ it 'is an instance of MML::DeathInfo' do
5
+ expect(death_info).to be_an_instance_of MML::DeathInfo
6
+ end
7
+
8
+ it 'date should be assigned properly' do
9
+ expect(death_info.date).to eq '2013-08-31'
10
+ end
11
+
12
+ it 'autopsy should be assgined properly' do
13
+ expect(death_info.autopsy).to be_true
14
+ end
15
+
16
+ it 'value should be assigned properly' do
17
+ expect(death_info.value).to eq 'The patient died of gastric cancer.'
18
+ end
19
+ end
@@ -18,9 +18,9 @@ describe MML::Department do
18
18
  expect {department.name = nil}.to raise_error ArgumentError
19
19
  end
20
20
 
21
- it 'name should not be empty' do
22
- expect {department.name = []}.to raise_error ArgumentError
23
- end
21
+ # it 'name should not be empty' do
22
+ # expect {department.name = []}.to raise_error ArgumentError
23
+ # end
24
24
  end
25
25
 
26
26
  it 'id should be properyl assigned' do
@@ -0,0 +1,23 @@
1
+ describe MML::DiagnosticCategory do
2
+ let(:diagnostic_category) {MML::DiagnosticCategory.new(value: 'mainDiagnosis', tableId: 'MML0012')}
3
+
4
+ it 'is an instance of DiagnosticCategory' do
5
+ expect(diagnostic_category).to be_an_instance_of MML::DiagnosticCategory
6
+ end
7
+
8
+ it 'value should be assigned properly' do
9
+ expect(diagnostic_category.value).to eq 'mainDiagnosis'
10
+ end
11
+
12
+ it 'value is mandatory' do
13
+ expect{diagnostic_category.value = nil}.to raise_error ArgumentError
14
+ end
15
+
16
+ it 'tableId should be assigned properly' do
17
+ expect(diagnostic_category.tableId).to eq 'MML0012'
18
+ end
19
+
20
+ it 'tableId is mandatory' do
21
+ expect{diagnostic_category.tableId = nil}.to raise_error ArgumentError
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ describe MML::Discharge do
2
+ let(:refer_to_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '55234567')}
3
+ let(:refer_to_name) {MML::Name.new(repCode: 'A', tableId: 'MML0025', family: 'Tanaka', given: 'Fujiko', degree: 'M.D.')}
4
+ let(:refer_to_facility_name) {MML::FacilityName.new(repCode: 'A', tableId: 'MML0025', value: 'New Millenium Heisei Hospital')}
5
+ let(:refer_to_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '32354678')}
6
+ let(:refer_to_facility) {MML::Facility.new(id: refer_to_facility_id, name: [refer_to_facility_name])}
7
+ let(:refer_to) {MML::PersonalizedInfo.new(id: refer_to_id, personName: [refer_to_name], facility: refer_to_facility)}
8
+ 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)}
9
+
10
+ it 'is an instance of MML::Discharge' do
11
+ expect(discharge).to be_an_instance_of MML::Discharge
12
+ end
13
+
14
+ it 'date should be assigned properly' do
15
+ expect(discharge.date).to eq '2013-08-31'
16
+ end
17
+
18
+ it 'dischargeCondition should be assigned properly' do
19
+ expect(discharge.dischargeCondition).to eq '4 P.O.D, the patient was transferred to the chronic hospital.'
20
+ end
21
+
22
+ it 'outcome should be assigned properly' do
23
+ expect(discharge.outcome).to eq 'transferChronic'
24
+ end
25
+
26
+ it 'referTo should be assigned properly' do
27
+ expect(discharge.referTo.personName[0].family).to eq 'Tanaka'
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ describe MML::DxItem do
2
+ let(:dx_item) {MML::DxItem.new(name: 'atrial fibrilation', code: 'I48', system: 'ICD10')}
3
+
4
+ it 'is an instance of MML::DxItem' do
5
+ expect(dx_item).to be_an_instance_of MML::DxItem
6
+ end
7
+
8
+ it 'name should be assigned properly' do
9
+ expect(dx_item.name).to eq 'atrial fibrilation'
10
+ end
11
+
12
+ it 'code should be assigned properly' do
13
+ expect(dx_item.code).to eq 'I48'
14
+ end
15
+
16
+ it 'system should be assigned properly' do
17
+ expect(dx_item.system).to eq 'ICD10'
18
+ end
19
+ end
@@ -0,0 +1,36 @@
1
+ describe MML::FamilyHistoryItem do
2
+ let(:registered_diagnosis) {MML::RegisteredDiagnosis.new(diagnosis: 'gastric cancer', code: 'C169-.007', system: 'ICD10', endDate: '1989-08-25', outcome: 'died')}
3
+ let(:family_history_item) {MML::FamilyHistoryItem.new(relation: 'motherInLaw', registeredDiagnosis: registered_diagnosis, age: 'P40Y', memo: 'scirrhous type')}
4
+
5
+ it 'is an instance of MML::FamilyHistoryItem' do
6
+ expect(family_history_item).to be_an_instance_of MML::FamilyHistoryItem
7
+ end
8
+
9
+ it 'relation should be assigned properly' do
10
+ expect(family_history_item.relation).to eq 'motherInLaw'
11
+ end
12
+
13
+ it 'relation is mandatory' do
14
+ expect {family_history_item.relation = nil}.to raise_error ArgumentError
15
+ end
16
+
17
+ it 'regsiteredDiagnosis should be assigned properly' do
18
+ expect(family_history_item.registeredDiagnosis.diagnosis).to eq 'gastric cancer'
19
+ end
20
+
21
+ it 'registeredDiagnosis is mandatory' do
22
+ expect {family_history_item.registeredDiagnosis = nil}.to raise_error ArgumentError
23
+ end
24
+
25
+ it 'age should be assigned properly' do
26
+ expect(family_history_item.age).to eq 'P40Y'
27
+ end
28
+
29
+ it 'age is optional' do
30
+ expect {family_history_item.age = nil}.not_to raise_error
31
+ end
32
+
33
+ it 'memo should be assigned properly' do
34
+ expect(family_history_item.memo).to eq 'scirrhous type'
35
+ end
36
+ end
@@ -0,0 +1,105 @@
1
+ describe MML::FirstClinic do
2
+ let(:registered_diagnosis) {MML::RegisteredDiagnosis.new(diagnosis: 'gastric cancer', code: 'C169-.007', system: 'ICD10', endDate: '1989-08-25', outcome: 'died')}
3
+ let(:family_history_item) {MML::FamilyHistoryItem.new(relation: 'motherInLaw', registeredDiagnosis: registered_diagnosis, age: 'P40Y', memo: 'scirrhous type')}
4
+ let(:id) { MML::Id.new(value: '12345', type: 'facility', tableId: 'MML0024', checkDigit: 5, checkDigitSchema: 'MML0001') }
5
+ let(:name) { MML::FacilityName.new(value: 'New Millenium Medical College Hospital', repCode: 'A', tableId: 'MML0025') }
6
+ let(:facility) { MML::Facility.new(name: [name], id: id) }
7
+ let(:birth_info) {MML::BirthInfo.new(facility: facility, deliveryWeeks: 'P38W', deliveryMethod: 'cesarean section', bodyWeight: 3370, bodyWeightUnit: 'g', bodyHeight: 50, bodyHeightUnit: 'cm', chestCircumference: 31.1, chestCircumferenceUnit: 'cm', headCircumference: 32.8, headCircumferenceUnit: 'cm', memo: 'intact')}
8
+ let(:vaccination_item1) {MML::VaccinationItem.new(vaccine: 'polio', injected: true, age: 'P6M', memo: 'first administration')}
9
+ let(:vaccination_item2) {MML::VaccinationItem.new(vaccine: 'flu', injected: false, age: 'P1M', memo: 'second administration')}
10
+ let(:past_history_item1) {MML::PastHistoryItem.new(timeExpression: '6 years old', eventExpression: ['appendectomy'])}
11
+ let(:past_history_item2) {MML::PastHistoryItem.new(timeExpression: '5 years ago', eventExpression: ['hypertension'])}
12
+ let(:past_history) {MML::PastHistory.new(freeNote: 'Appendectomy (6 years old), hypertension (5 years ago)', pastHistoryItem: [past_history_item1, past_history_item2])}
13
+ let(:first_clinic) {MML::FirstClinic.new(familyHistory: [family_history_item], birthInfo: birth_info, vaccination: [vaccination_item1, vaccination_item2],pastHistory: past_history, chiefComplaints: 'fever', presentIllnessNotes: 'fever up from 2 days ago, nasal discharge from 1day ago, sore throat, today.')}
14
+
15
+ it 'is an instance of MML::FirstClinc' do
16
+ expect(first_clinic).to be_an_instance_of MML::FirstClinic
17
+ end
18
+
19
+ it 'familyHistory should be recorded properly' do
20
+ expect(first_clinic.familyHistory[0].registeredDiagnosis.code).to eq 'C169-.007'
21
+ end
22
+
23
+ it 'familyHistory is optional' do
24
+ expect {first_clinic.familyHistory = nil}.not_to raise_error
25
+ end
26
+
27
+ it 'birthInfo should be assigned properly' do
28
+ expect(first_clinic.birthInfo.bodyWeight).to eq 3370
29
+ end
30
+
31
+ it 'birthInfo is optional' do
32
+ expect {first_clinic.birthInfo = nil}.not_to raise_error
33
+ end
34
+
35
+ it 'vaccination should be assigned properly' do
36
+ expect(first_clinic.vaccination[1].vaccine).to eq 'flu'
37
+ end
38
+
39
+ it 'vaccination is optional' do
40
+ expect {first_clinic.vaccination = nil}.not_to raise_error
41
+ end
42
+
43
+ it 'pastHistory should be assigned properly' do
44
+ expect(first_clinic.pastHistory.freeNote).to eq 'Appendectomy (6 years old), hypertension (5 years ago)'
45
+ end
46
+
47
+ it 'pastHistory is optional' do
48
+ expect {first_clinic.pastHistory = nil}.not_to raise_error
49
+ end
50
+
51
+ it 'chiefComplaints should be assigned properly' do
52
+ expect(first_clinic.chiefComplaints).to eq 'fever'
53
+ end
54
+
55
+ it 'chiefComplaints is optional' do
56
+ expect {first_clinic.chiefComplaints = nil}.not_to raise_error
57
+ end
58
+
59
+ it 'presentIllnessNotes should be assigned properly' do
60
+ expect(first_clinic.presentIllnessNotes).to eq 'fever up from 2 days ago, nasal discharge from 1day ago, sore throat, today.'
61
+ end
62
+
63
+ it 'presentIllnessNotes is optional' do
64
+ expect {first_clinic.presentIllnessNotes = nil}.not_to raise_error
65
+ end
66
+
67
+ describe '#to_xml' do
68
+ subject {first_clinic.to_xml}
69
+
70
+ it {should match '<mmlFcl:FirstClinicModule>'}
71
+ it {should match '<mmlFcl:familyHistory>'}
72
+ it {should match '<mmlFcl:familyHistoryItem>'}
73
+ it {should match '<mmlFcl:relation>motherInLaw</mmlFcl:relation>'}
74
+ it {should match '<mmlRd:RegisteredDiagnosisModule>'}
75
+ it {should match '>gastric cancer</mmlRd:diagnosis>'}
76
+ it {should match '</mmlRd:RegisteredDiagnosisModule>'}
77
+ it {should match '<mmlFcl:age>P40Y</mmlFcl:age>'}
78
+ it {should match '<mmlFcl:memo>scirrhous type</mmlFcl:memo>'}
79
+ it {should match '</mmlFcl:familyHistoryItem>'}
80
+ it {should match '</mmlFcl:familyHistory>'}
81
+ it {should match '<mmlFcl:childhood><mmlFcl:birthInfo>'}
82
+ it {should match '<mmlFc:Facility'}
83
+ it {should match '>New Millenium Medical College Hospital</mmlFc:name>'}
84
+ it {should match '</mmlFc:Facility>'}
85
+ it {should match '<mmlFcl:deliveryWeeks>P38W</mmlFcl:deliveryWeeks>'}
86
+ it {should match '<mmlFcl:deliveryMethod>cesarean section</mmlFcl:deliveryMethod>'}
87
+ it {should match '<mmlFcl:bodyWeight mmlFcl:unit="g">3370</mmlFcl:bodyWeight>'}
88
+ it {should match '<mmlFcl:bodyHeight mmlFcl:unit="cm">50</mmlFcl:bodyHeight>'}
89
+ it {should match '<mmlFcl:chestCircumference mmlFcl:unit="cm">31.1</mmlFcl:chestCircumference>'}
90
+ it {should match '<mmlFcl:headCircumference mmlFcl:unit="cm">32.8</mmlFcl:headCircumference>'}
91
+ it {should match '<mmlFcl:memo>intact</mmlFcl:memo>'}
92
+ it {should match '</mmlFcl:birthInfo><mmlFcl:vaccination>'}
93
+ it {should match '<mmlFcl:vaccinationItem><mmlFcl:vaccine>polio</mmlFcl:vaccine><mmlFcl:injected>true</mmlFcl:injected><mmlFcl:age>P6M</mmlFcl:age><mmlFcl:memo>first administration</mmlFcl:memo></mmlFcl:vaccinationItem>'}
94
+ it {should match '<mmlFcl:vaccinationItem><mmlFcl:vaccine>flu</mmlFcl:vaccine><mmlFcl:injected>false</mmlFcl:injected><mmlFcl:age>P1M</mmlFcl:age><mmlFcl:memo>second administration</mmlFcl:memo></mmlFcl:vaccinationItem>'}
95
+ it {should match '</mmlFcl:vaccination></mmlFcl:childhood>'}
96
+ it {should match '<mmlFcl:pastHistory>'}
97
+ it {should match '<mmlFcl:freeNote>Appendectomy \(6 years old\), hypertension \(5 years ago\)</mmlFcl:freeNote>'}
98
+ it {should match '<mmlFcl:pastHistoryItem><mmlFcl:timeExpression>6 years old</mmlFcl:timeExpression><mmlFcl:eventExpression>appendectomy</mmlFcl:eventExpression>'}
99
+ it {should match '<mmlFcl:pastHistoryItem><mmlFcl:timeExpression>5 years ago</mmlFcl:timeExpression><mmlFcl:eventExpression>hypertension</mmlFcl:eventExpression>'}
100
+ it {should match '</mmlFcl:pastHistory>'}
101
+ it {should match '<mmlFcl:chiefComplaints>fever</mmlFcl:chiefComplaints>'}
102
+ it {should match '<mmlFcl:presentIllnessNotes>fever up from 2 days ago, nasal discharge from 1day ago, sore throat, today.</mmlFcl:presentIllnessNotes>'}
103
+ it {should match '</mmlFcl:FirstClinicModule>'}
104
+ end
105
+ end
@@ -0,0 +1,39 @@
1
+ describe MML::InfectionItem do
2
+ let(:infection_item) {MML::InfectionItem.new(factor: 'Influenza', examValue: 'A+B-', identifiedDate: '2013-12-03', memo: 'drug resistance(-)')}
3
+
4
+ it 'is an instance of MML::InfectionItem' do
5
+ expect(infection_item).to be_an_instance_of MML::InfectionItem
6
+ end
7
+
8
+ it 'factor should be assigned properly' do
9
+ expect(infection_item.factor).to eq 'Influenza'
10
+ end
11
+
12
+ it 'factor is mandatory' do
13
+ expect {infection_item.factor = nil}.to raise_error ArgumentError
14
+ end
15
+
16
+ it 'examValue should be assigned properly' do
17
+ expect(infection_item.examValue).to eq 'A+B-'
18
+ end
19
+
20
+ it 'examValue is mandatory' do
21
+ expect {infection_item.examValue = nil}.to raise_error ArgumentError
22
+ end
23
+
24
+ it 'identifiedDate should be assigned properly' do
25
+ expect(infection_item.identifiedDate).to eq '2013-12-03'
26
+ end
27
+
28
+ it 'identifiedDate is optional' do
29
+ expect {infection_item.identifiedDate = nil}.not_to raise_error
30
+ end
31
+
32
+ it 'memo should be assigned properly' do
33
+ expect(infection_item.memo).to eq 'drug resistance(-)'
34
+ end
35
+
36
+ it 'memo is optional' do
37
+ expect {infection_item.memo = nil}.not_to raise_error
38
+ end
39
+ end
@@ -0,0 +1,49 @@
1
+ describe MML::InpatientItem do
2
+ let(:referer_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '23234567')}
3
+ let(:referer_name) {MML::Name.new(repCode: 'A', tableId: 'MML0025', family: 'Ono', given: 'Yoko', degree: 'M.D.')}
4
+ let(:referer_facility_name) {MML::FacilityName.new(repCode: 'A', tableId: 'MML0025', value: 'New Millenium Medical College Hospital')}
5
+ let(:referer_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '801.006.3')}
6
+ let(:referer_facility) {MML::Facility.new(id: referer_facility_id, name: [referer_facility_name])}
7
+ let(:referer) {MML::PersonalizedInfo.new(id: referer_id, personName: [referer_name], facility: referer_facility)}
8
+ let(:admission) {MML::Admission.new(date: '2013-12-08', admissionCondition: 'Emergency admission by ambulance', emergency: true, referFrom: referer)}
9
+
10
+ let(:refer_to_id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '55234567')}
11
+ let(:refer_to_name) {MML::Name.new(repCode: 'A', tableId: 'MML0025', family: 'Tanaka', given: 'Fujiko', degree: 'M.D.')}
12
+ let(:refer_to_facility_name) {MML::FacilityName.new(repCode: 'A', tableId: 'MML0025', value: 'New Millenium Heisei Hospital')}
13
+ let(:refer_to_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '32354678')}
14
+ let(:refer_to_facility) {MML::Facility.new(id: refer_to_facility_id, name: [refer_to_facility_name])}
15
+ let(:refer_to) {MML::PersonalizedInfo.new(id: refer_to_id, personName: [refer_to_name], facility: refer_to_facility)}
16
+ 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)}
17
+
18
+ let(:id) {MML::Id.new(type: 'facility', tableId: 'MML0024', value: '23456789')}
19
+ let(:name) {MML::Name.new(repCode: 'A', fullname: 'Kenji Araki')}
20
+ let(:personalized_info) {MML::PersonalizedInfo.new(id: id, personName: [name])}
21
+ let(:creator_license) { MML::CreatorLicense.new(tableId: 'MML0026', value: 'doctor')}
22
+ let(:staff_info) {MML::StaffInfo.new(personalizedInfo: personalized_info, creatorLicense: [creator_license])}
23
+
24
+ let(:inpatient_item) {MML::InpatientItem.new(admission: admission, discharge: discharge, staffs: [staff_info])}
25
+
26
+ it 'is an instance of MML::InpatientItem' do
27
+ expect(inpatient_item).to be_an_instance_of MML::InpatientItem
28
+ end
29
+
30
+ it 'admission should be assigned properly' do
31
+ expect(inpatient_item.admission.date).to eq '2013-12-08'
32
+ end
33
+
34
+ it 'admission is mandatory' do
35
+ expect {inpatient_item.admission = nil}.to raise_error ArgumentError
36
+ end
37
+
38
+ it 'discharge should be assigned properly' do
39
+ expect(inpatient_item.discharge.outcome).to eq 'transferChronic'
40
+ end
41
+
42
+ it 'discharge is mandatory' do
43
+ expect {inpatient_item.discharge = nil}.to raise_error ArgumentError
44
+ end
45
+
46
+ it 'staffs should be assigned properly' do
47
+ expect(inpatient_item.staffs[0].personalizedInfo.personName[0].fullname).to eq 'Kenji Araki'
48
+ end
49
+ end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ describe MML::InsuranceClass do
3
+ let(:insurance_class) { MML::InsuranceClass.new(classCode: '01', tableId: 'MML0031', value: '国保') }
4
+
5
+ it 'is an instance of MML::InsuranceClass' do
6
+ expect(insurance_class).to be_an_instance_of MML::InsuranceClass
7
+ end
8
+
9
+ it 'value should be assigned properly' do
10
+ expect(insurance_class.value).to eq '国保'
11
+ end
12
+
13
+ it 'value is mandatory' do
14
+ expect {insurance_class.value = nil}.to raise_error ArgumentError
15
+ end
16
+
17
+ it 'classCode should be assigned properly' do
18
+ expect(insurance_class.classCode).to eq '01'
19
+ end
20
+
21
+ it 'tableId should be assigned properly' do
22
+ expect(insurance_class.tableId).to eq 'MML0031'
23
+ end
24
+ end
@@ -0,0 +1,36 @@
1
+ describe MML::InsuranceClient do
2
+
3
+ let(:name) { MML::Name.new(repCode: 'A', fullname: 'Shinji KOBAYASHI')}
4
+ let(:address) { MML::Address.new(repCode: 'A', addressClass: 'business', tableId: 'MML0025', full: '506, Dept. 9, Kyoto Research Park (KRP), Awata-cho 91, Chudoji, Shimogyo-ku, Kyoto-city')}
5
+ let(:phone) { MML::Phone.new(telEquipType: 'PH', area: '075', city: '874', number: '7030') }
6
+
7
+ let(:insurance_client) {MML::InsuranceClient.new(personName: [name], addresses: [address], phones: [phone])}
8
+
9
+ it 'is an instance of MML::InsuranceClient' do
10
+ expect(insurance_client).to be_an_instance_of MML::InsuranceClient
11
+ end
12
+
13
+ it 'personName should be assigned properly' do
14
+ expect(insurance_client.personName[0].fullname).to eq 'Shinji KOBAYASHI'
15
+ end
16
+
17
+ it 'personName is optional' do
18
+ expect {insurance_client.personName = nil}.not_to raise_error
19
+ end
20
+
21
+ it 'addresses should be assigned properly' do
22
+ expect(insurance_client.addresses[0].addressClass).to eq 'business'
23
+ end
24
+
25
+ it 'addresses is optional' do
26
+ expect {insurance_client.addresses = nil}.not_to raise_error
27
+ end
28
+
29
+ it 'phones should be properly assigned' do
30
+ expect(insurance_client.phones[0].city).to eq '874'
31
+ end
32
+
33
+ it 'phones is optional' do
34
+ expect{insurance_client.phones = nil}.not_to raise_error
35
+ end
36
+ end
@@ -0,0 +1,182 @@
1
+ # -*- coding: utf-8 -*-
2
+ describe MML::Insurance do
3
+ let(:insurance_class) { MML::InsuranceClass.new(classCode: '01', tableId: 'MML0031', value: '国保') }
4
+ let(:master_id) { MML::Id.new(value: '0001', type: 'facility', repCode: 'A', tableId: 'MML0024') }
5
+ let(:name) { MML::Name.new(repCode: 'A', fullname: 'Shinji KOBAYASHI')}
6
+ let(:address) { MML::Address.new(repCode: 'A', addressClass: 'business', tableId: 'MML0025', full: '506, Dept. 9, Kyoto Research Park (KRP), Awata-cho 91, Chudoji, Shimogyo-ku, Kyoto-city')}
7
+ let(:phone) { MML::Phone.new(telEquipType: 'PH', area: '075', city: '874', number: '7030') }
8
+ let(:client) {MML::InsuranceClient.new(personName: [name], addresses: [address], phones: [phone])}
9
+ let(:insured_facility_id) {MML::Id.new(type: 'insurance', tableId: 'MML0027', value: '12345')}
10
+ let(:insured_facility_name) {MML::FacilityName.new(repCode: 'A', value: '宮崎市広域連合')}
11
+ let(:insured_facility_address) { MML::Address.new(repCode: 'A', prefecture: 'Miyazaki')}
12
+ let(:insured_facility_phone) {MML::Phone.new(telEquipType: 'PH', full: '075-123-4567')}
13
+ let(:insured_facility) {MML::Facility.new(id: insured_facility_id, name: [insured_facility_name])}
14
+ let(:insured_info) {MML::OrganizationInfo.new(facility: insured_facility, addresses: [insured_facility_address], phones: [insured_facility_phone])}
15
+ let(:work_facility_name) {MML::FacilityName.new(repCode: 'A', value: 'Miyazaki Univ.')}
16
+ let(:work_facility_id) {MML::Id.new(type: 'business', tableId: 'MML0027', value: '56789')}
17
+ let(:work_facility) {MML::Facility.new(id: work_facility_id, name: [work_facility_name])}
18
+ let(:work_address) {MML::Address.new(repCode: 'A', town: 'Kiyotake-cho')}
19
+ let(:work_phone) {MML::Phone.new(telEquipType: 'PH', area: '0985')}
20
+ let(:work_info) {MML::OrganizationInfo.new(facility: work_facility, addresses: [work_address], phones: [work_phone])}
21
+ let(:public_insurance_item) {MML::PublicInsuranceItem.new(priority: '1', providerName: '公費', provider: '15450034', recipient: '0009043', startDate: '1997-09-30', expiredDate: '1999-09-30', paymentRatio: 10_000, ratioType: 'fix')}
22
+ let(:insurance) { MML::Insurance.new(countryType: 'JPN', insuranceClass: insurance_class, insuranceNumber: '8001', group: '宮市みへし', number: '421', familyClass: false, clientInfo: client, continuedDiseases: ['diabetes mellitus'], startDate: '2013-10-01', expiredDate: '2018-03-31', paymentInRatio: 0.2, paymentOutRatio: 0.3, insuredInfo: insured_info, workInfo: work_info, publicInsurance: [public_insurance_item]) }
23
+
24
+ it 'should be an instance of MML::Insurance' do
25
+ expect(insurance).to be_an_instance_of MML::Insurance
26
+ end
27
+
28
+ it 'country type should be assigned properly' do
29
+ expect(insurance.countryType).to eq 'JPN'
30
+ end
31
+
32
+ it 'insuranceClass should be assigned properly' do
33
+ expect(insurance.insuranceClass.value).to eq '国保'
34
+ end
35
+
36
+ it 'insuranceNumber should be assigned properly' do
37
+ expect(insurance.insuranceNumber).to eq '8001'
38
+ end
39
+
40
+ it 'group should be assigned properly' do
41
+ expect(insurance.group).to eq '宮市みへし'
42
+ end
43
+
44
+ it 'group is mandatory' do
45
+ expect {insurance.group = nil}.to raise_error ArgumentError
46
+ end
47
+
48
+ it 'number should be assigned properly' do
49
+ expect(insurance.number).to eq '421'
50
+ end
51
+
52
+ it 'family class should be assigned properly' do
53
+ expect(insurance.familyClass).to be_false
54
+ end
55
+
56
+ it 'family class is mandatory' do
57
+ expect {insurance.familyClass = nil }.to raise_error ArgumentError
58
+ end
59
+
60
+ it 'clientInfo should be assigned properly' do
61
+ expect(insurance.clientInfo.personName[0].fullname).to eq 'Shinji KOBAYASHI'
62
+ end
63
+
64
+ it 'clientInfo is optional' do
65
+ expect{insurance.clientInfo = nil}.not_to raise_error
66
+ end
67
+
68
+ it 'continuedDiseases should be assigned properly' do
69
+ expect(insurance.continuedDiseases[0]).to eq 'diabetes mellitus'
70
+ end
71
+
72
+ it 'continuedDiseases is optional' do
73
+ expect{insurance.continuedDiseases = nil}.not_to raise_error
74
+ end
75
+
76
+ it 'startDate should be assigned properly' do
77
+ expect(insurance.startDate).to eq '2013-10-01'
78
+ end
79
+
80
+ it 'startDate is mandatory' do
81
+ expect{insurance.startDate = nil}.to raise_error ArgumentError
82
+ end
83
+
84
+ it 'expiredDate should be assigned properly' do
85
+ expect(insurance.expiredDate).to eq '2018-03-31'
86
+ end
87
+
88
+ it 'expiredDate is mandatory' do
89
+ expect{insurance.expiredDate = nil}.to raise_error ArgumentError
90
+ end
91
+
92
+ it 'paymentInRatio should be assigned properly' do
93
+ expect(insurance.paymentInRatio).to eq 0.2
94
+ end
95
+
96
+ it 'paymentOutRatio should be assigned properly' do
97
+ expect(insurance.paymentOutRatio).to eq 0.3
98
+ end
99
+
100
+ it 'insured info should be assigned properly' do
101
+ expect(insurance.insuredInfo.facility.id.value).to eq '12345'
102
+ end
103
+
104
+ it 'work info should be assined properly' do
105
+ expect(insurance.workInfo.facility.id.value).to eq '56789'
106
+ end
107
+
108
+ it 'public insurance item should assigned properly' do
109
+ expect(insurance.publicInsurance[0].provider).to eq '15450034'
110
+ end
111
+
112
+ context '#to_xml' do
113
+ subject {insurance.to_xml}
114
+
115
+ it {should match '<mmlHi:HealthInsuranceModule'}
116
+ it {should match 'mmlHi:countryType="JPN">'}
117
+ it {should match '<mmlHi:insuranceClass'}
118
+ it {should match 'mmlHi:ClassCode="01"'}
119
+ it {should match 'mmlHi:tableId="MML0031"'}
120
+ it {should match '国保</mmlHi:insuranceClass>'}
121
+ it {should match '<mmlHi:insuranceNumber>8001</mmlHi:insuranceNumber>'}
122
+ it {should match '<mmlHi:clientId>'}
123
+ it {should match '<mmlHi:group>宮市みへし</mmlHi:group>'}
124
+ it {should match '<mmlHi:number>421</mmlHi:number>'}
125
+ it {should match '</mmlHi:clientId>'}
126
+ it {should match '<mmlHi:familyClass>false</mmlHi:familyClass>'}
127
+ it {should match '<mmlHi:clientInfo>'}
128
+ it {should match '<mmlHi:personName>'}
129
+ it {should match '<mmlNm:Name mmlNm:repCode="A">'}
130
+ it {should match '<mmlNm:fullname>Shinji KOBAYASHI</mmlNm:fullname>'}
131
+ it {should match '</mmlNm:Name>'}
132
+ it {should match '</mmlHi:personName>'}
133
+ it {should match '<mmlHi:addresses>'}
134
+ it {should match '<mmlAd:Address'}
135
+ it {should match 'mmlAd:addressClass="business"'}
136
+ it {should match '<mmlAd:full>506, Dept. 9'}
137
+ it {should match '</mmlAd:Address>'}
138
+ it {should match '</mmlHi:addresses>'}
139
+ it {should match '<mmlHi:phones>'}
140
+ it {should match '<mmlPh:area>075</mmlPh:area>'}
141
+ it {should match '</mmlHi:phones>'}
142
+ it {should match '</mmlHi:clientInfo>'}
143
+ it {should match '<mmlHi:continuedDiseases>'}
144
+ it {should match '<mmlHi:disease>diabetes mellitus</mmlHi:disease>'}
145
+ it {should match '</mmlHi:continuedDiseases>'}
146
+ it {should match '<mmlHi:startDate>2013-10-01</mmlHi:startDate>'}
147
+ it {should match '<mmlHi:expiredDate>2018-03-31</mmlHi:expiredDate>'}
148
+ it {should match '<mmlHi:paymentInRatio>0.2</mmlHi:paymentInRatio>'}
149
+ it {should match '<mmlHi:paymentOutRatio>0.3</mmlHi:paymentOutRatio>'}
150
+ it {should match '<mmlHi:insuredInfo>'}
151
+ it {should match '<mmlHi:facility>'}
152
+ it {should match '<mmlFc:Facility>'}
153
+ it {should match '<mmlFc:name mmlFc:repCode="A">宮崎市広域連合</mmlFc:name>'}
154
+ it {should match '</mmlFc:Facility>'}
155
+ it {should match '</mmlHi:facility>'}
156
+ it {should match '<mmlHi:addresses>'}
157
+ it {should match '<mmlAd:prefecture>Miyazaki</mmlAd:prefecture>'}
158
+ it {should match '</mmlHi:addresses>'}
159
+ it {should match '<mmlHi:phones>'}
160
+ it {should match '<mmlPh:full>075-123-4567</mmlPh:full>'}
161
+ it {should match '</mmlHi:phones>'}
162
+ it {should match '</mmlHi:insuredInfo>'}
163
+ it {should match '<mmlHi:workInfo><mmlHi:facility>'}
164
+ it {should match '<mmlFc:name mmlFc:repCode="A">Miyazaki Univ.</mmlFc:name>'}
165
+ it {should match '<mmlHi:addresses><mmlAd:Address'}
166
+ it {should match '<mmlAd:town>Kiyotake-cho</mmlAd:town>'}
167
+ it {should match '</mmlAd:Address></mmlHi:addresses'}
168
+ it {should match '<mmlHi:phones><mmlPh:Phone mmlPh:telEquipType="PH"><mmlPh:area>0985</mmlPh:area></mmlPh:Phone></mmlHi:phones>'}
169
+ it {should match '</mmlHi:workInfo>'}
170
+ it {should match '<mmlHi:publicInsurance>'}
171
+ it {should match '<mmlHi:publicInsuranceItem mmlHi:priority="1">'}
172
+ it {should match '<mmlHi:providerName>公費</mmlHi:providerName>'}
173
+ it {should match '<mmlHi:provider>15450034</mmlHi:provider'}
174
+ it {should match '<mmlHi:recipient>0009043</mmlHi:recipient>'}
175
+ it {should match '<mmlHi:startDate>1997-09-30</mmlHi:startDate>'}
176
+ it {should match '<mmlHi:expiredDate>1999-09-30</mmlHi:expiredDate>'}
177
+ it {should match '<mmlHi:paymentRatio mmlHi:ratioType="fix">10000</mmlHi:paymentRatio>'}
178
+ it {should match '</mmlHi:publicInsuranceItem>'}
179
+ it {should match '</mmlHi:publicInsurance>'}
180
+ it {should match '</mmlHi:HealthInsuranceModule>'}
181
+ end
182
+ end