private DicomObject mkStgCmtResult(Association as, DicomObject rqdata) { DicomObject result = new BasicDicomObject(); result.putString(Tag.TransactionUID, VR.UI, rqdata.getString(Tag.TransactionUID)); DicomElement rqsq = rqdata.get(Tag.ReferencedSOPSequence); DicomElement resultsq = result.putSequence(Tag.ReferencedSOPSequence); if (stgcmtRetrieveAET != null) { result.putString(Tag.RetrieveAETitle, VR.AE, stgcmtRetrieveAET); } DicomElement failedsq = null; File dir = getDir(as); for (int i = 0, n = rqsq.countItems(); i < n; i++) { DicomObject rqItem = rqsq.getDicomObject(i); String uid = rqItem.getString(Tag.ReferencedSOPInstanceUID); DicomObject resultItem = new BasicDicomObject(); rqItem.copyTo(resultItem); if (stgcmtRetrieveAETs != null) { resultItem.putString(Tag.RetrieveAETitle, VR.AE, stgcmtRetrieveAETs); } File f = new File(dir, uid); if (f.isFile()) { resultsq.addDicomObject(resultItem); } else { resultItem.putInt(Tag.FailureReason, VR.US, NO_SUCH_OBJECT_INSTANCE); if (failedsq == null) { failedsq = result.putSequence(Tag.FailedSOPSequence); } failedsq.addDicomObject(resultItem); } } return result; }
private DicomObject toSCN(DicomObject ian) { DicomObject scn = new BasicDicomObject(); scn.putString(Tag.PatientID, VR.LO, ian.getString(Tag.PatientID)); scn.putString(Tag.PatientName, VR.PN, ian.getString(Tag.PatientName)); scn.putString(Tag.StudyID, VR.SH, ian.getString(Tag.StudyID)); scn.putString(Tag.StudyInstanceUID, VR.UI, ian.getString(Tag.StudyInstanceUID)); DicomElement ianSeriesSeq = ian.get(Tag.ReferencedSeriesSequence); DicomElement scnSeriesSeq = scn.putSequence(Tag.ReferencedSeriesSequence); DicomObject ianSeriesItem, scnSeriesItem, scnSOPItem; DicomElement ianSOPSeq, scnSOPSeq; for (int i = 0, n = ianSeriesSeq.countItems(); i < n; ++i) { ianSeriesItem = ianSeriesSeq.getDicomObject(i); scnSeriesItem = new BasicDicomObject(); scnSeriesItem.putString( Tag.SeriesInstanceUID, VR.UI, ianSeriesItem.getString(Tag.SeriesInstanceUID)); scnSeriesSeq.addDicomObject(scnSeriesItem); ianSOPSeq = ianSeriesItem.get(Tag.ReferencedSOPSequence); scnSOPSeq = scnSeriesItem.putSequence(Tag.ReferencedImageSequence); for (int j = 0, m = ianSOPSeq.countItems(); j < m; ++j) { scnSOPItem = new BasicDicomObject(); ianSOPSeq.getDicomObject(j).exclude(INSTANCE_AVAILABILITY).copyTo(scnSOPItem); scnSOPSeq.addDicomObject(scnSOPItem); } } return scn; }
public static TCEncapsulatedDocument create( TCObject tc, MimeType mimeType, String filename, InputStream in, String description) throws Exception { if (mimeType == null || !DOC_TYPES.contains(mimeType.getDocumentType())) { throw new Exception("Mime-Type is not supported (" + mimeType + ")"); } TCReferencedInstance ref = createReferencedInstance(tc, UID.EncapsulatedPDFStorage, MODALITY); DicomObject metaData = TCDocumentObject.createDicomMetaData( mimeType, filename, description, ref, tc.getPatientId(), tc.getPatientIdIssuer(), tc.getPatientName(), MODALITY); metaData.putString(Tag.TransferSyntaxUID, VR.UI, UID.ExplicitVRLittleEndian); metaData.putString( Tag.DocumentTitle, VR.ST, description != null && !description.isEmpty() ? description : getFileName(filename)); metaData.putString(Tag.MIMETypeOfEncapsulatedDocument, VR.LO, mimeType.getMimeTypeString()); metaData.putString(Tag.BurnedInAnnotation, VR.CS, "NO"); // $NON-NLS-1$ metaData.putSequence(Tag.ConceptNameCodeSequence, 0); try { return new TCEncapsulatedDocument(mimeType, ref, metaData, IOUtils.toByteArray(in)); } finally { if (in != null) { in.close(); } } }