#include "ltdic.h"
L_BOOL LDicomAssociate::IsRoleSelect(nID)
Determines whether Role Selection is enabled for the specified Presentation Context of the DICOM Associate.
Presentation ID of the Presentation Context for which you wish to check Role Selection. The presentation ID provides information about both the class type of the data and the transfer syntax to use when transferring the data. It also identifies a specific Presentation Context within an Associate.
Value | Meaning |
---|---|
TRUE | Role Selection is enabled for the specified Presentation Context of the DICOM Associate. |
FALSE | Role Selection is disabled for the specified Presentation Context of the DICOM Associate. |
If Role Selection is enabled, the role of the specified Presentation Context can be retrieved using LDicomAssociate::GetUserRole and LDicomAssociate::GetProviderRole. To set the role of the specified Presentation Context, call LDicomAssociate::SetRoleSelect.
Required DLLs and Libraries
Win32, x64
This example builds an associate request (pointed to by pAssociateAll)
that contains all the abstract syntaxes
present in m_pDicomAssociate, and adds all the abstract syntaxes not present in m_pDicomAssociate.
Each abstract syntax that was not in m_pDicomAssociate is given a default presentation context
L_INT LDicomAssociate_IsRoleSelectExample(LDicomAssociate *m_pDicomAssociate)
{
L_INT nRet;
L_UCHAR nID, nIDtemp;
pDICOMUID pUID;
CString strAbstractSyntax;
L_INT i, j;
LDicomAssociate* pAssociateAll;
CString strMsg;
CString strTmp;
L_TCHAR szAbstract[PDU_MAX_UID_SIZE + 1];
L_TCHAR szTransfer[PDU_MAX_UID_SIZE + 1];
//Create the new associate object
pAssociateAll =new LDicomAssociate(TRUE);
nIDtemp = 1;
pUID = LDicomUID::GetFirst();
while (pUID != NULL && nIDtemp != 255)
{
if ((pUID->nType == UID_TYPE_CLASS) || (pUID->nType == UID_TYPE_META_CLASS))
{
nRet = pAssociateAll->AddPresentation(nIDtemp, 0, pUID->pszCode);
if(nRet != DICOM_SUCCESS)
return nRet;
nIDtemp += 2;
}
pUID = LDicomUID::GetNext(pUID);
}
for (i = 0; i < pAssociateAll->GetPresentationCount(); i++)
{
nIDtemp = pAssociateAll->GetPresentation(i);
pAssociateAll->GetAbstract(nIDtemp, szAbstract, PDU_MAX_UID_SIZE+1);
strAbstractSyntax = szAbstract;
nID = m_pDicomAssociate->FindAbstract((L_TCHAR*)(LPCTSTR)strAbstractSyntax);
//if abstract not found in m_pDicomAssociate, add default transfer syntaxes so that
//the abstract syntax will not be rejected by the server
if (nID == 0)
{
pUID = LDicomUID::GetFirst();
while (pUID != NULL)
{
if (pUID->nType == UID_TYPE_TRANSFER1)
{
nRet = pAssociateAll->AddTransfer(nIDtemp, pUID->pszCode);
if(nRet != DICOM_SUCCESS)
return nRet;
}
pUID = LDicomUID::GetNext(pUID);
}
}
//abstract found in hAssociateRequest
//add transfer syntaxes for the abstract syntax found in hAssociateRequest
else
{
for (j = 0; j < m_pDicomAssociate->GetTransferCount(nID); j++)
{
m_pDicomAssociate->GetTransfer(nID, j, szTransfer, PDU_MAX_UID_SIZE + 1);
CString strTransferSyntax = szTransfer;
nRet = pAssociateAll->AddTransfer(nIDtemp, (L_TCHAR *)(LPCTSTR)strTransferSyntax);
if(nRet != DICOM_SUCCESS)
return nRet;
}
nRet = pAssociateAll->SetRoleSelect(
nIDtemp,
m_pDicomAssociate->IsRoleSelect(nID),
m_pDicomAssociate->GetUserRole(nID),
m_pDicomAssociate->GetProviderRole(nID)
);
if(nRet != DICOM_SUCCESS)
return nRet;
nRet = pAssociateAll->SetExtended(
nIDtemp,
m_pDicomAssociate->GetExtended(nID),
m_pDicomAssociate->GetLengthExtended(nID)
);
if(nRet != DICOM_SUCCESS)
return nRet;
}
}
//Display each abstract syntax (and some presentation context info) for pAssociateAll object
strMsg = "AssociateAll:";
for (i=0; i<pAssociateAll->GetPresentationCount(); i++)
{
nIDtemp = pAssociateAll->GetPresentation(i);
pAssociateAll->GetAbstract(nIDtemp, szAbstract, PDU_MAX_UID_SIZE+1);
strAbstractSyntax = szAbstract;
pUID = LDicomUID::Find((L_TCHAR *)(LPCTSTR)strAbstractSyntax);
strMsg += TEXT("\n");
strMsg += pUID->pszName;
if (pAssociateAll->IsRoleSelect(nIDtemp))
{
L_UCHAR uUserRole = pAssociateAll->GetUserRole(nIDtemp);
L_UCHAR uProviderRole = pAssociateAll->GetProviderRole(nIDtemp);
strTmp.Format(TEXT("UserRole[%d]ProviderRole[%d]"), uUserRole, uProviderRole);
strMsg = strMsg + strTmp;
}
}
AfxMessageBox(strMsg);
return DICOM_SUCCESS;
}