#
# Output number of images per study form input file list
# used to validate data in PACS Export and Transfer in October 2022
# Why: Needed to process a 400K item list of images files and group by study accession number with total of images see dicom files with python.
$dicomimages = Import-Csv -Delimiter "," -Path .\DicomFilelist-20220928-135709.csv
$studylistcount = $dicomimages |Group-Object -Property AccessionNumber
[System.Collections.ArrayList]$dicomtruth = @{}
$studylistcount |ForEach-Object {
$studygrp=$_.Group
$count= $_.count
$acc = $_.name
$mrn = $studygrp| Select-Object -ExpandProperty PatientID -First 1
$description = $studygrp| Select-Object -ExpandProperty SeriesDescription -First 1
$StudyDate = $studygrp| Select-Object -ExpandProperty StudyDate -First 1
$StudyInstanceUID = $studygrp| Select-Object -ExpandProperty StudyInstanceUID -First 1
$line = [pscustomobject]@{
StudyUID = $StudyInstanceUID
PatientMRN = $mrn
AccessionNumber = $acc
StudyDate = $StudyDate
StudyDescription = $description
NumberofImages = $count
}
$dicomtruth.add($line)|Out-Null
}
$truthfile = "c:\support\dicomtruth-" + $(get-date -f yyyyMMddhhmm) + ".csv"
$truthfile
$dicomtruth |Export-Csv -Path $truthfile
No comments:
Post a Comment