Example #1
0
static HRESULT CreatePatientNode(DcmDirectoryRecord *patientRecord, MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
	MSXML2::IXMLDOMElementPtr patient, wado;
	wado = pXMLDom->selectSingleNode("/wado_query");
	if(wado == NULL) return CO_E_NOT_SUPPORTED;
	patient = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Patient", "http://www.weasis.org/xsd");
	if(patient == NULL) return CO_E_NOT_SUPPORTED;

	const char *patientName = NULL, *patientID = NULL, *patientBirthDate = NULL, *patientBirthTime = NULL, *patientSex = NULL;
	if(patientRecord->findAndGetString(DCM_PatientsName, patientName).bad()) return CO_E_NOT_SUPPORTED;
	else patient->setAttribute("PatientName", patientName);
	if(patientRecord->findAndGetString(DCM_PatientID, patientID).bad()) return CO_E_NOT_SUPPORTED;
	else patient->setAttribute("PatientID", patientID);
	if(patientRecord->findAndGetString(DCM_PatientsBirthDate, patientBirthDate).good())
		patient->setAttribute("PatientBirthDate", patientBirthDate);
	if(patientRecord->findAndGetString(DCM_PatientsBirthTime, patientBirthTime).good())
		patient->setAttribute("PatientBirthTime", patientBirthTime);
	if(patientRecord->findAndGetString(DCM_PatientsSex, patientSex).good())
		patient->setAttribute("PatientSex", patientSex);

	wado->appendChild(patient);

	DcmDirectoryRecord *studyRec = NULL;
	while(studyRec = patientRecord->nextSub(studyRec))
	{
		if(studyRec->getRecordType() != ERT_Study) continue;
		CreateStudyNode(studyRec, patient, pXMLDom);
	}
	return S_OK;
}
Example #2
0
static HRESULT CreateStudyNode(DcmDirectoryRecord *studyRec, MSXML2::IXMLDOMElementPtr &patient, MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
	MSXML2::IXMLDOMElementPtr study = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Study", "http://www.weasis.org/xsd");
	if(study == NULL) return CO_E_NOT_SUPPORTED;

	const char *buff = NULL, *studyUID = NULL;
	if(studyRec->findAndGetString(DCM_StudyInstanceUID, studyUID).bad()) return CO_E_NOT_SUPPORTED;
	else study->setAttribute("StudyInstanceUID", studyUID);
	if(studyRec->findAndGetString(DCM_StudyDate, buff).bad()) return CO_E_NOT_SUPPORTED;
	else study->setAttribute("StudyDate", buff);
	if(studyRec->findAndGetString(DCM_StudyTime, buff).good()) study->setAttribute("StudyTime", buff);
	if(studyRec->findAndGetString(DCM_StudyID, buff).good()) study->setAttribute("StudyID", buff);
	if(studyRec->findAndGetString(DCM_AccessionNumber, buff).good()) study->setAttribute("AccessionNumber", buff);
	if(studyRec->findAndGetString(DCM_StudyDescription, buff).good()) study->setAttribute("StudyDescription", buff);
	if(studyRec->findAndGetString(DCM_ReferringPhysiciansName, buff).good()) study->setAttribute("ReferringPhysicianName", buff);
	patient->appendChild(study);

	DcmDirectoryRecord *seriesRec = NULL;
	while(seriesRec = studyRec->nextSub(seriesRec))
	{
		if(seriesRec->getRecordType() != ERT_Series) continue;
		CreateSeriesNode(seriesRec, study, pXMLDom, studyUID);
	}
	return S_OK;
}
Example #3
0
MSXML2::IXMLDOMNodePtr createNode(MSXML2::IXMLDOMDocumentPtr& xmlDoc, 
      const String& nodeName) {
  MSXML2::IXMLDOMNodePtr res = xmlDoc->createNode(1, nodeName.c_str(), _T("")); 
  if (res == NULL) {
    throw XMLUtils::ParseError();
  }

  return res;
}
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertBefore(MSXML2::IXMLDOMNode *refNode, LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			newNode = m_xmlnode->insertBefore(newNode.Detach(),(IUnknown*)refNode);
			return newNode.Detach();
		}
		return NULL;
	}
Example #5
0
void  addTextAttributeToNode(MSXML2::IXMLDOMDocumentPtr& xmlDoc,
      MSXML2::IXMLDOMNodePtr& targetNode, const String& attributeName, 
      const String& attributeValue) {
  MSXML2::IXMLDOMNodePtr attributeNode = 
  xmlDoc->createNode(NODE_ATTRIBUTE, attributeName.c_str(), _T("")); 

  setNodeText(attributeNode, attributeValue);
  MSXML2::IXMLDOMNamedNodeMapPtr attributes = targetNode->Getattributes();
  if (attributes == NULL) {
    throw XMLUtils::ParseError();
  }

  attributes->setNamedItem(attributeNode);
}
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertAfter(MSXML2::IXMLDOMNode *refNode, LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			MSXML2::IXMLDOMNodePtr nextNode = refNode->GetnextSibling();
			if (nextNode.GetInterfacePtr() != NULL)
				newNode = m_xmlnode->insertBefore(newNode.Detach(),(IUnknown*)nextNode);
			else
				newNode = m_xmlnode->appendChild(newNode.Detach());
			return newNode.Detach();
		}
		return NULL;
	}
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertNode(int index,LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			MSXML2::IXMLDOMNode* refNode = GetNode(index);
			if (refNode)
				newNode = m_xmlnode->insertBefore(newNode.Detach(),refNode);
			else
				newNode = m_xmlnode->appendChild(newNode.Detach());
			return newNode.Detach();
		}
		return NULL;
	}
