|
From: <aw...@us...> - 2011-07-12 13:37:42
|
Revision: 15679
http://dcm4che.svn.sourceforge.net/dcm4che/?rev=15679&view=rev
Author: awsjn
Date: 2011-07-12 13:37:33 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
[#WEB-412] Provide teaching-file search page based on matching of content-item sequence; initial commit
Modified Paths:
--------------
dcm4chee/dcm4chee-icons/trunk/src/main/java/org/dcm4chee/icons/ImageManager.java
dcm4chee/dcm4chee-usr/trunk/dcm4chee-usr-sar/dcm4chee-usr-sar-webcfg/src/main/resources/META-INF/roles-default.json
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-sar/dcm4chee-web-sar-webcfg/src/main/java/org/dcm4chee/web/service/webcfg/WebCfgService.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-sar/dcm4chee-web-sar-webcfg/src/main/resources/META-INF/roles-default.json
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-sar/dcm4chee-web-sar-webcfg/src/main/resources/META-INF/xmdesc/webcfg-xmbean.xml
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/MainPage.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/common/WadoImage.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/config/delegate/WebCfgDelegate.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/webapp/WEB-INF/dcm4chee.hive
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/test/java/org/dcm4chee/web/war/WicketApplicationTest.java
Added Paths:
-----------
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryBean.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilter.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterKey.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterValue.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryLocal.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryResultItem.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetails.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetailsAuthorTab.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetailsBibliographyTab.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetailsDefaultTab.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetailsDiagnosisTab.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetailsImagesTab.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetailsInfoTab.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCDetailsPanel.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCModel.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCMultiLineLabel.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCPanel.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCResultPanel.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/TCSearchPanel.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/TCKeyword.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/TCKeywordCatalogue.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/TCKeywordCatalogueProvider.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/TCKeywordListInput.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/TCKeywordNode.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/TCKeywordTreeInput.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/acr/
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/acr/ACRCatalogue.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/acr/ACRData.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/acr/ACRKeyword.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/acr/ACRKeywordNode.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/java/org/dcm4chee/web/war/tc/keywords/acr/TCKeywordACRInput.java
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCDetailsAuthorTab.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCDetailsBibliographyTab.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCDetailsDefaultTab.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCDetailsDiagnosisTab.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCDetailsImagesTab.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCDetailsInfoTab.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCDetailsPanel.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCPanel.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCResultPanel.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/TCSearchPanel.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/keywords/
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/keywords/TCKeywordListInput.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/keywords/TCKeywordTreeInput.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/keywords/acr/
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/keywords/acr/TCKeywordACRInput.html
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/order-ascending.png
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/order-descending.png
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/order-none.png
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/package.properties
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/package_de.properties
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/package_ja.properties
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/popup-close-mouse-on.png
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/popup-close-mouse-out.png
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/tc-style.css
dcm4chee/dcm4chee-web/trunk/dcm4chee-web-war/src/main/resources/org/dcm4chee/web/war/tc/tc-utils.js
Modified: dcm4chee/dcm4chee-icons/trunk/src/main/java/org/dcm4chee/icons/ImageManager.java
===================================================================
--- dcm4chee/dcm4chee-icons/trunk/src/main/java/org/dcm4chee/icons/ImageManager.java 2011-07-11 14:04:22 UTC (rev 15678)
+++ dcm4chee/dcm4chee-icons/trunk/src/main/java/org/dcm4chee/icons/ImageManager.java 2011-07-12 13:37:33 UTC (rev 15679)
@@ -178,4 +178,7 @@
new ResourceReference(ImageManager.class, "trash/empty_trash.png");
public static final ResourceReference IMAGE_TRASH_RESTORE =
new ResourceReference(ImageManager.class, "trash/restore.png");
+
+ public static final ResourceReference IMAGE_TC_IMAGE_PLACEHOLDER =
+ new ResourceReference(ImageManager.class, "tc/empty-image.png");
}
Modified: dcm4chee/dcm4chee-usr/trunk/dcm4chee-usr-sar/dcm4chee-usr-sar-webcfg/src/main/resources/META-INF/roles-default.json
===================================================================
--- dcm4chee/dcm4chee-usr/trunk/dcm4chee-usr-sar/dcm4chee-usr-sar-webcfg/src/main/resources/META-INF/roles-default.json 2011-07-11 14:04:22 UTC (rev 15678)
+++ dcm4chee/dcm4chee-usr/trunk/dcm4chee-usr-sar/dcm4chee-usr-sar-webcfg/src/main/resources/META-INF/roles-default.json 2011-07-12 13:37:33 UTC (rev 15679)
@@ -1,3 +1,3 @@
{"description":"","dicomRole":false,"roleGroups":[],"rolename":"JBossAdmin","superuser":false,"swarmPrincipals":["JBossAdmin"],"uuid":"ca4686c2-1140-498f-9287-1cbe8ab0145a","webRole":true}
-{"description":"","dicomRole":false,"roleGroups":[],"rolename":"WebAdmin","superuser":false,"swarmPrincipals":["Mpps2MwlLink","FolderActions","Dashboard","FileSystem","AEWrite","MWLRead","UserRead","SystemInfo","UserManagement","FolderRead","MWLWrite","FolderWrite","RoleWrite","AERead","RoleRead","LoginAllowed","StudyPermissionsWrite","Superuser","Queue","ReportWrite","ReportRead","TrashRead","TrashActions","UserWrite","IgnoreEditTimeLimit"],"uuid":"40fe37ca-ca04-42ba-85df-3f02c7a46ac2","webRole":true}
-{"description":"","dicomRole":false,"roleGroups":[],"rolename":"WebUser","superuser":false,"swarmPrincipals":["Mpps2MwlLink","FolderActions","Dashboard","AEWrite","FileSystem","MWLRead","SystemInfo","FolderRead","MWLWrite","FolderWrite","AERead","LoginAllowed","StudyPermissionsWrite","Queue","ReportRead","TrashRead","TrashActions"],"uuid":"a2d823d9-4f12-4f20-a380-93e43a6968ca","webRole":true}
+{"description":"","dicomRole":false,"roleGroups":[],"rolename":"WebAdmin","superuser":false,"swarmPrincipals":["Mpps2MwlLink","FolderActions","Dashboard","FileSystem","AEWrite","MWLRead","UserRead","SystemInfo","UserManagement","FolderRead","MWLWrite","FolderWrite","RoleWrite","AERead","RoleRead","LoginAllowed","StudyPermissionsWrite","Superuser","Queue","ReportWrite","ReportRead","TrashRead","TrashActions","UserWrite","IgnoreEditTimeLimit","TCRead"],"uuid":"40fe37ca-ca04-42ba-85df-3f02c7a46ac2","webRole":true}
+{"description":"","dicomRole":false,"roleGroups":[],"rolename":"WebUser","superuser":false,"swarmPrincipals":["Mpps2MwlLink","FolderActions","Dashboard","AEWrite","FileSystem","MWLRead","SystemInfo","FolderRead","MWLWrite","FolderWrite","AERead","LoginAllowed","StudyPermissionsWrite","Queue","ReportRead","TrashRead","TrashActions","TCRead"],"uuid":"a2d823d9-4f12-4f20-a380-93e43a6968ca","webRole":true}
Added: dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryBean.java
===================================================================
--- dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryBean.java (rev 0)
+++ dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryBean.java 2011-07-12 13:37:33 UTC (rev 15679)
@@ -0,0 +1,230 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa-Gevaert AG.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.dcm4chee.web.dao.tc;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.dcm4chee.archive.entity.File;
+import org.dcm4chee.archive.entity.Instance;
+import org.dcm4chee.web.dao.tc.TCQueryFilterValue.QueryParam;
+import org.dcm4chee.web.dao.util.QueryUtil;
+import org.jboss.annotation.ejb.LocalBinding;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Bernhard Ableitinger <ber...@ag...>
+ * @version $Revision$ $Date$
+ * @since May 05, 2011
+ */
+@Stateless
+@LocalBinding(jndiBinding = TCQueryLocal.JNDI_NAME)
+public class TCQueryBean implements TCQueryLocal {
+
+ private static final Logger log = LoggerFactory
+ .getLogger(TCQueryBean.class);
+
+ @PersistenceContext(unitName = "dcm4chee-arc")
+ private EntityManager em;
+
+ public int countMatchingInstances(TCQueryFilter filter, List<String> roles) {
+ if (roles != null && roles.isEmpty()) {
+ return 0;
+ }
+
+ boolean doStudyPermissionCheck = roles != null;
+
+ StringBuilder sb = new StringBuilder(64);
+ sb.append(" Select COUNT(*) FROM Instance instance");
+
+ if (doStudyPermissionCheck) {
+ sb.append(" LEFT JOIN instance.series series");
+ sb.append(" LEFT JOIN series.study s");
+ }
+
+ sb.append(" LEFT JOIN FETCH instance.conceptNameCode sr_code");
+ sb.append(" WHERE (instance.sopClassUID = '1.2.840.10008.5.1.4.1.1.88.11')");
+ sb.append(" AND (sr_code.codeValue = 'TCE006')");
+ sb.append(" AND (sr_code.codingSchemeDesignator = 'IHERADTF')");
+
+ Set<Entry<TCQueryFilterKey, TCQueryFilterValue<?>>> entries = filter
+ .getEntries();
+ Set<QueryParam[]> paramSets = null;
+
+ if (entries != null) {
+ for (Entry<TCQueryFilterKey, TCQueryFilterValue<?>> e : entries) {
+ sb.append(" AND (");
+
+ QueryParam[] params = e.getValue().appendSQLWhereConstraint(
+ e.getKey(), sb);
+ if (params != null) {
+ if (paramSets == null) {
+ paramSets = new HashSet<QueryParam[]>();
+ }
+
+ paramSets.add(params);
+ }
+
+ sb.append(")");
+ }
+ }
+
+ if (doStudyPermissionCheck) {
+ QueryUtil.appendDicomSecurityFilter(sb);
+ }
+
+ Query query = em.createQuery(sb.toString());
+
+ if (doStudyPermissionCheck) {
+ query.setParameter("roles", roles);
+ }
+
+ if (paramSets != null) {
+ for (QueryParam[] paramSet : paramSets) {
+ if (paramSet != null) {
+ for (QueryParam param : paramSet) {
+ query.setParameter(param.getKey(), param.getValue());
+ }
+ }
+ }
+ }
+
+ return ((Number) query.getSingleResult()).intValue();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Instance> findMatchingInstances(TCQueryFilter filter,
+ List<String> roles) {
+ if (roles != null && roles.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ boolean doStudyPermissionCheck = roles != null;
+
+ StringBuilder sb = new StringBuilder(64);
+ sb.append(" FROM Instance instance");
+
+ if (doStudyPermissionCheck) {
+ sb.append(" LEFT JOIN instance.series series");
+ sb.append(" LEFT JOIN series.study s");
+ }
+
+ sb.append(" LEFT JOIN FETCH instance.conceptNameCode sr_code");
+ sb.append(" LEFT JOIN FETCH instance.media");
+ sb.append(" WHERE (instance.sopClassUID = '1.2.840.10008.5.1.4.1.1.88.11')");
+ sb.append(" AND (sr_code.codeValue = 'TCE006')");
+ sb.append(" AND (sr_code.codingSchemeDesignator = 'IHERADTF')");
+
+ Set<Entry<TCQueryFilterKey, TCQueryFilterValue<?>>> entries = filter
+ .getEntries();
+ Set<QueryParam[]> paramSets = null;
+
+ if (entries != null) {
+ for (Entry<TCQueryFilterKey, TCQueryFilterValue<?>> e : entries) {
+ sb.append(" AND (");
+
+ QueryParam[] params = e.getValue().appendSQLWhereConstraint(
+ e.getKey(), sb);
+ if (params != null) {
+ if (paramSets == null) {
+ paramSets = new HashSet<QueryParam[]>();
+ }
+
+ paramSets.add(params);
+ }
+
+ sb.append(")");
+ }
+ }
+
+ if (doStudyPermissionCheck) {
+ QueryUtil.appendDicomSecurityFilter(sb);
+ }
+
+ Query query = em.createQuery(sb.toString());
+
+ if (doStudyPermissionCheck) {
+ query.setParameter("roles", roles);
+ }
+
+ if (paramSets != null) {
+ for (QueryParam[] paramSet : paramSets) {
+ if (paramSet != null) {
+ for (QueryParam param : paramSet) {
+ query.setParameter(param.getKey(), param.getValue());
+ }
+ }
+ }
+ }
+
+ log.info("Executing teaching-file query: " + query.toString());
+
+ List<Instance> instances = query.getResultList();
+
+ if (instances != null) {
+ for (Instance instance : instances) {
+ // touch dicom tree
+ instance.getSeries().getSeriesInstanceUID();
+ instance.getSeries().getStudy().getStudyInstanceUID();
+ instance.getSeries().getStudy().getPatient().getPatientID();
+
+ List<File> files = instance.getFiles();
+ if (files != null) {
+ for (File file : files) {
+ file.getFilePath();
+ file.getFileSystem().getDirectoryPath();
+ }
+ }
+ }
+
+ log.info(instances.size() + " matching teaching-files found!");
+ }
+
+ return instances;
+ }
+
+}
Added: dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilter.java
===================================================================
--- dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilter.java (rev 0)
+++ dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilter.java 2011-07-12 13:37:33 UTC (rev 15679)
@@ -0,0 +1,503 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa-Gevaert AG.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.dcm4chee.web.dao.tc;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.dcm4chee.archive.entity.Code;
+import org.dcm4chee.web.dao.tc.TCQueryFilterValue.AcquisitionModality;
+import org.dcm4chee.web.dao.tc.TCQueryFilterValue.Category;
+import org.dcm4chee.web.dao.tc.TCQueryFilterValue.Level;
+import org.dcm4chee.web.dao.tc.TCQueryFilterValue.PatientSex;
+import org.dcm4chee.web.dao.tc.TCQueryFilterValue.YesNo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Bernhard Ableitinger <ber...@ag...>
+ * @version $Revision$ $Date$
+ * @since May 05, 2011
+ */
+public class TCQueryFilter implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static Logger log = LoggerFactory.getLogger(TCQueryFilter.class);
+
+ private Map<TCQueryFilterKey, TCQueryFilterValue<?>> values;
+
+ public void clear() {
+ if (values != null) {
+ values.clear();
+ values = null;
+ }
+ }
+
+ public Set<Entry<TCQueryFilterKey, TCQueryFilterValue<?>>> getEntries() {
+ return values != null ? values.entrySet() : null;
+ }
+
+ public String getAbstract() {
+ return (String) getValue(TCQueryFilterKey.Abstract);
+ }
+
+ public void setAbstract(String abstr) {
+ putValue(TCQueryFilterKey.Abstract, abstr);
+ }
+
+ public AcquisitionModality getAcquisitionModality() {
+ return (AcquisitionModality) getValue(TCQueryFilterKey.AcquisitionModality);
+ }
+
+ public void setAcquisitionModality(AcquisitionModality acquisitionModality) {
+ putValue(
+ TCQueryFilterKey.AcquisitionModality,
+ acquisitionModality != null ? TCQueryFilterValue
+ .create(acquisitionModality) : null);
+ }
+
+ public String getAnatomy() {
+ try {
+ return (String) getValue(TCQueryFilterKey.Anatomy);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'anatomy' is not of type String. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setAnatomy(String anatomy) {
+ putValue(TCQueryFilterKey.Anatomy, anatomy);
+ }
+
+ public String getAuthorAffiliation() {
+ return (String) getValue(TCQueryFilterKey.AuthorAffiliation);
+ }
+
+ public void setAuthorAffiliation(String authorAffiliation) {
+ putValue(TCQueryFilterKey.AuthorAffiliation, authorAffiliation);
+ }
+
+ public String getAuthorContact() {
+ return (String) getValue(TCQueryFilterKey.AuthorContact);
+ }
+
+ public void setAuthorContact(String authorContact) {
+ putValue(TCQueryFilterKey.AuthorContact, authorContact);
+ }
+
+ public String getAuthorName() {
+ return (String) getValue(TCQueryFilterKey.AuthorName);
+ }
+
+ public void setAuthorName(String authorName) {
+ putValue(TCQueryFilterKey.AuthorName, authorName);
+ }
+
+ public Category getCategory() {
+ return (Category) getValue(TCQueryFilterKey.Category);
+ }
+
+ public void setCategory(Category category) {
+ putValue(TCQueryFilterKey.Category,
+ category != null ? TCQueryFilterValue.create(category) : null);
+ }
+
+ public String getDiagnosis() {
+ try {
+ return (String) getValue(TCQueryFilterKey.Diagnosis);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'diagnosis' is not of type String. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setDiagnosis(String diagnosis) {
+ putValue(TCQueryFilterKey.Diagnosis, diagnosis);
+ }
+
+ public YesNo getDiagnosisConfirmed() {
+ return (YesNo) getValue(TCQueryFilterKey.DiagnosisConfirmed);
+ }
+
+ public void setDiagnosisConfirmed(YesNo diagnosisConfirmed) {
+ putValue(
+ TCQueryFilterKey.DiagnosisConfirmed,
+ diagnosisConfirmed != null ? TCQueryFilterValue
+ .create(diagnosisConfirmed) : null);
+ }
+
+ public String getDiffDiagnosis() {
+ try {
+ return (String) getValue(TCQueryFilterKey.DifferentialDiagnosis);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'diff-diagnosis' is not of type String. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setDiffDiagnosis(String diffDiagnosis) {
+ putValue(TCQueryFilterKey.DifferentialDiagnosis, diffDiagnosis);
+ }
+
+ public String getDiscussion() {
+ return (String) getValue(TCQueryFilterKey.Discussion);
+ }
+
+ public void setDiscussion(String discussion) {
+ putValue(TCQueryFilterKey.Discussion, discussion);
+ }
+
+ public String getFinding() {
+ try {
+ return (String) getValue(TCQueryFilterKey.Finding);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'finding' is not of type String. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setFinding(String finding) {
+ putValue(TCQueryFilterKey.Finding, finding);
+ }
+
+ public String getHistory() {
+ return (String) getValue(TCQueryFilterKey.History);
+ }
+
+ public void setHistory(String history) {
+ putValue(TCQueryFilterKey.History, history);
+ }
+
+ public String getKeyword() {
+ try {
+ return (String) getValue(TCQueryFilterKey.Keyword);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'keyword' is not of type String. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setKeyword(String keyword) {
+ putValue(TCQueryFilterKey.Keyword, keyword);
+ }
+
+ public Level getLevel() {
+ return (Level) getValue(TCQueryFilterKey.Level);
+ }
+
+ public void setLevel(Level level) {
+ putValue(TCQueryFilterKey.Level,
+ level != null ? TCQueryFilterValue.create(level) : null);
+ }
+
+ public String getOrganSystem() {
+ try {
+ return (String) getValue(TCQueryFilterKey.OrganSystem);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'organ-system' is not of type String. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setOrganSystem(String organSystem) {
+ putValue(TCQueryFilterKey.OrganSystem, organSystem);
+ }
+
+ public String getPathology() {
+ try {
+ return (String) getValue(TCQueryFilterKey.Pathology);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'pathology' is not of type String. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setPathology(String pathology) {
+ putValue(TCQueryFilterKey.Pathology, pathology);
+ }
+
+ public PatientSex getPatientSex() {
+ return (PatientSex) getValue(TCQueryFilterKey.PatientSex);
+ }
+
+ public void setPatientSex(PatientSex patientSex) {
+ putValue(TCQueryFilterKey.PatientSex,
+ patientSex != null ? TCQueryFilterValue.create(patientSex)
+ : null);
+ }
+
+ public String getPatientSpecies() {
+ return (String) getValue(TCQueryFilterKey.PatientSpecies);
+ }
+
+ public void setPatientSpecies(String patientSpecies) {
+ putValue(TCQueryFilterKey.PatientSpecies, patientSpecies);
+ }
+
+ public String getBibliographicReference() {
+ return (String) getValue(TCQueryFilterKey.BibliographicReference);
+ }
+
+ public void setBibliographicReference(String bibliographicReference) {
+ putValue(TCQueryFilterKey.BibliographicReference,
+ bibliographicReference);
+ }
+
+ public String getTitle() {
+ return (String) getValue(TCQueryFilterKey.Title);
+ }
+
+ public void setTitle(String title) {
+ putValue(TCQueryFilterKey.Title, title);
+ }
+
+ public Code getAnatomyCode() {
+ try {
+ return (Code) getValue(TCQueryFilterKey.Anatomy);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'anatomy' not of type Code. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setAnatomyCode(Code anatomyCode) {
+ putValue(TCQueryFilterKey.Anatomy,
+ anatomyCode != null ? TCQueryFilterValue.create(anatomyCode)
+ : null);
+ }
+
+ public Code getDiagnosisCode() {
+ try {
+ return (Code) getValue(TCQueryFilterKey.Diagnosis);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'diagnosis' not of type Code. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setDiagnosisCode(Code diagnosisCode) {
+ putValue(
+ TCQueryFilterKey.Diagnosis,
+ diagnosisCode != null ? TCQueryFilterValue
+ .create(diagnosisCode) : null);
+ }
+
+ public Code getDiffDiagnosisCode() {
+ try {
+ return (Code) getValue(TCQueryFilterKey.DifferentialDiagnosis);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'diff-diagnosis' not of type Code. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setDiffDiagnosisCode(Code diffDiagnosisCode) {
+ putValue(
+ TCQueryFilterKey.DifferentialDiagnosis,
+ diffDiagnosisCode != null ? TCQueryFilterValue
+ .create(diffDiagnosisCode) : null);
+ }
+
+ public Code getFindingCode() {
+ try {
+ return (Code) getValue(TCQueryFilterKey.Finding);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'finding' not of type Code. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setFindingCode(Code findingCode) {
+ putValue(TCQueryFilterKey.Finding,
+ findingCode != null ? TCQueryFilterValue.create(findingCode)
+ : null);
+ }
+
+ public Code getKeywordCode() {
+ try {
+ return (Code) getValue(TCQueryFilterKey.Keyword);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'keyword' not of type Code. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setKeywordCode(Code keywordCode) {
+ putValue(TCQueryFilterKey.Keyword,
+ keywordCode != null ? TCQueryFilterValue.create(keywordCode)
+ : null);
+ }
+
+ public Code getOrganSystemCode() {
+ try {
+ return (Code) getValue(TCQueryFilterKey.OrganSystem);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'organ-system' not of type Code. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setOrganSystemCode(Code organSystemCode) {
+ putValue(
+ TCQueryFilterKey.OrganSystem,
+ organSystemCode != null ? TCQueryFilterValue
+ .create(organSystemCode) : null);
+ }
+
+ public Code getPathologyCode() {
+ try {
+ return (Code) getValue(TCQueryFilterKey.Pathology);
+ } catch (ClassCastException e) {
+ log.warn(
+ "TC property 'pathology' not of type Code. Returning null...",
+ e);
+
+ return null;
+ }
+ }
+
+ public void setPathologyCode(Code pathologyCode) {
+ putValue(
+ TCQueryFilterKey.Pathology,
+ pathologyCode != null ? TCQueryFilterValue
+ .create(pathologyCode) : null);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("TC search for ");
+
+ if (values != null && !values.isEmpty()) {
+ boolean first = true;
+ sb.append(values.size() + " attributes (");
+ for (Map.Entry<TCQueryFilterKey, TCQueryFilterValue<?>> me : values
+ .entrySet()) {
+ if (!first) {
+ sb.append(", ");
+ } else {
+ first = false;
+ }
+
+ sb.append(me.getKey().name());
+ sb.append("=");
+ sb.append("'" + me.getValue() + "'");
+ }
+ sb.append(")");
+ } else {
+ sb.append("0 attributes");
+ }
+
+ return sb.toString();
+ }
+
+ public Object getValue(TCQueryFilterKey key) {
+ TCQueryFilterValue<?> value = values != null ? values.get(key) : null;
+
+ return value != null ? value.getValue() : null;
+ }
+
+ private void putValue(TCQueryFilterKey key, String value) {
+ putValue(
+ key,
+ value != null && value.length() > 0 ? TCQueryFilterValue
+ .create(value) : null);
+ }
+
+ private void putValue(TCQueryFilterKey key, TCQueryFilterValue<?> value) {
+ if (value == null) {
+ if (values != null) {
+ values.remove(key);
+
+ if (values.isEmpty()) {
+ values = null;
+ }
+ }
+ } else {
+ if (values == null) {
+ values = new HashMap<TCQueryFilterKey, TCQueryFilterValue<?>>(3);
+ }
+
+ values.put(key, value);
+ }
+ }
+
+}
Added: dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterKey.java
===================================================================
--- dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterKey.java (rev 0)
+++ dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterKey.java 2011-07-12 13:37:33 UTC (rev 15679)
@@ -0,0 +1,105 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa-Gevaert AG.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.dcm4chee.web.dao.tc;
+
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+import org.dcm4che2.data.VR;
+import org.dcm4chee.archive.entity.Code;
+
+/**
+ * @author Bernhard Ableitinger <ber...@ag...>
+ * @version $Revision$ $Date$
+ * @since May 05, 2011
+ */
+public enum TCQueryFilterKey {
+ Abstract("IHERADTF", "TCE104", "Abstract"),
+ AcquisitionModality("DCM", "121139", "Modality"),
+ Anatomy("DCM", "112005","Radiographic Anatomy",true),
+ AuthorAffiliation("IHERADTF", "TCE102","Affiliation"),
+ AuthorContact("IHERADTF", "TCE103", "Contact"),
+ AuthorName("IHERADTF", "TCE101", "Author"),
+ Category("IHERADTF", "TCE109","Category"),
+ Diagnosis("IHERADTF", "TCE107", "Diagnosis",true),
+ DiagnosisConfirmed("IHERADTF", "TCE111", "Diagnosis confirmed"),
+ DifferentialDiagnosis("DCM", "111023", "Differential Diagnosis/Impression",true),
+ Discussion("IHERADTF", "TCE106", "Discussion"),
+ Finding("DCM", "121071","Finding",true),
+ History("DCM", "121060", "History"),
+ Keyword("IHERADTF", "TCE105", "Keywords",true),
+ Level("IHERADTF", "TCE110","Level"),
+ OrganSystem("IHERADTF", "TCE108", "Organ system"),
+ Pathology("DCM", "111042", "Pathology",true),
+ PatientSex("AGFAIMPAXEE", "TF102","Patient Sex"),
+ PatientSpecies("AGFAIMPAXEE", "TF103","Patient Species"),
+ BibliographicReference("AGFAIMPAXEE", "TF005","Bibliographic Reference"),
+ Title("AGFAIMPAXEE", "TF001", "Title");
+
+ private Code code;
+ private boolean supportsCodeValue;
+
+ private TCQueryFilterKey(String designator, String value, String meaning) {
+ this(designator, value, meaning, false);
+ }
+
+ private TCQueryFilterKey(String designator, String value, String meaning, boolean supportsCodeValue) {
+ this.code = createCode(designator, value, meaning);
+ this.supportsCodeValue = supportsCodeValue;
+ }
+
+ public Code getCode() {
+ return code;
+ }
+
+ public boolean supportsCodeValue()
+ {
+ return supportsCodeValue;
+ }
+
+ private static Code createCode(String designator, String value,
+ String meaning) {
+ DicomObject dataset = new BasicDicomObject();
+ dataset.putString(Tag.CodingSchemeDesignator, VR.SH, designator);
+ dataset.putString(Tag.CodeValue, VR.SH, value);
+ dataset.putString(Tag.CodeMeaning, VR.LO, meaning);
+
+ return new Code(dataset);
+ }
+
+}
Added: dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterValue.java
===================================================================
--- dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterValue.java (rev 0)
+++ dcm4chee/dcm4chee-web/trunk/dcm4chee-web-ejb/src/main/java/org/dcm4chee/web/dao/tc/TCQueryFilterValue.java 2011-07-12 13:37:33 UTC (rev 15679)
@@ -0,0 +1,470 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa-Gevaert AG.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.dcm4chee.web.dao.tc;
+
+import java.io.Serializable;
+import java.util.Random;
+
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+import org.dcm4che2.data.VR;
+import org.dcm4chee.archive.entity.Code;
+
+/**
+ * @author Bernhard Ableitinger <ber...@ag...>
+ * @version $Revision$ $Date$
+ * @since May 06, 2011
+ */
+public abstract class TCQueryFilterValue<T> implements Serializable {
+ private T value;
+
+ public TCQueryFilterValue(T value) {
+ this.value = value;
+ }
+
+ public T getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return value != null ? value.toString() : null;
+ }
+
+ public abstract QueryParam[] appendSQLWhereConstraint(TCQueryFilterKey key,
+ StringBuilder sb);
+
+ public static TCQueryFilterValue<String> create(String value) {
+ return new TCQueryFilterValue<String>(value) {
+ @Override
+ public QueryParam[] appendSQLWhereConstraint(TCQueryFilterKey key,
+ StringBuilder sb) {
+ QueryParam searchStringParam = new QueryParam("searchString",
+ "%" + getValue() + "%");
+ QueryParam conceptNameValueParam = new QueryParam(
+ "conceptNameValue", key.getCode().getCodeValue());
+ QueryParam conceptNameDesignatorParam = new QueryParam(
+ "conceptNameDesignator", key.getCode()
+ .getCodingSchemeDesignator());
+
+ sb.append("EXISTS (");
+ sb.append("FROM ContentItem content_item");
+ sb.append(" INNER JOIN content_item.conceptName concept_name");
+ sb.append(" WHERE (instance.sopInstanceUID = content_item.instance.sopInstanceUID)");
+ sb.append(" AND (content_item.relationshipType = 'CONTAINS')");
+ sb.append(" AND (content_item.textValue LIKE :"
+ + searchStringParam.getKey() + ")");
+ sb.append(" AND (concept_name.codeValue = :"
+ + conceptNameValueParam.getKey() + ")");
+ sb.append(" AND (concept_name.codingSchemeDesignator = :"
+ + conceptNameDesignatorParam.getKey() + ")");
+ sb.append(")");
+
+ if (key.supportsCodeValue())
+ {
+ QueryParam conceptCodeMeaningParam = new QueryParam(
+ "conceptCodeMeaning", "%" + getValue() + "%");
+
+ sb.append(" OR ");
+
+ sb.append("EXISTS (");
+ sb.append("FROM ContentItem content_item");
+ sb.append(" INNER JOIN content_item.conceptName concept_name");
+ sb.append(" INNER JOIN content_item.conceptCode concept_code");
+ sb.append(" WHERE (instance.sopInstanceUID = content_item.instance.sopInstanceUID)");
+ sb.append(" AND (content_item.relationshipType = 'CONTAINS')");
+ sb.append(" AND (concept_name.codeValue = :"
+ + conceptNameValueParam.getKey() + ")");
+ sb.append(" AND (concept_name.codingSchemeDesignator = :"
+ + conceptNameDesignatorParam.getKey() + ")");
+ sb.append(" AND (concept_code.codeMeaning LIKE :"
+ + conceptCodeMeaningParam.getKey() + ")");
+ sb.append(")");
+
+ return new QueryParam[] { searchStringParam,
+ conceptNameValueParam, conceptNameDesignatorParam,
+ conceptCodeMeaningParam };
+ }
+
+
+ return new QueryParam[] { searchStringParam,
+ conceptNameValueParam, conceptNameDesignatorParam };
+ }
+ };
+ }
+
+ public static TCQueryFilterValue<Code> create(Code code) {
+ return new TCQueryFilterValue<Code>(code) {
+ @Override
+ public QueryParam[] appendSQLWhereConstraint(TCQueryFilterKey key,
+ StringBuilder sb) {
+ QueryParam conceptNameValueParam = new QueryParam(
+ "conceptNameValue", key.getCode().getCodeValue());
+ QueryParam conceptNameDesignatorParam = new QueryParam(
+ "conceptNameDesignator", key.getCode()
+ .getCodingSchemeDesignator());
+ QueryParam conceptCodeValueParam = new QueryParam(
+ "conceptCodeValue", getValue().getCodeValue());
+ QueryParam conceptCodeDesignatorParam = new QueryParam(
+ "conceptCodeDesignator", getValue()
+ .getCodingSchemeDesignator());
+ QueryParam searchStringParam = new QueryParam("searchString",
+ "%" + getValue().getCodeValue() + "%");
+
+ sb.append("EXISTS (");
+ sb.append("FROM ContentItem content_item");
+ sb.append(" INNER JOIN content_item.conceptName concept_name");
+ sb.append(" INNER JOIN content_item.conceptCode concept_code");
+ sb.append(" WHERE (instance.sopInstanceUID = content_item.instance.sopInstanceUID)");
+ sb.append(" AND (content_item.relationshipType = 'CONTAINS')");
+ sb.append(" AND (concept_name.codeValue = :"
+ + conceptNameValueParam.getKey() + ")");
+ sb.append(" AND (concept_name.codingSchemeDesignator = :"
+ + conceptNameDesignatorParam.getKey() + ")");
+ sb.append(" AND (concept_code.codeValue = :"
+ + conceptCodeValueParam.getKey() + ")");
+ sb.append(" AND (concept_code.codingSchemeDesignator = :"
+ + conceptCodeDesignatorParam.getKey() + ")");
+ sb.append(")");
+
+ sb.append(" OR ");
+
+ sb.append("EXISTS (");
+ sb.append("FROM ContentItem content_item");
+ sb.append(" INNER JOIN content_item.conceptName concept_name");
+ sb.append(" WHERE (instance.sopInstanceUID = content_item.instance.sopInstanceUID)");
+ sb.append(" AND (content_item.relationshipType = 'CONTAINS')");
+ sb.append(" AND (content_item.textValue LIKE :"
+ + searchStringParam.getKey() + ")");
+ sb.append(" AND (concept_name.codeValue = :"
+ + conceptNameValueParam.getKey() + ")");
+ sb.append(" AND (concept_name.codingSchemeDesignator = :"
+ + conceptNameDesignatorParam.getKey() + ")");
+ sb.append(")");
+
+ return new QueryParam[] { conceptNameValueParam,
+ conceptNameDesignatorParam, conceptCodeValueParam,
+ conceptCodeDesignatorParam, searchStringParam };
+ }
+ };
+ }
+
+ public static TCQueryFilterValue<Code> create(String designator,
+ String value) {
+ return create(createCode(designator, value, null));
+ }
+
+ public static TCQueryFilterValue<DicomCodeEnum> create(DicomCodeEnum value) {
+ return new TCQueryFilterValue<DicomCodeEnum>(value) {
+ @Override
+ public QueryParam[] appendSQLWhereConstraint(TCQueryFilterKey key,
+ StringBuilder sb) {
+ QueryParam conceptNameValueParam = new QueryParam(
+ "conceptNameValue", key.getCode().getCodeValue());
+ QueryParam conceptNameDesignatorParam = new QueryParam(
+ "conceptNameDesignator", key.getCode()
+ .getCodingSchemeDesignator());
+ QueryParam conceptCodeValueParam = new QueryParam(
+ "conceptCodeValue", getValue().getCode().getCodeValue());
+ QueryParam conceptCodeDesignatorParam = new QueryParam(
+ "conceptCodeDesignator", getValue().getCode()
+ .getCodingSchemeDesignator());
+
+ sb.append("EXISTS (");
+ sb.append("FROM ContentItem content_item");
+ sb.append(" INNER JOIN content_item.conceptName concept_name");
+ sb.append(" INNER JOIN content_item.conceptCode concept_code");
+ sb.append(" WHERE (instance.sopInstanceUID = content_item.instance.sopInstanceUID)");
+ sb.append(" AND (content_item.relationshipType = 'CONTAINS')");
+ sb.append(" AND (concept_name.codeValue = :"
+ + conceptNameValueParam.getKey() + ")");
+ sb.append(" AND (concept_name.codingSchemeDesignator = :"
+ + conceptNameDesignatorParam.getKey() + ")");
+ sb.append(" AND (concept_code.codeValue = :"
+ + conceptCodeValueParam.getKey() + ")");
+ sb.append(" AND (concept_code.codingSchemeDesignator = :"
+ + conceptCodeDesignatorParam.getKey() + ")");
+ sb.append(")");
+
+ return new QueryParam[] { conceptNameValueParam,
+ conceptNameDesignatorParam, conceptCodeValueParam,
+ conceptCodeDesignatorParam };
+ }
+ };
+ }
+
+ public static TCQueryFilterValue<DicomStringEnum> create(
+ DicomStringEnum value) {
+ return new TCQueryFilterValue<DicomStringEnum>(value) {
+ @Override
+ public QueryParam[] appendSQLWhereConstraint(TCQueryFilterKey key,
+ StringBuilder sb) {
+ QueryParam searchStringParam = new QueryParam("searchString",
+ getValue().getString());
+ QueryParam conceptNameValueParam = new QueryParam(
+ "conceptNameValue", key.getCode().getCodeValue());
+ QueryParam conceptNameDesignatorParam = new QueryParam(
+ "conceptNameDesignator", key.getCode()
+ .getCodingSchemeDesignator());
+
+ sb.append("EXISTS (");
+ sb.append("FROM ContentItem content_item");
+ sb.append(" INNER JOIN content_item.conceptName concept_name");
+ sb.append(" WHERE (instance.sopInstanceUID = content_item.instance.sopInstanceUID)");
+ sb.append(" AND (content_item.relationshipType = 'CONTAINS')");
+ sb.append(" AND (content_item.textValue = :"
+ + searchStringParam.getKey() + ")");
+ sb.append(" AND (concept_name.codeValue = :"
+ + conceptNameValueParam.getKey() + ")");
+ sb.append(" AND (concept_name.codingSchemeDesignator = :"
+ + conceptNameDesignatorParam.getKey() + ")");
+ sb.append(")");
+
+ return new QueryParam[] { searchStringParam,
+ conceptNameValueParam, conceptNameDesignatorParam };
+ }
+ };
+ }
+
+ private static Code createCode(String designator, String value,
+ String meaning) {
+ DicomObject dataset = new BasicDicomObject();
+ dataset.putString(Tag.CodingSchemeDesignator, VR.SH, designator);
+ dataset.putString(Tag.CodeValue, VR.SH, value);
+ dataset.putString(Tag.CodeMeaning, VR.LO, meaning == null ? ""
+ : meaning);
+
+ return new Code(dataset);
+ }
+
+ public static class QueryParam {
+ private static final Random random = new Random();
+
+ private String key;
+
+ private Object value;
+
+ public QueryParam(String key_prefix, Object value) {
+ this.key = key_prefix + "_" + random.nextInt(Integer.MAX_VALUE);
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+ }
+
+ private static interface DicomCodeEnum {
+ public Code getCode();
+ }
+
+ private static interface DicomStringEnum {
+ public String getString();
+ }
+
+ public static enum Level implements DicomCodeEnum {
+ Primary("TCE201", "IHERADTF"), Intermediate("TCE202", "IHERADTF"), Advanced(
+ "TCE203", "IHERADTF");
+
+ private Code code;
+
+ private Level(String v, String d) {
+ code = createCode(d, v, null);
+ }
+
+ public Code getCode() {
+ return code;
+ }
+
+ public static Level get(Code code) {
+ if (code != null) {
+ for (Level level : values()) {
+ if (code.equals(level.getCode())) {
+ return level;
+ }
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public static enum YesNo implements DicomCodeEnum {
+ Yes("SRT", "R-0038D"), No("SRT", "R-00339D");
+
+ private Code code;
+
+ private YesNo(String v, String d) {
+ code = createCode(d, v, null);
+ }
+
+ public Code getCode() {
+ return code;
+ }
+
+ public static YesNo get(Code code) {
+ if (code != null) {
+ for (YesNo yesNo : values()) {
+ if (code.equals(yesNo.getCode())) {
+ return yesNo;
+ }
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public static enum PatientSex implements DicomStringEnum {
+ Male("M"), Female("F"), Other("O"), Unknown("U");
+
+ private String value;
+
+ private PatientSex(String v) {
+ this.value = v;
+ }
+
+ public String getString() {
+ return value;
+ }
+
+ public static PatientSex get(String value) {
+ if (value != null) {
+ for (PatientSex sex : values()) {
+ if (value.equals(sex.getString())) {
+ return sex;
+ }
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public static enum AcquisitionModality implements DicomStringEnum {
+ CT("CT"), MR("MR"), CR("CR"), NM("NM"), US("US"), PT("PT"), XA("XA"), RF(
+ "RF"), DX("DX"), MG("MG"), ECG("ECG"), OT("OT");
+
+ private String value;
+
+ private AcquisitionModality(String v) {
+ this.value = v;
+ }
+
+ public String getString() {
+ return value;
+ }
+
+ public static AcquisitionModality get(String value) {
+ if (value != null) {
+ for (AcquisitionModality m : values()) {
+ if (value.equals(m.getString())) {
+ return m;
+ }
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public static enum Purpose implements DicomCodeEnum {
+ ForTeaching("TCE001", "IHERADTF"), ForClinicalTrial("TCE002",
+ "IHERADTF"), ForResearch("TCE007", "IHERADTF"), ForPublication(
+ "TCE008", "IHERADTF");
+
+ private Code code;
+
+ private Purpose(String v, String d) {
+ code = createCode(d, v, null);
+ }
+
+ public Code getCode() {
+ return code;
+ }
+
+ public static Purpose get(Code code) {
+ if (code != null) {
+ for (Purpose purpose : values()) {
+ if (code.equals(purpose.getCode())) {
+ return purpose;
+ }
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public static enum Category implements DicomCodeEnum {
+ Musculoskeletal("TCE301", "IHERADTF"), Pulmonary("TCE302", "IHERADTF"), Cardiovascular(
+ "TCE303", "IHERADTF"), Gastrointestinal("TCE304", "IHERADTF"), Genitourinary(
+ "TCE305", "IHERADTF"), Neuro("TCE306", "IHERADTF"), Nuclear(
+ "TCE308", "IHERADTF"), Ultrasound("TCE309", "IHERADTF"), VascularAndInterventional(
+ ...
[truncated message content] |