ez7gen 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/ez7gen +6 -0
- data/lib/ez7gen.rb +23 -0
- data/lib/ez7gen/config/schema/2.4/2.4.HL7.xml +13904 -0
- data/lib/ez7gen/config/schema/2.4/VAZ2.4.HL7.xml +3085 -0
- data/lib/ez7gen/config/schema/2.4/added/coded-tables.xml +730 -0
- data/lib/ez7gen/config/schema/2.4/rules/2.4.HL7.yml +4 -0
- data/lib/ez7gen/config/schema/2.4/rules/VAZ2.4.HL7.yml +6 -0
- data/lib/ez7gen/config/schema/2.5/2.5.HL7.xml +10008 -0
- data/lib/ez7gen/config/schema/2.5/VAZ2.5.HL7.xml +7 -0
- data/lib/ez7gen/config/schema/2.5/added/coded-tables.xml +549 -0
- data/lib/ez7gen/config/schema/readme.txt +0 -0
- data/lib/ez7gen/config/templates/2.4/eiv table update-mfn_m01 20151201.xml +416 -0
- data/lib/ez7gen/config/templates/2.4/eiv table update-mfn_y01.xml +416 -0
- data/lib/ez7gen/config/templates/2.4/eiv-ec-MFN_X01_reg request 20160126.xml +659 -0
- data/lib/ez7gen/config/templates/2.4/examples/ADT_A60.txt +69 -0
- data/lib/ez7gen/config/templates/2.4/examples/eiv table update-mfn_m01 20151201.txt +21 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_dss_units-query_qbp_q13-qbp_q13.txt +26 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_ecs_procedures_query_qbp_q13-qbp_q13.txt +26 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_patient eligibility_response-rsp_k11-080714.txt +44 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_diagnosis_query_qbp_q11-qbp_q11.txt +21 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_diagnosis_response_rsp_k11-rsp_k11.txt +42 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_dss_units_response_rtb_k13-rtb_k13.txt +49 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_ecs_filer_request_dft_p03-dft_p03-080714.txt +31 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_ecs_filer_response_ack_p03-ack_p03.txt +21 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_esc_procedures_response_rtb_k13-rtb_k13.txt +40 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_patient_eclass_query_qbp_q11-qbp_q11.txt +21 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_patient_problems_query_qbp_q11-qbp_q11.txt +21 -0
- data/lib/ez7gen/config/templates/2.4/examples/mhvsm_standardhl7lib_patinet_problems_response_rsp_k11-rsp_k11.txt +33 -0
- data/lib/ez7gen/config/templates/2.4/examples/orur01rvbecv2.txt +31 -0
- data/lib/ez7gen/config/templates/2.4/examples/sqwm vitals-oru_ro1.txt +52 -0
- data/lib/ez7gen/config/templates/2.4/examples/vista sqwm-adt_a60.txt +40 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_dss_units_query_qbp_q13-qbp_q13.xml +312 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_ecs_procedures_query_qbp_q13-qbp_q13.xml +314 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_patient eligibility_response-rsp_k11-080714.xml +640 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_diagnosis_query_qbp_q11-qbp_q11.xml +284 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_diagnosis_response_rsp_k11-rsp_k11-rsp_k11.xml +563 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_dss_units_response_rtb_k13-rtb_k13-rtb_k13.xml +365 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_ecs_filer_request_dft_p03-dft_p03-080714.xml +2172 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_ecs_filer_response_ack_p03-ack_p03.xml +269 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_ecs_procedures_response_rtb_k13-rtb_k13-rtb_k13.xml +354 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_patient_eclass_query_qbp_q11-qbp_q11.xml +284 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_patient_problems_query_qbp_q11-qbp_q11.xml +282 -0
- data/lib/ez7gen/config/templates/2.4/mhvsm_standardhl7lib_patient_problems_response_rsp_k11-rsp_k11-rsp_k11.xml +565 -0
- data/lib/ez7gen/config/templates/2.4/orur01rvbecv2.xml +1529 -0
- data/lib/ez7gen/config/templates/2.4/sqwm vitals-oru_r01.xml +2975 -0
- data/lib/ez7gen/config/templates/2.4/vista sqwm-adt_a60.xml +1360 -0
- data/lib/ez7gen/message_factory.rb +142 -0
- data/lib/ez7gen/msg_error_handler.rb +33 -0
- data/lib/ez7gen/profile_parser.rb +321 -0
- data/lib/ez7gen/resources/properties-with-comments.yml +51 -0
- data/lib/ez7gen/resources/properties.yml +325 -0
- data/lib/ez7gen/service/2.4/dynamic_field_generator.rb +45 -0
- data/lib/ez7gen/service/2.4/field_generator.rb +1586 -0
- data/lib/ez7gen/service/2.5/field_generator.rb +75 -0
- data/lib/ez7gen/service/base_field_generator.rb +451 -0
- data/lib/ez7gen/service/segment_generator.rb +218 -0
- data/lib/ez7gen/service/segment_picker.rb +147 -0
- data/lib/ez7gen/service/template_generator.rb +213 -0
- data/lib/ez7gen/service/type_aware_field_generator.rb +1583 -0
- data/lib/ez7gen/service/utils.rb +75 -0
- data/lib/ez7gen/structure_parser.rb +331 -0
- data/lib/ez7gen/version.rb +38 -0
- data/test/Additional Tables with values_v1.1.txt +1653 -0
- data/test/added_shema_test.rb +143 -0
- data/test/app-tmp.rb +225 -0
- data/test/at.txt +1 -0
- data/test/backburner.zip +0 -0
- data/test/codes.txt +262 -0
- data/test/codes1.txt +1240 -0
- data/test/data_types_exploration_test.rb +213 -0
- data/test/dynamic_field_generated_test.rb +292 -0
- data/test/message_factory_24_custom_test.rb +648 -0
- data/test/message_factory_25_test.rb +50 -0
- data/test/message_factory_adm_test.rb +558 -0
- data/test/message_factory_gen_test.rb +63 -0
- data/test/message_factory_lab_test.rb +107 -0
- data/test/message_factory_pharm_test.rb +121 -0
- data/test/message_factory_template_24_test.rb +730 -0
- data/test/message_factory_test.rb +220 -0
- data/test/msg_error_handler_test.rb +59 -0
- data/test/profile_parser_test.rb +542 -0
- data/test/quick_run.rb +880 -0
- data/test/segment_generator_test.rb +656 -0
- data/test/segment_picker_test.rb +279 -0
- data/test/structrure_parser_test.rb +355 -0
- data/test/template_generator_test.rb +164 -0
- data/test/type_aware_field_generator_test.rb +582 -0
- data/test/utils_test.rb +97 -0
- metadata +215 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../lib/ez7gen/message_factory'
|
3
|
+
|
4
|
+
class MessageFactoryTest < Test::Unit::TestCase
|
5
|
+
# alias :orig_run :run
|
6
|
+
# def run(*args,&blk)
|
7
|
+
# 4.times { orig_run(*args,&blk) }
|
8
|
+
# end
|
9
|
+
|
10
|
+
#set to true to write messages to a file
|
11
|
+
@@PERSIST = true
|
12
|
+
|
13
|
+
@@VS =
|
14
|
+
[
|
15
|
+
# {:std=>"2.4", :path=>"../test/test-config/schema/2.4", :profiles=>[{:doc=>"2.4.HL7", :name=>"2.4", :std=>"1", :path=>"../test/test-config/schema/2.4/2.4.HL7.xml"}, {:doc=>"VAZ2.4.HL7", :name=>"VAZ2.4", :description=>"2.4 schema with VA defined tables and Z segments", :base=>"2.4", :path=>"../test/test-config/schema/2.4/VAZ2.4.HL7.xml.bkp"}]},
|
16
|
+
{:std=>"2.4", :path=>"../test/test-config/schema/2.4", :profiles=>[{:doc=>"2.4.HL7", :name=>"2.4", :std=>"1", :path=>"../test/test-config/schema/2.4/2.4.HL7.xml"}, {:doc=>"VAZ2.4.HL7", :name=>"VAZ2.4", :description=>"2.4 schema with VA defined tables and Z segments", :base=>"2.4", :path=>"../test/test-config/schema/2.4/VAZ2.4HL7.xml"}]},
|
17
|
+
{:std=>"2.5", :path=>"../test/test-config/schema/2.5", :profiles=>[{:doc=>"2.5.HL7", :name=>"2.5", :std=>"1", :path=>"../test/test-config/schema/2.5/2.5.HL7.xml"}, {:doc=>"TEST2.5.HL7", :name=>"TEST2.5", :description=>"2.5 mockup schema for testing", :base=>"2.4", :path=>"../test/test-config/schema/2.5/VAZ2.5.HL7.xml"}]}
|
18
|
+
]
|
19
|
+
|
20
|
+
|
21
|
+
# helper message to persist the
|
22
|
+
def saveMsg(event, hl7, ver)
|
23
|
+
if(defined?(@@PERSIST) && @@PERSIST) then
|
24
|
+
# File.open("../msg-samples/#{ver}/#{event}.txt", 'a') { |f| f.write(hl7); f.write("\n\n") }
|
25
|
+
File.write("../msg-samples/#{ver}/#{event}-#{Time.new.strftime('%H%M%S%L')}.txt", hl7);
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Called before every test method runs. Can be used
|
30
|
+
# to set up fixture information.
|
31
|
+
def setup
|
32
|
+
# Do nothing
|
33
|
+
end
|
34
|
+
|
35
|
+
# Called after every test method runs. Can be used to tear
|
36
|
+
# down fixture information.
|
37
|
+
|
38
|
+
def teardown
|
39
|
+
# Do nothing
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_lookup_template_for_event
|
43
|
+
std='2.4'
|
44
|
+
ver='VAZ2.4.HL7'
|
45
|
+
event='ADT_A60'
|
46
|
+
|
47
|
+
factory = MessageFactory.new({std: std, version: ver, event:event, version_store: @@VS, use_template: 'vista sqwm-adt_a60.xml'})
|
48
|
+
expected = "/Users/romansova/RubymineProjects/ez7gen/ez7gen-web/config/templates/2.4/vista sqwm-adt_a60.xml"
|
49
|
+
assert_equal expected, factory.templatePath
|
50
|
+
|
51
|
+
factory = MessageFactory.new({std: std, version: ver, event: event, use_template: false, version_store: @@VS})
|
52
|
+
assert_nil factory.templatePath
|
53
|
+
|
54
|
+
factory = MessageFactory.new({std: std, version: ver, event:event, version_store: @@VS})
|
55
|
+
assert_nil factory.templatePath
|
56
|
+
|
57
|
+
event='ADT_60'
|
58
|
+
factory = MessageFactory.new({std: std, version: ver, event:event, version_store: @@VS})
|
59
|
+
assert_nil factory.templatePath
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_problem
|
64
|
+
|
65
|
+
# e = "PTR_PCF"
|
66
|
+
# e = "RSP_K13"
|
67
|
+
# e = 'SRM_S01'
|
68
|
+
# e = 'TBR_R08'
|
69
|
+
#e = 'RSP_K25'# ORG.10 and STF.20 need to be populated ONLY with the code from table 66, without the description (which is very confusing, in my opinion, since the data type is CE, but the allowed length is only 2).
|
70
|
+
# e = 'SQM_S25'# batch 8; ARQ.13.1 – the value needs to come from table 335; APR.5.2 – the value needs to come from table 294
|
71
|
+
# e = "TBR_R08" #missing data type in RDT segment
|
72
|
+
# e = "PTR_PCF"
|
73
|
+
#["PMU_B01", "PMU_B03", "PMU_B04"] #This was reported to you before – STF. Field 20, repetition 1 is larger than segment structure 2.4:STF
|
74
|
+
# e = "PMU_B01"
|
75
|
+
# e = "MFN_M02"
|
76
|
+
# e = "MFN_M05"
|
77
|
+
# MFN_M07, MFN_M09 and MFN_M12
|
78
|
+
# e = "MFN_M09" # OM1 missing field 18 /, ()
|
79
|
+
# e = 'RRA_O18'
|
80
|
+
# e = 'TBR_R08' # RDT
|
81
|
+
e = "QBP_Q11"
|
82
|
+
ver= '2.4.HL7'
|
83
|
+
hl7 = MessageFactory.new({std: '2.4', version: ver, event:e, version_store: @@VS, loadfactor: 1}).generate
|
84
|
+
puts hl7
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_all
|
89
|
+
all_events = ["ACK", "ACK_N02", "ACK_R01", "ADR_A19", "ADT_A01", "ADT_A02", "ADT_A03", "ADT_A04", "ADT_A05", "ADT_A06", "ADT_A07", "ADT_A08", "ADT_A09", "ADT_A10", "ADT_A11", "ADT_A12", "ADT_A13", "ADT_A14", "ADT_A15", "ADT_A16", "ADT_A17", "ADT_A18", "ADT_A20", "ADT_A21", "ADT_A22", "ADT_A23", "ADT_A24", "ADT_A25", "ADT_A26", "ADT_A27", "ADT_A28", "ADT_A29", "ADT_A30", "ADT_A31", "ADT_A32", "ADT_A33", "ADT_A34", "ADT_A35", "ADT_A36", "ADT_A37", "ADT_A38", "ADT_A39", "ADT_A40", "ADT_A41", "ADT_A42", "ADT_A43", "ADT_A44", "ADT_A45", "ADT_A46", "ADT_A47","ADT_A48", "ADT_A49", "ADT_A50", "ADT_A51", "ADT_A52", "ADT_A53", "ADT_A54", "ADT_A55", "ADT_A60", "ADT_A61", "ADT_A62", "BAR_P01", "BAR_P02", "BAR_P05", "BAR_P06", "BAR_P10", "BHS", "CRM_C01", "CRM_C02", "CRM_C03", "CRM_C04", "CRM_C05", "CRM_C06", "CRM_C07", "CRM_C08", "CSU_C09", "CSU_C10", "CSU_C11", "CSU_C12", "DFT_P03", "DFT_P11", "DOC_T12", "DSR_P04", "DSR_Q01", "DSR_Q03", "EAC_U07", "EAN_U09", "EAR_U08", "EDR_R07", "EQQ_Q04", "ERP_R09", "ESR_U02", "ESU_U01", "FHS", "INR_U06", "INU_U05", "LSR_U13", "LSU_U12", "MDM_T01", "MDM_T02", "MDM_T03", "MDM_T04", "MDM_T05", "MDM_T06", "MDM_T07", "MDM_T08", "MDM_T09", "MDM_T10", "MDM_T11", "MFK_M01", "MFK_M02", "MFK_M03", "MFK_M04", "MFK_M05", "MFK_M06", "MFK_M07", "MFN_M01", "MFN_M02", "MFN_M03", "MFN_M04", "MFN_M05", "MFN_M06", "MFN_M07", "MFN_M08", "MFN_M09", "MFN_M10", "MFN_M11", "MFN_M12", "MFQ_M01", "MFQ_M01_2", "MFQ_M02_2", "MFQ_M03_2", "MFQ_M04_2", "MFQ_M05_2", "MFQ_M06_2", "MFR_M01", "MFR_M02", "MFR_M03", "MFR_M04", "MFR_M05", "MFR_M06", "NMD_N02", "NMQ_N01", "NMR_N01", "NUL_K11", "NUL_K13", "NUL_K15", "NUL_K21", "NUL_K22", "NUL_K23", "NUL_K24", "NUL_K25", "NUL_O04", "NUL_O06", "NUL_O08", "NUL_O10", "NUL_O12", "NUL_O14", "NUL_O16", "NUL_O18", "NUL_O20", "NUL_O22", "NUL_PC5", "NUL_PCA", "NUL_PCF", "NUL_PCL", "NUL_R04", "NUL_R07", "NUL_R08", "NUL_R09", "NUL_RAR", "NUL_RDR", "NUL_RER", "NUL_RGR", "NUL_ROR", "NUL_V02", "NUL_V03", "NUL_Z74", "NUL_Z82", "NUL_Z86", "NUL_Z88", "NUL_Z90", "OMD_O03", "OMG_O19", "OML_O21", "OMN_O07", "OMP_O09", "OMS_O05", "ORD_O04", "ORF_R04", "ORF_W02", "ORG_O20", "ORL_O22", "ORM_O01", "ORN_O08", "ORP_O10", "ORR_O02", "ORS_O06", "ORU_R01", "ORU_W01", "OSQ_Q06", "OSR_Q06", "OUL_R21", "PEX_P07", "PEX_P08", "PGL_PC6", "PGL_PC7", "PGL_PC8", "PIN_I07", "PMU_B01", "PMU_B02", "PMU_B03", "PMU_B04", "PMU_B05", "PMU_B06", "PPG_PCG", "PPG_PCH", "PPG_PCJ", "PPP_PCB", "PPP_PCC", "PPP_PCD", "PPR_PC1", "PPR_PC2", "PPR_PC3", "PPT_PCL", "PPV_PCA", "PRR_PC5", "PTR_PCF", "QBP_Q11", "QBP_Q13", "QBP_Q15", "QBP_Q21", "QBP_Q22", "QBP_Q23", "QBP_Q24", "QBP_Q25", "QBP_Z73", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z81", "QBP_Z85", "QBP_Z87", "QBP_Z89", "QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99", "QCK_Q02", "QCN_J01", "QRY_A19", "QRY_P04", "QRY_PC4", "QRY_PC9", "QRY_PCE", "QRY_PCK", "QRY_Q01", "QRY_Q02", "QRY_Q26", "QRY_Q27", "QRY_Q28", "QRY_Q29", "QRY_Q30", "QRY_R02", "QRY_T12", "QRY_W01", "QRY_W02", "QSB_Q16", "QSB_Z83", "QSX_J02", "QVR_Q17", "RAR_RAR", "RAS_O17", "RCI_I05", "RCL_I06", "RDE_O11", "RDR_RDR", "RDS_O13", "RDY_K15", "RDY_Z80", "RDY_Z98", "REF_I12", "REF_I13", "REF_I14", "REF_I15", "RER_RER", "RGR_RGR", "RGV_O15", "ROR_ROR", "RPA_I08", "RPA_I09", "RPA_I10", "RPA_I11", "RPI_I01", "RPI_I04", "RPL_I02", "RPR_I03", "RQA_I08", "RQA_I09", "RQA_I10", "RQA_I11", "RQC_I05", "RQC_I06", "RQI_I01", "RQI_I02", "RQI_I03", "RQP_I04", "RQQ_Q09", "RRA_O18", "RRD_O14", "RRE_O12", "RRG_O16", "RRI_I12", "RRI_I13", "RRI_I14", "RRI_I15", "RSP_K11", "RSP_K13", "RSP_K15", "RSP_K21", "RSP_K22", "RSP_K23", "RSP_K24", "RSP_K25", "RSP_Z82", "RSP_Z84", "RSP_Z86", "RSP_Z88", "RSP_Z90", "RTB_K13", "RTB_Knn", "RTB_Q13", "RTB_Z74", "RTB_Z76", "RTB_Z78", "RTB_Z92", "RTB_Z94", "RTB_Z96", "SIU_S12", "SIU_S13", "SIU_S14", "SIU_S15", "SIU_S16", "SIU_S17", "SIU_S18", "SIU_S19", "SIU_S20", "SIU_S21", "SIU_S22", "SIU_S23", "SIU_S24", "SIU_S26", "SPQ_Q08", "SQM_S25", "SQR_S25", "SRM_S01", "SRM_S02", "SRM_S03", "SRM_S04", "SRM_S05", "SRM_S06", "SRM_S07", "SRM_S08", "SRM_S09", "SRM_S10", "SRM_S11", "SRR_S01", "SRR_S02", "SRR_S03", "SRR_S04", "SRR_S05", "SRR_S06", "SRR_S07", "SRR_S08", "SRR_S09", "SRR_S10", "SRR_S11", "SSR_U04", "SSU_U03", "SUR_P09", "TBR_R08", "TCR_U11", "TCU_U10", "UDM_Q05", "VQQ_Q07", "VXQ_V01", "VXR_V03", "VXU_V04", "VXX_V02"]
|
90
|
+
#a = ["ACK", "ACK_N02", "ACK_R01", "ADR_A19", "ADT_A01", "ADT_A02", "ADT_A03", "ADT_A04", "ADT_A05", "ADT_A06", "ADT_A07", "ADT_A08", "ADT_A09", "ADT_A10", "ADT_A11", "ADT_A12", "ADT_A13", "ADT_A14", "ADT_A15", "ADT_A16", "ADT_A17", "ADT_A18", "ADT_A20", "ADT_A21", "ADT_A22", "ADT_A23", "ADT_A24", "ADT_A25", "ADT_A26", "ADT_A27", "ADT_A28", "ADT_A29", "ADT_A30", "ADT_A31", "ADT_A32", "ADT_A33", "ADT_A34", "ADT_A35", "ADT_A36", "ADT_A37", "ADT_A38", "ADT_A39", "ADT_A40", "ADT_A41", "ADT_A42", "ADT_A43", "ADT_A44", "ADT_A45", "ADT_A46", "ADT_A47"]#, "ADT_A48", "ADT_A49", "ADT_A50", "ADT_A51", "ADT_A52", "ADT_A53", "ADT_A54", "ADT_A55", "ADT_A60", "ADT_A61", "ADT_A62", "BAR_P01", "BAR_P02", "BAR_P05", "BAR_P06", "BAR_P10", "BHS", "CRM_C01", "CRM_C02", "CRM_C03", "CRM_C04", "CRM_C05", "CRM_C06", "CRM_C07", "CRM_C08", "CSU_C09", "CSU_C10", "CSU_C11", "CSU_C12", "DFT_P03", "DFT_P11", "DOC_T12", "DSR_P04", "DSR_Q01", "DSR_Q03", "EAC_U07", "EAN_U09", "EAR_U08", "EDR_R07", "EQQ_Q04", "ERP_R09", "ESR_U02", "ESU_U01", "FHS", "INR_U06", "INU_U05", "LSR_U13", "LSU_U12", "MDM_T01", "MDM_T02", "MDM_T03", "MDM_T04", "MDM_T05", "MDM_T06", "MDM_T07", "MDM_T08", "MDM_T09", "MDM_T10", "MDM_T11", "MFK_M01", "MFK_M02", "MFK_M03", "MFK_M04", "MFK_M05", "MFK_M06", "MFK_M07", "MFN_M01", "MFN_M02", "MFN_M03", "MFN_M04", "MFN_M05", "MFN_M06", "MFN_M07", "MFN_M08", "MFN_M09", "MFN_M10", "MFN_M11", "MFN_M12", "MFQ_M01", "MFQ_M01_2", "MFQ_M02_2", "MFQ_M03_2", "MFQ_M04_2", "MFQ_M05_2", "MFQ_M06_2", "MFR_M01", "MFR_M02", "MFR_M03", "MFR_M04", "MFR_M05", "MFR_M06", "NMD_N02", "NMQ_N01", "NMR_N01", "NUL_K11", "NUL_K13", "NUL_K15", "NUL_K21", "NUL_K22", "NUL_K23", "NUL_K24", "NUL_K25", "NUL_O04", "NUL_O06", "NUL_O08", "NUL_O10", "NUL_O12", "NUL_O14", "NUL_O16", "NUL_O18", "NUL_O20", "NUL_O22", "NUL_PC5", "NUL_PCA", "NUL_PCF", "NUL_PCL", "NUL_R04", "NUL_R07", "NUL_R08", "NUL_R09", "NUL_RAR", "NUL_RDR", "NUL_RER", "NUL_RGR", "NUL_ROR", "NUL_V02", "NUL_V03", "NUL_Z74", "NUL_Z82", "NUL_Z86", "NUL_Z88", "NUL_Z90", "OMD_O03", "OMG_O19", "OML_O21", "OMN_O07", "OMP_O09", "OMS_O05", "ORD_O04", "ORF_R04", "ORF_W02", "ORG_O20", "ORL_O22", "ORM_O01", "ORN_O08", "ORP_O10", "ORR_O02", "ORS_O06", "ORU_R01", "ORU_W01", "OSQ_Q06", "OSR_Q06", "OUL_R21", "PEX_P07", "PEX_P08", "PGL_PC6", "PGL_PC7", "PGL_PC8", "PIN_I07", "PMU_B01", "PMU_B02", "PMU_B03", "PMU_B04", "PMU_B05", "PMU_B06", "PPG_PCG", "PPG_PCH", "PPG_PCJ", "PPP_PCB", "PPP_PCC", "PPP_PCD", "PPR_PC1", "PPR_PC2", "PPR_PC3", "PPT_PCL", "PPV_PCA", "PRR_PC5", "PTR_PCF", "QBP_Q11", "QBP_Q13", "QBP_Q15", "QBP_Q21", "QBP_Q22", "QBP_Q23", "QBP_Q24", "QBP_Q25", "QBP_Z73", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z81", "QBP_Z85", "QBP_Z87", "QBP_Z89", "QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99", "QCK_Q02", "QCN_J01", "QRY_A19", "QRY_P04", "QRY_PC4", "QRY_PC9", "QRY_PCE", "QRY_PCK", "QRY_Q01", "QRY_Q02", "QRY_Q26", "QRY_Q27", "QRY_Q28", "QRY_Q29", "QRY_Q30", "QRY_R02", "QRY_T12", "QRY_W01", "QRY_W02", "QSB_Q16", "QSB_Z83", "QSX_J02", "QVR_Q17", "RAR_RAR", "RAS_O17", "RCI_I05", "RCL_I06", "RDE_O11", "RDR_RDR", "RDS_O13", "RDY_K15", "RDY_Z80", "RDY_Z98", "REF_I12", "REF_I13", "REF_I14", "REF_I15", "RER_RER", "RGR_RGR", "RGV_O15", "ROR_ROR", "RPA_I08", "RPA_I09", "RPA_I10", "RPA_I11", "RPI_I01", "RPI_I04", "RPL_I02", "RPR_I03", "RQA_I08", "RQA_I09", "RQA_I10", "RQA_I11", "RQC_I05", "RQC_I06", "RQI_I01", "RQI_I02", "RQI_I03", "RQP_I04", "RQQ_Q09", "RRA_O18", "RRD_O14", "RRE_O12", "RRG_O16", "RRI_I12", "RRI_I13", "RRI_I14", "RRI_I15", "RSP_K11", "RSP_K13", "RSP_K15", "RSP_K21", "RSP_K22", "RSP_K23", "RSP_K24", "RSP_K25", "RSP_Z82", "RSP_Z84", "RSP_Z86", "RSP_Z88", "RSP_Z90", "RTB_K13", "RTB_Knn", "RTB_Q13", "RTB_Z74", "RTB_Z76", "RTB_Z78", "RTB_Z92", "RTB_Z94", "RTB_Z96", "SIU_S12", "SIU_S13", "SIU_S14", "SIU_S15", "SIU_S16", "SIU_S17", "SIU_S18", "SIU_S19", "SIU_S20", "SIU_S21", "SIU_S22", "SIU_S23", "SIU_S24", "SIU_S26", "SPQ_Q08", "SQM_S25", "SQR_S25", "SRM_S01", "SRM_S02", "SRM_S03", "SRM_S04", "SRM_S05", "SRM_S06", "SRM_S07", "SRM_S08", "SRM_S09", "SRM_S10", "SRM_S11", "SRR_S01", "SRR_S02", "SRR_S03", "SRR_S04", "SRR_S05", "SRR_S06", "SRR_S07", "SRR_S08", "SRR_S09", "SRR_S10", "SRR_S11", "SSR_U04", "SSU_U03", "SUR_P09", "TBR_R08", "TCR_U11", "TCU_U10", "UDM_Q05", "VQQ_Q07", "VXQ_V01", "VXR_V03", "VXU_V04", "VXX_V02"]
|
91
|
+
#b = ["ADT_A48", "ADT_A49", "ADT_A50", "ADT_A51", "ADT_A52", "ADT_A53", "ADT_A54", "ADT_A55", "ADT_A60", "ADT_A61", "ADT_A62", "BAR_P01", "BAR_P02", "BAR_P05", "BAR_P06", "BAR_P10", "BHS", "CRM_C01", "CRM_C02", "CRM_C03", "CRM_C04", "CRM_C05", "CRM_C06", "CRM_C07", "CRM_C08"]
|
92
|
+
#c = ["CSU_C09", "CSU_C10", "CSU_C11", "CSU_C12", "DFT_P03", "DFT_P11", "DOC_T12", "DSR_P04", "DSR_Q01", "DSR_Q03", "EAC_U07", "EAN_U09", "EAR_U08", "EDR_R07", "EQQ_Q04", "ERP_R09", "ESR_U02", "ESU_U01", "FHS", "INR_U06", "INU_U05", "LSR_U13", "LSU_U12", "MDM_T01", "MDM_T02"]
|
93
|
+
# MFQ_M01 - needs requirements;
|
94
|
+
#d = ["MDM_T03", "MDM_T04", "MDM_T05", "MDM_T06", "MDM_T07", "MDM_T08", "MDM_T09", "MDM_T10", "MDM_T11", "MFK_M01", "MFK_M02", "MFK_M03", "MFK_M04", "MFK_M05", "MFK_M06", "MFK_M07", "MFN_M01", "MFN_M02", "MFN_M03", "MFN_M04", "MFN_M05", "MFN_M06", "MFN_M07", "MFN_M08", "MFN_M09", "MFN_M10", "MFN_M11", "MFN_M12", "MFQ_M01", "MFQ_M01_2", "MFQ_M02_2", "MFQ_M03_2", "MFQ_M04_2", "MFQ_M05_2", "MFQ_M06_2", "MFR_M01", "MFR_M02", "MFR_M03", "MFR_M04", "MFR_M05", "MFR_M06"]
|
95
|
+
# e = ["NMD_N02", "NMQ_N01", "NMR_N01", "NUL_K11", "NUL_K13", "NUL_K15", "NUL_K21", "NUL_K22", "NUL_K23", "NUL_K24", "NUL_K25", "NUL_O04", "NUL_O06", "NUL_O08", "NUL_O10", "NUL_O12", "NUL_O14", "NUL_O16", "NUL_O18", "NUL_O20", "NUL_O22", "NUL_PC5", "NUL_PCA", "NUL_PCF", "NUL_PCL", "NUL_R04", "NUL_R07", "NUL_R08", "NUL_R09", "NUL_RAR", "NUL_RDR", "NUL_RER", "NUL_RGR", "NUL_ROR", "NUL_V02", "NUL_V03", "NUL_Z74", "NUL_Z82", "NUL_Z86", "NUL_Z88", "NUL_Z90", "OMD_O03", "OMG_O19"]
|
96
|
+
#e1 = ["OML_O21", "OMN_O07", "OMP_O09", "OMS_O05", "ORD_O04", "ORF_R04", "ORF_W02", "ORG_O20", "ORL_O22", "ORM_O01", "ORN_O08", "ORP_O10", "ORR_O02", "ORS_O06", "ORU_R01", "ORU_W01", "OSQ_Q06", "OSR_Q06", "OUL_R21", "PEX_P07", "PEX_P08", "PGL_PC6", "PGL_PC7", "PGL_PC8", "PIN_I07", "PMU_B01", "PMU_B02", "PMU_B03", "PMU_B04", "PMU_B05", "PMU_B06", "PPG_PCG", "PPG_PCH", "PPG_PCJ", "PPP_PCB", "PPP_PCC", "PPP_PCD", "PPR_PC1", "PPR_PC2", "PPR_PC3", "PPT_PCL", "PPV_PCA", "PRR_PC5"]
|
97
|
+
#g = ["PTR_PCF", "QBP_Q11", "QBP_Q13", "QBP_Q15", "QBP_Q21", "QBP_Q22", "QBP_Q23", "QBP_Q24", "QBP_Q25", "QBP_Z73", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z81", "QBP_Z85", "QBP_Z87", "QBP_Z89", "QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99", "QCK_Q02", "QCN_J01", "QRY_A19", "QRY_P04", "QRY_PC4", "QRY_PC9", "QRY_PCE", "QRY_PCK", "QRY_Q01", "QRY_Q02", "QRY_Q26", "QRY_Q27", "QRY_Q28", "QRY_Q29", "QRY_Q30", "QRY_R02", "QRY_T12", "QRY_W01", "QRY_W02", "QSB_Q16", "QSB_Z83"]
|
98
|
+
#h = ["QSX_J02", "QVR_Q17", "RAR_RAR", "RAS_O17", "RCI_I05", "RCL_I06", "RDE_O11", "RDR_RDR", "RDS_O13", "RDY_K15", "RDY_Z80", "RDY_Z98", "REF_I12", "REF_I13", "REF_I14", "REF_I15", "RER_RER", "RGR_RGR", "RGV_O15", "ROR_ROR", "RPA_I08", "RPA_I09", "RPA_I10", "RPA_I11", "RPI_I01", "RPI_I04", "RPL_I02", "RPR_I03", "RQA_I08", "RQA_I09", "RQA_I10", "RQA_I11", "RQC_I05", "RQC_I06", "RQI_I01", "RQI_I02", "RQI_I03", "RQP_I04", "RQQ_Q09", "RRA_O18", "RRD_O14", "RRE_O12", "RRG_O16"]
|
99
|
+
#i = ["RRI_I12", "RRI_I13", "RRI_I14", "RRI_I15", "RSP_K11", "RSP_K13", "RSP_K15", "RSP_K21", "RSP_K22", "RSP_K23", "RSP_K24", "RSP_K25", "RSP_Z82", "RSP_Z84", "RSP_Z86", "RSP_Z88", "RSP_Z90", "RTB_K13", "RTB_Knn", "RTB_Q13", "RTB_Z74", "RTB_Z76", "RTB_Z78", "RTB_Z92", "RTB_Z94", "RTB_Z96", "SIU_S12", "SIU_S13", "SIU_S14", "SIU_S15", "SIU_S16", "SIU_S17", "SIU_S18", "SIU_S19", "SIU_S20", "SIU_S21", "SIU_S22", "SIU_S23", "SIU_S24", "SIU_S26", "SPQ_Q08", "SQM_S25", "SQR_S25"]
|
100
|
+
#j = ["SRM_S01", "SRM_S02", "SRM_S03", "SRM_S04", "SRM_S05", "SRM_S06", "SRM_S07", "SRM_S08", "SRM_S09", "SRM_S10", "SRM_S11", "SRR_S01", "SRR_S02", "SRR_S03", "SRR_S04", "SRR_S05", "SRR_S06", "SRR_S07", "SRR_S08", "SRR_S09", "SRR_S10", "SRR_S11", "SSR_U04", "SSU_U03", "SUR_P09", "TBR_R08", "TCR_U11", "TCU_U10", "UDM_Q05", "VQQ_Q07", "VXQ_V01", "VXR_V03", "VXU_V04", "VXX_V02"]
|
101
|
+
errors = []#["BAR_P10", "BAR_P06", "BHS", "ERP_R09", "FHS", "MFN_M01", "MFN_M03", "MFN_M08", "MFN_M11", "MFR_M01","MFR_M02","MFR_M03","MFR_M04","MFR_M05","MFR_M06","NMR_N01","NUL_K11","NUL_PC5","NUL_PCA","NUL_PCF", "NUL_PCL", "NUL_R09", "ORM_O01","PGL_PC6","PGL_PC7","PGL_PC8","PPG_PCG"]
|
102
|
+
er = ["BAR_P10", "BAR_P06", "BHS", "ERP_R09", "FHS", "MFN_M01", "MFN_M03", "MFN_M08", "MFN_M11", "MFR_M01","MFR_M02","MFR_M03","MFR_M04","MFR_M05","MFR_M06","NMR_N01","NUL_K11","NUL_PC5","NUL_PCA","NUL_PCF", "NUL_PCL", "NUL_R09", "ORM_O01","PGL_PC6","PGL_PC7","PGL_PC8","PPG_PCG"]
|
103
|
+
#batch 0 (a)
|
104
|
+
# a_err =[]
|
105
|
+
# er += a_err
|
106
|
+
# #batch 1 (b)
|
107
|
+
# b_err =[]
|
108
|
+
# er += b_err
|
109
|
+
#batch 2 (c)
|
110
|
+
# c_err =[]
|
111
|
+
# er += c_err
|
112
|
+
#batch 3 (d) MFQ_M01 - needs requirements;
|
113
|
+
# d_err =[]
|
114
|
+
# er += d_err
|
115
|
+
#batch 4 (e)
|
116
|
+
# e_err = []
|
117
|
+
# er += e_err
|
118
|
+
#batch 5 (e1)
|
119
|
+
e1_err = ["ORR_O02", "PPG_PCH", "PPG_PCJ", "PPP_PCB", "PPP_PCC", "PPP_PCD", "PPR_PC1", "PPR_PC2", "PPR_PC3", "PPT_PCL", "PPV_PCA", "PRR_PC5"]
|
120
|
+
er += e1_err
|
121
|
+
#batch 6 (g)
|
122
|
+
g_err =["PTR_PCF", "QBP_Q13", "QBP_Q15", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99"]
|
123
|
+
er += g_err
|
124
|
+
# batch 7 (h)
|
125
|
+
h_err = ["QVR_Q17", "RQQ_Q09"]
|
126
|
+
# h_err = ["RSP_K13", "RTB_K13", "RTB_Q13"] #segment RDF missing second field - fixed
|
127
|
+
# h_err = ["RSP_K25"] #This issue was already reported earlier: ORG.10 and STF.20 need to be populated ONLY -fixed
|
128
|
+
er += h_err
|
129
|
+
# batch 8 (i)
|
130
|
+
#i_err = ["SQM_S25"] ## batch 8; ARQ.13.1 – the value needs to come from table 335; APR.5.2 – the value needs to come from table 294 - fixed
|
131
|
+
i_err = ["RSP_K11", "SPQ_Q08"] # tools side error
|
132
|
+
er += i_err
|
133
|
+
#batch 9 (j)
|
134
|
+
j_err = ["SUR_P09"] # causes intermediate errors - too complex with repeating groups MSH~{~FAC~{~PSH~PDC~}~PSH~{~FAC~PDC~NTE~}~}
|
135
|
+
er += j_err
|
136
|
+
|
137
|
+
#ARQ.13.1 – the value needs to come from table 335
|
138
|
+
#APR.5.2 – the value needs to come from table 294
|
139
|
+
|
140
|
+
# batch 2 (c) # to complex
|
141
|
+
bl = ["CSU_C09","CSU_C10", "CSU_C11","CSU_C12"]
|
142
|
+
# "MFQ_M01_2","MFQ_M02_2","MFQ_M03_2","MFQ_M04_2", "MFQ_M05_2","MFQ_M06_2", per Galina, but not in my 2.4 schema
|
143
|
+
# "MFR_M01_2", "MFR_M02_2", "MFR_M03_3", "MFR_M04_2", "MFR_M05_2", "MFR_M06_2"
|
144
|
+
bl += ["NMD","NMQ", "NMR","OMD_O03"] #black list, Ensemble issues
|
145
|
+
|
146
|
+
# batch 3 (d)
|
147
|
+
bl += ["MFN_M02"] # Unescaped separator(s) (|^~&) found in value 'L&I' for elementary data type 'ST' at segment 5:PRA, field 6, repetition 1, component 1, subcomponent 1.
|
148
|
+
bl += ["MFQ_M01_2", "MFQ_M02_2", "MFQ_M03_2", "MFQ_M04_2", "MFQ_M05_2", "MFQ_M06_2"] # black listed redundant messages - all use the same message structure
|
149
|
+
# batch 4 (e)
|
150
|
+
bl += ["NUL_K11", "NUL_K13", "NUL_K15", "NUL_K21", "NUL_K22", "NUL_K23", "NUL_K24", "NUL_K25", "NUL_O04", "NUL_O06", "NUL_O08", "NUL_O10", "NUL_O12", "NUL_O14", "NUL_O16", "NUL_O18", "NUL_O20", "NUL_O22", "NUL_PC5", "NUL_PCA", "NUL_PCF", "NUL_PCL", "NUL_R04", "NUL_R07", "NUL_R08", "NUL_R09", "NUL_RAR", "NUL_RDR", "NUL_RER", "NUL_RGR", "NUL_ROR", "NUL_V02", "NUL_V03", "NUL_Z74", "NUL_Z82", "NUL_Z86", "NUL_Z88", "NUL_Z90"] #batch (e)
|
151
|
+
# batch 5 (e1)
|
152
|
+
bl += ["ORD_O04"] # too complex with subgroups
|
153
|
+
bl += ["PMU_B04"] # fixed others PMU_B04 has html encodded chars
|
154
|
+
# fixed ["PMU_B01", "PMU_B03", "PMU_B04"] #This was reported to you before – STF. Field 20, repetition 1 is larger than segment structure 2.4:STF
|
155
|
+
# batch 6 (g)
|
156
|
+
bl += ["QBP_Z73", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z81","QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99", "QSB_Z83"] #per Galina batch 6
|
157
|
+
bl += ["QBP_Z85","QBP_Z87","QBP_Z89"] # added 3 more per Galina
|
158
|
+
|
159
|
+
# batch 7 (h)
|
160
|
+
bl += ["RDY_Z98", "RDY_Z80"]
|
161
|
+
# batch 8 (i)
|
162
|
+
bl += ["RSP_Z82", "RSP_Z84", "RSP_Z86", "RSP_Z88", "RSP_Z90", "RTB_Z74", "RTB_Z76", "RTB_Z78", "RTB_Z92", "RTB_Z94", "RTB_Z96"]
|
163
|
+
# j batch (9)
|
164
|
+
# bl += []
|
165
|
+
|
166
|
+
|
167
|
+
#also = ['ACK_N02', 'ACK_R01', 'DFT_P11', 'QRY_P04', 'QRY_Q26', 'QRY_Q27', 'QRY_Q28', 'QRY_Q29', 'QRY_Q30', 'RSP_K13', 'RSP_K15', 'RTB_Knn', 'RTB_Q13']
|
168
|
+
|
169
|
+
#a = ['ACK_N02', 'ACK_R01']
|
170
|
+
# c = ['DFT_P11'],
|
171
|
+
# g = ['QRY_P04', 'QRY_Q26', 'QRY_Q27', 'QRY_Q28', 'QRY_Q29', 'QRY_Q30'],
|
172
|
+
# i =['RSP_K13', 'RSP_K15', 'RTB_Knn', 'RTB_Q13']
|
173
|
+
|
174
|
+
all = all_events - er
|
175
|
+
all -= bl
|
176
|
+
# errors = ["NUL_PCF", "NUL_PCL", "NUL_R09", "ORM_O01","PGL_PC6","PGL_PC7","PGL_PC8","PPG_PCG"]
|
177
|
+
# "ERP_R09" :NameError: undefined method `QIP' for class `TypeAwareFieldGenerator'
|
178
|
+
# "MFN_M08" :NoMethodError: undefined method `join' for "992":String
|
179
|
+
# "MFN_M11" : NoMethodError: undefined method `join' for "934":String
|
180
|
+
# lst = errors.last
|
181
|
+
# lst_idx = all.index(lst) + 1
|
182
|
+
# events = all - errors
|
183
|
+
# events = all[lst_idx ..-1]
|
184
|
+
# p events
|
185
|
+
ver= '2.4.HL7'
|
186
|
+
puts "errors size: #{er.size}"
|
187
|
+
puts "known errors : #{er}"
|
188
|
+
puts "-----"
|
189
|
+
|
190
|
+
puts "black list size: #{bl.size}"
|
191
|
+
puts "black list : #{bl}"
|
192
|
+
puts "-----"
|
193
|
+
|
194
|
+
puts "messages size: #{all.size}"
|
195
|
+
puts "messages : #{all}"
|
196
|
+
puts "-----"
|
197
|
+
|
198
|
+
all.each{|e|
|
199
|
+
begin
|
200
|
+
puts "\n------------------#{e}------------------\n"
|
201
|
+
hl7 = MessageFactory.new({std: '2.4', version: ver, event:e, version_store: @@VS, loadfactor: 1}).generate
|
202
|
+
puts hl7
|
203
|
+
saveMsg(e+'-'+Ez7gen::VERSION, hl7, ver)
|
204
|
+
rescue Exception =>z
|
205
|
+
errors << e
|
206
|
+
end
|
207
|
+
}
|
208
|
+
p errors
|
209
|
+
puts "errors size: #{errors.size}"
|
210
|
+
# ["BHS", "ERP_R09", "FHS", "MFN_M01", "MFN_M03", "MFN_M08", "MFN_M11", "MFR_M01", "MFR_M02", "MFR_M03", "MFR_M04", "MFR_M05", "MFR_M06", "NUL_K11", "NUL_PC5", "NUL_PCA", "NUL_PCF", "NUL_PCL", "NUL_R09", "ORM_O01", "ORR_O02", "PGL_PC6", "PGL_PC7", "PGL_PC8", "PPG_PCG", "PPG_PCH", "PPG_PCJ", "PPP_PCB", "PPP_PCC", "PPP_PCD", "PPR_PC1", "PPR_PC2", "PPR_PC3", "PPT_PCL", "PPV_PCA", "PRR_PC5", "PTR_PCF", "QBP_Q13", "QBP_Q15", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99", "QVR_Q17", "RQQ_Q09", "RSP_K11", "SPQ_Q08"]
|
211
|
+
# 51
|
212
|
+
# ["BHS", "ERP_R09", "FHS", "MFN_M01", "MFN_M03", "MFN_M08", "MFN_M11", "MFR_M01", "MFR_M02", "MFR_M03", "MFR_M04", "MFR_M05", "MFR_M06", "NUL_K11", "NUL_PC5", "NUL_PCA", "NUL_PCF", "NUL_PCL", "NUL_R09", "ORM_O01", "ORR_O02", "OSR_Q06", "PGL_PC6", "PGL_PC7", "PGL_PC8", "PPG_PCG", "PPG_PCH", "PPG_PCJ", "PPP_PCB", "PPP_PCC", "PPP_PCD", "PPR_PC1", "PPR_PC2", "PPR_PC3", "PPT_PCL", "PPV_PCA", "PRR_PC5", "PTR_PCF", "QBP_Q13", "QBP_Q15", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99", "QVR_Q17", "RQQ_Q09", "RSP_K11", "SPQ_Q08"]
|
213
|
+
# 52
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'ez7gen/msg_error_handler'
|
3
|
+
|
4
|
+
class MsgErrorHandlerTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
# Called before every test method runs. Can be used
|
7
|
+
# to set up fixture information.
|
8
|
+
def setup
|
9
|
+
# Do nothing
|
10
|
+
end
|
11
|
+
|
12
|
+
# Called after every test method runs. Can be used to tear
|
13
|
+
# down fixture information.
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
# Do nothing
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_success_message
|
20
|
+
ok="MSH|^~\&|EnsembleHL7|ISC|404|707|201607162200||ACK^A01|171|P|2.4|234
|
21
|
+
MSA|AA|171"
|
22
|
+
errors = MsgErrorHandler.new().handle(ok)
|
23
|
+
assert_nil(errors)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def test_error_message
|
28
|
+
# msg = "MSH|^~\&|EnsembleHL7|ISC|404|808|201607162206||ACK^A05|218|P|2.4|936
|
29
|
+
# MSA|AE|218
|
30
|
+
# ERR||||E|<Ens>ErrGeneral|||ERROR <Ens>ErrGeneral: Not forwarding message 9292 with message body Id=4610, Doc Identifier=218, SessionId=9292 because of validation failure: ERROR <Ens>ErrGeneral: Field size restriction exceeded in segment 8:DB1. Field 2, repetition 1 is larger than segment structure 2.4:DB1 permits it to be.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Invalid value 'ABCDDEFRTYURYRURURUR' appears in segment 8:DB1, field 2, repetition 1, component 1, subcomponent 1, but does not appear in code table 2.4:334.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Field size restriction exceeded in segment 11:DG1. Field 6, repetition 1 is larger than segment structure 2.4:DG1 permits it to be.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Invalid value 'xxxxxxxxxx' appears in segment 11:DG1, field 6, repetition 1, component 1, subcomponent 1, but does not appear in code table 2.4:52.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Field size restriction exceeded in segment 11:DG1. Field 18, repetition 1 is larger than segment structure 2.4:DG1 permits it to be.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Invalid value 'ZZZZZZZ' appears in segment 11:DG1, field 18, repetition 1, component 1, subcomponent 1, but does not appear in code table 2.4:136."
|
31
|
+
msg = "MSH|^~\&|EnsembleHL7|ISC|404|808|201607162206||ACK^A05|218|P|2.4|936
|
32
|
+
MSA|AE|218
|
33
|
+
ERR||||E|<Ens>ErrGeneral|||ERROR <Ens>ErrGeneral: Not forwarding message 9292 with message body Id=4610, Doc Identifier=218, SessionId=9292 because of validation failure: ERROR <Ens>ErrGeneral: Field size restriction exceeded in segment 8:DB1. Field 2, repetition 1 is larger than segment structure 2.4:DB1 permits it to be.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Invalid value 'ABCDDEFRTYURYRURURUR' appears in segment 8:DB1, field 2, repetition 1, component 1, subcomponent 1, but does not appear in code table 2.4:334.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Field size restriction exceeded in segment 11:DG1. Field 6, repetition 1 is larger than segment structure 2.4:DG1 permits it to be.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Invalid value 'xxxxxxxxxx' appears in segment 11:DG1, field 6, repetition 1, component 1, subcomponent 1, but does not appear in code table 2.4:52.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Field size restriction exceeded in segment 11:DG1. Field 18, repetition 1 is larger than segment structure 2.4:DG1 permits it to be.\X0D\\X0A\+\X0D\\X0A\ERROR <Ens>ErrGeneral: Invalid value 'ZZZZZZZ' appears in segment 11:DG1, field 18, repetition 1, component 1, subcomponent 1, but does not appear in code table 2.4:136."
|
34
|
+
errors = MsgErrorHandler.new().handle(msg)
|
35
|
+
assert_not_nil(errors)
|
36
|
+
assert_equal(7, errors.size)
|
37
|
+
puts errors
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_error_message_1
|
41
|
+
msg = "MSA|AA|807nsembleHL7|ISC|PRCHCPS|707|201608162035||ACK^A11|807|P|2.4|294"
|
42
|
+
errors = MsgErrorHandler.new().handle(msg)
|
43
|
+
puts errors
|
44
|
+
assert_nil(errors)
|
45
|
+
# assert_equal(7, errors.size)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_error_message_2
|
49
|
+
msg = "MSH|^~\&|EnsembleHL7|ISC|VISTA SQWM|442^HL7.CHEYENNE.MED.VA.GOV:5274^DNS|201608222024||ACK^A60|442 744187|T|2.4
|
50
|
+
MSA|AE|442 744187
|
51
|
+
ERR||||E|<Ens>ErrGeneral|||ERROR <Ens>ErrGeneral: Not forwarding message 13404 with message body Id=6912, Doc Identifier=442 744187, SessionId=13404 because of validation failure: ERROR <Ens>ErrGeneral: Invalid value 'F' appears in segment 4:IAM, field 2, repetition 1, component 1, subcomponent 1, but does not appear in code table 2.4:127."
|
52
|
+
errors = MsgErrorHandler.new().handle(msg)
|
53
|
+
puts errors
|
54
|
+
assert_not_nil(errors)
|
55
|
+
assert_equal(2, errors.size)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
@@ -0,0 +1,542 @@
|
|
1
|
+
# require "minitest/autorun"
|
2
|
+
require 'test/unit'
|
3
|
+
require 'benchmark'
|
4
|
+
require 'logger'
|
5
|
+
require_relative '../lib/ez7gen/profile_parser'
|
6
|
+
|
7
|
+
class ProfileParserTest < Test::Unit::TestCase
|
8
|
+
include Utils
|
9
|
+
def setup
|
10
|
+
vs =
|
11
|
+
[
|
12
|
+
{:std=>"2.4", :path=>"../test/test-config/schema/2.4", :profiles=>[{:doc=>"2.4.HL7", :name=>"2.4", :std=>"1", :path=>"../test/test-config/schema/2.4/2.4.HL7.xml"}, {:doc=>"VAZ2.4.HL7", :name=>"VAZ2.4", :description=>"2.4 schema with VA defined tables and Z segments", :base=>"2.4", :path=>"../test/test-config/schema/2.4/VAZ2.4.HL7.xml"}]},
|
13
|
+
{:std=>"2.5", :path=>"../test/test-config/schema/2.5", :profiles=>[{:doc=>"2.5.HL7", :name=>"2.5", :std=>"1", :path=>"../test/test-config/schema/2.5/2.5.HL7.xml"}, {:doc=>"TEST2.5.HL7", :name=>"TEST2.5", :description=>"2.5 mockup schema for testing", :base=>"2.4", :path=>"../test/test-config/schema/2.5/VAZ2.5.HL7.xml"}]}
|
14
|
+
]
|
15
|
+
@attrs = {std: '2.4', version: '2.4.HL7', event: 'ADT_A01', version_store: vs}
|
16
|
+
# @parser = ProfileParser.new(attributes)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
@attrs = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_init_base
|
25
|
+
parser = ProfileParser.new(@attrs)
|
26
|
+
assert(parser !=nil)
|
27
|
+
|
28
|
+
xml = parser.instance_variable_get('@xml')
|
29
|
+
assert_equal('2.4.HL7', xml.Export.Document.attributes[:name])
|
30
|
+
|
31
|
+
# assert_equal(2, parser.)
|
32
|
+
# assert(hl7 != nil)
|
33
|
+
# refute_nil(hl7)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_init_custom
|
37
|
+
@attrs[:version] = 'VAZ2.4.HL7'
|
38
|
+
parser = ProfileParser.new(@attrs)
|
39
|
+
assert(parser !=nil)
|
40
|
+
# get access to private field
|
41
|
+
xml = parser.instance_variable_get('@xml')
|
42
|
+
assert_equal('VAZ2.4.HL7', xml.Export.Document.attributes[:name])
|
43
|
+
# assert(hl7 != nil)
|
44
|
+
# refute_nil(hl7)
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def test_getMessageDefinition
|
49
|
+
parser = ProfileParser.new(@attrs)
|
50
|
+
expected = "MSH~EVN~PID~[~PD1~]~[~{~ROL~}~]~[~{~NK1~}~]~PV1~[~PV2~]~[~{~ROL~}~]~[~{~DB1~}~]~[~{~OBX~}~]~[~{~AL1~}~]~[~{~DG1~}~]~[~DRG~]~[~{~PR1~[~{~ROL~}~]~}~]~[~{~GT1~}~]~[~{~IN1~[~IN2~]~[~{~IN3~}~]~[~{~ROL~}~]~}~]~[~ACC~]~[~UB1~]~[~UB2~]~[~PDA~]"
|
51
|
+
assert_equal(expected, parser.get_message_definition())
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_getMessageStructure_ADT_01
|
55
|
+
parser = ProfileParser.new(@attrs)
|
56
|
+
assert_equal('ADT_A01', parser.get_message_structure('ADT_A01'))
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_getMessageStructure_ADT_04
|
60
|
+
parser = ProfileParser.new(@attrs)
|
61
|
+
assert_equal('ADT_A01', parser.get_message_structure('ADT_A04'))
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_getSegmentStructure
|
65
|
+
parser = ProfileParser.new(@attrs)
|
66
|
+
al1 = parser.get_segment_structure('[~{~AL1~}~]')
|
67
|
+
puts al1
|
68
|
+
assert_equal 6, al1.size
|
69
|
+
assert_equal('Set ID - AL1', al1.first['description'.to_sym])
|
70
|
+
end
|
71
|
+
|
72
|
+
# def test_processSegments
|
73
|
+
# parser = ProfileParser.new(@attrs)
|
74
|
+
# struct = "MSH~EVN~PID~[~PD1~]~[~{~ROL~}~]~[~{~NK1~}~]~PV1~[~PV2~]~[~{~ROL~}~]~[~{~DB1~}~]~[~{~OBX~}~]~[~{~AL1~}~]~[~{~DG1~}~]~[~DRG~]~[~{~PR1~[~{~ROL~}~]~}~]~[~{~GT1~}~]~[~{~IN1~[~IN2~]~[~{~IN3~}~]~[~{~ROL~}~]~}~]~[~ACC~]~[~UB1~]~[~UB2~]~[~PDA~]"
|
75
|
+
# results = parser.process_segments(struct)
|
76
|
+
# puts results
|
77
|
+
# assert_equal(2, results.size())
|
78
|
+
# # "MSH~EVN~PID~0~1~2~PV1~3~4~5~6~7~8~9~11~12~16~17~18~19~20"
|
79
|
+
# # ["[~PD1~]", "[~{~ROL~}~]", "[~{~NK1~}~]", "[~PV2~]", "[~{~ROL~}~]", "[~{~DB1~}~]", "[~{~OBX~}~]", "[~{~AL1~}~]", "[~{~DG1~}~]", "[~DRG~]", "[~{~ROL~}~]", ["PR1", "[~{~ROL~}~]"], "[~{~GT1~}~]", "[~IN2~]", "[~{~IN3~}~]", "[~{~ROL~}~]", ["IN1", "[~IN2~]", "[~{~IN3~}~]", "[~{~ROL~}~]"], "[~ACC~]", "[~UB1~]", "[~UB2~]", "[~PDA~]"]
|
80
|
+
#
|
81
|
+
#
|
82
|
+
# profile_idx = 0
|
83
|
+
# segments_idx = 1
|
84
|
+
# #refactored, results returned as collection of arrays instead of map
|
85
|
+
#
|
86
|
+
# assert_equal(21, results[segments_idx].size())
|
87
|
+
# assert_equal('[~PD1~]', results[segments_idx][0])
|
88
|
+
# end
|
89
|
+
|
90
|
+
|
91
|
+
# def test_processSegments_RSP_K22_group
|
92
|
+
# parser = ProfileParser.new(@attrs)
|
93
|
+
# struct = 'MSH~MSA~[~ERR~]~QAK~QPD~{~[~PID~[~PD1~]~[~QRI~]~]~}~[~DSC~]'
|
94
|
+
# profile, encodedSegments = parser.process_segments(struct)
|
95
|
+
# # p profile
|
96
|
+
# # p encodedSegments
|
97
|
+
# assert_equal(7, profile.size())
|
98
|
+
# assert_equal(6, encodedSegments.size()) # to groups
|
99
|
+
#
|
100
|
+
# assert_equal(3, encodedSegments[3].size())
|
101
|
+
# assert_equal('Array', encodedSegments[3].class.name)
|
102
|
+
# end
|
103
|
+
|
104
|
+
# def test_processSegments_not_optional_group
|
105
|
+
# # <MessageStructure name='ADT_A45' definition='MSH~EVN~PID~[~PD1~]~{~MRG~PV1~}' />
|
106
|
+
# parser = ProfileParser.new(@attrs)
|
107
|
+
# struct = "MSH~[~{~ROL~}~]~[~PD1~]~{~MRG~PV1~}"
|
108
|
+
# results = parser.process_segments(struct)
|
109
|
+
# p results
|
110
|
+
# assert_equal(2, results.size())
|
111
|
+
#
|
112
|
+
# profile_idx = 0
|
113
|
+
# segments_idx = 1
|
114
|
+
# #refactored, results returned as collection of arrays instead of map
|
115
|
+
#
|
116
|
+
# assert_equal(3, results[segments_idx].size())
|
117
|
+
# assert_equal('[~{~ROL~}~]', results[segments_idx][0])
|
118
|
+
# end
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
def test_codeTable
|
123
|
+
parser = ProfileParser.new(@attrs)
|
124
|
+
attributes = parser.get_code_table("62")
|
125
|
+
p attributes[0].class
|
126
|
+
p attributes.size
|
127
|
+
#p attributes
|
128
|
+
|
129
|
+
# assert_equal(3, attributes.size)
|
130
|
+
puts attributes
|
131
|
+
assert_equal('1', attributes[0][:position])
|
132
|
+
assert_equal('02', attributes[1][:value])
|
133
|
+
assert_equal('Census management', attributes[2][:description])
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_codeTable_Added
|
137
|
+
parser = ProfileParser.new(@attrs)
|
138
|
+
attributes = parser.get_code_table('296')
|
139
|
+
p attributes[0].class
|
140
|
+
p attributes.size
|
141
|
+
# assert (attributes[0][:position] =='1' && attributes[0][:value] =='EN')
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_codeTable_NoVals
|
145
|
+
parser = ProfileParser.new(@attrs)
|
146
|
+
attributes = parser.get_code_table("-296")
|
147
|
+
p attributes[0].class
|
148
|
+
p attributes.size
|
149
|
+
assert (attributes[0][:position] =='1' && attributes[0][:value] =='...')
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_codeTable_blank
|
153
|
+
parser = ProfileParser.new(@attrs)
|
154
|
+
attributes = parser.get_code_table("")
|
155
|
+
p attributes
|
156
|
+
print attributes.empty?
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_codeTable_special_ch
|
160
|
+
parser = ProfileParser.new(@attrs)
|
161
|
+
attributes = parser.get_code_table("417")
|
162
|
+
# p attributes.*[:description]
|
163
|
+
actual = attributes.collect{|a| a[:description]}
|
164
|
+
# p actual
|
165
|
+
assert actual.include?("Carcinoma-unspecified type")
|
166
|
+
assert_false actual.include?('Degeneration & necrosise')
|
167
|
+
assert_equal 12, attributes.size
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_codeTable_special_ch_2
|
171
|
+
parser = ProfileParser.new(@attrs)
|
172
|
+
# now look in val and description - no 'L&I'
|
173
|
+
attributes = parser.get_code_table("338")
|
174
|
+
# p attributes.*[:description]
|
175
|
+
actual = attributes.collect{|a| a[:value]}
|
176
|
+
# p actual
|
177
|
+
assert_false actual.include?('L&I')#('L&I')
|
178
|
+
assert_equal 10, attributes.size
|
179
|
+
end
|
180
|
+
|
181
|
+
# def test_getSegments
|
182
|
+
# parser = ProfileParser.new(@attrs)
|
183
|
+
# results = parser.get_segments
|
184
|
+
# profile_idx = 0
|
185
|
+
# segments_idx = 1
|
186
|
+
# #refactored, results returned as collection of arrays instead of map
|
187
|
+
# assert_equal(21, results[profile_idx].size())
|
188
|
+
# assert_equal('[~PD1~]', results[segments_idx][0])
|
189
|
+
# end
|
190
|
+
|
191
|
+
# def test_getSegments_vaz
|
192
|
+
# puts Benchmark.measure("segments"){
|
193
|
+
# @attrs[:version] = 'VAZ2.4.HL7'
|
194
|
+
# parser = ProfileParser.new(@attrs)
|
195
|
+
# # parser = ProfileParser.new({version:'vaz2.4', event:'ADT_A01'})
|
196
|
+
# results = parser.get_segments
|
197
|
+
# puts results
|
198
|
+
# }
|
199
|
+
# # assert_equal(21, results[:@encodedSegments].size())
|
200
|
+
# # assert_equal('[~PD1~]', results[:@encodedSegments][0])
|
201
|
+
# end
|
202
|
+
|
203
|
+
def test_lookupMessageTypes_vaz24
|
204
|
+
@attrs[:version] = 'VAZ2.4.HL7'
|
205
|
+
parser = ProfileParser.new(@attrs)
|
206
|
+
# parser = ProfileParser.new({version: 'vaz2.4', event: 'ADT_A01'})
|
207
|
+
results = parser.lookup_message_types()
|
208
|
+
puts results
|
209
|
+
assert_equal 50, results.size
|
210
|
+
|
211
|
+
results = parser.lookup_message_types({filter: 'ADT_|QBP_|RSP_', group:'Admission'})
|
212
|
+
puts results
|
213
|
+
assert_equal 11, results.size
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_lookupMessageTypes_24_all
|
217
|
+
|
218
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
219
|
+
# {std: version[:std], version: p[:doc], version_store: versions}
|
220
|
+
parser = ProfileParser.new(@attrs)
|
221
|
+
results = parser.lookup_message_types()
|
222
|
+
assert_equal 390, results.size
|
223
|
+
|
224
|
+
# puts results
|
225
|
+
results = parser.lookup_message_types(nil)
|
226
|
+
assert_equal 390, results.size
|
227
|
+
# puts results
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_lookupMessageTypes_24_ADT
|
231
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
232
|
+
parser = ProfileParser.new(@attrs)
|
233
|
+
# parser = ProfileParser.new({version:'2.4'})
|
234
|
+
filter = {filter: 'ADT_A', group: 'ADT'}
|
235
|
+
results = parser.lookup_message_types(filter)
|
236
|
+
# puts results
|
237
|
+
assert_equal 57, results.size
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_lookupMessageTypes_24_QBP
|
242
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
243
|
+
parser = ProfileParser.new(@attrs)
|
244
|
+
filter = {filter: 'QBP_Q2', group: 'QBP'}
|
245
|
+
# parser = ProfileParser.new({version:'2.4'})
|
246
|
+
results = parser.lookup_message_types(filter)
|
247
|
+
# puts results
|
248
|
+
assert_equal 5, results.size
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_lookupMessageTypes_24_RSP_K2
|
252
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
253
|
+
parser = ProfileParser.new(@attrs)
|
254
|
+
# parser = ProfileParser.new({version:'2.4'})
|
255
|
+
filter = {filter: 'RSP_K2', group: 'RSP'}
|
256
|
+
results = parser.lookup_message_types(filter)
|
257
|
+
# puts results
|
258
|
+
assert_equal 5, results.size
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_lookupMessageTypes_24_Admissions
|
262
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
263
|
+
parser = ProfileParser.new(@attrs)
|
264
|
+
# parser = ProfileParser.new({version:'2.4'})
|
265
|
+
# if(message.starts_with('ADT_')||message.starts_with('QBP_')||message.starts_with('RSP_'))
|
266
|
+
# results = parser.lookup_message_types('ADT_A|QBP_Q2|RSP_K2')
|
267
|
+
results = parser.lookup_message_types(ProfileParser::FILTER_ADM)
|
268
|
+
puts results[0]
|
269
|
+
assert_equal 66, results.size
|
270
|
+
assert_equal({:name=>'ADT_A01', :code=>'ADT/ACK - Admit / visit notification', :group=>'Admissions'}, results[0])
|
271
|
+
end
|
272
|
+
|
273
|
+
|
274
|
+
# def test_is_group_true_encoded
|
275
|
+
# parser = ProfileParser.new(@attrs)
|
276
|
+
# isCheck, tokens = parser.is_group?("{~3~}")
|
277
|
+
# assert_true isCheck
|
278
|
+
# assert_equal(['3'], tokens)
|
279
|
+
# end
|
280
|
+
|
281
|
+
# def test_is_group_true_all_required
|
282
|
+
# parser = ProfileParser.new(@attrs)
|
283
|
+
# isCheck, tokens = parser.is_group?("{~MRG~PV1~}")
|
284
|
+
# assert_true isCheck
|
285
|
+
# assert_equal(["MRG", "PV1"], tokens)
|
286
|
+
# end
|
287
|
+
|
288
|
+
# def test_is_group_false
|
289
|
+
# parser = ProfileParser.new(@attrs)
|
290
|
+
# isCheck, tokens = parser.is_group?("{~MRG~}")
|
291
|
+
# assert_true !isCheck
|
292
|
+
# assert_equal(['MRG'], tokens)
|
293
|
+
# end
|
294
|
+
|
295
|
+
# def test_is_group_resolved
|
296
|
+
# parser = ProfileParser.new(@attrs)
|
297
|
+
# tokens =[]
|
298
|
+
# isCheck, tokens = parser.is_group?("{~25~}")
|
299
|
+
# p tokens
|
300
|
+
# assert_true isCheck
|
301
|
+
# # assert_true isCheck && parser.is_group_resolved?(tokens) # check for case of all groups resolved
|
302
|
+
# assert_equal(['25'], tokens)
|
303
|
+
#
|
304
|
+
# isCheck, tokens = parser.is_group?("{~25~[~17~]~}")
|
305
|
+
# p tokens
|
306
|
+
# assert_true isCheck
|
307
|
+
# # assert_true isCheck && parser.is_group_resolved?(tokens) # check for case of all groups resolved
|
308
|
+
# assert_equal(['25','17'], tokens)
|
309
|
+
#
|
310
|
+
# isCheck, tokens = parser.is_group?("{~25~[~OBX~]~}")
|
311
|
+
# p tokens
|
312
|
+
# assert_true isCheck
|
313
|
+
# # assert_false isCheck && parser.is_group_resolved?(tokens) # check for case of all groups resolved
|
314
|
+
# assert_equal(['25','OBX'], tokens)
|
315
|
+
#
|
316
|
+
# # isCheck, tokens = parser.is_group?("{~ORC~OBR~11~12~13~15~{~25~}~[~{~FT1~}~]~[~{~CTI~}~]~[~BLG~]~}")
|
317
|
+
# isCheck, tokens = parser.is_group?("~ORC~OBR~11~12~13~15~{~25~}~[~{~FT1~}~]~[~{~CTI~}~]~[~BLG~]~")
|
318
|
+
# p tokens
|
319
|
+
# assert_true isCheck
|
320
|
+
# # assert_false isCheck && parser.is_group_resolved?(tokens) # check for case of all groups resolved
|
321
|
+
# assert_equal(["ORC", "OBR", "11", "12", "13", "15", "25", "FT1", "CTI", "BLG"], tokens)
|
322
|
+
#
|
323
|
+
# end
|
324
|
+
|
325
|
+
|
326
|
+
def test_init_with_versions
|
327
|
+
# vs =
|
328
|
+
# [
|
329
|
+
# {:std=>"2.4", :path=>"../test/test-config/schema/2.4", :profiles=>[{:doc=>"2.4.HL7", :name=>"2.4", :std=>"1", :path=>"../test/test-config/schema/2.4/2.4.HL7.xml"}, {:doc=>"VAZ2.4.HL7", :name=>"VAZ2.4", :description=>"2.4 schema with VA defined tables and Z segments", :base=>"2.4", :path=>"../test/test-config/schema/2.4/VAZ2.4.HL7.xml.bkp"}]},
|
330
|
+
# {:std=>"2.5", :path=>"../test/test-config/schema/2.5", :profiles=>[{:doc=>"2.5.HL7", :name=>"2.5", :std=>"1", :path=>"../test/test-config/schema/2.5/2.5.HL7.xml"}, {:doc=>"TEST2.5.HL7", :name=>"TEST2.5", :description=>"2.5 mockup schema for testing", :base=>"2.4", :path=>"../test/test-config/schema/2.5/VAZ2.5.HL7.xml"}]}
|
331
|
+
# ]
|
332
|
+
# pps = ProfileParserStub.new({std: '2.4.', version: '2.4.HL7', version_store: vs})
|
333
|
+
pps = ProfileParser.new(@attrs)
|
334
|
+
filter = {filter: 'QBP_Q2', group: 'QBP'}
|
335
|
+
results = pps.lookup_message_types(filter)
|
336
|
+
# puts results
|
337
|
+
assert_equal 5, results.size
|
338
|
+
|
339
|
+
end
|
340
|
+
|
341
|
+
# use test configurations for lookup methods to run throug different scenarios
|
342
|
+
class ProfileParserStub < ProfileParser
|
343
|
+
|
344
|
+
def self.get_schema_location
|
345
|
+
'../test/test-config/schema/'
|
346
|
+
end
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
# use of a stab to point to location of test resources
|
351
|
+
def test_lookup_versions
|
352
|
+
versions = ProfileParserStub.lookup_versions()
|
353
|
+
assert_equal 2, versions.size
|
354
|
+
|
355
|
+
coll=[]
|
356
|
+
versions.each{ |version|
|
357
|
+
ver_attrs={}
|
358
|
+
# standard
|
359
|
+
ver_attrs[:std] = version[:std]
|
360
|
+
#versions
|
361
|
+
ver_attrs[:versions] = version[:profiles].inject([]){|col,p| col << {name: p[:doc], code: p[:name], desc: (p[:std])? 'Base': p[:description]}}
|
362
|
+
|
363
|
+
#events
|
364
|
+
# version[:profiles].each{|p|
|
365
|
+
|
366
|
+
# parser = ProfileParserStub.new({std: version[:std], version: p[:doc], version_store: versions})
|
367
|
+
# events = parser.lookup_message_types('ADT_A|QBP_Q2|RSP_K2')#@@ADM_FILTER
|
368
|
+
# e_map[p[:name]]= events
|
369
|
+
# }
|
370
|
+
filter = ProfileParserStub::FILTER_ADM
|
371
|
+
|
372
|
+
evn_attrs = version[:profiles].inject({}){|h,p|
|
373
|
+
h.merge({p[:name] => ProfileParserStub.new({std: version[:std], version: p[:doc], version_store: versions}).lookup_message_types(filter)})
|
374
|
+
}
|
375
|
+
ver_attrs[:events] = evn_attrs
|
376
|
+
|
377
|
+
# add map with versions and events for each standard to the array
|
378
|
+
coll << ver_attrs
|
379
|
+
}
|
380
|
+
|
381
|
+
versions_to_client = {standards: coll}
|
382
|
+
$log.unknown versions_to_client
|
383
|
+
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_lookup_versions_using_rules
|
387
|
+
|
388
|
+
versions = ProfileParserStub.lookup_versions()
|
389
|
+
assert_equal 2, versions.size
|
390
|
+
|
391
|
+
coll=[]
|
392
|
+
versions.each{ |version|
|
393
|
+
ver_attrs={}
|
394
|
+
# standard
|
395
|
+
ver_attrs[:std] = version[:std]
|
396
|
+
#versions
|
397
|
+
ver_attrs[:versions] = version[:profiles].inject([]){|col,p| col << {name: p[:doc], code: p[:name], desc: (p[:std])? 'Base': p[:description]}}
|
398
|
+
|
399
|
+
|
400
|
+
evn_attrs = version[:profiles].inject({}){|h,p|
|
401
|
+
filter_map = nil
|
402
|
+
exclusions = ProfileParserStub.getExclusionFilterRule(p[:name], p[:doc])
|
403
|
+
h.merge({p[:name] => ProfileParserStub.new({std: version[:std], version: p[:doc], version_store: versions}).lookup_message_types(filter_map, exclusions)})
|
404
|
+
}
|
405
|
+
|
406
|
+
# filter = ProfileParserStub.getExclusionFilter(p[:name], p[:doc]);
|
407
|
+
# if(p[:name]=='2.4' && p[:doc]=='2.4.HL7')
|
408
|
+
# assert_equal 137, filter.size
|
409
|
+
# elsif
|
410
|
+
# assert_equal 0, filter.size
|
411
|
+
# end
|
412
|
+
|
413
|
+
ver_attrs[:events] = evn_attrs
|
414
|
+
|
415
|
+
# add map with versions and events for each standard to the array
|
416
|
+
coll << ver_attrs
|
417
|
+
}
|
418
|
+
|
419
|
+
versions_to_client = {standards: coll}
|
420
|
+
puts versions_to_client
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
def test_getExclusionFilter
|
425
|
+
std = '2.4'
|
426
|
+
version = "2.4.HL7"
|
427
|
+
filter = ProfileParserStub.getExclusionFilterRule(std, version);
|
428
|
+
puts filter
|
429
|
+
assert_equal 137, filter.size
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_getExclusionFilter_no_rules_file
|
433
|
+
std = '2.4'
|
434
|
+
version = "Bla-bla"
|
435
|
+
filter = ProfileParserStub.getExclusionFilterRule(std, version);
|
436
|
+
puts filter
|
437
|
+
assert_equal 0, filter.size
|
438
|
+
end
|
439
|
+
|
440
|
+
def test_lookup_message_types_24_Pharm
|
441
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
442
|
+
parser = ProfileParser.new(@attrs)
|
443
|
+
# 1 OMP_O09 Pharmacy/treatment order message
|
444
|
+
# 2 ORP_O10 Pharmacy/treatment order acknowledgement
|
445
|
+
# 3 RDE_O11 Pharmacy/treatment encoded order message
|
446
|
+
# 4 RRE_O12 Pharmacy/treatment encoded order acknowledgement
|
447
|
+
# 5 RDS_O13 Pharmacy dispense message
|
448
|
+
# 6 RRD_O14 Pharmacy/treatment dispense acknowledgement
|
449
|
+
# 7 RGV_O15 Pharmacy give message
|
450
|
+
# 8 RRG_O16 Pharmacy/treatment give acknowledgement
|
451
|
+
# 9 RAS_O17 Pharmacy administration message
|
452
|
+
# 10 RRA_O18 Pharmacy/treatment administration acknowledgement
|
453
|
+
|
454
|
+
# filter= {filter: 'OMP_|ORP_|RDE_|RRE_|RDS_|RRD_|RGV_|RRG_|RAS_|RRA_', group: 'Pharmacy'}
|
455
|
+
|
456
|
+
results = parser.lookup_message_types(ProfileParser::FILTER_PH)
|
457
|
+
puts results[0]
|
458
|
+
assert_equal 10, results.size
|
459
|
+
assert_equal({:name=>"OMP_O09", :code=>"OMP - Pharmacy/treatment order", :group=>"Pharmacy"}, results[0])
|
460
|
+
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_lookup_message_types_24_all
|
464
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
465
|
+
parser = ProfileParser.new(@attrs)
|
466
|
+
|
467
|
+
# all
|
468
|
+
all = parser.lookup_message_types()
|
469
|
+
assert_equal 390, parser.lookup_message_types().size
|
470
|
+
msgs = []
|
471
|
+
all.each{|it| msgs << it[:name] }
|
472
|
+
# p msgs
|
473
|
+
# ["ACK", "ACK_N02", "ACK_R01", "ADR_A19", "ADT_A01", "ADT_A02", "ADT_A03", "ADT_A04", "ADT_A05", "ADT_A06", "ADT_A07", "ADT_A08", "ADT_A09", "ADT_A10", "ADT_A11", "ADT_A12", "ADT_A13", "ADT_A14", "ADT_A15", "ADT_A16", "ADT_A17", "ADT_A18", "ADT_A20", "ADT_A21", "ADT_A22", "ADT_A23", "ADT_A24", "ADT_A25", "ADT_A26", "ADT_A27", "ADT_A28", "ADT_A29", "ADT_A30", "ADT_A31", "ADT_A32", "ADT_A33", "ADT_A34", "ADT_A35", "ADT_A36", "ADT_A37", "ADT_A38", "ADT_A39", "ADT_A40", "ADT_A41", "ADT_A42", "ADT_A43", "ADT_A44", "ADT_A45", "ADT_A46", "ADT_A47", "ADT_A48", "ADT_A49", "ADT_A50", "ADT_A51", "ADT_A52", "ADT_A53", "ADT_A54", "ADT_A55", "ADT_A60", "ADT_A61", "ADT_A62", "BAR_P01", "BAR_P02", "BAR_P05", "BAR_P06", "BAR_P10", "BHS", "CRM_C01", "CRM_C02", "CRM_C03", "CRM_C04", "CRM_C05", "CRM_C06", "CRM_C07", "CRM_C08", "CSU_C09", "CSU_C10", "CSU_C11", "CSU_C12", "DFT_P03", "DFT_P11", "DOC_T12", "DSR_P04", "DSR_Q01", "DSR_Q03", "EAC_U07", "EAN_U09", "EAR_U08", "EDR_R07", "EQQ_Q04", "ERP_R09", "ESR_U02", "ESU_U01", "FHS", "INR_U06", "INU_U05", "LSR_U13", "LSU_U12", "MDM_T01", "MDM_T02", "MDM_T03", "MDM_T04", "MDM_T05", "MDM_T06", "MDM_T07", "MDM_T08", "MDM_T09", "MDM_T10", "MDM_T11", "MFK_M01", "MFK_M02", "MFK_M03", "MFK_M04", "MFK_M05", "MFK_M06", "MFK_M07", "MFN_M01", "MFN_M02", "MFN_M03", "MFN_M04", "MFN_M05", "MFN_M06", "MFN_M07", "MFN_M08", "MFN_M09", "MFN_M10", "MFN_M11", "MFN_M12", "MFQ_M01", "MFQ_M01_2", "MFQ_M02_2", "MFQ_M03_2", "MFQ_M04_2", "MFQ_M05_2", "MFQ_M06_2", "MFR_M01", "MFR_M02", "MFR_M03", "MFR_M04", "MFR_M05", "MFR_M06", "NMD_N02", "NMQ_N01", "NMR_N01", "NUL_K11", "NUL_K13", "NUL_K15", "NUL_K21", "NUL_K22", "NUL_K23", "NUL_K24", "NUL_K25", "NUL_O04", "NUL_O06", "NUL_O08", "NUL_O10", "NUL_O12", "NUL_O14", "NUL_O16", "NUL_O18", "NUL_O20", "NUL_O22", "NUL_PC5", "NUL_PCA", "NUL_PCF", "NUL_PCL", "NUL_R04", "NUL_R07", "NUL_R08", "NUL_R09", "NUL_RAR", "NUL_RDR", "NUL_RER", "NUL_RGR", "NUL_ROR", "NUL_V02", "NUL_V03", "NUL_Z74", "NUL_Z82", "NUL_Z86", "NUL_Z88", "NUL_Z90", "OMD_O03", "OMG_O19", "OML_O21", "OMN_O07", "OMP_O09", "OMS_O05", "ORD_O04", "ORF_R04", "ORF_W02", "ORG_O20", "ORL_O22", "ORM_O01", "ORN_O08", "ORP_O10", "ORR_O02", "ORS_O06", "ORU_R01", "ORU_W01", "OSQ_Q06", "OSR_Q06", "OUL_R21", "PEX_P07", "PEX_P08", "PGL_PC6", "PGL_PC7", "PGL_PC8", "PIN_I07", "PMU_B01", "PMU_B02", "PMU_B03", "PMU_B04", "PMU_B05", "PMU_B06", "PPG_PCG", "PPG_PCH", "PPG_PCJ", "PPP_PCB", "PPP_PCC", "PPP_PCD", "PPR_PC1", "PPR_PC2", "PPR_PC3", "PPT_PCL", "PPV_PCA", "PRR_PC5", "PTR_PCF", "QBP_Q11", "QBP_Q13", "QBP_Q15", "QBP_Q21", "QBP_Q22", "QBP_Q23", "QBP_Q24", "QBP_Q25", "QBP_Z73", "QBP_Z75", "QBP_Z77", "QBP_Z79", "QBP_Z81", "QBP_Z85", "QBP_Z87", "QBP_Z89", "QBP_Z91", "QBP_Z93", "QBP_Z95", "QBP_Z97", "QBP_Z99", "QCK_Q02", "QCN_J01", "QRY_A19", "QRY_P04", "QRY_PC4", "QRY_PC9", "QRY_PCE", "QRY_PCK", "QRY_Q01", "QRY_Q02", "QRY_Q26", "QRY_Q27", "QRY_Q28", "QRY_Q29", "QRY_Q30", "QRY_R02", "QRY_T12", "QRY_W01", "QRY_W02", "QSB_Q16", "QSB_Z83", "QSX_J02", "QVR_Q17", "RAR_RAR", "RAS_O17", "RCI_I05", "RCL_I06", "RDE_O11", "RDR_RDR", "RDS_O13", "RDY_K15", "RDY_Z80", "RDY_Z98", "REF_I12", "REF_I13", "REF_I14", "REF_I15", "RER_RER", "RGR_RGR", "RGV_O15", "ROR_ROR", "RPA_I08", "RPA_I09", "RPA_I10", "RPA_I11", "RPI_I01", "RPI_I04", "RPL_I02", "RPR_I03", "RQA_I08", "RQA_I09", "RQA_I10", "RQA_I11", "RQC_I05", "RQC_I06", "RQI_I01", "RQI_I02", "RQI_I03", "RQP_I04", "RQQ_Q09", "RRA_O18", "RRD_O14", "RRE_O12", "RRG_O16", "RRI_I12", "RRI_I13", "RRI_I14", "RRI_I15", "RSP_K11", "RSP_K13", "RSP_K15", "RSP_K21", "RSP_K22", "RSP_K23", "RSP_K24", "RSP_K25", "RSP_Z82", "RSP_Z84", "RSP_Z86", "RSP_Z88", "RSP_Z90", "RTB_K13", "RTB_Knn", "RTB_Q13", "RTB_Z74", "RTB_Z76", "RTB_Z78", "RTB_Z92", "RTB_Z94", "RTB_Z96", "SIU_S12", "SIU_S13", "SIU_S14", "SIU_S15", "SIU_S16", "SIU_S17", "SIU_S18", "SIU_S19", "SIU_S20", "SIU_S21", "SIU_S22", "SIU_S23", "SIU_S24", "SIU_S26", "SPQ_Q08", "SQM_S25", "SQR_S25", "SRM_S01", "SRM_S02", "SRM_S03", "SRM_S04", "SRM_S05", "SRM_S06", "SRM_S07", "SRM_S08", "SRM_S09", "SRM_S10", "SRM_S11", "SRR_S01", "SRR_S02", "SRR_S03", "SRR_S04", "SRR_S05", "SRR_S06", "SRR_S07", "SRR_S08", "SRR_S09", "SRR_S10", "SRR_S11", "SSR_U04", "SSU_U03", "SUR_P09", "TBR_R08", "TCR_U11", "TCU_U10", "UDM_Q05", "VQQ_Q07", "VXQ_V01", "VXR_V03", "VXU_V04", "VXX_V02"]
|
474
|
+
|
475
|
+
end
|
476
|
+
|
477
|
+
def test_lookup_message_groups
|
478
|
+
@attrs.delete(:event)# no events passed to lookup all event types
|
479
|
+
parser = ProfileParser.new(@attrs)
|
480
|
+
results = parser.lookup_message_groups([ProfileParser::FILTER_PH, ProfileParser::FILTER_ADM])
|
481
|
+
puts results
|
482
|
+
assert_equal 76, results.size
|
483
|
+
assert_equal({:name=>"OMP_O09", :code=>"OMP - Pharmacy/treatment order", :group=>"Pharmacy"}, results[0])
|
484
|
+
assert_equal({:name=>"RSP_K24", :code=>"RSP - Allocate identifiers response", :group=>"Admissions"}, results[75])
|
485
|
+
|
486
|
+
end
|
487
|
+
|
488
|
+
def test_get_templates
|
489
|
+
parser = ProfileParser.new(@attrs)
|
490
|
+
path = "../test/test-config/templates/2.4/"
|
491
|
+
# path = '/Users/romansova/RubymineProjects/ez7gen/test/test-config/templates/2.4'
|
492
|
+
#templates = Dir.entries(path).select {|f| f =~/.xml/}.sort
|
493
|
+
# templates = Dir.glob("#{path}/*")
|
494
|
+
#templates = Dir[path + '/*.xml'].
|
495
|
+
# templates = Dir.glob(path + '/*.xml').select{|f| File(f)}
|
496
|
+
templates = parser.get_templates(path)
|
497
|
+
puts templates
|
498
|
+
end
|
499
|
+
|
500
|
+
|
501
|
+
def test_lookup_events
|
502
|
+
@attrs[:version] = 'VAZ2.4.HL7'
|
503
|
+
parser = ProfileParser.new(@attrs)
|
504
|
+
lookup_params ={}
|
505
|
+
lookup_params[:templates_path] = File.expand_path("../test-config/templates/#{@attrs[:std]}/", __FILE__)
|
506
|
+
|
507
|
+
results = parser.lookup_events(lookup_params);
|
508
|
+
|
509
|
+
end
|
510
|
+
|
511
|
+
|
512
|
+
# def test_processSegments_pharm
|
513
|
+
# # first pass
|
514
|
+
# # 1) look for repeading groups
|
515
|
+
# # 2) brake them into subgroups - arrays
|
516
|
+
# # second pass
|
517
|
+
# # 3) go over and find optional groups
|
518
|
+
# # 4) brake them into subgroups - arrays
|
519
|
+
# #
|
520
|
+
# # arr
|
521
|
+
# # e
|
522
|
+
# # arr [e,arr[e,e,e],arr[e,e,e],e, e,]
|
523
|
+
# # seg : "[~17~19~20~{~21~OBR~22~23~{~OBX~24~}~}~]"
|
524
|
+
#
|
525
|
+
# # to do
|
526
|
+
# # resolve {} complex groups
|
527
|
+
# # within {} complex groups finish encoding
|
528
|
+
# # handle complex [] groups
|
529
|
+
# # handle groups need to handle arrays of subgroups
|
530
|
+
# # refactor!!!
|
531
|
+
#
|
532
|
+
#
|
533
|
+
# parser = ProfileParser.new(@attrs)
|
534
|
+
# struct = 'MSH~[~{~NTE~}~]~[~PID~[~PD1~]~[~{~NTE~}~]~[~PV1~[~PV2~]~]~[~{~IN1~[~IN2~]~[~IN3~]~}~]~[~GT1~]~[~{~AL1~}~]~]~{~ORC~OBR~[~{~NTE~}~]~[~CTD~]~[~{~DG1~}~]~[~{~OBX~[~{~NTE~}~]~}~]~{~[~[~PID~[~PD1~]~]~[~PV1~[~PV2~]~]~[~{~AL1~}~]~{~[~ORC~]~OBR~[~{~NTE~}~]~[~CTD~]~{~OBX~[~{~NTE~}~]~}~}~]~}~[~{~FT1~}~]~[~{~CTI~}~]~[~BLG~]~}'
|
535
|
+
# # struct = "MSH~EVN~PID~[~PD1~]~[~{~ROL~}~]~[~{~NK1~}~]~PV1~[~PV2~]~[~{~ROL~}~]~[~{~DB1~}~]~[~{~OBX~}~]~[~{~AL1~}~]~[~{~DG1~}~]~[~DRG~]~[~{~PR1~[~{~ROL~}~]~}~]~[~{~GT1~}~]~[~{~IN1~[~IN2~]~[~{~IN3~}~]~[~{~ROL~}~]~}~]~[~ACC~]~[~UB1~]~[~UB2~]~[~PDA~]"
|
536
|
+
# results = parser.process(struct)
|
537
|
+
# puts results
|
538
|
+
# assert_equal(2, results.size())
|
539
|
+
#
|
540
|
+
# end
|
541
|
+
|
542
|
+
end
|