示例#1
0
文件: ddr.c 项目: ccteng/dicomprop
CONDITION
DDR_GetSeriesList(DCM_OBJECT ** object, const char *patientID,
		  const char *studyInstanceUID, LST_HEAD ** seriesList)
{
    LST_HEAD *studyList;
    DDR_STUDY *sPtr;
    CONDITION cond;
    U32 offset;
    DCM_OBJECT *seriesObject;

    studyList = LST_Create();
    cond = DDR_GetStudyList(object, patientID, &studyList);
    if (cond != DDR_NORMAL)
	return cond;

    sPtr = LST_Dequeue(&studyList);
    while (sPtr != NULL) {
	if (strcmp(sPtr->StudyInstanceUID, studyInstanceUID) == 0) {
	    offset = sPtr->SeriesLinkOffset;
	    while (offset != 0) {
		cond = DCM_GetSequenceByOffset(object, DCM_DIRRECORDSEQUENCE,
					       offset, &seriesObject);
		if (cond != DCM_NORMAL) {
		    return DDR_ERROR;
		}
		addSeriesRecord(&seriesObject, seriesList);
		offset = offsetNextRecord(&seriesObject);
	    }
	}
	free(sPtr);
	sPtr = LST_Dequeue(&studyList);
    }
    LST_Destroy(&studyList);
    return DDR_NORMAL;
}
示例#2
0
文件: icon.c 项目: nagyistge/ctn
/* ICON_GetStudyOffset
**
** Purpose:
**	Describe the purpose of the function
**
** Parameter Dictionary:
**	Define the parameters to the function
**
** Return Values:
**
** Notes:
**
** Algorithm:
**	Description of the algorithm (optional) and any other notes.
*/
CONDITION
ICON_GetStudyOffset(char *file, char *accessionNumber, ICON_STUDYOFFSET * study)
{
    LST_HEAD
	* list = NULL;
    CONDITION
	cond;
    LIST_ICON_STUDYOFFSET
	* item;

    cond = ICON_GetStudyOffsetLst(file, &list);
    if (cond != ICON_NORMAL)
	return (cond);
    while (((item = LST_Dequeue(&list)) != NULL) &&
	   (strcmp(accessionNumber, item->studyoffset.accessionNumber)))
	free(item);
    if (item == NULL)
	return COND_PushCondition(ICON_ACCESSIONNOTFOUND,
	       ICON_Message(ICON_ACCESSIONNOTFOUND), accessionNumber, file);
    *study = item->studyoffset;
    free(item);
    while ((item = LST_Dequeue(&list)) != NULL)
	free(item);
    (void) LST_Destroy(&list);
    return (ICON_NORMAL);
}
示例#3
0
文件: ddr.c 项目: ccteng/dicomprop
CONDITION
DDR_GetStudyList(DCM_OBJECT ** object, const char *patientID,
		 LST_HEAD ** lst)
{
    LST_HEAD *patientList;
    DDR_PATIENT *pPtr;
    CONDITION cond;
    U32 offset;
    DCM_OBJECT *studyObject;

    /*
     * Create a patient list and get all of the patients in the DICOMDIR
     * object
     */

    patientList = LST_Create();
    cond = DDR_GetPatientList(object, &patientList);
    pPtr = LST_Dequeue(&patientList);

    /*
     * Scan through the patient list for a patient whose patient ID matches
     * that passed * by the caller.  When we find that, walk through the
     * study list for that patient * and fill the caller's list with
     * DDR_STUDY records.
     */

    while (pPtr != NULL) {
	if (strcmp(pPtr->PatientID, patientID) == 0) {
	    offset = pPtr->StudyLinkOffset;
	    while (offset != 0) {
		cond = DCM_GetSequenceByOffset(object, DCM_DIRRECORDSEQUENCE,
					       offset, &studyObject);
		if (cond != DCM_NORMAL) {
		    exit(1);	/* repair */
		}
		addStudyRecord(&studyObject, lst);
		offset = offsetNextRecord(&studyObject);
	    }
	}
	free(pPtr);
	pPtr = LST_Dequeue(&patientList);
    }

    LST_Destroy(&patientList);
    return DDR_NORMAL;
}
示例#4
0
文件: fisget.c 项目: ccteng/dicomprop
void
FIS_ClearList(LST_HEAD * l)
{
    LST_NODE
    * n;

    while ((n = LST_Dequeue(&l)) != NULL)
	free(n);
}
示例#5
0
文件: fileview.c 项目: nagyistge/ctn
static void localDirectory(llist entries)
{
  LST_HEAD *patientList;
  DCM_OBJECT *dirFile;
  DDR_PATIENT *patientNode;
  CONDITION cond;

  cond = DCM_OpenFile("/tmp/dicomdir", DCM_ORDERLITTLEENDIAN | DCM_PART10FILE,
		      &dirFile);
  patientList = LST_Create();

  cond = DDR_GetPatientList(&dirFile, &patientList);

  html_header();
  html_begin_body_options("DICOM Patient Search", "bgcolor=#ffffff");

  printf("Please select one patient to see a list of studies<p>\n");

  printf("<form method=GET action=""/cgi-bin/acc_agent.cgi"">\n");

  patientNode = LST_Dequeue(&patientList);
  printf("<select name=patientID size=10>\n");
  while(patientNode != NULL) {
    printf("<option value=""%s"">%s %s %s\n",
	   patientNode->PatientID,
	   patientNode->PatientID,
	   patientNode->PatientName,
	   patientNode->BirthDate);
    free(patientNode);
    patientNode = LST_Dequeue(&patientList);
  }
  printf("</select>\n");
  printf("<br>\n");
  printf("<input type=submit value=""LocalPatientSelect"" name=submitSearch>\n");
  printf("<input type=submit value=""Retrieve All Studies from Archive"" name=submitSearch>\n");

  printf("</form>\n");
  html_end();
  LST_Destroy(&patientList);

  DCM_CloseObject(&dirFile);
}
示例#6
0
文件: select.c 项目: nagyistge/ctn
static void
clearList(LST_HEAD * lst)
{
    LST_NODE
    * node;

    if (lst == NULL)
	return;
    while ((node = LST_Dequeue(&lst)) != NULL)
	free(node);
}
示例#7
0
文件: control.c 项目: bhavik86/Dicom
CONDITION
DMAN_ClearList(LST_HEAD * lst)
{
    LST_NODE	* node;

    if (lst != NULL) {
    	while ((node = LST_Dequeue(&lst)) != NULL)
    		free(node);
    }
    return DMAN_NORMAL;
}
示例#8
0
文件: fileview.c 项目: nagyistge/ctn
static void directoryToHTML(const char* path)
{
  LST_HEAD* l;
#if 0
  char topDirectory[1024];
  char currentDirectory[1024];
  char key[1024];
#endif
  FILE_ENTRY* f;
  char parentPath[1024];
  char *c;

  strcpy(parentPath, path);
  c = parentPath + strlen(parentPath);
  while (*(--c) != '/')
    ;
  *c = '\0';

  l = LST_Create();
  listDirectory(path, &l);

  html_header();
  html_begin_body_options("File View", "bgcolor=#ffffff");

  while ((f = LST_Dequeue(&l)) != NULL) {
    if (strcmp(f->fileName, "..") == 0) {
      printf("<br><a href=""/cgi-bin/fileview.cgi"
		"?submitSearch=FileSelect"
		"&Key=%s"
		"&CurrentDirectory=%s"
		"&>%s</a>\n",
	   ".",
	   parentPath,
	   f->fileName);
    } else {
      printf("<br><a href=""/cgi-bin/fileview.cgi"
		"?submitSearch=FileSelect"
		"&Key=%s"
		"&CurrentDirectory=%s"
		"&>%s</a>\n",
	   f->fileName,
	   path,
	   f->fileName);
    }
    free(f);
  }
  html_end();
  LST_Destroy(&l);
}
示例#9
0
文件: fileview.c 项目: nagyistge/ctn
static void localPatientSelect(llist entries)
{
  LST_HEAD *studyList;
  DCM_OBJECT *dirFile;
  DDR_STUDY *studyNode;
  CONDITION cond;

  cond = DCM_OpenFile("/tmp/dicomdir", DCM_ORDERLITTLEENDIAN | DCM_PART10FILE,
		      &dirFile);
  studyList = LST_Create();

  cond = DDR_GetStudyList(&dirFile,
		cgi_val(entries, "patientID"),
		&studyList);

  html_header();
  html_begin_body_options("DICOM Study Search", "bgcolor=#ffffff");

  studyNode = LST_Dequeue(&studyList);
  printf("<tt>\n");
  while(studyNode != NULL) {
    printf("%s %s %s %s <br>\n",
	   studyNode->StudyDate,
	   studyNode->AccessionNumber,
	   studyNode->StudyID,
	   studyNode->StudyDescription);

    free(studyNode);
    studyNode = LST_Dequeue(&studyList);
  }
  printf("</tt>\n");
  html_end();


  DCM_CloseObject(&dirFile);
}
示例#10
0
static void
dumpCommitRequests(FIS_HANDLE ** fisHandle)
{
    LST_HEAD *requestList;
    FIS_STORAGECOMMITREQRECORD *commitReq;
    CONDITION cond;

    requestList = LST_Create();
    if (requestList == NULL) {
	fprintf(stderr, "Could not create an initial request list. Exiting now.\n");
	return;
    }
    cond = FIS_Get(fisHandle, FIS_K_STORAGECOMMITREQ, FIS_K_STORAGECOMMITREQ,
		   NULL, 0, requestList);
    if (cond != FIS_NORMAL) {
	COND_DumpConditions();
	return;
    }
    printf("%64s %16s %16s %12s %14s %12s %14s\n",
	   "Transaction UID",
	   "Requesting App",
	   "Responding App",
	   "Request Date",
	   "Request Time",
	   "Response Date",
	   "Response Time");

    while ((commitReq = LST_Dequeue(&requestList)) != NULL) {
	if (!(commitReq->Flag & FIS_K_SCOMMIT_REQDAT))
	    commitReq->ReqDat[0] = '\0';
	if (!(commitReq->Flag & FIS_K_SCOMMIT_REQTIM))
	    commitReq->ReqTim[0] = '\0';
	if (!(commitReq->Flag & FIS_K_SCOMMIT_RESDAT))
	    commitReq->ResDat[0] = '\0';
	if (!(commitReq->Flag & FIS_K_SCOMMIT_RESTIM))
	    commitReq->ResTim[0] = '\0';
	printf("%64s %16s %16s %12s %14s %12s %14s\n",
	       commitReq->TraUID,
	       commitReq->ReqAE,
	       commitReq->ResAE,
	       commitReq->ReqDat,
	       commitReq->ReqTim,
	       commitReq->ResDat,
	       commitReq->ResTim);
	free(commitReq);
    }
    LST_Destroy(&requestList);
}
示例#11
0
文件: icon.c 项目: nagyistge/ctn
/* ICON_DumpStudyOffset
**
** Purpose:
**	Dumps an icon index file.
**
** Parameter Dictionary:
**	Define the parameters to the function
**
** Return Values:
**
** Notes:
**
** Algorithm:
**	Description of the algorithm (optional) and any other notes.
*/
CONDITION
ICON_DumpStudyOffset(char *file)
{
    LST_HEAD
	* list = NULL;
    CONDITION
	cond;
    LIST_ICON_STUDYOFFSET
	* item;
    int
        count = 0;

    cond = ICON_GetStudyOffsetLst(file, &list);
    if (cond != ICON_NORMAL)
	return (cond);
    while ((item = LST_Dequeue(&list)) != NULL) {
	printf("(%03d) Accession Number = %s \toffset = %d\n",
	       count++,
	       item->studyoffset.accessionNumber,
	       item->studyoffset.Offset);
	free(item);
    }
    return (ICON_NORMAL);
}
示例#12
0
/* exitApplication
**
** Purpose:
**	Exit the application in presence of some errors. Before exiting,
**	free all the handles which were allocated to the application
**
** Parameter Dictionary:
**	cond	The condition that caused the app to exit
**
** Return Values:
**	None
**
** Notes:
**
** Algorithm:
**	Description of the algorithm (optional) and any other notes.
*/
void
exitApplication(CONDITION cond)
{
    CONDITION
    rtnCond;

    fprintf(stderr, "Freeing all handles\n");
    /* free all handles here */
#ifdef ASG
    if (appHandles.gqID != -1) {
	rtnCond = kill_queue(appHandles.gqID);
	if (CTN_ERROR(rtnCond)) {
	    fprintf(stderr, "APP Error freeing generalized queue\n");
	    COND_DumpConditions();
	}
    }
#endif
    if (appHandles.network) {
	rtnCond = DUL_DropNetwork(&appHandles.network);
	if (CTN_ERROR(rtnCond)) {
	    fprintf(stderr, "APP Error freeing network key\n");
	    COND_DumpConditions();
	}
    }
    if (appHandles.association) {
	rtnCond = DUL_DropAssociation(&appHandles.association);
	if (CTN_ERROR(rtnCond)) {
	    fprintf(stderr, "APP Error freeing association key\n");
	    COND_DumpConditions();
	}
    }
    if (appHandles.service) {
	rtnCond = DUL_ClearServiceParameters(appHandles.service);
	if (CTN_ERROR(rtnCond)) {
	    fprintf(stderr, "APP Error clearing service parameters\n");
	    COND_DumpConditions();
	}
    }
    if (appHandles.processList) {
	PROCESS_ELEMENT
	    * e = NULL;
	e = LST_Head(&appHandles.processList);
	if (e != NULL)
	    (void) LST_Position(&appHandles.processList, e);
	while (e != NULL) {
	    free(e);
	    e = LST_Dequeue(&appHandles.processList);
	}
	rtnCond = LST_Destroy(&appHandles.processList);
	if (CTN_ERROR(rtnCond)) {
	    fprintf(stderr, "APP Error freeing Process List\n");
	    COND_DumpConditions();
	}
    }
    /* Now the final exit */
    if (CTN_ERROR(cond)) {
	fprintf(stderr, "\n\n");
	fprintf(stderr, "APP Abnormal Exit\n");
	COND_DumpConditions();
	fprintf(stderr, "\n\n");
	exit(1);		/* error exit status */
    }
    fprintf(stderr, "\n\n");
    exit(0);			/* normal exit */
}
示例#13
0
static CONDITION
studyComponentSet(MSG_N_SET_REQ * request, MSG_N_SET_RESP * response,
                  CALLBACK_CTX * ctx)
{
    CONDITION cond;
    FIS_STUDYCOMPONENTRECORD sc;
    long flag;
    FIS_SCSERIESRECORD *series;
    FIS_SCIMAGERECORD *image;

    response->status = MSG_K_SUCCESS;

    if (request->dataSetType != DCM_CMDDATANULL) {
        (void) DCM_DumpElements(&request->dataSet, 0);
    } else {
        response->status = MSG_K_MISSINGATTRIBUTE;
        goto ExitPoint;
    }

    cond = FIS_ParseObject(&request->dataSet, FIS_K_STUDYCOMPONENT, &sc);
    if (cond != FIS_NORMAL) {
        response->status = MSG_K_PROCESSINGFAILURE;
        goto ExitPoint;
    }
    sc.Flag &= STUDYCOMPONENT_SET_FLAGS;
    if (sc.Flag == 0)
        goto ExitPoint;

    strcpy(sc.StuComUID, request->instanceUID);
    sc.Flag |= FIS_K_STUDYCOMP_STUCOMUID;
    cond = FIS_Update(ctx->fis, FIS_K_STUDYCOMPONENT, &sc);
    if (cond != FIS_NORMAL) {
        response->status = MSG_K_PROCESSINGFAILURE;
        goto ExitPoint;
    }
    if (sc.Flag & FIS_K_STUDYCOMP_SERIESLIST) {
        /*  Delete existing values in series/image tables and insert new values */
        cond = FIS_Delete(ctx->fis, FIS_K_SCSERIES, FIS_K_STUDYCOMPONENT,
                          request->instanceUID);
        if (cond != FIS_NORMAL) {
            response->status = MSG_K_PROCESSINGFAILURE;
            goto ExitPoint;
        }
        cond = FIS_Delete(ctx->fis, FIS_K_SCIMAGE, FIS_K_STUDYCOMPONENT,
                          request->instanceUID);
        if (cond != FIS_NORMAL) {
            response->status = MSG_K_PROCESSINGFAILURE;
            goto ExitPoint;
        }
        while ((series = LST_Dequeue(&sc.SeriesList)) != NULL) {
            strcpy(series->StuComUID, sc.StuComUID);
            series->Flag |= FIS_K_SCSERIES_STUCOMUID;

            cond = FIS_Insert(ctx->fis, FIS_K_SCSERIES, series);
            if (cond != FIS_NORMAL) {
                response->status = MSG_K_PROCESSINGFAILURE;
                COND_DumpConditions();
                goto ExitPoint;
            }
            while ((image = LST_Dequeue(&series->ImageList)) != NULL) {
                strcpy(image->SerInsUID, series->SerInsUID);
                strcpy(image->StuComUID, series->StuComUID);
                image->Flag |= FIS_K_SCIMAGE_SERINSUID | FIS_K_SCIMAGE_STUCOMUID;

                cond = FIS_Insert(ctx->fis, FIS_K_SCIMAGE, image);
                if (cond != FIS_NORMAL) {
                    response->status = MSG_K_PROCESSINGFAILURE;
                    COND_DumpConditions();
                    goto ExitPoint;
                }
                free(image);
            }
            (void) LST_Destroy(&series->ImageList);
            free(series);
        }
        (void) LST_Destroy(&sc.SeriesList);


    }
    response->dataSetType = DCM_CMDDATANULL;
    strcpy(response->classUID, request->classUID);
    strcpy(response->instanceUID, request->instanceUID);
    response->conditionalFields = MSG_K_N_SETRESP_REQUESTEDCLASSUID |
                                  MSG_K_N_SETRESP_REQUESTEDINSTANCEUID;

ExitPoint:
    COND_DumpConditions();
    return 1;
}
示例#14
0
main(int argc, char **argv)
{
    CONDITION cond;
    LST_HEAD *l,
       *elementList;
    DCM_ELEMENT_NODE *n,
       *elementNode;
    unsigned short group;
    CTNBOOLEAN uidDictionary = FALSE;

    while (--argc > 0 && (*++argv)[0] == '-') {
	switch (*(argv[0] + 1)) {
	case 'u':
	    uidDictionary = TRUE;
	    break;
	default:
	    fprintf(stderr, "Unrecognized option: %s\n", *argv);
	    exit(1);
	    break;
	}
    }

    THR_Init();
    if (uidDictionary) {
	UID_ScanDictionary(uidCallback, 0);
	THR_Shutdown();
	return 0;
    }
    l = LST_Create();
    if (l == NULL) {
	THR_Shutdown();
	return 1;
    }
    elementList = LST_Create();
    if (elementList == NULL) {
	THR_Shutdown();
	return 1;
    }
    cond = DCM_GroupDictionary(0xffff, &l, groupCallback);
    if (cond != DCM_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(1);
    }
    n = LST_Dequeue(&l);
    while (n != NULL) {
	group = DCM_TAG_GROUP(n->e.tag);
	printf("%04x  %s\n", group, n->e.description);

	cond = DCM_ElementDictionary(DCM_MAKETAG(group, 0xffff), &elementList,
				     elementCallback);
	if (cond != DCM_NORMAL) {
	    COND_DumpConditions();
	    THR_Shutdown();
	    exit(1);
	}
	elementNode = LST_Dequeue(&elementList);
	while (elementNode != NULL) {
	    printf("  %04x %04x %s %s\n",
		   DCM_TAG_GROUP(elementNode->e.tag),
		   DCM_TAG_ELEMENT(elementNode->e.tag),
		   translate(elementNode->e.representation),
		   elementNode->e.description);

	    free(elementNode);
	    elementNode = LST_Dequeue(&elementList);
	}

	free(n);
	n = LST_Dequeue(&l);
    }
    THR_Shutdown();
    return 0;
}
示例#15
0
文件: cget.c 项目: nagyistge/ctn
static CONDITION
cgetCallback(MSG_C_GET_REQ * request, MSG_C_GET_RESP * response,
	   MSG_C_STORE_REQ * storeRequest, MSG_C_STORE_RESP * storeResponse,
	     int responseCount, char *SOPClass, char *queryLevel,
/*	     CGET_PARAMS * cgetParams) */
	     void *cgetParamsPtr)
{
    CONDITION cond;
    static LST_HEAD *imageList = NULL;
    IDB_HANDLE **handle;
    static QUERY_MAP
        map[] = {{"PATIENT", IDB_PATIENT_LEVEL},
    {"STUDY", IDB_STUDY_LEVEL},
    {"SERIES", IDB_SERIES_LEVEL},
    {"IMAGE", IDB_IMAGE_LEVEL},
    };
    int
        i,
        searchQueryEnd;
    CTNBOOLEAN
	done;
    long
        selectCount;

    IDB_Query
	queryStructure;
    QUERY_LIST_ITEM
	* queryItem;
    static LST_HEAD
    *   queryList = NULL,
       *failedList = NULL;
    static DUL_NETWORKKEY
    *   network;
    DUL_ASSOCIATESERVICEPARAMETERS
	* params;
    DCM_ELEMENT
	e = {
	DCM_IDFAILEDINSTANCEUIDLIST, DCM_UI, "", 1, 0, NULL
    };
    IDB_InstanceListElement
	* instance;
    MSG_STATUS_DESCRIPTION
	statusDescription;	/* to check the status returned by a
				 * StoreResponse */
/*  The following definition and cast operation allow us to satisfy prototypes
**  for get callbacks as defined in dicom_services.h.
*/
    CGET_PARAMS *cgetParams;
    cgetParams = (CGET_PARAMS *) cgetParamsPtr;

    network = *cgetParams->network;
    params = cgetParams->params;
    handle = cgetParams->handle;

    strcpy(response->classUID, request->classUID);
    response->conditionalFields = DCM_CMDDATANULL;
    response->dataSetType = DCM_CMDDATANULL;
    response->identifier = NULL;

    if (response->status == MSG_K_CANCEL) {
	if (!silent)
	    printf("CGet cancelled\n");
	if (queryList != NULL) {
	    while ((queryItem = LST_Dequeue(&queryList)) != NULL)
		free(queryItem);
	}
	response->conditionalFields |= MSG_K_C_GET_COMPLETED |
	    MSG_K_C_GET_FAILED | MSG_K_C_GET_WARNING;
	/* check if there is any failed UID list existing */
	if (failedList != NULL) {
	    response->dataSetType = DCM_CMDDATAIDENTIFIER;
	    response->identifier = failedList;
	}
	response->conditionalFields |= MSG_K_C_GET_REMAINING;
	return SRV_NORMAL;
    }
/*  Check if there was a store response from the previous store request.
**  If so, set various fields of the CGetResponse message.
**  The first time this callback is invoked, store response will be
**  NULL and response count will equal 0.
*/

    if (storeResponse != NULL) {
	if (!silent) {
	    printf("Store Response received\n");
	    MSG_DumpMessage(storeResponse, stdout);
	}
	cond = MSG_StatusLookup(storeResponse->status,
				MSG_K_C_STORE_RESP, &statusDescription);
	if (cond != MSG_NORMAL) {
	    fprintf(stderr, "Invalid status code in store response: %s\n",
		    storeResponse->status);
	    return 0;		/* repair */
	}
	switch (statusDescription.statusClass) {
	case MSG_K_CLASS_SUCCESS:
	    response->completedSubOperations++;
	    break;
	case MSG_K_CLASS_WARNING:
	    response->warningSubOperations++;
	    break;
	case MSG_K_CLASS_REFUSED:
	case MSG_K_CLASS_FAILURE:
	    response->failedSubOperations++;
	    break;
	default:
	    fprintf(stderr, "Invalid status code in store response: %s\n",
		    storeResponse->status);
	    break;
	}
/*
** A status of pending does not contain a failed UID list. Also, a
** pending status must contain the number of remaining, completed,
** failed and warning sub operations
*/
	response->dataSetType = DCM_CMDDATANULL;
	response->identifier = NULL;
	response->conditionalFields |= MSG_K_C_GET_REMAINING |
	    MSG_K_C_GET_COMPLETED | MSG_K_C_GET_FAILED |
	    MSG_K_C_GET_WARNING;
	/* we send a PENDING response */
	response->status = MSG_K_C_GET_SUBOPERATIONSCONTINUING;
    }
    if (imageList == NULL) {
	imageList = LST_Create();
	if (imageList == NULL)
	    return 0;
    }
    if (!silent) {
	printf("CGet callback\n");
	printf("SOP Class:      %s\n", SOPClass);
	printf("Query Level:    %s\n", queryLevel);
	printf("Response Count: %d\n", responseCount);
    }
    if (responseCount == 0) {
	if (!silent)
	    (void) DCM_DumpElements(&request->identifier, 0);
#ifdef CTN_MULTIBYTE
	cond = parseQueryMB(&request->identifier, &queryStructure);
#else
	cond = parseQuery(&request->identifier, &queryStructure);
#endif
	if (cond != APP_NORMAL)
	    return 0;
	for (i = 0, done = FALSE; !done && i < (int) DIM_OF(map); i++) {
	    if (strcmp(map[i].levelChar, queryLevel) == 0) {
		searchQueryEnd = map[i].levelInt;
		done = TRUE;
	    }
	}
	switch (searchQueryEnd) {
	case IDB_PATIENT_LEVEL:
	    queryStructure.study.StuInsUID[0] = '\0';
	    queryStructure.StudyQFlag = QF_STU_StuInsUID;
	    queryStructure.StudyNullFlag = QF_STU_StuInsUID;

	    queryStructure.series.SerInsUID[0] = '\0';
	    queryStructure.SeriesQFlag = QF_SER_SerInsUID;
	    queryStructure.SeriesNullFlag = QF_SER_SerInsUID;

	    queryStructure.image.SOPInsUID[0] = '\0';
	    queryStructure.ImageQFlag = QF_IMA_SOPInsUID;
	    queryStructure.ImageNullFlag = QF_IMA_SOPInsUID;
	    break;
	case IDB_STUDY_LEVEL:
	    queryStructure.series.SerInsUID[0] = '\0';
	    queryStructure.SeriesQFlag = QF_SER_SerInsUID;
	    queryStructure.SeriesNullFlag = QF_SER_SerInsUID;

	    queryStructure.image.SOPInsUID[0] = '\0';
	    queryStructure.ImageQFlag = QF_IMA_SOPInsUID;
	    queryStructure.ImageNullFlag = QF_IMA_SOPInsUID;
	    break;
	case IDB_SERIES_LEVEL:
	    queryStructure.image.SOPInsUID[0] = '\0';
	    queryStructure.ImageQFlag = QF_IMA_SOPInsUID;
	    queryStructure.ImageNullFlag = QF_IMA_SOPInsUID;
	    break;
	case IDB_IMAGE_LEVEL:
	    break;
	}

	if (strcmp(SOPClass, DICOM_SOPPATIENTQUERY_GET) == 0)
	    cond = IDB_Select(handle, PATIENT_ROOT, IDB_PATIENT_LEVEL,
			      IDB_IMAGE_LEVEL,
		  &queryStructure, &selectCount, selectCallback, imageList);
	else if (strcmp(SOPClass, DICOM_SOPPATIENTSTUDYQUERY_GET) == 0)
	    cond = IDB_Select(handle, PATIENTSTUDY_ONLY, IDB_PATIENT_LEVEL,
			      IDB_IMAGE_LEVEL,
		  &queryStructure, &selectCount, selectCallback, imageList);
	else if (strcmp(SOPClass, DICOM_SOPSTUDYQUERY_GET) == 0)
	    cond = IDB_Select(handle, STUDY_ROOT, IDB_PATIENT_LEVEL,
			      IDB_IMAGE_LEVEL,
		  &queryStructure, &selectCount, selectCallback, imageList);
	else
	    cond = 0;

	if ((cond != IDB_NORMAL) && (cond != IDB_NOMATCHES)) {
	    COND_DumpConditions();
	    return 0;
	}
	response->remainingSubOperations = LST_Count(&imageList);
	if (!silent)
	    printf("Total store requests: %d\n", response->remainingSubOperations);

	failedList = LST_Create();
	if (failedList == NULL)
	    return 0;
    }
    if (imageList != NULL)
	queryItem = LST_Dequeue(&imageList);
    else
	queryItem = NULL;

    if (queryItem != NULL) {
	instance = LST_Head(&queryItem->query.image.InstanceList);
	if (instance != NULL) {
	    storeRequest->dataSetType = DCM_CMDDATAOTHER;
	    strcpy(storeRequest->classUID, queryItem->query.image.SOPClaUID);
	    strcpy(storeRequest->instanceUID, queryItem->query.image.SOPInsUID);

	    if (!silent)
		printf("Image file name: %s\n", instance->Path);

	    if (strcmp(instance->Transfer, DICOM_TRANSFERLITTLEENDIAN) == 0) {
		cond = DCM_OpenFile(instance->Path,
				  DCM_ORDERLITTLEENDIAN | DCM_NOGROUPLENGTH,
				    &storeRequest->dataSet);
	    } else {
		cond = DCM_OpenFile(instance->Path,
				    DCM_PART10FILE | DCM_NOGROUPLENGTH,
				    &storeRequest->dataSet);
		(void) DCM_RemoveGroup(&storeRequest->dataSet, DCM_GROUPFILEMETA);
	    }

	    if (cond != DCM_NORMAL)
		return 0;	/* repair */
	} else
	    return 0;		/* repair */

	free(queryItem);	/* repair - memory leak */

	response->remainingSubOperations--;
	if (!silent)
	    MSG_DumpMessage(response, stdout);
    } else {			/* No more requests remain */

	storeRequest->dataSetType = DCM_CMDDATANULL;
	if ((response->failedSubOperations == 0) &&
	    (response->warningSubOperations == 0)) {

	    /* complete success */
	    response->status = MSG_K_SUCCESS;
	    response->dataSetType = DCM_CMDDATANULL;
	    response->identifier = NULL;
	    response->conditionalFields |= MSG_K_C_GET_COMPLETED |
		MSG_K_C_GET_FAILED | MSG_K_C_GET_WARNING;
	} else if ((response->warningSubOperations == 0) &&
		   (response->completedSubOperations == 0)) {
	    /* All sub operations failed */
	    response->status = MSG_K_C_GET_UNABLETOPROCESS;
	    response->dataSetType = DCM_CMDDATAIDENTIFIER;
	    response->identifier = failedList;
	    response->conditionalFields |= MSG_K_C_GET_COMPLETED |
		MSG_K_C_GET_FAILED | MSG_K_C_GET_WARNING;
	} else {
	    /* Some sub operations may have failed or had warnings */
	    response->status = MSG_K_C_GET_COMPLETEWITHFAILURES;
	    response->dataSetType = DCM_CMDDATAIDENTIFIER;
	    response->identifier = failedList;
	    response->conditionalFields |= MSG_K_C_GET_COMPLETED |
		MSG_K_C_GET_FAILED | MSG_K_C_GET_WARNING;
	}
    }

    return SRV_NORMAL;
}
示例#16
0
文件: fileview.c 项目: nagyistge/ctn
static void selectSeries(llist entries)
{
  CONDITION cond;
  char dbKey[64];
  char studyUID[65];
  char seriesUID[65];
  IDB_Query series;
  QUERY_LIST_ITEM *item;
  IDB_InstanceListElement *instancePtr;
  unsigned long byteCount = 0;
  char password[64];
  DMAN_HANDLE *controlHandle;

  LST_HEAD *destinationList;

  openCTN(&controlHandle);

  strcpy(dbKey, cgi_val(entries, "DBKey"));
  strcpy(studyUID, cgi_val(entries, "StudyUID"));
  strcpy(seriesUID, cgi_val(entries, "SeriesUID"));
  strcpy(password, cgi_val(entries, "password"));

  TBL_SetOption("OPEN_SPEEDUP");
  cond = searchOneSeries(dbKey, studyUID, seriesUID, &series);

  html_header();
  html_begin_body_options("CTN Archive: Series Management", "bgcolor=#ffffff");

  printf("<table>\n");

  printf("<TR><TH align=right>Name: <TH align=left>%s</TR>\n",
	 series.patient.PatNam);
  printf("<TR><TH align=right>Date of Birth: <TH align=left>%s</TR>\n",
	 series.patient.PatBirDat);
  printf("<TR><TH align=right>Series Number: <TH align=left>%s</TR>\n",
	 series.series.SerNum);
  printf("<TR><TH align=right>Image Count: <TH align=left>%d</TR>\n",
	 series.series.NumSerRelIma);

  printf("</table>\n");

  printf("<form method=GET action=""archive_agent.cgi"">\n");
  printf("<input type=hidden name=DBKey value=%s>\n", dbKey);
  printf("<input type=hidden name=StudyUID value=%s>\n", studyUID);
  printf("<input type=hidden name=SeriesUID value=%s>\n", seriesUID);
  printf("<input type=hidden name=password value=%s>\n", password);


  { DMAN_VIDEOIMAGEDEST *video;

    destinationList = LST_Create();

    cond = listOfDestinations(&controlHandle, destinationList);

    printf("<select name=DestinationApplication size=10>\n");

    video = LST_Dequeue(&destinationList);
    while (video != NULL) {
      /*char tmp[1024];*/
      DMAN_APPLICATIONENTITY ae;

      memset(&ae, 0, sizeof(ae));
      ae.Type = DMAN_K_APPLICATIONENTITY;
      DMAN_LookupApplication(&controlHandle, video->RespondingTitle, &ae);

      /*sprintf(tmp, "%17s %s", ae.Title, ae.Title, ae.Node, ae.Comment);*/
      printf("<option value=""%s"">%16s %15s %d %s\n",
/*	   ae.Title,*/
	   video->RespondingTitle,
	   ae.Title,
	   ae.Node,
	   ae.Port,
	   ae.Comment);

      free(video);
      video = LST_Dequeue(&destinationList);
    }
    printf("</select>\n");
  }
  LST_Destroy(&destinationList);

  printf("<br>\n");
  printf("<input type=submit value=""MoveSeries"" name=submitSearch>\n");

  printf("</form>\n");

  html_end();
}
示例#17
0
文件: fileview.c 项目: nagyistge/ctn
static void selectStudy(llist entries)
{
  CONDITION cond;
  char dbKey[64];
  char studyUID[65];
  IDB_Query study;
  LST_HEAD *imageList;
  LST_HEAD *seriesList;
  QUERY_LIST_ITEM *item;
  IDB_InstanceListElement *instancePtr;
  unsigned long byteCount = 0;
  char password[64];


  strcpy(dbKey, cgi_val(entries, "DBKey"));
  strcpy(studyUID, cgi_val(entries, "StudyUID"));
  strcpy(password, cgi_val(entries, "password"));

  TBL_SetOption("OPEN_SPEEDUP");
  cond = searchOneStudy(dbKey, studyUID, &study);

  imageList = LST_Create();
  seriesList = LST_Create();
  cond = searchImages(dbKey, studyUID, imageList);
  while ((item = LST_Dequeue(&imageList)) != NULL) {

    instancePtr = LST_Dequeue(&(item->query.image.InstanceList));

    if (instancePtr != NULL)
      byteCount += instancePtr->Size;
#if 0
    while (instancePtr != NULL) {
      free(instancePtr);
      instancePtr = LST_Dequeue(&(item->query.image.InstanceList));
    }

    free(item);
#endif
  }

  html_header();
  html_begin_body_options("CTN Archive: Study Management", "bgcolor=#ffffff");

  printf("<table>\n");
  printf("<TR><TH>Name: <TH>%s</TR>\n", study.patient.PatNam);
  printf("<TR><TH>Date of Birth: <TH>%s</TR>\n", study.patient.PatBirDat);
  printf("<TR><TH>Accession Number: <TH>%s</TR>\n", study.study.AccNum);
  printf("<TR><TH>Study Date: <TH>%s</TR>\n", study.study.StuDat);
  printf("<TR><TH>Study Description: <TH>%s</TR>\n", study.study.StuDes);
  printf("<TR><TH>Series: <TH>%d</TR>\n", study.study.NumStuRelSer);
  printf("<TR><TH>Images: <TH>%d</TR>\n", study.study.NumStuRelIma);
  printf("<TR><TH>Image Volume: <TH>%d bytes</TR>\n", byteCount);
  printf("</table>\n");

  printf("<form method=GET action=""archive_agent.cgi"">\n");
  printf("<input type=hidden name=DBKey value=%s>\n", dbKey);
  printf("<input type=hidden name=StudyUID value=%s>\n", studyUID);

/*********/
  printf("<pre>\n");
  cond = searchSeries(dbKey, studyUID, seriesList);
  item = LST_Dequeue(&seriesList);
  printf("%-10s %6s %15s %15s %15s <br>",
	"Series #",
	"Images",
	"Proc Name",
	"Series Des",
	"Body Part");
  while(item != NULL) {
    char tmp[1024];
    sprintf(tmp, "%-10s %6d %15s %15s %15s",
	    item->query.series.SerNum,
	    item->query.series.NumSerRelIma,
	    item->query.series.ProNam,
	    item->query.series.SerDes,
	    item->query.series.BodParExa);

    printf(
"<a href=""/cgi-bin/archive_agent.cgi?submitSearch=%s&DBKey=%s&\
password=%s&StudyUID=%s&SeriesUID=%s"">%s</a>\n",
	   "SeriesSelect",
	   dbKey,
	   password,
	   studyUID,
	   item->query.series.SerInsUID,
	   tmp);

    free(item);
    item = LST_Dequeue(&seriesList);
  }
  printf("</pre>\n");
/**********/

  if (strcmp(password, "READONLY") != 0) {
    printf("<input type=submit value=""Delete_Study"" name=submitSearch>\n");
  }
  printf("</form>\n");

  html_end();
}
示例#18
0
文件: fileview.c 项目: nagyistge/ctn
static void selectArchive(llist entries)
{
  CONDITION cond;
  LST_HEAD *studyList;
  char dbKey[64];
  QUERY_LIST_ITEM *item;
  IDB_Limits limits;
  char password[64];
  int flag = 0;

  studyList = LST_Create();
  strcpy(dbKey, cgi_val(entries, "DBKey"));
  strcpy(password, cgi_val(entries, "password"));

  TBL_SetOption("OPEN_SPEEDUP");
  cond = listOfStudies(dbKey, studyList);
  orderStudyListByName(studyList);

  flag = passwordCompare(dbKey, password);
  if (flag == 0)
    strcpy(password, "READONLY");

  memset(&limits, 0, sizeof(limits));
  cond = dbLimits(dbKey, &limits);

  html_header();
  html_begin_body_options("CTN Archive: List of Studies", "bgcolor=#ffffff");

  if (flag == 0) {
    printf("Read only access granted <br>\n");
  }

  printf("CTN Archive: %s <br> \n", dbKey);
  { char *remoteUser;

    remoteUser = getenv("REMOTE_USER");
    if (remoteUser == NULL)
      remoteUser = "******";

    printf("Remote user: %s<br>\n", remoteUser);
  }

  printf("%d patients, %d studies, %d images <br>\n",
	 limits.PatientCount,
	 limits.StudyCount,
	 limits.ImageCount);
  printf("DB Size/Limits (MB): %d/%d<br>\n",
	 limits.DBSize/1000000,
	 limits.DBLimit);
#if 0
  printf("%d studies <br><br>\n", LST_Count(&studyList));
#endif

  printf("<pre>\n");
  item = LST_Dequeue(&studyList);
  while(item != NULL) {
    char tmp[1024];
    sprintf(tmp, "%-30s %8s (%2d series) %-32s",
	    item->query.patient.PatNam,
	    item->query.study.StuDat,
	    item->query.study.NumStuRelSer,
	    item->query.study.StuDes);

#if 0
    printf("<a href=""/cgi-bin/archive_agent.cgi?submitSearch=%s&DBKey=%s&StudyUID=%s"">%s</a><br>\n",
#endif

    printf(
"<a href=""/cgi-bin/archive_agent.cgi?submitSearch=%s&DBKey=%s&\
password=%s&StudyUID=%s"">%s</a>\n",
	   "StudySelect",
	   dbKey,
	   password,
	   item->query.study.StuInsUID,
	   tmp);

    free(item);
    item = LST_Dequeue(&studyList);
  }
  printf("</pre>\n");

  LST_Destroy(&studyList);

  html_end();
}