Right, well I did not solve a problem but I bypassed.
In fact, the DICOM file that is saved on my disk after recovery from the PACS is still not displayed correctly with the other viewers (DICOMWork, Intrasence ...), it should miss information in a field.
But my program does not use this information. Since I just look at the image dimensions (height and weight) and some other characteristics (pixelSpacing. ..), and pixelData, so I can use its in my program files anyway.
So here is my code, which suits me, but must have an error:
Code: Select all
/***
Permet de manipuler un ensemble de commandes entrantes et de réagir en conséquence, par exemple \ réponse envoi via DIMSE_sendXXXResponse ().
Le gestionnaire de la norme ne connaît que la façon de traiter une demande d'écho en appelant handleEchoRequest ().
*/
OFCondition ScpPerso::handleIncomingCommand(T_DIMSE_Message *msg, const DcmPresentationContextInfo &info)
{
OFCondition cond;
switch(msg->CommandField)
{
case DIMSE_C_ECHO_RQ :
{
// Process C-ECHO request
cond = handleECHORequest( msg->msg.CEchoRQ, info.presentationContextID );
break;
}// ende DIMSE_C_ECHO_RQ
case DIMSE_C_STORE_RQ:
{
T_DIMSE_C_StoreRSP response;
T_DIMSE_C_StoreRQ request = msg->msg.CStoreRQ;
DcmDataset *statusDetail = NULL;
T_ASC_PresentationContextID presID = info.presentationContextID;
DcmDataset *dataObject = new DcmDataset();
if (receiveDIMSEDataset(&presID, &dataObject,NULL,NULL).good())
{
if (dataObject != NULL)
{
//ON COMMENCE PAR DEFINIR LE NOM DU FICHIER QUI SERA STOCKER SUR LE DISQUE DUR
OFString OFserieName;
dataObject->findAndGetOFString(DCM_ProtocolName, OFserieName,0, true); if (OFserieName.c_str() == "" || OFserieName.c_str() == "NULL") dataObject->findAndGetOFString(DCM_SeriesDescription, OFserieName,0, true);
QString serieName = OFserieName.c_str();
//BVALUE
bool bValueTrouvee = false;
bool probAvecBValue = false;
QString bValue = "";
QString bValueName = "";
if ( (serieName.contains(Outils::DIFF,Qt::CaseInsensitive)) && (!(serieName.contains(Outils::DDIFF,Qt::CaseInsensitive))) && (!(serieName.contains(Outils::ADC,Qt::CaseInsensitive))) )
{
bValue = getBValue(dataObject, false);
if (bValue!="") bValueTrouvee = true;
else
{
bValue = "28011986t";
probAvecBValue = true;
}
//La bValue peut être de deux aspects : *ep_b1000t or 500t
if(bValue.contains("*ep_"))
{
bValueName = bValue.split("_")[1];
}
else bValueName = bValue;
//TRAITEMENT MANUELLE POUR LA BVALUE - BESOIN CRUCIALE DE CORRIGER CA !!!!!!!!!!!!
if ( (!(bValueName.contains("t"))) && (bValueName.contains("0")) && (!(bValueName.contains("1"))) && (!(bValueName.contains("5")))) bValueName = "0";
else if ( (!(bValueName.contains("t"))) && (bValueName.contains("5")) && (!(bValueName.contains("0"))) && (!(bValueName.contains("1")))) bValueName = "500";
else if ( (!(bValueName.contains("t"))) && (bValueName.contains("1")) && (!(bValueName.contains("0"))) && (!(bValueName.contains("5")))) bValueName = "1000";
if (bValueName.startsWith("b")) bValueName.remove(0,1);
if (!(bValueName.endsWith("t"))) bValueName.append("t");
bValueName.append("_");
}
else bValueName = "";
//INSTANCE NUMBER
QString instanceNumber = getInstanceNumber(dataObject);
if (instanceNumber!="") instanceNumber.append("_");
//SLICE NUMBER
QString sliceName = "IMAGE";
//NOM DE LA COPIE
QString copyName = bValueName+""+instanceNumber+""+sliceName;
//E_TransferSyntax - SYNTAXE DE TRANSERT
//OFString OFwriteXferUID;
//dataObject->findAndGetOFString(DCM_TransferSyntaxUID, OFwriteXferUID);
//E_TransferSyntax writeXfer = ;
//QString add = OFwriteXferUID.c_str();QMessageBox::information(0,"",add);
// determine the transfer syntax which shall be used to write the information to the file
//E_TransferSyntax xfer = opt_writeTransferSyntax; if (xfer == EXS_Unknown) xfer = dataObject->getOriginalXfer();
E_TransferSyntax writeXfer = dataObject->getOriginalXfer();
//E_EncodingType - TYPE D'ENCODAGE
OFString OFEncodingType;
//dataObject->findAndGetOFString(DCM_EncodingType, OFEncodingType,0, true);
E_EncodingType encodingType = EET_UndefinedLength;
//E_GrpLenEncoding
OFString OFgroupLength;
//dataObject->findAndGetOFString(DCM_GroupeLenght, OFEncodingType,0, true);
E_GrpLenEncoding groupLength = EGL_recalcGL;
//E_PaddingEncoding
OFString OFpadEncoding;
//dataObject->findAndGetOFString(DCM_paddingEncoding, OFEncodingType,0, true);
E_PaddingEncoding padEncoding = EPD_withoutPadding;//EPD_noChange;
//padLength
OFString OFpadLength;
//dataObject->findAndGetOFString(DCM_paddingEncoding, OFEncodingType,0, true);
Uint32 padLength = OFstatic_cast(Uint32, 0);//0;
//subPadLength
OFString OFsubPadLength;
//dataObject->findAndGetOFString(DCM_subPadLegth, OFsubPadLength,0, true);
Uint32 subPadLength = OFstatic_cast(Uint32, 0);//0;
QString path = MedicTool2::pathLoadedSerie+"/"+copyName;
/** save object to a DICOM file.
* This method only supports DICOM objects stored as a dataset, i.e. without meta header.
* Use DcmFileFormat::saveFile() to save files with meta header.
* @param fileName name of the file to save
* @param writeXfer transfer syntax used to write the data (EXS_Unknown means use current)
* @param encodingType flag, specifying the encoding with undefined or explicit length
* @param groupLength flag, specifying how to handle the group length tags
* @param padEncoding flag, specifying how to handle the padding tags
* @param padLength number of bytes used for the dataset padding (has to be an even number)
* @param subPadLength number of bytes used for the item padding (has to be an even number)
* @return status, EC_Normal if successful, an error code otherwise
*/
//dataObject->saveFile(path+".dcm",EXS_LittleEndianExplicit);//writeXfer,encodingType,groupLength,padEncoding,padLength,subPadLength);
//DcmDataset *dataset = fileformat.getDataset();
//dataset->putAndInsertString(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);
//dataset->putAndInsertString(DCM_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
//dataset->putAndInsertString(DCM_PatientName, "Doe^John");
///* ... */
//dataset->putAndInsertUint8Array(DCM_PixelData, pixelData, pixelLength);
DcmFileFormat *fileformat = new DcmFileFormat(dataObject);
OFCondition status = fileformat->saveFile(path, writeXfer, encodingType, groupLength, padEncoding, padLength, (OFTrue) ? EWM_fileformat : EWM_dataset);
bzero((char*)&response, sizeof(response));
response.DimseStatus = STATUS_Success;
response.MessageIDBeingRespondedTo = request.MessageID;
response.DataSetType = DIMSE_DATASET_NULL;
strcpy(response.AffectedSOPClassUID, request.AffectedSOPClassUID);
strcpy(response.AffectedSOPInstanceUID, request.AffectedSOPInstanceUID);
response.opts = (O_STORE_AFFECTEDSOPCLASSUID | O_STORE_AFFECTEDSOPINSTANCEUID);
if (request.opts & O_STORE_RQ_BLANK_PADDING) response.opts |= O_STORE_RSP_BLANK_PADDING;
if (dcmPeerRequiresExactUIDCopy.get()) response.opts |= O_STORE_PEER_REQUIRES_EXACT_UID_COPY;
OFCondition cond = sendSTOREResponse(presID, request, response, statusDetail);
/*
if( cond.bad() )
QMessageBox::information(0,"","Impossible d'envoyer la réponse C-Store");
else
QMessageBox::information(0,"","Response C-STORE envoyée avec succée");
*/
}
else QMessageBox::information(0,"","Pas d'information recue");
}
else QMessageBox::information(0,"","Pas de dcmdataset.");
break;
}
default:{
// We cannot handle this kind of message. Note that the condition will be returned
// and that the caller is responsible to end the association if desired.
OFString tempStr;
DCMNET_ERROR("Cannot handle this kind of DIMSE command (0x" << STD_NAMESPACE hex << STD_NAMESPACE setfill('0') << STD_NAMESPACE setw(4) << OFstatic_cast(unsigned int, msg->CommandField) << ")");
DCMNET_DEBUG(DIMSE_dumpMessage(tempStr, *msg, DIMSE_INCOMING));
cond = DIMSE_BADCOMMANDTYPE;
}// Ende default
}// Ende case
return cond;
}