利用dcmtk工具查詢PACS,找到同一患者兩次以上的檢查的數據

 

目的:

利用dcmtk工具查詢PACS,找到同一患者兩次以上的檢查的數據

步驟:

1 find 需要的數據,輸出到文本

 

findscu.exe 10.9.9.9 104 -aec PACS_AE -aet OUR_AE -k 0008,0052=PATIENT -P +sr -k PatientID -k StudyInstanceUID -k NumberOfPatientRelatedStudies > find.txt

I: ---------------------------
I: Find Response: 1 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [A0180 ]                                 #   6, 1 PatientID
I: (0010,0030) DA [19370101]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 2 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [P00812469 ]                             #  10, 1 PatientID
I: (0010,0030) DA [19711002]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 3 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [P00812449 ]                             #  10, 1 PatientID
I: (0010,0030) DA [20120610]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 4 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [P00746565 ]                             #  10, 1 PatientID
I: (0010,0030) DA [19771106]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [2 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [2 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [3 ]                                     #   2, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 5 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [A0093 ]                                 #   6, 1 PatientID
I: (0010,0030) DA [19470101]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 6 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [CT0581499 ]                             #  10, 1 PatientID
I: (0010,0030) DA [19460118]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [5 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [17]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [823 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 7 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [P00812424 ]                             #  10, 1 PatientID
I: (0010,0030) DA [19461221]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [3 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [3 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [4 ]                                     #   2, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 8 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [002_S_2073]                             #  10, 1 PatientID
I: (0010,0030) DA [19470423]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [170 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 9 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [A0181 ]                                 #   6, 1 PatientID
I: (0010,0030) DA [19470101]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 10 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [006_S_0322]                             #  10, 1 PatientID
I: (0010,0030) DA [19401105]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [166 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 11 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [P00787721 ]                             #  10, 1 PatientID
I: (0010,0030) DA [20120701]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 12 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [010_S_4135]                             #  10, 1 PatientID
I: (0010,0030) DA [19541205]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [170 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 13 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [A0185 ]                                 #   6, 1 PatientID
I: (0010,0030) DA [19360101]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 14 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [041_S_4874]                             #  10, 1 PatientID
I: (0010,0030) DA [19541113]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 15 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [012_S_4128]                             #  10, 1 PatientID
I: (0010,0030) DA [19330909]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 16 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [024_S_1063]                             #  10, 1 PatientID
I: (0010,0030) DA [19280616]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [146 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 17 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [033_S_0741]                             #  10, 1 PatientID
I: (0010,0030) DA [19260409]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [166 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 18 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [009_S_4741]                             #  10, 1 PatientID
I: (0010,0030) DA [19500922]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 19 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [11094760]                               #   8, 1 PatientID
I: (0010,0030) DA [19720913]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [3 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [271 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 20 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [P00811319 ]                             #  10, 1 PatientID
I: (0010,0030) DA [19450307]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [2 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [2 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [4 ]                                     #   2, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 21 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [A0110 ]                                 #   6, 1 PatientID
I: (0010,0030) DA [19430101]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 22 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [A0111 ]                                 #   6, 1 PatientID
I: (0010,0030) DA [19450101]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 23 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [013_S_2389]                             #  10, 1 PatientID
I: (0010,0030) DA [19530819]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [170 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 24 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [037_S_4381]                             #  10, 1 PatientID
I: (0010,0030) DA [19570103]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [176 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 25 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [067_S_0176]                             #  10, 1 PatientID
I: (0010,0030) DA [19310605]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [160 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 26 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [031_S_4024]                             #  10, 1 PatientID
I: (0010,0030) DA [19550501]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [170 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 27 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [031_S_2233]                             #  10, 1 PatientID
I: (0010,0030) DA [19550529]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [170 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 28 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [003_S_1122]                             #  10, 1 PatientID
I: (0010,0030) DA [19300324]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [F ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [160 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 
I: ---------------------------
I: Find Response: 29 (Pending)
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0052) CS [PATIENT ]                               #   8, 1 QueryRetrieveLevel
I: (0008,0080) LO (no value available)                     #   0, 0 InstitutionName
I: (0010,0020) LO [PID-20190323-112443-0001]               #  24, 1 PatientID
I: (0010,0030) DA [19540101]                               #   8, 1 PatientBirthDate
I: (0010,0040) CS [M ]                                     #   2, 1 PatientSex
I: (0020,1200) IS [1 ]                                     #   2, 1 NumberOfPatientRelatedStudies
I: (0020,1202) IS [9 ]                                     #   2, 1 NumberOfPatientRelatedSeries
I: (0020,1204) IS [441 ]                                   #   4, 1 NumberOfPatientRelatedInstances
I: 

Q:爲啥不用NumberOfPatientRelatedStudies直接過濾

A:部分PACS不支持。

 

2 找到多次檢查的數據和行號,輸出到文本

type find.txt | findstr /N /R /C:"\<[2-9] \]                                     #   2, 1 NumberOfPatientRelatedStudies" > num.txt

 

3 合併行號

call get_numbers.bat

@echo off
setlocal EnableDelayedExpansion

echo 1 > n.txt
set out
call :_DATE
echo %out%
echo 1!out! > n.txt
echo done 
goto :EOF

:_DATE
FOR /F "tokens=1" %%A in (num.txt) do ( 
	SET result=%%A & echo !result!
	SET ver=!result:~0,-4!
	SET /a new=!ver!-3
    SET out=!out!:!new!:!ver!
)
GOTO :eof

4 找到所有目標數據的PatientID

 

call print_file_string.bat -n . find.txt 1 /R /C:".*"

@echo off

rem Description:
rem   Script for string lines extraction from a text/binary file by findstr
rem   utility pattern and/or line number.

rem Command arguments:
rem %1 - Optional flags:
rem      -n - prints line number prefix "<N>:" for each found string from file.
rem           By default, the line number prefix does not print.
rem      -f1 - filter by line numbers for strings after %4..%N filter pattern.
rem           By default, filters by line numbers from the file.
rem      -pe - treats input file as a Portable Executable file
rem           (the strings.exe must exist).
rem           By default, the file treated as a text file.
rem %1 - Path to a directory with a file to extract.
rem %2 - Relative path to a text/binary file with strings.
rem %3 - Set of line numbers separated by : character to print strings of.
rem      These line numbers by default are line numbers of strings from the
rem      file, not from filtered output. If you want to point line numbers
rem      after %4..%N filter pattern, then you must use -f1 flag.
rem      If empty, then treated as "all strings".
rem %4..%N - Arguments for findstr command line in first filter.
rem      If empty, then treated as /R /C:".*", which means "any string".

rem CAUTION:
rem   DO NOT use /N flag in %4..%N arguments, instead use script -n flag to
rem   print strings w/ line number prefix.

rem Examples:
rem 1. call print_file_string.bat -n . example.txt 1:20:10:30 /R /C:".*"
rem Prints 1, 10, 20, 30 lines of the example.txt file sorted by line number
rem and prints them w/ line number prefix:
rem
rem 2. call print_file_string.bat . example.txt 100 /R /C:".*"
rem Prints 100'th string of example.txt file and prints it w/o line number
rem prefix.
rem
rem 3. call print_file_string.bat -pe c:\Application res.dll "" /B /C:"VERSION="
rem Prints all strings from the c:\Application\res.dll binary file, where
rem strings beginning by the "VERSION=" string and prints them w/o line number
rem prefix.
rem
rem 4. call print_file_string.bat -pe c:\Application res.dll 1:20:10:30 /R /C:".*"
rem Prints 1, 10, 20, 30 lines of string resources from the
rem c:\Application\res.dll binary file, where strings beginning by the
rem "VERSION=" string and prints them w/o line number prefix.

setlocal EnableDelayedExpansion

set "?~dp0=%~dp0"
set "?~nx0=%~nx0"

rem script flags
set FLAG_PRINT_LINE_NUMBER_PREFIX=0
set FLAG_F1_LINE_NUMBER_FILTER=0
set FLAG_FILE_FORMAT_PE=0

rem flags
set "FLAGS="

:FLAGS_LOOP

rem flags always at first
set "FLAG=%~1"

if not "%FLAG%" == "" ^
if not "%FLAG:~0,1%" == "-" set "FLAG="

if not "%FLAG%" == "" (
  if "%FLAG%" == "-n" set FLAG_PRINT_LINE_NUMBER_PREFIX=1
  if "%FLAG%" == "-f1" set FLAG_F1_LINE_NUMBER_FILTER=1
  if "%FLAG%" == "-pe" set FLAG_FILE_FORMAT_PE=1
  shift

  rem read until no flags
  goto FLAGS_LOOP
)

set "DIR_PATH=%~dpf1"
set "FILE_PATH=%~2"

set "FILE_PATH_PREFIX="
if not "%DIR_PATH%" == "" set "FILE_PATH_PREFIX=%DIR_PATH%\"

if not "%FILE_PATH_PREFIX%" == "" ^
if not exist "%FILE_PATH_PREFIX%" (
  echo.%?~nx0%: error: Directory path does not exist: "%FILE_PATH_PREFIX%"
  exit /b 1
) >&2

if "%FILE_PATH%" == "" (
  echo.%?~nx0%: error: File path does not set.
  exit /b 2
) >&2

if not exist "%FILE_PATH_PREFIX%%FILE_PATH%" (
  echo.%?~nx0%: error: File path does not exist: "%FILE_PATH_PREFIX%%FILE_PATH%"
  exit /b 3
) >&2

set "LINE_NUMBERS=%~3"

set "FINDSTR_LINES_FILTER_CMD_LINE="
if "%LINE_NUMBERS%" == "" goto FINDSTR_LINES_FILTER_END

set LINE_NUMBER_INDEX=1
:FINDSTR_LINES_FILTER_LOOP
set "LINE_NUMBER="
for /F "tokens=%LINE_NUMBER_INDEX% delims=:" %%i in ("%LINE_NUMBERS%") do set "LINE_NUMBER=%%i"

rem read LINE numbers from file
FOR /F "tokens=1" %%A in (n.txt) do ( 
    SET LINE_NUMBERS=%%A
)

if "%LINE_NUMBER%" == "" goto FINDSTR_LINES_FILTER_END

set FINDSTR_LINES_FILTER_CMD_LINE=!FINDSTR_LINES_FILTER_CMD_LINE! /C:"!LINE_NUMBER!:"
set /A LINE_NUMBER_INDEX+=1
goto FINDSTR_LINES_FILTER_LOOP

:FINDSTR_LINES_FILTER_END

shift
shift
shift

set "FINDSTR_FIRST_FILTER_CMD_LINE="

:FINDSTR_FIRST_FILTER_LOOP
set ARG=%1

if not "!ARG!" == "" (
  set FINDSTR_FIRST_FILTER_CMD_LINE=!FINDSTR_FIRST_FILTER_CMD_LINE! !ARG!
  shift
  goto FINDSTR_FIRST_FILTER_LOOP
)

if "!FINDSTR_FIRST_FILTER_CMD_LINE!" == "" set FINDSTR_FIRST_FILTER_CMD_LINE=/R /C:".*"

set OUTPUT_HAS_NUMBER_PREFIX=0

rem in case if /N at the end
set "FINDSTR_FIRST_FILTER_CMD_LINE=!FINDSTR_FIRST_FILTER_CMD_LINE! "

rem 1. add /N parameter to first filter if must print line prefixes and -f1 flag is not set.
rem 2. flags prefixed output if must print line prefixes.
if %FLAG_PRINT_LINE_NUMBER_PREFIX% NEQ 0 (
  if %FLAG_F1_LINE_NUMBER_FILTER% EQU 0 (
    if "!FINDSTR_FIRST_FILTER_CMD_LINE:/N =!" == "!FINDSTR_FIRST_FILTER_CMD_LINE!" (
      set "FINDSTR_FIRST_FILTER_CMD_LINE=/N !FINDSTR_FIRST_FILTER_CMD_LINE!"
    )
  )
  set OUTPUT_HAS_NUMBER_PREFIX=1
)

rem 1. add /N parameter to first filter and flags prefixed output if lines filter is not empty and -f1 flag is not set.
rem 2. add /B parameter to lines filter if lines filter is not empty
if not "!FINDSTR_LINES_FILTER_CMD_LINE!" == "" (
  if %FLAG_F1_LINE_NUMBER_FILTER% EQU 0 (
    if "!FINDSTR_FIRST_FILTER_CMD_LINE:/N =!" == "!FINDSTR_FIRST_FILTER_CMD_LINE!" (
      set "FINDSTR_FIRST_FILTER_CMD_LINE=/N !FINDSTR_FIRST_FILTER_CMD_LINE!"
      set OUTPUT_HAS_NUMBER_PREFIX=1
    )
  )
  if "!FINDSTR_LINES_FILTER_CMD_LINE:/B =!" == "!FINDSTR_LINES_FILTER_CMD_LINE!" (
    set "FINDSTR_LINES_FILTER_CMD_LINE=/B !FINDSTR_LINES_FILTER_CMD_LINE!"
  )
)

rem 1. remove /N parameter from first filter if -f1 flag is set.
rem 2. flags prefixed output if -f1 flag is set.
if %FLAG_F1_LINE_NUMBER_FILTER% NEQ 0 (
  if not "!FINDSTR_FIRST_FILTER_CMD_LINE:/N =!" == "!FINDSTR_FIRST_FILTER_CMD_LINE!" (
    set "FINDSTR_FIRST_FILTER_CMD_LINE=!FINDSTR_FIRST_FILTER_CMD_LINE:/N =!"
  )
  set OUTPUT_HAS_NUMBER_PREFIX=1
)

if "%TOOLS_PATH%" == "" set "TOOLS_PATH=%?~dp0%"
rem set "TOOLS_PATH=%TOOLS_PATH:\=/%"
if "%TOOLS_PATH:~-1%" == "\" set "TOOLS_PATH=%TOOLS_PATH:~0,-1%"

if %FLAG_FILE_FORMAT_PE% EQU 0 (
  set CMD_LINE=type "%FILE_PATH_PREFIX%%FILE_PATH%" ^| findstr !FINDSTR_FIRST_FILTER_CMD_LINE!
) else (
  rem add EULA acception into registry to avoid EULA acception GUI dialog
  reg add HKCU\Software\Sysinternals\Strings /v EulaAccepted /t REG_DWORD /d 0x00000001 /f >nul 2>nul

  rem @ for bug case workaround
  set CMD_LINE=@"%TOOLS_PATH%\strings.exe" -q "%FILE_PATH_PREFIX%%FILE_PATH%" ^| findstr !FINDSTR_FIRST_FILTER_CMD_LINE!
)


if %FLAG_F1_LINE_NUMBER_FILTER% NEQ 0 set CMD_LINE=!CMD_LINE! ^| findstr /N /R /C:".*"
if not "!FINDSTR_LINES_FILTER_CMD_LINE!" == "" set CMD_LINE=!CMD_LINE! ^| findstr !FINDSTR_LINES_FILTER_CMD_LINE!

echo %LINE_NUMBERS%= = = = = =

rem if %CMD_LINE% EQU 0 (
rem echo %CMD_LINE%
rem 	echo 00000000000
rem )

rem echo !CMD_LINE! >&2
(
  endlocal
  rem to avoid ! character truncation
  setlocal DisableDelayedExpansion
  if %OUTPUT_HAS_NUMBER_PREFIX% NEQ 0 (
    if %FLAG_PRINT_LINE_NUMBER_PREFIX% NEQ 0 (
      %CMD_LINE% 2>nul
    ) else ( 

	  echo %CMD_LINE%======
      for /F "usebackq eol= tokens=1,* delims=:" %%i in (`^(%CMD_LINE: | findstr = ^| findstr %^) 2^>nul`) do echo.%%j
    )
  ) else (
    %CMD_LINE% 2>nul
  )
)

exit /b 0

 

5 合併代碼

find_patientid.bat

@echo off

type find.txt | findstr /N /R /C:"\<[2-9] \]                                     #   2, 1 NumberOfPatientRelatedStudies" > num.txt

ping -n 1 127.0.0.1 > nul
call get_numbers.bat
ping -n 1 127.0.0.1 > nul
call print_file_string.bat -n . find.txt 1 /R /C:".*"

 

參考資料

https://stackoverflow.com/questions/2701910/windows-batch-file-to-echo-a-specific-line-number

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章