private Map string2Codes(String codes, String defaultDesign) { StringTokenizer st = new StringTokenizer(codes, ","); Map map = new HashMap(); int nrOfTokens; StringTokenizer stCode; Dataset ds; String codeValue; while (st.hasMoreTokens()) { stCode = new StringTokenizer(st.nextToken(), "^"); nrOfTokens = stCode.countTokens(); if (nrOfTokens < 2) { throw new IllegalArgumentException( "Wrong format of human performer configuration! (<codeValue>[^<designator>]^<meaning>)"); } ds = dof.newDataset(); codeValue = stCode.nextToken(); ds.putSH(Tags.CodeValue, codeValue); if (nrOfTokens > 2) { ds.putSH(Tags.CodingSchemeDesignator, stCode.nextToken()); } else if (defaultDesign != null) { ds.putSH(Tags.CodingSchemeDesignator, defaultDesign); } ds.putLO(Tags.CodeMeaning, stCode.nextToken()); map.put(codeValue, ds); } return map; }
/** * Check a DicomObject and record any failing lookups in the database. * * @param fileObject the object to process. * @return the same FileObject if the result is true; otherwise null. */ public FileObject process(FileObject fileObject) { String cmd; lastFileIn = new File(fileObject.getFile().getAbsolutePath()); lastTimeIn = System.currentTimeMillis(); if (fileObject instanceof DicomObject) { DicomObject dob = (DicomObject) fileObject; if (dcmScriptFile != null) { DAScript daScript = DAScript.getInstance(dcmScriptFile); scriptTable = new ScriptTable(daScript); lutProps = LookupTable.getProperties(lutFile); synchronized (this) { Dataset ds = dob.getDataset(); charset = ds.getSpecificCharacterSet(); boolean ok = checkDataset(ds); if (!ok) { try { recman.commit(); } catch (Exception unable) { } ; if (quarantine != null) quarantine.insert(fileObject); return null; } } } } lastFileOut = new File(fileObject.getFile().getAbsolutePath()); lastTimeOut = System.currentTimeMillis(); return fileObject; }
private void coerceNCreateRQ(Command rspCmd, Dataset rqData) { rqData.putUI(Tags.SOPClassUID, rspCmd.getAffectedSOPClassUID()); rqData.putUI(Tags.SOPInstanceUID, rspCmd.getAffectedSOPInstanceUID()); initSPSModificationDateandTime(rqData); if (!rqData.containsValue(Tags.WorklistLabel)) rqData.putLO(Tags.WorklistLabel, service.getWorklistLabel()); }
/* * Get the contents of an input dataset element by tag, * handling CTP elements specially. * @param tag the element tag * @return the value of the specified element in the current dataset, * @throws Exception if the element is missing. */ public String contents(int tag) throws Exception { SpecificCharacterSet cs = inDS.getSpecificCharacterSet(); // Handle FileMetaInfo references if ((inFMI != null) && ((tag & 0x7FFFFFFF) < 0x80000)) { DcmElement el = inFMI.get(tag); if (el == null) throw new Exception(Tags.toString(tag) + " missing"); return el.getString(cs); } // Not FMI, handle DataSet references boolean ctp = false; if (((tag & 0x00010000) != 0) && ((tag & 0x0000ff00) != 0)) { int blk = (tag & 0xffff0000) | ((tag & 0x0000ff00) >> 8); try { ctp = inDS.getString(blk).equals("CTP"); } catch (Exception notCTP) { ctp = false; } } DcmElement el = inDS.get(tag); if (el == null) throw new Exception(Tags.toString(tag) + " missing"); if (ctp) return new String(inDS.getByteBuffer(tag).array()); String[] s = el.getStrings(cs); if (s.length == 1) return s[0]; if (s.length == 0) return ""; StringBuffer sb = new StringBuffer(s[0]); for (int i = 1; i < s.length; i++) { sb.append("\\" + s[i]); } return sb.toString(); }
/** * @param string * @return * @throws NeedRedirectionException * @throws IOException */ private Dataset getDataset(Dataset ds) throws IOException { String iuid = ds.getString(Tags.SOPInstanceUID); File file = ridSupport.getDICOMFile(iuid); if (log.isDebugEnabled()) log.debug("DCM file for " + ds.getString(Tags.SOPInstanceUID) + ":" + file); if (file == null) return null; Dataset dsFile; if (!ridSupport.isUseOrigFile()) { FileDataSource dsrc = null; try { dsrc = (FileDataSource) ridSupport .getMBeanServer() .invoke( ridSupport.getQueryRetrieveScpName(), "getDatasourceOfInstance", new Object[] {iuid}, new String[] {String.class.getName()}); } catch (Exception e) { log.error("Failed to get updated DICOM file", e); } file = new File(file + ".dcm"); file.deleteOnExit(); OutputStream os = new BufferedOutputStream(new FileOutputStream(file)); dsrc.isWriteFile(); dsrc.writeTo(os, null); os.close(); dsFile = loadDataset(file); file.delete(); } else { dsFile = loadDataset(file); } return dsFile; }
protected Dataset doNCreate(ActiveAssociation assoc, Dimse rq, Command rspCmd) throws IOException, DcmServiceException { Command cmd = rq.getCommand(); String iuid = cmd.getAffectedSOPInstanceUID(); Dataset ds = rq.getDataset(); String suid = ds.getString(Tags.StudyInstanceUID); if (suid == null) { throw new DcmServiceException(Status.MissingAttribute, "Missing Study Instance UID"); } if (iuid == null) { rspCmd.putUI(Tags.AffectedSOPInstanceUID, iuid = suid); } else { checkStudyIuid(iuid, ds); } try { StudyMgt stymgt = getStudyMgtHome().create(); try { stymgt.createStudy(ds, service.patientMatching()); } finally { try { stymgt.remove(); } catch (Exception e) { log.warn("Failed to remove StudyMgt Session Bean", e); } } } catch (DcmServiceException e) { throw e; } catch (Exception e) { throw new DcmServiceException(Status.ProcessingFailure, e); } service.sendStudyMgtNotification(assoc, Command.N_CREATE_RQ, 0, iuid, ds); return null; }
private static void checkContentItem(Dataset rqData, int tag, int... sqTags) throws DcmServiceException { DcmElement sq = rqData.get(tag); if (sq == null || sq.isEmpty()) return; int[] sqTags1 = cat(sqTags, tag); for (int i = 0, n = sq.countItems(); i < n; i++) { Dataset item = sq.getItem(i); type1(item, Tags.ValueType, sqTags1); type1(item, Tags.ConceptNameCodeSeq, sqTags1); checkCodeItem(item, ItemCount.SINGLE, Tags.ConceptNameCodeSeq, sqTags1); String valueType = item.getString(Tags.ValueType); if (valueType.equals("DATETIME")) type1(item, Tags.DateTime, sqTags1); else if (valueType.equals("DATE")) type1(item, Tags.Date, sqTags1); else if (valueType.equals("TIME")) type1(item, Tags.Time, sqTags1); else if (valueType.equals("PNAME")) type1(item, Tags.PersonName, sqTags1); else if (valueType.equals("UIDREF")) type1(item, Tags.UID, sqTags1); else if (valueType.equals("TEXT")) type1(item, Tags.TextValue, sqTags1); else if (valueType.equals("CODE")) { type1(item, Tags.ConceptCodeSeq, sqTags1); checkCodeItem(item, ItemCount.SINGLE, Tags.ConceptCodeSeq, sqTags1); } else if (valueType.equals("NUMERIC")) { type1(item, Tags.NumericValue, sqTags1); type1(item, Tags.MeasurementUnitsCodeSeq, sqTags1); checkCodeItem(item, ItemCount.SINGLE, Tags.MeasurementUnitsCodeSeq, sqTags1); } else throw new DcmServiceException( Status.InvalidAttributeValue, errorMessage("Invalid Value Type: " + valueType + " ", Tags.ValueType, sqTags1)); } }
/** * @param ds * @param outFile * @return * @throws IOException */ private RIDResponseObject handleSVG(Dataset ds, BaseDocument doc) throws IOException { OutputStream out = doc.getOutputStream(); try { DcmElement elem = ds.get(Tags.WaveformSeq); WaveformGroup wfgrp = new WaveformGroup( ds.getString(Tags.SOPClassUID), elem, 0, ridSupport.getWaveformCorrection()); // TODO all groups if (log.isDebugEnabled()) log.debug(wfgrp); WaveformInfo wfInfo = new WaveformInfo(ds); SVGCreator svgCreator = new SVGCreator(wfgrp, wfInfo, new Float(27.6f), new Float(20.3f)); svgCreator.toXML(out); out.close(); return new RIDStreamResponseObjectImpl( doc.getInputStream(), CONTENT_TYPE_SVGXML, HttpServletResponse.SC_OK, null); } catch (Throwable t) { if (out != null) try { out.close(); } catch (IOException e) { } log.error("Cant create SVG for Waveform!", t); log.error("Waveform Dataset:"); log.error(ds); return new RIDStreamResponseObjectImpl( null, RIDSupport.CONTENT_TYPE_HTML, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while creating waveform SVG! Reason:" + t.getMessage()); } }
/** @ejb.interface-method */ public void setAttributes(Dataset ds) { setPpsStartDateTime(ds.getDateTime(Tags.PPSStartDate, Tags.PPSStartTime)); setPpsStatus(ds.getString(Tags.GPPPSStatus)); AttributeFilter filter = AttributeFilter.getExcludePatientAttributeFilter(); byte[] b = DatasetUtils.toByteArray(filter.filter(ds), filter.getTransferSyntaxUID()); if (log.isDebugEnabled()) { log.debug("setEncodedAttributes(byte[" + b.length + "])"); } setEncodedAttributes(b); }
private Dataset loadDataset(File file) throws IOException { BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); Dataset ds = factory.newDataset(); try { ds.readFile(bis, null, -1); } finally { try { bis.close(); } catch (IOException ignore) { } } if (log.isDebugEnabled()) log.debug("Dataset for file " + file + " :" + ds); return ds; }
private String codes2String(Map codes) { if (codes == null || codes.isEmpty()) return ""; StringBuffer sb = new StringBuffer(); Dataset ds; String design; for (Iterator iter = codes.values().iterator(); iter.hasNext(); ) { ds = (Dataset) iter.next(); design = ds.getString(Tags.CodingSchemeDesignator); sb.append(ds.getString(Tags.CodeValue)).append("^"); if (design != null) sb.append(design).append("^"); sb.append(ds.getString(Tags.CodeMeaning)).append(","); } return sb.substring(0, sb.length() - 1); }
private void checkUPSPerformedProcedure(Dataset rqData) throws DcmServiceException { DcmElement sq = rqData.get(Tags.UPSPerformedProcedureSeq); if (sq == null || sq.isEmpty()) return; int n = sq.countItems(); if (n > 1) throw new DcmServiceException( Status.InvalidAttributeValue, errorMessage("More than 1 item of Attribute: ", Tags.UPSPerformedProcedureSeq)); Dataset item = sq.getItem(); checkActualHumanPerformers(item); checkCodeItem( item, ItemCount.MULTIPLE, Tags.PerformedStationNameCodeSeq, Tags.UPSPerformedProcedureSeq); checkCodeItem( item, ItemCount.MULTIPLE, Tags.PerformedStationClassCodeSeq, Tags.UPSPerformedProcedureSeq); checkCodeItem( item, ItemCount.MULTIPLE, Tags.PerformedStationGeographicLocationCodeSeq, Tags.UPSPerformedProcedureSeq); checkCodeItem( item, ItemCount.MULTIPLE, Tags.PerformedProcessingApplicationsCodeSeq, Tags.UPSPerformedProcedureSeq); checkCodeItem( item, ItemCount.SINGLE, Tags.PerformedWorkitemCodeSeq, Tags.UPSPerformedProcedureSeq); checkContentItem(item, Tags.PerformedProcessingParametersSeq, Tags.UPSPerformedProcedureSeq); checkImageSOPInstanceAndSourceReference( item, Tags.OutputInformationSeq, Tags.UPSPerformedProcedureSeq); }
private void checkStudyIuid(String iuid, Dataset ds) throws DcmServiceException { String suid = ds.getString(Tags.StudyInstanceUID); if (suid != null && !suid.equals(iuid)) { throw new DcmServiceException( Status.InvalidAttributeValue, "Study Instance UID must match SOP Instance UID"); } }
/** * Get the name of the creator block associated with a private element. * * @param tag the element. * @return the value of the creator element claiming the block in which the tag resides, or the * empty string if the tag is not a private element or the creator element does not exist. */ public String getCreator(int tag) { if ((tag & 0x10000) == 0) return ""; int group = tag & 0xffff0000; int block = (tag >> 8) & 0xff; int creatorTag = group | block; return inDS.getString(creatorTag, ""); }
private static int getInt(Dataset ds, int tag, int defaultValue) { try { return ds.getInteger(tag).intValue(); } catch (Exception ex) { return defaultValue; } }
private static String getString(Dataset ds, int tag, String defaultValue) { try { return ds.getString(tag); } catch (Exception ex) { return defaultValue; } }
private static void type1(Dataset rqData, int tag, int... sqTags) throws DcmServiceException { if (!rqData.containsValue(tag)) { type2(rqData, tag, sqTags); new DcmServiceException( sqTags.length == 0 ? Status.MissingAttributeValue : Status.InvalidAttributeValue, errorMessage("Missing Attribute Value: ", tag, sqTags)); } }
private void checkUPSCommunicationsURI(Dataset progressInfo) throws DcmServiceException { DcmElement sq = progressInfo.get(Tags.UPSCommunicationsURISeq); if (sq == null) return; for (int i = 0, n = sq.countItems(); i < n; i++) { Dataset item = sq.getItem(i); type1(item, Tags.ContactURI, Tags.UPSProgressInformationSeq, Tags.UPSCommunicationsURISeq); } }
private static void shallBeEmpty(Dataset rqData, int tag, int... sqTags) throws DcmServiceException { type2(rqData, tag, sqTags); if (rqData.containsValue(tag)) { throw new DcmServiceException( Status.InvalidAttributeValue, errorMessage("Shall be empty Attribute: ", tag, sqTags)); } }
private static void checkImageSOPInstanceAndSourceReference( Dataset rqData, int tag, int... sqTags) throws DcmServiceException { DcmElement sq = rqData.get(tag); if (sq == null) return; int[] sqTags1 = cat(sqTags, tag); int[] sqTags2 = cat(sqTags1, Tags.RefSOPSeq); for (int i = 0, n = sq.countItems(); i < n; i++) { Dataset item = sq.getItem(i); type1(item, Tags.RefSOPSeq, sqTags1); DcmElement refSOPSeq = item.get(Tags.RefSOPSeq); for (int j = 0, m = refSOPSeq.countItems(); j < m; j++) { Dataset refSOP = refSOPSeq.getItem(j); type1(refSOP, Tags.RefSOPClassUID, sqTags2); type1(refSOP, Tags.RefSOPInstanceUID, sqTags2); } } }
/* * Store a value in the output dataset. * If the output dataset is null, this method does nothing. * * This method works around the bug in dcm4che which inserts the wrong * VR (SH) when storing an empty element of VR = PN. It also handles the * problem in older dcm4che versions which threw an exception when an * empty DA element was created. It also forces the VR of private * elements to LO. And finally, it handles multi-valued elements. * @param tag the element tag. * @param vr the value representation. * @param value the value to store. */ public void putXX(int tag, int vrInt, String value) throws Exception { if (outDS == null) return; if (value == null) value = ""; if ((tag & 0x10000) != 0) { if ((tag & 0xffff) < 0x100) outDS.putLO(tag, value); else { String creator = getPrivateCreator(tag); if (!creator.equals("")) { PrivateTagIndex ptIndex = PrivateTagIndex.getInstance(); String vr = ptIndex.getVR(creator, tag); if (!vr.equals("")) { try { outDS.putXX(tag, VRs.valueOf(vr), value); return; } catch (Exception useDefault) { } } } if (value.length() <= 64) outDS.putLO(tag, value); else outDS.putLT(tag, value); } } else if (value.equals("")) { if (vrInt == VRs.PN) outDS.putXX(tag, vrInt, " "); else outDS.putXX(tag, vrInt); } else { // Do this in such a way that we handle multivalued elements. String[] s = value.split("\\\\"); outDS.putXX(tag, vrInt, s); } }
/** * Prepares the Dataset representing the search key in C-FIND. As no values are set, the keys * match to every content in the archive. The user has to specify concret values to limit the * searchSee PS 3.4 - C.6.2.1.2 Study level. * * <p>As the result for C-FIND these keys are filled with the values found in the archive. * * @param cfg the configuration properties for this class. * @throws ParseException if a given properties for the keys was not found. */ private void initKeys(ConfigProperties cfg) throws ParseException { // Remove all keys keys = dof.newDataset(); // Query/Retrieve Level. PS 3.4 - C.6.2 Study Root SOP Class Group keys.putCS(Tags.QueryRetrieveLevel, getQueryRetrieveLevel(STUDY_LEVEL)); // UNIQUE STUDY LEVEL KEY FOR THE STUDY. See PS 3.4 - C.6.2.1.2 Study level keys.putUI(Tags.StudyInstanceUID); // REQUIRED STUDY LEVEL KEY FOR THE STUDY. See PS 3.4 - C.6.2.1.2 Study level keys.putDA(Tags.StudyDate); // Not defined: StudyTime // Not defined: AccessionNumber keys.putPN(Tags.PatientName); keys.putLO(Tags.PatientID); // Not defined: StudyID // OPTIONAL STUDY LEVEL KEY FOR THE STUDY. See PS 3.4 - C.6.2.1.2 Study level keys.putUS(Tags.NumberOfStudyRelatedSeries); keys.putUS(Tags.NumberOfStudyRelatedInstances); // mutch more defined... // Add the keys found in the configuration properties addQueryKeys(cfg); }
private RIDResponseObject handlePDF(Dataset ds, BaseDocument doc) throws IOException { OutputStream out = doc.getOutputStream(); OutputStream tmpOut = null; File tmpFile = null; try { tmpFile = File.createTempFile("fop_", null); tmpFile.deleteOnExit(); tmpOut = new FileOutputStream(tmpFile); DcmElement elem = ds.get(Tags.WaveformSeq); WaveformGroup[] wfgrps = getWaveformGroups(elem, ds.getString(Tags.SOPClassUID)); WaveformInfo wfInfo = new WaveformInfo(ds); FOPCreator fopCreator = new FOPCreator(wfgrps, wfInfo, new Float(28.6f), new Float(20.3f)); fopCreator.toXML(tmpOut); tmpOut.close(); Fop fop = ridSupport.newFop(MimeConstants.MIME_PDF, out); SAXTransformerFactory tf = (SAXTransformerFactory) TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); t.transform( new StreamSource(new FileInputStream(tmpFile)), new SAXResult(fop.getDefaultHandler())); out.close(); tmpFile.delete(); InputStream in = doc.getInputStream(); return new RIDStreamResponseObjectImpl( in, in.available(), RIDSupport.CONTENT_TYPE_PDF, HttpServletResponse.SC_OK, null); } catch (Throwable t) { try { if (out != null) out.close(); if (tmpOut != null) tmpOut.close(); } catch (IOException e) { } if (tmpFile.exists()) tmpFile.delete(); log.error("Cant create PDF for Waveform!", t); log.error("Waveform Dataset:"); log.error(ds); return new RIDStreamResponseObjectImpl( null, RIDSupport.CONTENT_TYPE_HTML, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while creating waveform PDF! Reason:" + t.getMessage()); } }
public static boolean equalsPixelData(File f1, File f2) throws IOException { InputStream in1 = new BufferedInputStream(new FileInputStream(f1)); try { InputStream in2 = new BufferedInputStream(new FileInputStream(f2)); try { Dataset attrs = DcmObjectFactory.getInstance().newDataset(); DcmParserFactory pf = DcmParserFactory.getInstance(); DcmParser p1 = pf.newDcmParser(in1); DcmParser p2 = pf.newDcmParser(in2); p1.setDcmHandler(attrs.getDcmHandler()); p1.parseDcmFile(FileFormat.DICOM_FILE, Tags.PixelData); p2.parseDcmFile(FileFormat.DICOM_FILE, Tags.PixelData); int samples = attrs.getInt(Tags.SamplesPerPixel, 1); int frames = attrs.getInt(Tags.NumberOfFrames, 1); int rows = attrs.getInt(Tags.Rows, 1); int columns = attrs.getInt(Tags.Columns, 1); int bitsAlloc = attrs.getInt(Tags.BitsAllocated, 8); int bitsStored = attrs.getInt(Tags.BitsStored, bitsAlloc); int frameLength = rows * columns * samples * bitsAlloc / 8; int pixelDataLength = frameLength * frames; if (pixelDataLength > p1.getReadLength() || pixelDataLength > p2.getReadLength()) { return false; } byte[] b1 = new byte[BUFFER_SIZE]; byte[] b2 = new byte[BUFFER_SIZE]; int[] mask = {0xff, 0xff}; int len, len2; if (bitsAlloc == 16 && bitsStored < 16) { mask[p1.getDcmDecodeParam().byteOrder == ByteOrder.LITTLE_ENDIAN ? 1 : 0] = 0xff >>> (16 - bitsStored); } int pos = 0; while (pos < pixelDataLength) { len = in1.read(b1, 0, Math.min(pixelDataLength - pos, BUFFER_SIZE)); if (len < 0) // EOF return false; int off = 0; while (off < len) { off += len2 = in2.read(b2, off, len - off); if (len2 < 0) // EOF return false; } for (int i = 0; i < len; i++, pos++) if (((b1[i] - b2[i]) & mask[pos & 1]) != 0) return false; } return true; } finally { in2.close(); } } finally { in1.close(); } }
private static void checkRelatedProcedureSteps(Dataset rqData) throws DcmServiceException { DcmElement sq = rqData.get(Tags.RelatedProcedureStepSeq); if (sq == null) return; for (int i = 0, n = sq.countItems(); i < n; i++) { Dataset item = sq.getItem(i); type1(item, Tags.RefSOPClassUID, Tags.RelatedProcedureStepSeq); type1(item, Tags.RefSOPInstanceUID, Tags.RelatedProcedureStepSeq); type1(item, Tags.PurposeOfReferenceCodeSeq, Tags.RelatedProcedureStepSeq); checkCodeItem( item, ItemCount.SINGLE, Tags.PurposeOfReferenceCodeSeq, Tags.RelatedProcedureStepSeq); } }
private static void checkScheduledHumanPerformers(Dataset rqData) throws DcmServiceException { DcmElement sq = rqData.get(Tags.ScheduledHumanPerformersSeq); if (sq == null) return; for (int i = 0, n = sq.countItems(); i < n; i++) { Dataset item = sq.getItem(i); type1(item, Tags.HumanPerformerCodeSeq, Tags.ScheduledHumanPerformersSeq); checkCodeItem( item, ItemCount.SINGLE, Tags.HumanPerformerCodeSeq, Tags.ScheduledHumanPerformersSeq); type1(item, Tags.HumanPerformerName, Tags.ScheduledHumanPerformersSeq); type1(item, Tags.HumanPerformerOrganization, Tags.ScheduledHumanPerformersSeq); } }
private String[] toIuids(Dataset ds, boolean seriesIuids) throws DcmServiceException { List iuids = new ArrayList(); DcmElement sersq = ds.get(Tags.RefSeriesSeq); if (sersq == null) { throw new DcmServiceException(Status.MissingAttribute, "Missing Referenced Series Seq."); } for (int i = 0, n = sersq.countItems(); i < n; ++i) { Dataset ser = sersq.getItem(i); String siuid = ser.getString(Tags.SeriesInstanceUID); if (siuid == null) { throw new DcmServiceException(Status.MissingAttribute, "Missing Series Instance UID"); } if (seriesIuids) { iuids.add(siuid); } else { DcmElement sops = ser.get(Tags.RefSOPSeq); if (sops == null) { throw new DcmServiceException(Status.MissingAttribute, "Missing Referenced SOP Seq."); } for (int j = 0, m = sops.countItems(); j < m; ++j) { Dataset sop = sops.getItem(i); String iuid = sop.getString(Tags.RefSOPInstanceUID); if (iuid == null) { throw new DcmServiceException( Status.MissingAttribute, "Missing Referenced SOP Instance UID"); } iuids.add(iuid); } } } return (String[]) iuids.toArray(new String[iuids.size()]); }
/* * Get the private creator string for a private data element. * @param tag the tag. * @return the the block owner or the tag, or the empoty string if the element * is not a private data element. */ public String getPrivateCreator(int tag) { if ((tag & 0x10000) != 0) { int block = (tag & 0xFF00) >> 8; if (block != 0) { String owner; int pce = (tag & 0xFFFF0000) | block; // First see if the element is in outDS. try { owner = outDS.getString(pce); if (owner != null) return owner; } catch (Exception notThere) { } // See if it is in inDS; try { owner = inDS.getString(pce); if (owner != null) return owner; } catch (Exception notThere) { } } } return ""; }
public static Object valueOf(Dataset ds) { String cuid = ds.getString(Tags.SOPClassUID); if (UIDs.GrayscaleSoftcopyPresentationStateStorage.equals(cuid)) return new PresentationStateModel(ds); if (UIDs.BasicTextSR.equals(cuid) || UIDs.EnhancedSR.equals(cuid) || UIDs.ComprehensiveSR.equals(cuid) || UIDs.KeyObjectSelectionDocument.equals(cuid) || UIDs.MammographyCADSR.equals(cuid) || UIDs.ProcedureLogStorage.equals(cuid) || UIDs.XRayRadiationDoseSR.equals(cuid)) return new StructuredReportModel(ds); if (UIDs.TwelveLeadECGWaveformStorage.equals(cuid) || UIDs.GeneralECGWaveformStorage.equals(cuid) || UIDs.AmbulatoryECGWaveformStorage.equals(cuid) || UIDs.HemodynamicWaveformStorage.equals(cuid) || UIDs.CardiacElectrophysiologyWaveformStorage.equals(cuid) || UIDs.BasicVoiceAudioWaveformStorage.equals(cuid)) return new WaveformModel(ds); if (ds.getString(Tags.MIMETypeOfEncapsulatedDocument) != null) { return new EncapsulatedModel(ds); } return new ImageModel(ds); }
void sendPPS(boolean create, Dataset pps, String aet) throws Exception { ActiveAssociation aa = openAssociation(aet, UIDs.GeneralPurposePerformedProcedureStepSOPClass); try { Association a = aa.getAssociation(); DcmObjectFactory dof = DcmObjectFactory.getInstance(); Command cmdRq = dof.newCommand(); final String iuid = pps.getString(Tags.SOPInstanceUID); if (create) { cmdRq.initNCreateRQ(a.nextMsgID(), UIDs.GeneralPurposePerformedProcedureStepSOPClass, iuid); } else { cmdRq.initNSetRQ(a.nextMsgID(), UIDs.GeneralPurposePerformedProcedureStepSOPClass, iuid); } Dimse dimseRq = AssociationFactory.getInstance().newDimse(PCID_GPPPS, cmdRq, pps.exclude(SOP_IUID)); if (log.isDebugEnabled()) { log.debug("GP-PPS Attributes:"); log.debug(pps); } final Dimse dimseRsp = aa.invoke(dimseRq).get(); final Command cmdRsp = dimseRsp.getCommand(); final int status = cmdRsp.getStatus(); switch (status) { case 0x0000: break; case 0x0116: log.warn( "Received Warning Status 116H (=Attribute Value Out of Range) from remote AE " + aet); break; default: throw new DcmServiceException(status, cmdRsp.getString(Tags.ErrorComment)); } } finally { try { aa.release(true); } catch (Exception e) { log.warn("Failed to release " + aa.getAssociation()); } } }