-
Notifications
You must be signed in to change notification settings - Fork 3
/
dpush
executable file
·155 lines (116 loc) · 3.68 KB
/
dpush
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
# filename: dpush
# description: push all DICOM files to DaRIS
# input: cid, directory of DICOM file
# Toan Nguyen, June 2012
# last modified: May 2014 Michael Eager
# Copyright © 2012-2013 Toan Nguyen <toan.nguyen@monash.edu>
# Copyright © 2014- Michael Eager ,michael.eager@monash.edu>
#
# This file is part of Agilent2Dicom.
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# test ${MASSIVEUSERNAME+defined} || echo "MASSIVUSERNAME not found"
#Check whether we are on MASSIVE or the Agilent console (Redhat 6.5)
if test ${MASSIVEUSERNAME+defined}; then
FDF2DCMPATH=$(dirname $0)
# export PATH=${PATH}:${DCMTK}
else
DCMTKPATH="/home/vnmr1/src/dcmtk-3.6.0/bin"
FDF2DCMPATH="/home/vnmr1/src/Agilent2Dicom"
echo ${DCMTKPATH}
echo ${FDF2DCMPATH}
# load dcm tools
# DCMODIFY=./dcmtools/bin/DCMODIFY
export PATH=${PATH}:${DCMTKPATH}
fi
test -x storescu || (echo "storescu not found"; exit 1)
STORESCU="storescu --debug --arguments --verbose "
#"java -cp $(dirname $0)/../lib/dcmtools.jar nig.dicom.util.StoreSCU"
usage() {
echo "Usage: dpush -c cid -s server dicom_dir"
}
#parse input
while getopts c:s:h OPTION
do
case ${OPTION} in
h) usage
exit 1
;;
c) ASSET_CID=${OPTARG}
;;
s) SERVER_STR=${OPTARG}
;;
?) usage
exit 1
;;
esac
done
shift $((${OPTIND} - 1))
DICOM_DIR=$1
if [ -z ${ASSET_CID} ]
then {
echo "Error: must input asset cid"
exit 1;
}
fi
if [ -z ${DICOM_DIR} ]
then {
echo "Error: must input DICOM directory"
exit 1;
}
fi
if [ -z ${SERVER_STR} ]
then {
echo "Error: must input server string (e.g. titanium, mf-erc)"
exit 1;
}
fi
if [ ! -f $(which storescu) ]; then
echo "cannot find dcmtk's storescu in PATH"
exit 1;
fi
if [ ! -f ${FDF2DCMPATH}/daris.cfg ]; then
echo "cannot find daris.cfg in Agilent2Dicom folder"
exit 1;
fi
# parse information in .daris file for sending DICOM
SUCCESS=0
for strline in $( cat ${FDF2DCMPATH}/daris.cfg ); do
substrings=${strline//:/ }
set -- ${substrings}
if [ $1 == ${SERVER_STR} ]; then
DICOM_SERVER=$2
DICOM_PORT=$4
DICOM_CALLING_AET=$7
DICOM_CALLED_AET=$8
DICOM_PORT=$9
MFHOSTNAME=$1
MFLUX_SID_FILE=~/.MFLUX_SID_${MFHOSTNAME};
SUCCESS=1
break
fi
done
if [ ${SUCCESS} == 0 ]; then
echo "Error: cannot find setting, check server name again"
exit 1
fi
# files=$(find ${DICOM_DIR} -type f -name "*.dcm")
# echo "Modify meta-data with DCMTOOLS"
# ${DCMODIFY} "(0010,0010)=DARIS^${ASSET_CID}" ${files} || (echo "DCMODIFY failed." && exit 1)
# ${DCMODIFY} "(0020,0010)=DARIS^${ASSET_CID}" ${files} || exit 1
echo "Upload to DaRIS"
${STORESCU} --aetitle ${DICOM_CALLING_AET} --call ${DICOM_CALLED_AET} ${DICOM_SERVER} ${DICOM_PORT} --scan-pattern "*.dcm" --scan-directories ${DICOM_DIR} || (echo "STORESCU failed." && exit 1 )
echo "File upload to DaRIS completed."
exit 0