Example #8
0
static HRESULT CreateInstanceNode(DcmDirectoryRecord *instanceRec, MSXML2::IXMLDOMElementPtr &series, MSXML2::IXMLDOMDocumentPtr &pXMLDom, const char *studyUID, const char *seriesUID)
{
	MSXML2::IXMLDOMElementPtr instance = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Instance", "http://www.weasis.org/xsd");
	if(instance == NULL) return CO_E_NOT_SUPPORTED;
	const char *buff = NULL, *instanceUID = NULL, *transferSyntax = NULL;
	if(instanceRec->findAndGetString(DCM_ReferencedSOPInstanceUIDInFile, instanceUID).bad()) return CO_E_NOT_SUPPORTED;
	else instance->setAttribute("SOPInstanceUID", instanceUID);
	if(instanceRec->findAndGetString(DCM_ReferencedTransferSyntaxUIDInFile, transferSyntax).bad()) return CO_E_NOT_SUPPORTED;
	else instance->setAttribute("TransferSyntaxUID", transferSyntax);

	char url[512];
	sprintf_s(url, "getindex.exe?requestType=WADO&studyUID=%s&seriesUID=%s&objectUID=%s&contentType=application%%2Fdicom&transferSyntax=%s", 
		studyUID, seriesUID, instanceUID, transferSyntax);
	instance->setAttribute("DirectDownloadFile", url);

	if(instanceRec->findAndGetString(DCM_InstanceNumber, buff).good()) instance->setAttribute("InstanceNumber", buff);
	series->appendChild(instance);
	return S_OK;
}
Example #9
0
static HRESULT CreateWADO(MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
	HRESULT hr = pXMLDom.CreateInstance(__uuidof(MSXML2::DOMDocument30));
	if (FAILED(hr)) return hr;
	pXMLDom->preserveWhiteSpace = VARIANT_FALSE;
	pXMLDom->async = VARIANT_FALSE;

	MSXML2::IXMLDOMElementPtr wado;
	MSXML2::IXMLDOMProcessingInstructionPtr pi;
	pi = pXMLDom->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"GBK\"");
	if (pi != NULL)
	{
		pXMLDom->appendChild(pi);
		pi.Release();
	}

	pi = pXMLDom->createProcessingInstruction("xml-stylesheet", "type=\"text/xml\" href=\"../xslt/wadolist.xsl\"");
	if (pi != NULL)
	{
		pXMLDom->appendChild(pi);
		pi.Release();
	}

	wado = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "wado_query", "http://www.weasis.org/xsd");
	wado->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
	wado->setAttribute("requireOnlySOPInstanceUID", "false");
	pXMLDom->appendChild(wado);
	wado->setAttribute("wadoURL", "http://localhost/pacs/cgi-bin/");
	/*
	MSXML2::IXMLDOMElementPtr httpTag;
	httpTag = pXMLDom->selectSingleNode("/wado_query/httpTag");
	if( ! httpTag )
	{
		httpTag = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "httpTag", "http://www.weasis.org/xsd");
		wado->appendChild(httpTag);
	}
	httpTag->setAttribute("key", "callingAE");
	httpTag->setAttribute("value", "DEVICE");
	*/
	return S_OK;
}
Example #10
0
static HRESULT CreateSeriesNode(DcmDirectoryRecord *seriesRec, MSXML2::IXMLDOMElementPtr &study, MSXML2::IXMLDOMDocumentPtr &pXMLDom, const char *studyUID)
{
	MSXML2::IXMLDOMElementPtr series = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Series", "http://www.weasis.org/xsd");
	if(series == NULL) return CO_E_NOT_SUPPORTED;

	const char *buff = NULL, *seriesUID = NULL;
	if(seriesRec->findAndGetString(DCM_SeriesInstanceUID, seriesUID).bad()) return CO_E_NOT_SUPPORTED;
	else series->setAttribute("SeriesInstanceUID", seriesUID);
	if(seriesRec->findAndGetString(DCM_Modality, buff).bad()) return CO_E_NOT_SUPPORTED;
	else series->setAttribute("Modality", buff);
	if(seriesRec->findAndGetString(DCM_SeriesDescription, buff).good()) series->setAttribute("SeriesDescription", buff);
	if(seriesRec->findAndGetString(DCM_SeriesNumber, buff).good()) series->setAttribute("SeriesNumber", buff);
	study->appendChild(series);

	DcmDirectoryRecord *instanceRec = NULL;
	while(instanceRec = seriesRec->nextSub(instanceRec))
	{
		if(instanceRec->getRecordType() != ERT_Image) continue;
		CreateInstanceNode(instanceRec, series, pXMLDom, studyUID, seriesUID);
	}

	return S_OK;
}