/** * Get the tag for a DICOM element. This method supports dcm4che names as well as hex strings, * with or without enclosing parentheses or square brackets and with or without a comma separating * the group and the element numbers. This method also supports private group names defined in the * script. This method differs from the DicomObject method of the same name in that it also * supports names for private group elements in the form 0009[ID]02, where ID is the block owner * ID. Examples of element specifications containing block owner IDs are: * * <ul> * <li>9,[blockID]02 * <li>(9,[blockID]02) * <li>[9,[blockID]02] * <li>0009[blockID]02 * </ul> * * @param name the dcm4che element name or coded hex value. * @return the tag, or zero if the name cannot be parsed as an element specification */ public int getElementTag(String name) { if (name == null) return 0; name = name.trim(); int k = name.length() - 1; if (name.startsWith("[") && name.endsWith("]")) name = name.substring(1, k).trim(); else if (name.startsWith("(") && name.endsWith(")")) name = name.substring(1, k).trim(); // Try it as a standard element specification int tag = DicomObject.getElementTag(name); if (tag != 0) return tag; // Try it as a private element name Integer tagInteger = privateElementNames.get(name); if (tagInteger != null) return tagInteger.intValue(); // Try to match it as a private group element with a block specification Matcher matcher = pgPattern.matcher(name); if (matcher.matches()) { int group = StringUtil.getHexInt(matcher.group(1)); if ((group & 1) == 1) { // It's a private group; get the block ID and the element offset String blockID = matcher.group(2).toUpperCase(); int elem = StringUtil.getHexInt(matcher.group(3)); // Now get the tag of the private group creator int creatorTag = pgIndex.getTagForID(group, blockID); if (creatorTag != 0) { return (group << 16) | ((creatorTag & 0xFF) << 8) | (elem & 0xFF); } } } // Try to match it as a private creator element with a block specification matcher = pcPattern.matcher(name); if (matcher.matches()) { int group = StringUtil.getHexInt(matcher.group(1)); if ((group & 1) == 1) { // It's a private group; get the block ID String blockID = matcher.group(2).toUpperCase(); // Now get the tag of the private group creator int creatorTag = pgIndex.getTagForID(group, blockID); if (creatorTag != 0) return creatorTag; } } return 0; }
/** * Update the indexes for this object. This stage tracks the following data: * * <ul> * <li>Processing date (today) * <li>PatientID * <li>StudyInstanceUID * <li>SeriesInstanceUID * <li>SOPInstanceUID * </ul> * * It creates table entries for the values in this object. IDs which are not unique may be * overwritten by subsequent objects (e.g. duplicates). Thus, the tables contain only records of * unique objects that have been processed. * * @param fileObject the object to process. * @return the same FileObject if the result is true; otherwise null. */ public FileObject process(FileObject fileObject) { lastFileIn = new File(fileObject.getFile().getAbsolutePath()); lastTimeIn = System.currentTimeMillis(); try { if (fileObject instanceof DicomObject) { DicomObject dob = (DicomObject) fileObject; String date = StringUtil.getDate(""); String patientID = dob.getPatientID(); String studyInstanceUID = dob.getStudyInstanceUID(); String seriesInstanceUID = dob.getSeriesInstanceUID(); String sopInstanceUID = dob.getSOPInstanceUID(); index(dateIndex, date, patientID); index(patientIndex, patientID, studyInstanceUID); index(studyIndex, studyInstanceUID, seriesInstanceUID); index(seriesIndex, seriesInstanceUID, sopInstanceUID); recman.commit(); } } catch (Exception skip) { logger.debug("Unable to process " + fileObject.getFile()); } lastFileOut = new File(fileObject.getFile().getAbsolutePath()); lastTimeOut = System.currentTimeMillis(); return fileObject; }
/** * The servlet method that responds to an HTTP GET. This method returns a summary page containing * information on the pipeline or stage specified by the p and s query parameters. * * @param req The HttpServletRequest provided by the servlet container. * @param res The HttpServletResponse provided by the servlet container. */ public void doGet(HttpRequest req, HttpResponse res) { super.loadParameters(req); // Get the parameters. int x = StringUtil.getInt(req.getParameter("plugin"), -1); // Return the page res.write(getPage(p, s, x)); res.setContentType("html"); res.disableCaching(); res.send(); }
/** * Construct a Query from an XML document in the form described on the RSNA MIRC wiki. * * @param queryDoc the MIRCquery XML DOM object. */ public Query(Document queryDoc) { super(); Element root = queryDoc.getDocumentElement(); unknown = root.getAttribute("unknown").trim().equals("yes"); bgcolor = root.getAttribute("bgcolor").trim(); display = root.getAttribute("display").trim(); icons = root.getAttribute("icons").trim(); orderby = root.getAttribute("orderby").trim(); firstresult = StringUtil.getInt(root.getAttribute("firstresult")); if (firstresult <= 0) firstresult = 1; maxresults = StringUtil.getInt(root.getAttribute("maxresults")); if (maxresults <= 0) maxresults = 1; StringBuffer sb = new StringBuffer(); Node child = root.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) { String dbname = child.getNodeName(); String text = getTextContent(child); if (!text.equals("")) { this.put(dbname, text); containsNonFreetextQueries = true; } if (dbname.equals("temp")) isTempQuery = true; } else if (child.getNodeType() == Node.TEXT_NODE) { sb.append(" " + child.getTextContent()); } child = child.getNextSibling(); } String freetext = sb.toString().replaceAll("\\s+", " ").trim(); isBlankQuery = freetext.equals(""); isSpecialQuery = root.getAttribute("special").trim().equals("yes"); this.put("freetext", freetext); setAgeRange(root); // log(); }
// Create an HTML page containing the form for configuring the file. private String getScriptPage(int pipe, int stage, File file) { String template = "/DAEditor.html"; String page = FileUtil.getText(Cache.getInstance().getFile(template)); String table = makeList(); Properties props = new Properties(); props.setProperty("closebox", "/icons/home.png"); props.setProperty("home", home); props.setProperty("context", "/" + context); props.setProperty("profilespath", "/profiles"); props.setProperty("profilepath", "/profile"); props.setProperty("scriptpath", "/script"); props.setProperty("scriptfile", file.getAbsolutePath().replaceAll("\\\\", "/")); props.setProperty("pipe", "" + pipe); props.setProperty("stage", "" + stage); page = StringUtil.replace(page, props); return page; }
// Create an HTML page containing the list of script files. private String getListPage() { String template = "/DAList.html"; String page = FileUtil.getText(Cache.getInstance().getFile(template)); String table = makeList(); Properties props = new Properties(); props.setProperty("home", home); props.setProperty("table", table); props.setProperty("homeicon", ""); if (!home.equals("")) { props.setProperty( "homeicon", "<img src=\"/icons/home.png\" onclick=\"window.open('" + home + "','_self');\" title=\"Return to the home page\" style=\"margin:2\"/>"); } page = StringUtil.replace(page, props); return page; }
public ScriptTable(DAScript script) { super(); Document scriptXML = script.toXML(); Element scriptRoot = scriptXML.getDocumentElement(); Node child = scriptRoot.getFirstChild(); while (child != null) { if ((child instanceof Element) && child.getNodeName().equals("e")) { Element eChild = (Element) child; if (eChild.getAttribute("en").equals("T")) { int tag = StringUtil.getHexInt(eChild.getAttribute("t")); String command = eChild.getTextContent(); Matcher processMatcher = processPattern.matcher(command); Matcher lookupMatcher = lookupPattern.matcher(command); Integer tagInteger = new Integer(tag); if (processMatcher.find() || lookupMatcher.find()) { this.put(tagInteger, command); } } } child = child.getNextSibling(); } }