From e60d0f377016bed8632509f45ed26d9f59c986a8 Mon Sep 17 00:00:00 2001 From: wyb <1977763549@qq.com> Date: Fri, 23 Aug 2024 17:02:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B9=BF=E5=B7=9E=E4=B8=AD=E8=A5=BF?= =?UTF-8?q?=E5=8C=BB=E7=BB=93=E5=90=88pmrs=E6=8E=A5=E5=8F=A3=E9=87=87?= =?UTF-8?q?=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data-config/gzzxyjh-pmrs-emrtype-alis | 227 +++++ data-config/gzzxyjh-ws-config | 9 + .../docus/server/gzzxyjh/AssortConfig.java | 42 + .../com/docus/server/gzzxyjh/FileDto.java | 31 + .../gzzxyjh/job/GzZxyJhPMRSCollectJob.java | 212 +++++ .../server/util/JaxWsDynamicClientUtil.java | 69 ++ .../com/docus/server/util/TableJsonRead.java | 195 ++++ .../java/com/docus/server/util/XmlUtil.java | 857 ++++++++++++++++++ 8 files changed, 1642 insertions(+) create mode 100644 data-config/gzzxyjh-pmrs-emrtype-alis create mode 100644 data-config/gzzxyjh-ws-config create mode 100644 src/main/java/com/docus/server/gzzxyjh/AssortConfig.java create mode 100644 src/main/java/com/docus/server/gzzxyjh/FileDto.java create mode 100644 src/main/java/com/docus/server/gzzxyjh/job/GzZxyJhPMRSCollectJob.java create mode 100644 src/main/java/com/docus/server/util/JaxWsDynamicClientUtil.java create mode 100644 src/main/java/com/docus/server/util/TableJsonRead.java create mode 100644 src/main/java/com/docus/server/util/XmlUtil.java diff --git a/data-config/gzzxyjh-pmrs-emrtype-alis b/data-config/gzzxyjh-pmrs-emrtype-alis new file mode 100644 index 0000000..c6e8090 --- /dev/null +++ b/data-config/gzzxyjh-pmrs-emrtype-alis @@ -0,0 +1,227 @@ +[ + { + "emrTypeCode": "defaut", + "assortId": "" + }, + {"emrTypeCode": "AgreeRecord","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Anaes_Agree_Record","assortId": "C2C40DB213E76592B696244F423152C4"}, + {"emrTypeCode": "AnaesthesiaAgree","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Blood_Transfusion_Record","assortId": "B2835AB12202CDF825860A305E4D7AE1"}, + {"emrTypeCode": "Ops_Agree_Record","assortId": "3DC3F75E2666D0730BCA08A617C20704"}, + {"emrTypeCode": "Ops_Agree_Record","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Other_Agree_Record","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Public_Record","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Scan.ZQGZS","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Special_Check_Record","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Special_Check_Record","assortId": "8B90E00DBF4B25BF2D0083F2E786BA76"}, + {"emrTypeCode": "病理","assortId": "04B1A1E0DDE32223FF8C65487177C7C2"}, + {"emrTypeCode": "Partogram","assortId": "BFD4063331AD45FB83C7332DF49ECBF4"}, + {"emrTypeCode": "Partogram_Record","assortId": "BFD4063331AD45FB83C7332DF49ECBF4"}, + {"emrTypeCode": "Scan.CCT","assortId": "BFD4063331AD45FB83C7332DF49ECBF4"}, + {"emrTypeCode": "Scan.CEZL","assortId": "15246251F41142438351F5FA90DD7AF9"}, + {"emrTypeCode": "Scan.CJC","assortId": "BFD4063331AD45FB83C7332DF49ECBF4"}, + {"emrTypeCode": "FirstPage","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"}, + {"emrTypeCode": "First_Page","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"}, + {"emrTypeCode": "First_Page_Case","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"}, + {"emrTypeCode": "PMR.BASY","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"}, + {"emrTypeCode": "Scan.BASY","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"}, + {"emrTypeCode": "OperationRecord","assortId": "1D0FCD8E4162D51E2655067915B68E96"}, + {"emrTypeCode": "Operation_Record","assortId": "1D0FCD8E4162D51E2655067915B68E96"}, + {"emrTypeCode": "Operation_Record","assortId": "1D0FCD8E4162D51E2655067915B68E96"}, + {"emrTypeCode": "OpsRiskEvaluate","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "OpsSafeCheck","assortId": "1429AFC1870B60E563903022D733D443"}, + {"emrTypeCode": "Scan.SSHLDJL","assortId": "hljl"}, + {"emrTypeCode": "Scan.SSXGJL","assortId": "1D0FCD8E4162D51E2655067915B68E96"}, + {"emrTypeCode": "ConsultationRecord","assortId": "075086B52919A0DBC0734EE3FF8A8A59"}, + {"emrTypeCode": "Consultation_Order_Record","assortId": "075086B52919A0DBC0734EE3FF8A8A59"}, + {"emrTypeCode": "Consultation_Record","assortId": "075086B52919A0DBC0734EE3FF8A8A59"}, + {"emrTypeCode": "Consultation_Record","assortId": "075086B52919A0DBC0734EE3FF8A8A59"}, + {"emrTypeCode": "24In_Dead_Record","assortId": "DB65417382ED778C2EA14470FBE5466B"}, + {"emrTypeCode": "24In_Record","assortId": "91AEF4D8FAD38646A223016B99349D3F"}, + {"emrTypeCode": "InRecord","assortId": "5A74EEAC6970FB03397E6B80E4DC7219"}, + {"emrTypeCode": "In_Record","assortId": "5A74EEAC6970FB03397E6B80E4DC7219"}, + {"emrTypeCode": "In_Record","assortId": "5A74EEAC6970FB03397E6B80E4DC7219"}, + {"emrTypeCode": "PMR.Evaluation","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"}, + {"emrTypeCode": "GM","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"}, + {"emrTypeCode": "PMR.BLOOD_TRANS","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"}, + {"emrTypeCode": "PMR.LIS","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"}, + {"emrTypeCode": "RT","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"}, + {"emrTypeCode": "Scan.JYBG","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"}, + {"emrTypeCode": "Scan.YWJYBG","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"}, + {"emrTypeCode": "Scan.MZBL","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "2022022515","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "2022062504","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "2022062508","assortId": "07BACE747E6C440B9FCC36A6F529C0B3"}, + {"emrTypeCode": "2022062510","assortId": "07BACE747E6C440B9FCC36A6F529C0B3"}, + {"emrTypeCode": "2022062511","assortId": "hljl"}, + {"emrTypeCode": "AnaesthesiaRecord","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "OpsAfterVisitationRecord","assortId": "520832CB908E21E570D7C7A3F01EF384"}, + {"emrTypeCode": "OpsAnaesthesiaRecord","assortId": "1D0FCD8E4162D51E2655067915B68E96"}, + {"emrTypeCode": "OpsVisitationRecord","assortId": "8B0D105A3BB9DC994CEAC80D80EEA540"}, + {"emrTypeCode": "PMR.AIS","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "Scan.MZXGJL","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "anes_informed_consent","assortId": "C2C40DB213E76592B696244F423152C4"}, + {"emrTypeCode": "anes_record","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "anes_summary","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "equipment_inventory1","assortId": "07BACE747E6C440B9FCC36A6F529C0B3"}, + {"emrTypeCode": "nurse_record","assortId": "hljl"}, + {"emrTypeCode": "oper_safety_verification","assortId": "1429AFC1870B60E563903022D733D443"}, + {"emrTypeCode": "pacu_record","assortId": "hljl"}, + {"emrTypeCode": "postoperative_anes_visit","assortId": "8B0D105A3BB9DC994CEAC80D80EEA540"}, + {"emrTypeCode": "pre_anes_visit","assortId": "8B0D105A3BB9DC994CEAC80D80EEA540"}, + {"emrTypeCode": "pre_nurse_visit","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "shoushufusu","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "shoushujiaojiedan","assortId": "FF246633CB15136448471EDD30FEB6E1"}, + {"emrTypeCode": "Admission_Assess","assortId": "hljl"}, + {"emrTypeCode": "Catheters","assortId": "hljl"}, + {"emrTypeCode": "Catheters_Record","assortId": "hljl"}, + {"emrTypeCode": "Chinese_Nurse","assortId": "hljl"}, + {"emrTypeCode": "Chinese_Nurse_Record","assortId": "hljl"}, + {"emrTypeCode": "Chinese_Nurse_Record","assortId": "hljl"}, + {"emrTypeCode": "Danger_Nurse_Record","assortId": "hljl"}, + {"emrTypeCode": "Danger_Nurse_Record","assortId": "hljl"}, + {"emrTypeCode": "In_Assess_Record","assortId": "hljl"}, + {"emrTypeCode": "In_Assess_Record","assortId": "hljl"}, + {"emrTypeCode": "Normal_Nurse","assortId": "hljl"}, + {"emrTypeCode": "NurseBook","assortId": "hljl"}, + {"emrTypeCode": "NurseForm","assortId": "hljl"}, + {"emrTypeCode": "NurseFormRec","assortId": "hljl"}, + {"emrTypeCode": "NurseFormRec","assortId": "hljl"}, + {"emrTypeCode": "NurseRecord","assortId": "hljl"}, + {"emrTypeCode": "Nurse_Measure","assortId": "hljl"}, + {"emrTypeCode": "Out_Assess","assortId": "hljl"}, + {"emrTypeCode": "Out_Assess_Record","assortId": "hljl"}, + {"emrTypeCode": "PMR.XTJC","assortId": "hljl"}, + {"emrTypeCode": "Scan.HLPG","assortId": "hljl"}, + {"emrTypeCode": "Scan.HLXGJL","assortId": "hljl"}, + {"emrTypeCode": "Surgical Resuscitation","assortId": "hljl"}, + {"emrTypeCode": "Transport_Record","assortId": "hljl"}, + {"emrTypeCode": "Transport_book","assortId": "hljl"}, + {"emrTypeCode": "PMR.HIS","assortId": "E348EE6045DA800A9DA3E106986A16BC"}, + {"emrTypeCode": "Scan.YZD","assortId": "E348EE6045DA800A9DA3E106986A16BC"}, + {"emrTypeCode": "Dead_Record","assortId": "DB65417382ED778C2EA14470FBE5466B"}, + {"emrTypeCode": "OutRecord","assortId": "91AEF4D8FAD38646A223016B99349D3F"}, + {"emrTypeCode": "Out_Record","assortId": "91AEF4D8FAD38646A223016B99349D3F"}, + {"emrTypeCode": "Out_Record","assortId": "91AEF4D8FAD38646A223016B99349D3F"}, + {"emrTypeCode": "CT","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "DR","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_1","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_401","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_402","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_403","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_404","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_405","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_406","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_407","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_408","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_409","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_410","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_411","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_412","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_413","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_414","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_415","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_416","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_417","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_418","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_419","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_420","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ECG_421","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "EI","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "EL","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "ES","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "MR","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "Scan.JCBG","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "Scan.YWJCBG","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "US","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"}, + {"emrTypeCode": "Path","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "AttendingInvestigate","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "BloodRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "CrisisRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "DifficultyDiscuss_bak","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "DirectorBigInvestigate","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "DirectorInvestigate","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "FirstRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "HandRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "ICU_Rescue","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "LeaveHospitalRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "MomentSummarize","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "NormalRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "OperRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "OpsDiscuss","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "OpsFirstRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "OpsSummarize","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "ProcessRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "Process_ConsultationR","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "SalvageRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "ShiftRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "ShiftToRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "StrengthenMonitoring","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "TurnOutRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "Medical_Book","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Medical_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Medical_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Medical_Insur_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Medical_Rating_Scale","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Nurse_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Public_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Public_book","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Scan.GGLWS","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "PMR.IN_NOTICE","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Scan.RYTZD","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "DeadDiscuss","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "DeadDiscuss_bak","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "Baby_Temperature_Record","assortId": "hljl"}, + {"emrTypeCode": "TemperatureRecord","assortId": "2BCC34D0449C2FD2972EEB5F4CAD7E1D"}, + {"emrTypeCode": "Temperature_Record","assortId": "2BCC34D0449C2FD2972EEB5F4CAD7E1D"}, + {"emrTypeCode": "Temperature_Record","assortId": "2BCC34D0449C2FD2972EEB5F4CAD7E1D"}, + {"emrTypeCode": "HDS","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Scan.Other","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Scan.RYJBXX","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "InOtherRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "In_Other_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "In_Other_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Scan.HLJLD","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Scan.ZRWDJ","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "PMP.ICU","assortId": "hljl"}, + {"emrTypeCode": "IcuNurseRecord","assortId": "hljl"}, + {"emrTypeCode": "Icu_Nurse_Record","assortId": "hljl"}, + {"emrTypeCode": "Cancer_Discuss_Record","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "DifficultyDiscuss","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "Discuss","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "Discuss_Record","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "EmgNurseRecord","assortId": "hljl"}, + {"emrTypeCode": "EmgSalvageRecord","assortId": "hljl"}, + {"emrTypeCode": "Emg_NurseRecord","assortId": "hljl"}, + {"emrTypeCode": "Emg_SalvageRecord","assortId": "hljl"}, + {"emrTypeCode": "In_Record_FC","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "NurseConsultationRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Nurse_Agree_Record","assortId": "EABEEB5D628449A7930F4C0A9953A754"}, + {"emrTypeCode": "Nurse_Consultation_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Operation_Other_Report","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutAgreeRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutDiseaseRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutEmergencyRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutFirstPage","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutMedicalRecords","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutNurseBook","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutNurseRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutRecordPortal","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "OutTemperatureRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_Agree_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_Disease_Record","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"}, + {"emrTypeCode": "Out_Emergency_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_First","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_First_Page","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_Medical_Records","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_Nurse_Measure","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_Nurse_Record","assortId": "hljl"}, + {"emrTypeCode": "Out_SecondNew","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_Second_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "Out_Temperature_Record","assortId": "hljl"}, + {"emrTypeCode": "PMR.Paper","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "SecondNew","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "SecondRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}, + {"emrTypeCode": "SegmentRecord","assortId": "9DD481903F5CB2EE0CCAC3F639D93E3E"} +] \ No newline at end of file diff --git a/data-config/gzzxyjh-ws-config b/data-config/gzzxyjh-ws-config new file mode 100644 index 0000000..dd7d79c --- /dev/null +++ b/data-config/gzzxyjh-ws-config @@ -0,0 +1,9 @@ +{ + "pmrs":{ + "collectorId":"1", + "url": "http://192.168.12.121:3000/ws/service?wsdl", + "namespaceUri": "http://ws.sie.com", + "operationName": "service", + "param": "flow=02-PAPERLESS-PMRS,app=JS_MR_DOC" + } +} \ No newline at end of file diff --git a/src/main/java/com/docus/server/gzzxyjh/AssortConfig.java b/src/main/java/com/docus/server/gzzxyjh/AssortConfig.java new file mode 100644 index 0000000..868ac19 --- /dev/null +++ b/src/main/java/com/docus/server/gzzxyjh/AssortConfig.java @@ -0,0 +1,42 @@ +package com.docus.server.gzzxyjh; + +import com.alibaba.fastjson.JSON; +import com.docus.core.util.Func; +import com.docus.server.util.TableJsonRead; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author wyb + */ +public class AssortConfig { + private final static String CONFIG_FILE_PATH = "data-config"; + private final static String CONFIG_FILE_NAME = "gzzxyjh-pmrs-emrtype-alis"; + + public static List getConfig() { + TableJsonRead jsonReader = new TableJsonRead(); + String configJson = jsonReader.ReadContent(CONFIG_FILE_PATH, CONFIG_FILE_NAME); + if (configJson == null) { + return new ArrayList<>(); + } + List configs = JSON.parseArray(configJson, Config.class); + if (Func.isEmpty(configs)) { + return new ArrayList<>(); + } + return configs; + } + + @Data + public static class Config { + private String emrTypeCode; + private String assortId; + } + + public static void main(String[] args) + { + List taskConfig = getConfig(); + System.out.println(taskConfig); + } +} diff --git a/src/main/java/com/docus/server/gzzxyjh/FileDto.java b/src/main/java/com/docus/server/gzzxyjh/FileDto.java new file mode 100644 index 0000000..278c75b --- /dev/null +++ b/src/main/java/com/docus/server/gzzxyjh/FileDto.java @@ -0,0 +1,31 @@ +package com.docus.server.gzzxyjh; + +import lombok.Data; + +/** + *

+ * 病案基本信息 + *

+ * + * @author jiashi + * @since 2021-04-14 + */ +@Data +public class FileDto { + + private String PMR_ID; + + private String PMR_NAME; + + private String RCD_TYPE_CODE; + + private String RCD_TYPE_NAME; + + private String PMR_NAME_NO; + + private String PMR_URL; + + private String EMR_TYPE_CODE; + + private String EMR_TYPE_NAME; +} diff --git a/src/main/java/com/docus/server/gzzxyjh/job/GzZxyJhPMRSCollectJob.java b/src/main/java/com/docus/server/gzzxyjh/job/GzZxyJhPMRSCollectJob.java new file mode 100644 index 0000000..bfb915f --- /dev/null +++ b/src/main/java/com/docus/server/gzzxyjh/job/GzZxyJhPMRSCollectJob.java @@ -0,0 +1,212 @@ +package com.docus.server.gzzxyjh.job; + +import com.alibaba.fastjson.JSONObject; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.exception.BaseException; +import com.docus.infrastructure.web.api.CommonResult; +import com.docus.infrastructure.web.api.ResultCode; +import com.docus.server.gzzxyjh.AssortConfig; +import com.docus.server.gzzxyjh.FileDto; +import com.docus.server.rpc.DownPlatformService; +import com.docus.server.rpc.TaskDistributeService; +import com.docus.server.rpc.dto.*; +import com.docus.server.util.JaxWsDynamicClientUtil; +import com.docus.server.util.TableJsonRead; +import com.docus.server.util.XmlUtil; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author YongBin Wen + * @date 2024/8/16 14:45 + */ +@Component +@Slf4j +public class GzZxyJhPMRSCollectJob { + + @Autowired + private DownPlatformService downPlatformService; + @Autowired + private TaskDistributeService taskDistributeService; + + + @XxlJob("GzZxyJhPMRSCollectJob") + public void pmrsCollectJob() { + // 1.获取任务和患者信息 2.查询接口文件 3.上报下载 + List assortConfig = AssortConfig.getConfig(); + + String configPath = "data-config"; + String configName = "gzzxyjh-ws-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + + JSONObject pmrsConfig = configOjb.getJSONObject("pmrs"); + String collectorId = pmrsConfig.getString("collectorId"); + String url = pmrsConfig.getString("url"); + String namespaceUri = pmrsConfig.getString("namespaceUri"); + String operationName = pmrsConfig.getString("operationName"); + String param1 = pmrsConfig.getString("param"); + + CommonResult commonResult = taskDistributeService.getNoViewTaskByCollectorId(collectorId); + if (ResultCode.SUCCESS.getCode().equals(commonResult.getCode()) + && commonResult.getData() != null) { + ReportDownTwoDto downTwoDto = commonResult.getData(); + ReportTaskTwoDto task = downTwoDto.getTasks().get(0); + log.info(">>>>>>>>>>>>>>>>>>>>>> 广州中西医结合pmrs采集任务,获取了任务:{}", Func.toJson(task)); + + ReportHospitalTwoDto hospitalTwoDto = downTwoDto.getHospitals().get(0); + ReportPatientTwoDto reportPatientTwoDto = downTwoDto.getPatient(); + String jzh = downTwoDto.getJzh(); + jzh = jzh.split("_")[0]; + + String param2 = "" + jzh + ""; + String[] params = {param1, param2}; + String result = JaxWsDynamicClientUtil.send(url, namespaceUri, operationName, params); + List fileDtos = parseFileDtos(result); + + int size = fileDtos.size(); + log.info("住院号:{},住院次数:{},记账号:{} 采集pmrs数据:{} 条!数据:{}", reportPatientTwoDto.getInpatientNo(), hospitalTwoDto.getAdmissTimes(), jzh, size, Func.toJson(fileDtos)); + if (size <= 0) { + return; + } + + ReportDownPatientDto patient = new ReportDownPatientDto(); + patient.setPatientid(downTwoDto.getPatientId()); + + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setCollectorid(collectorId); + reportDownDto.setIp("java-pmrs-job"); + reportDownDto.setPatient(patient); + + int sort = 0; + for (FileDto fileDto : fileDtos) { + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(fileDto.getPMR_URL()); + reportDownScanFileDto.setFiletitle(fileDto.getPMR_NAME()); + reportDownScanFileDto.setSerialnum(fileDto.getPMR_ID()); + reportDownScanFileDto.setFilesource(1); + reportDownScanFileDto.setFiletype(1); + reportDownScanFileDto.setFilestoragetype(1); + reportDownScanFileDto.setTaskid(task.getTaskId()); + reportDownScanFileDto.setSort(++sort); + List scanFiles = Collections.singletonList(reportDownScanFileDto); + + String emrTypeCode = fileDto.getEMR_TYPE_CODE(); + String assortId = getAssortId(emrTypeCode, assortConfig); + reportDownDto.setAssortid(assortId); + reportDownDto.setScanfiles(scanFiles); + downPlatformService.report(reportDownDto); + } + + + } + } + + private List parseFileDtos(String str) { + + XmlUtil xml = XmlUtil.of(str); + //请求结果状态 + String status = "0"; + Node statusNode = xml.getNode("/MESSAGE/HEADER/STATUS"); + if (Func.isNotEmpty(statusNode)) { + status = statusNode.getTextContent(); + } + if ("0".equals(status)) { + return new ArrayList<>(); + } + List list = new ArrayList(); + NodeList rows = xml.getNodeList("/MESSAGE/BODY/ROWS/ROW"); + for (int i = 1; i <= rows.getLength(); i++) { + Node PMR_ID_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/PMR_ID"); + String PMR_ID = null; + if (Func.isNotEmpty(PMR_ID_NODE)) { + PMR_ID = PMR_ID_NODE.getTextContent(); + } + Node PMR_NAME_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/PMR_NAME"); + String PMR_NAME = null; + if (Func.isNotEmpty(PMR_NAME_NODE)) { + PMR_NAME = PMR_NAME_NODE.getTextContent(); + } + Node PMR_NAME_NO_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/PMR_NAME_NO"); + String PMR_NAME_NO = null; + if (Func.isNotEmpty(PMR_NAME_NO_NODE)) { + PMR_NAME_NO = PMR_NAME_NO_NODE.getTextContent(); + } + Node PMR_URL_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/PMR_URL"); + String PMR_URL = null; + if (Func.isNotEmpty(PMR_URL_NODE)) { + PMR_URL = PMR_URL_NODE.getTextContent(); + } + Node RCD_TYPE_CODE_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/RCD_TYPE_CODE"); + String RCD_TYPE_CODE = null; + if (Func.isNotEmpty(RCD_TYPE_CODE_NODE)) { + RCD_TYPE_CODE = RCD_TYPE_CODE_NODE.getTextContent(); + } + Node RCD_TYPE_NAME_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/RCD_TYPE_NAME"); + String RCD_TYPE_NAME = null; + if (Func.isNotEmpty(RCD_TYPE_NAME_NODE)) { + RCD_TYPE_NAME = RCD_TYPE_NAME_NODE.getTextContent(); + } + Node EMR_TYPE_CODE_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/EMR_TYPE_CODE"); + String EMR_TYPE_CODE = null; + if (Func.isNotEmpty(EMR_TYPE_CODE_NODE)) { + EMR_TYPE_CODE = EMR_TYPE_CODE_NODE.getTextContent(); + } + Node EMR_TYPE_NAME_NODE = xml.getNode("/MESSAGE/BODY/ROWS/ROW[" + i + "]/EMR_TYPE_NAME"); + String EMR_TYPE_NAME = null; + if (Func.isNotEmpty(EMR_TYPE_NAME_NODE)) { + EMR_TYPE_NAME = EMR_TYPE_NAME_NODE.getTextContent(); + } + if (Func.isEmpty(PMR_URL)) { + throw new BaseException("第" + i + "条文件数据文件地址为空"); + } + FileDto dto = new FileDto(); + dto.setPMR_ID(PMR_ID); + dto.setPMR_NAME(PMR_NAME); + dto.setPMR_NAME_NO(PMR_NAME_NO); + dto.setPMR_URL(PMR_URL); + dto.setRCD_TYPE_CODE(RCD_TYPE_CODE); + dto.setRCD_TYPE_NAME(RCD_TYPE_NAME); + dto.setEMR_TYPE_CODE(EMR_TYPE_CODE); + dto.setEMR_TYPE_NAME(EMR_TYPE_NAME); + list.add(dto); + } + return list; + + } + + private String getAssortId(String emrTypeCode, List assortConfig) { + String defaut = ""; + for (AssortConfig.Config config : assortConfig) { + if (emrTypeCode.equals(config.getEmrTypeCode())) { + return config.getAssortId(); + } + if ("defaut".equals(config.getEmrTypeCode())) { + defaut = config.getAssortId(); + } + } + return defaut; + } + + public static void main(String[] args) { + System.out.println(AssortConfig.getConfig()); + String jzh = "10086_1"; + jzh = jzh.split("_")[0]; + System.out.println(jzh); + String configPath = "data-config"; + String configName = "gzzxyjh-ws-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + + JSONObject pmrsConfig = configOjb.getJSONObject("pmrs"); + System.out.println(pmrsConfig); + } +} diff --git a/src/main/java/com/docus/server/util/JaxWsDynamicClientUtil.java b/src/main/java/com/docus/server/util/JaxWsDynamicClientUtil.java new file mode 100644 index 0000000..b493f86 --- /dev/null +++ b/src/main/java/com/docus/server/util/JaxWsDynamicClientUtil.java @@ -0,0 +1,69 @@ +package com.docus.server.util; + +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.namespace.QName; +import java.util.Arrays; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 使用JaxWsDynamicClientFactory 调用 webservice + * + * @author wyb + */ +public class JaxWsDynamicClientUtil { + + private static final JaxWsDynamicClientFactory CLIENT_FACTORY = JaxWsDynamicClientFactory.newInstance(); + private static final Map CLIENT_MAP = new ConcurrentHashMap<>(); + private static final Logger logger = LoggerFactory.getLogger(JaxWsDynamicClientUtil.class); + + public static String send(String wsdlUrl, String namespaceUri, String operationName, Object[] params) { + logger.info("wsdlUrl:" + wsdlUrl + " ,namespaceUri: " + namespaceUri + " ,operationName:" + operationName + ",param:" + Arrays.toString(params)); + try { + Client client = getClient(wsdlUrl); + Object[] result; + if (namespaceUri == null || namespaceUri.isEmpty()) { + result = client.invoke(operationName, params); + } else { + QName qName = new QName(namespaceUri, operationName); + result = client.invoke(qName, params); + } + logger.info("wsdlUrl:" + wsdlUrl + ",namespaceUri: " + namespaceUri + " ,operationName:" + operationName + ",param:" + Arrays.toString(params) + " 调用成功!"); + if (result == null || result[0] == null) { + return null; + } + return String.valueOf(result[0]); + } catch (Exception ex) { + logger.error("wsdlUrl:" + wsdlUrl + ",namespaceUri: " + namespaceUri + " ,operationName:" + operationName + ",param:" + Arrays.toString(params) + " 调用失败了!_"+ex.getMessage(), ex); + return null; + } + } + + public static Client getClient(String wsdlUrl) { + if (CLIENT_MAP.get(wsdlUrl) == null) { + synchronized (JaxWsDynamicClientUtil.class) { + if (CLIENT_MAP.get(wsdlUrl) == null) { + Client client = CLIENT_FACTORY.createClient(wsdlUrl); + setClientParam(client); + CLIENT_MAP.put(wsdlUrl, client); + } + } + } + return CLIENT_MAP.get(wsdlUrl); + } + + private static void setClientParam(Client client) { + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + httpClientPolicy.setConnectionTimeout(30 * 1000); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(30 * 1000); + HTTPConduit clientConduit = (HTTPConduit) client.getConduit(); + clientConduit.setClient(httpClientPolicy); + } +} diff --git a/src/main/java/com/docus/server/util/TableJsonRead.java b/src/main/java/com/docus/server/util/TableJsonRead.java new file mode 100644 index 0000000..3763481 --- /dev/null +++ b/src/main/java/com/docus/server/util/TableJsonRead.java @@ -0,0 +1,195 @@ +package com.docus.server.util; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.util.StringUtils; + +import java.io.*; + +public class TableJsonRead { + + /** + * 读取数据结构 + * @param path 路径后缀 + * @param fileName 文件名称 + * @return + */ + public T Read(String path,String fileName,Class clazz){ + String currentPath=CurrentPath(); + path = currentPath+"\\"+path; + StringBuilder sb = new StringBuilder(); + T dto =null; + File file = new File(path+"\\"+fileName); + try { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + BufferedReader bufferedReader = null; + bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); + String line; + while (!StringUtils.isEmpty(line = bufferedReader.readLine())) { + sb.append(line); + } + if (sb.length() > 0) { + ObjectMapper objectMapper = new ObjectMapper(); + //dto = (T)JSONObject.parse(sb.toString()); + dto= objectMapper.readValue(sb.toString(), clazz); + //dto = objectMapper.convertValue(o, new TypeReference() { }); + } + bufferedReader.close(); + } + + return dto; + } + catch (Exception ex){ + ex.printStackTrace(); + return null; + } + } + + public T Read(File file,Class clazz) { + StringBuilder sb = new StringBuilder(); + T dto =null; + try { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + BufferedReader bufferedReader = null; + bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); + String line; + while (!StringUtils.isEmpty(line = bufferedReader.readLine())) { + sb.append(line); + } + if (sb.length() > 0) { + ObjectMapper objectMapper = new ObjectMapper(); + //dto = (T)JSONObject.parse(sb.toString()); + dto= objectMapper.readValue(sb.toString(), clazz); + //dto = objectMapper.convertValue(o, new TypeReference() { }); + } + bufferedReader.close(); + } + + return dto; + } + catch (Exception ex){ + ex.printStackTrace(); + return null; + } + } + /** + * 取得当前jar路径 + * @return + */ + public static String CurrentPath(){ + File dir = new File("."); + String currentpath =""; + try { + currentpath = dir.getCanonicalPath(); + } catch (IOException e) { + e.printStackTrace(); + } + return currentpath; + } + + /** + * 取得当前jar路径 + * @return + */ + public static String currentPath(String dir){ + String path = CurrentPath() + File.separator + dir; + File file = new File(path); + if (!file.exists()) { + file.mkdirs(); + } + return path; + } + + + + /** + * 读取文件内容 + * @param path + * @param fileName + * @return + */ + public String ReadContent(String path,String fileName){ + String currentPath=CurrentPath(); + path = currentPath+"\\"+path; + StringBuilder sb = new StringBuilder(); + File file = new File(path+"\\"+fileName); + try { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + BufferedReader bufferedReader = null; + bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); + String line; + while (!StringUtils.isEmpty(line = bufferedReader.readLine())) { + sb.append(line); + } + + bufferedReader.close(); + } + + return sb.toString(); + } + catch (Exception ex){ + ex.printStackTrace(); + return null; + } + } + + /** + * 保存json至文件 + * @param path 路径后缀 + * @param fileName 文件名称 + * @param data json信息 + * @return + */ + public void Save(String path,String fileName,String data){ + String currentPath=CurrentPath(); + path = currentPath+"\\"+path; + FileWriter fwriter = null; + try { + File file = new File(path); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + fwriter = new FileWriter(path+"\\"+fileName); + fwriter.write(data); + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + try { + fwriter.flush(); + fwriter.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } + +} diff --git a/src/main/java/com/docus/server/util/XmlUtil.java b/src/main/java/com/docus/server/util/XmlUtil.java new file mode 100644 index 0000000..1df8a0e --- /dev/null +++ b/src/main/java/com/docus/server/util/XmlUtil.java @@ -0,0 +1,857 @@ +/* + * Copyright (c) 2018-2028, DreamLu All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: DreamLu 卢春梦 (596392912@qq.com) + */ +package com.docus.server.util; + +import com.docus.core.util.Exceptions; +import com.docus.core.util.IoUtil; +import org.springframework.lang.Nullable; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; + +/** + * xpath解析xml + * + *
+ *     文档地址:
+ *     http://www.w3school.com.cn/xpath/index.asp
+ * 
+ * + * @author L.cm + */ +public class XmlUtil { + private final XPath path; + private final Document doc; + + private XmlUtil(InputSource inputSource) throws ParserConfigurationException, SAXException, IOException { + DocumentBuilderFactory dbf = getDocumentBuilderFactory(); + DocumentBuilder db = dbf.newDocumentBuilder(); + doc = db.parse(inputSource); + path = getXPathFactory().newXPath(); + } + + /** + * 创建工具类 + * + * @param inputSource inputSource + * @return XmlUtil + */ + private static XmlUtil create(InputSource inputSource) { + try { + return new XmlUtil(inputSource); + } catch (ParserConfigurationException | SAXException | IOException e) { + throw Exceptions.unchecked(e); + } + } + + /** + * 转换工具类 + * + * @param inputStream inputStream + * @return XmlUtil + */ + public static XmlUtil of(InputStream inputStream) { + InputSource inputSource = new InputSource(inputStream); + return create(inputSource); + } + + /** + * 转换工具类 + * + * @param xmlStr xmlStr + * @return XmlUtil + */ + public static XmlUtil of(String xmlStr) { + StringReader sr = new StringReader(xmlStr.trim()); + InputSource inputSource = new InputSource(sr); + XmlUtil xmlUtil = create(inputSource); + IoUtil.closeQuietly(sr); + return xmlUtil; + } + + /** + * 转换路径 + * + * @param expression 表达式 + * @param item 实体 + * @param returnType 返回类型 + * @return Object + */ + private Object evalXPath(String expression, @Nullable Object item, QName returnType) { + item = null == item ? doc : item; + try { + return path.evaluate(expression, item, returnType); + } catch (XPathExpressionException e) { + throw Exceptions.unchecked(e); + } + } + + /** + * 获取String + * + * @param expression 路径 + * @return {String} + */ + public String getString(String expression) { + return (String) evalXPath(expression, null, XPathConstants.STRING); + } + + /** + * 获取Boolean + * + * @param expression 路径 + * @return {String} + */ + public Boolean getBoolean(String expression) { + return (Boolean) evalXPath(expression, null, XPathConstants.BOOLEAN); + } + + /** + * 获取Number + * + * @param expression 路径 + * @return {Number} + */ + public Number getNumber(String expression) { + return (Number) evalXPath(expression, null, XPathConstants.NUMBER); + } + + /** + * 获取某个节点 + * + * @param expression 路径 + * @return {Node} + */ + public Node getNode(String expression) { + return (Node) evalXPath(expression, null, XPathConstants.NODE); + } + + /** + * 获取子节点 + * + * @param expression 路径 + * @return NodeList + */ + public NodeList getNodeList(String expression) { + return (NodeList) evalXPath(expression, null, XPathConstants.NODESET); + } + + + /** + * 获取String + * + * @param node 节点 + * @param expression 相对于node的路径 + * @return {String} + */ + public String getString(Object node, String expression) { + return (String) evalXPath(expression, node, XPathConstants.STRING); + } + + /** + * 获取 + * + * @param node 节点 + * @param expression 相对于node的路径 + * @return {String} + */ + public Boolean getBoolean(Object node, String expression) { + return (Boolean) evalXPath(expression, node, XPathConstants.BOOLEAN); + } + + /** + * 获取 + * + * @param node 节点 + * @param expression 相对于node的路径 + * @return {Number} + */ + public Number getNumber(Object node, String expression) { + return (Number) evalXPath(expression, node, XPathConstants.NUMBER); + } + + /** + * 获取某个节点 + * + * @param node 节点 + * @param expression 路径 + * @return {Node} + */ + public Node getNode(Object node, String expression) { + return (Node) evalXPath(expression, node, XPathConstants.NODE); + } + + /** + * 获取子节点 + * + * @param node 节点 + * @param expression 相对于node的路径 + * @return NodeList + */ + public NodeList getNodeList(Object node, String expression) { + return (NodeList) evalXPath(expression, node, XPathConstants.NODESET); + } + + /** + * 针对没有嵌套节点的简单处理 + * + * @return map集合 + */ + public Map toMap() { + Element root = doc.getDocumentElement(); + Map params = new HashMap<>(16); + + // 将节点封装成map形式 + NodeList list = root.getChildNodes(); + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + if (node instanceof Element) { + params.put(node.getNodeName(), node.getTextContent()); + } + } + return params; + } + + private static volatile boolean preventedXXE = false; + + private static DocumentBuilderFactory getDocumentBuilderFactory() throws ParserConfigurationException { + DocumentBuilderFactory dbf = XmlHelperHolder.documentBuilderFactory; + if (!preventedXXE) { + synchronized (XmlUtil.class) { + if (!preventedXXE) { + preventXXE(dbf); + } + } + } + return dbf; + } + + /** + * preventXXE + * + * @param dbf + * @throws ParserConfigurationException + */ + private static void preventXXE(DocumentBuilderFactory dbf) throws ParserConfigurationException { + // This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented + // Xerces 2 only - http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl + dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + + // If you can't completely disable DTDs, then at least do the following: + // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities + // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities + + // JDK7+ - http://xml.org/sax/features/external-general-entities + dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); + + // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities + // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities + + // JDK7+ - http://xml.org/sax/features/external-parameter-entities + dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); + + // Disable external DTDs as well + dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + + // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" + dbf.setXIncludeAware(false); + dbf.setExpandEntityReferences(false); + preventedXXE = true; + } + + private static XPathFactory getXPathFactory() { + return XmlHelperHolder.xPathFactory; + } + + /** + * 内部类单例 + */ + private static class XmlHelperHolder { + private static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + private static XPathFactory xPathFactory = XPathFactory.newInstance(); + } + private static String str; + static { + str=" \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 59 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 205室 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 耳鼻咽喉头颈外科 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 2号楼16楼西区 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 南方医科大学顺德医院 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 突发特发性听觉丧失 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 常规 \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 治愈 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 张存良 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 耳鼻咽喉头颈外科 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 突发特发性听觉丧失 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 文本 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 乳房病类 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 治愈 \n" + + " \n" + + " O \n" + + " \n" + + " 0 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 01 \n" + + " \n" + + " 出院医嘱 \n" + + " \n" + + "
\n"; + } + + public static void main(String[] args) { + XmlUtil a=XmlUtil.of(str); + Node node=null; + //id-消息流水号 + node = a.getNode("/PRPA_HIP0032/id/@extension"); + String serialId = node.toString(); + System.out.println(serialId); + //住院流水号 + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/item/@extension"); + String jzh = node.toString(); + System.out.println(jzh); + //住院号标识 + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/id/item/@extension"); + String inpatientNo = node.toString(); + System.out.println(inpatientNo); + //住院次数[] + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/lengthOfStayQuantity[@unit='次']/@value"); + String admissTimes=node.toString(); + System.out.println(admissTimes); + //姓名 + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/name/item/part/@value"); + String name = node.toString(); + System.out.println(name); + //入院日期时间 + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/low/@value"); + String admissDate = node.toString(); + System.out.println(admissDate); + //出院日期时间 + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/high/@value"); + String disDate = node.toString(); + System.out.println(disDate); + //入院诊断科室名称[] + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='入院诊断']/section/entry[@displayName='入院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name"); + String admissDeptName = node.getTextContent(); + System.out.println(admissDeptName); + //出院诊断科室名称[] + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='出院诊断']/section/entry[@displayName='出院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name"); + String disDeptName = node.getTextContent(); + System.out.println(disDeptName); + //主治医师[] + node = a.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/authenticator[@displayName='主治医师']/assignedEntity/assignedPerson/name"); + String attendingName = node.getTextContent(); + System.out.println(attendingName); + } +}