You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
565 lines
22 KiB
565 lines
22 KiB
|
1 month ago
|
program DfcDatz;
|
||
|
|
|
||
|
|
{$APPTYPE CONSOLE}
|
||
|
|
|
||
|
|
uses
|
||
|
|
ControlsAtomFix,
|
||
|
|
DefineTypes,
|
||
|
|
|
||
|
|
Windows,
|
||
|
|
ActiveX,
|
||
|
|
Classes,
|
||
|
|
DfcDats,
|
||
|
|
Graphics,
|
||
|
|
IniFiles,
|
||
|
|
JPEG,
|
||
|
|
msxml,
|
||
|
|
SysUtils;
|
||
|
|
|
||
|
|
{$R resData.res}
|
||
|
|
|
||
|
|
var
|
||
|
|
nI, nX1Len, nPPLen : Integer;
|
||
|
|
gPSInStr, gPPInStr, gTargetDcmFile : string;
|
||
|
|
gDcmFileInfo : TDcmFileInfo;
|
||
|
|
gDebugOutput, gDebugConvert : Boolean;
|
||
|
|
|
||
|
|
function InitP1XMLStr:string;
|
||
|
|
var
|
||
|
|
sDate, sTime, aAccNo: string;
|
||
|
|
|
||
|
|
function GetPSex:string;
|
||
|
|
begin
|
||
|
|
if Odd(Random(2)) then
|
||
|
|
Result := 'M'
|
||
|
|
else
|
||
|
|
Result := 'F';
|
||
|
|
end;
|
||
|
|
begin
|
||
|
|
Randomize;
|
||
|
|
sDate := GetRndDateStr(5);
|
||
|
|
sTime := GetRndTimeStr;
|
||
|
|
aAccNo := GetRndStr(8);
|
||
|
|
Result := '<XML>';
|
||
|
|
Result := Result + '<ODSP>';
|
||
|
|
Result := Result + '<EXEPIN DICOMType="3020">'; //DICOMType : 1000=Image, 2000=Report, 3000=Data(3010=������3020=��ѹ��3040=���⣬3080=�ۺ�)
|
||
|
|
|
||
|
|
//Result := Result + '<Patient PatientID="!"@#$^&*()<>'':;'12345" PatientName="P' + GetRndStr(7);
|
||
|
|
//Result := Result + '" PatientSex="" PatientDOB=""></Patient>';
|
||
|
|
|
||
|
|
Result := Result + '<Patient PatientID="' + GetRndStr(8) + '" PatientName="P' + GetRndStr(7);
|
||
|
|
Result := Result + '" PatientSex="' + GetPSex + '" PatientDOB="' + GetRndDateStr(100) + '"></Patient>';
|
||
|
|
|
||
|
|
Result := Result + '<Study StudyDate="' + sDate + '" StudyTime="' + sTime + '" StudyID="' + GetRndStr(8);
|
||
|
|
Result := Result + '" SOPClassUID=" 1.2.840.10008.5.1.4.1.1.7" InstitutionName="HuiMu IT Co., Ltd."></Study>';
|
||
|
|
Result := Result + '<Series SeriesDate="' + sDate + '" SeriesTime="' + sTime + '" SeriesNumber="' + GetRndStr(8);
|
||
|
|
Result := Result + '" Modality="IOP" Manufacturer="HM-OEIS"></Series>';
|
||
|
|
Result := Result + '<Image InstanceNumber="1" Laterality="#NULL#" ImageLaterality="R"></Image>';
|
||
|
|
Result := Result + '<ExamData>';
|
||
|
|
Result := Result + '<RefractionL SPH="-2.25" CYL="-0.62" AXIS="96" PD="12.0" SE="-1.00"/>';
|
||
|
|
Result := Result + '<RefractionR SPH="-2.25" CYL="-0.62" AXIS="96" PD="12.0" SE="-0.50"/>';
|
||
|
|
Result := Result + '<IOPL Pressure="16"/>';
|
||
|
|
Result := Result + '<IOPR Pressure="12"/>';
|
||
|
|
Result := Result + '<VisionL VAN="1.0" VAG="1.2"/>';
|
||
|
|
Result := Result + '<VisionR VAN="0.8" VAG="1.2"/>';
|
||
|
|
Result := Result + '</ExamData>';
|
||
|
|
Result := Result + '</EXEPIN>';
|
||
|
|
Result := Result + '</ODSP>';
|
||
|
|
Result := Result + '</XML>';
|
||
|
|
end;
|
||
|
|
|
||
|
|
function InitXMLP1Info(aXMLData: string):Boolean;
|
||
|
|
var
|
||
|
|
//tFile: TextFile;
|
||
|
|
//sXML : string;
|
||
|
|
node : IXMLDOMElement;
|
||
|
|
vXMLHelper : IXMLDOMDocument;
|
||
|
|
begin
|
||
|
|
Result := False;
|
||
|
|
nX1Len := Length(aXMLData);
|
||
|
|
WriteLogText(44, 'I', 'InitXMLP1Info ' + IntToStr(nX1Len) + ' bytes');
|
||
|
|
try
|
||
|
|
{
|
||
|
|
sXML := '';
|
||
|
|
AssignFile(tFile, 'C:\Users\User\Desktop\ImgList.xml');
|
||
|
|
Reset(tFile);
|
||
|
|
while not Eof(tFile) do
|
||
|
|
begin
|
||
|
|
Readln(tFile, sTmp);
|
||
|
|
sXML := sXML + sTmp;
|
||
|
|
end;
|
||
|
|
CloseFile(tFile);
|
||
|
|
//Showmessage(sXML);
|
||
|
|
//}
|
||
|
|
|
||
|
|
if Length(aXMLData) < 1 then
|
||
|
|
begin
|
||
|
|
aXMLData := InitP1XMLStr;
|
||
|
|
nPPLen := Length(aXMLData);
|
||
|
|
if DebugHook = 1 then
|
||
|
|
nX1Len := nPPLen;
|
||
|
|
end;
|
||
|
|
|
||
|
|
vXMLHelper := CoDOMDocument.Create;
|
||
|
|
if vXMLHelper.loadXML(aXMLData) then
|
||
|
|
begin
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('DICOMType') <> nil then
|
||
|
|
gDcmFileInfo.DICOMType := StrToIntDef(node.attributes.getNamedItem('DICOMType').Text, 0);
|
||
|
|
if node.attributes.getNamedItem('DebugConvert') <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('DebugConvert').Text = '1' then
|
||
|
|
gDebugConvert := True;
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/Patient'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('PatientID') <> nil then
|
||
|
|
gDcmFileInfo.PatientID := Trim(node.attributes.getNamedItem('PatientID').Text);
|
||
|
|
if node.attributes.getNamedItem('PatientIssuerID') <> nil then
|
||
|
|
gDcmFileInfo.PatientIssuerID := Trim(node.attributes.getNamedItem('PatientIssuerID').Text);
|
||
|
|
if node.attributes.getNamedItem('PatientName') <> nil then
|
||
|
|
gDcmFileInfo.PatientName := Trim(node.attributes.getNamedItem('PatientName').Text);
|
||
|
|
if node.attributes.getNamedItem('PatientDOB') <> nil then
|
||
|
|
gDcmFileInfo.PatientDOB := Trim(node.attributes.getNamedItem('PatientDOB').Text);
|
||
|
|
if node.attributes.getNamedItem('PatientSex') <> nil then
|
||
|
|
gDcmFileInfo.PatientSex := Trim(node.attributes.getNamedItem('PatientSex').Text);
|
||
|
|
end;
|
||
|
|
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/Study'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('AccessionNumber') <> nil then
|
||
|
|
gDcmFileInfo.AccessionNumber := Trim(node.attributes.getNamedItem('AccessionNumber').Text);
|
||
|
|
if node.attributes.getNamedItem('StudyInstanceUID') <> nil then
|
||
|
|
gDcmFileInfo.StudyInstanceUID := Trim(node.attributes.getNamedItem('StudyInstanceUID').Text);
|
||
|
|
if node.attributes.getNamedItem('StudyID') <> nil then
|
||
|
|
gDcmFileInfo.StudyID := Trim(node.attributes.getNamedItem('StudyID').Text);
|
||
|
|
if node.attributes.getNamedItem('StudyDate') <> nil then
|
||
|
|
gDcmFileInfo.StudyDate := Trim(node.attributes.getNamedItem('StudyDate').Text);
|
||
|
|
if node.attributes.getNamedItem('StudyTime') <> nil then
|
||
|
|
gDcmFileInfo.StudyTime := Trim(node.attributes.getNamedItem('StudyTime').Text);
|
||
|
|
if node.attributes.getNamedItem('StudyDescription') <> nil then
|
||
|
|
gDcmFileInfo.StudyDescription := Trim(node.attributes.getNamedItem('StudyDescription').Text);
|
||
|
|
if node.attributes.getNamedItem('ReferringPhysicianName') <> nil then
|
||
|
|
gDcmFileInfo.ReferringPhysicianName := Trim(node.attributes.getNamedItem('ReferringPhysicianName').Text);
|
||
|
|
end;
|
||
|
|
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/Series'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('SeriesInstanceUID') <> nil then
|
||
|
|
gDcmFileInfo.SeriesInstanceUID := Trim(node.attributes.getNamedItem('SeriesInstanceUID').Text);
|
||
|
|
if node.attributes.getNamedItem('Modality') <> nil then
|
||
|
|
gDcmFileInfo.Modality := Trim(node.attributes.getNamedItem('Modality').Text);
|
||
|
|
if node.attributes.getNamedItem('SeriesNumber') <> nil then
|
||
|
|
gDcmFileInfo.SeriesNumber := Trim(node.attributes.getNamedItem('SeriesNumber').Text);
|
||
|
|
if node.attributes.getNamedItem('SeriesDate') <> nil then
|
||
|
|
gDcmFileInfo.SeriesDate := Trim(node.attributes.getNamedItem('SeriesDate').Text);
|
||
|
|
if node.attributes.getNamedItem('SeriesTime') <> nil then
|
||
|
|
gDcmFileInfo.SeriesTime := Trim(node.attributes.getNamedItem('SeriesTime').Text);
|
||
|
|
if node.attributes.getNamedItem('SeriesDescription') <> nil then
|
||
|
|
gDcmFileInfo.SeriesDescription := Trim(node.attributes.getNamedItem('SeriesDescription').Text);
|
||
|
|
if node.attributes.getNamedItem('InstitutionName') <> nil then
|
||
|
|
gDcmFileInfo.InstitutionName := Trim(node.attributes.getNamedItem('InstitutionName').Text);
|
||
|
|
if node.attributes.getNamedItem('Manufacturer') <> nil then
|
||
|
|
gDcmFileInfo.Manufacturer := Trim(node.attributes.getNamedItem('Manufacturer').Text);
|
||
|
|
if node.attributes.getNamedItem('ModelName') <> nil then
|
||
|
|
gDcmFileInfo.ModelName := Trim(node.attributes.getNamedItem('ModelName').Text);
|
||
|
|
if node.attributes.getNamedItem('SoftwareVersions') <> nil then
|
||
|
|
gDcmFileInfo.SoftwareVersions := Trim(node.attributes.getNamedItem('SoftwareVersions').Text);
|
||
|
|
if node.attributes.getNamedItem('CreatorVersionUID') <> nil then
|
||
|
|
gDcmFileInfo.CreatorVersionUID := Trim(node.attributes.getNamedItem('CreatorVersionUID').Text);
|
||
|
|
end;
|
||
|
|
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/Image'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('SOPInstanceUID') <> nil then
|
||
|
|
gDcmFileInfo.SOPInstanceUID := Trim(node.attributes.getNamedItem('SOPInstanceUID').Text);
|
||
|
|
if node.attributes.getNamedItem('ImageDate') <> nil then
|
||
|
|
gDcmFileInfo.ImageDate := Trim(node.attributes.getNamedItem('ImageDate').Text);
|
||
|
|
if node.attributes.getNamedItem('ImageTime') <> nil then
|
||
|
|
gDcmFileInfo.ImageTime := Trim(node.attributes.getNamedItem('ImageTime').Text);
|
||
|
|
if node.attributes.getNamedItem('ImageType') <> nil then
|
||
|
|
gDcmFileInfo.ImageType := Trim(node.attributes.getNamedItem('ImageType').Text);
|
||
|
|
if node.attributes.getNamedItem('InstanceNumber') <> nil then
|
||
|
|
gDcmFileInfo.ImageNumber := StrToIntDef(node.attributes.getNamedItem('InstanceNumber').Text, 1);
|
||
|
|
if node.attributes.getNamedItem('Laterality') <> nil then
|
||
|
|
gDcmFileInfo.Laterality := Trim(node.attributes.getNamedItem('Laterality').Text);
|
||
|
|
if node.attributes.getNamedItem('ImageLaterality') <> nil then
|
||
|
|
gDcmFileInfo.ImageLaterality := Trim(node.attributes.getNamedItem('ImageLaterality').Text);
|
||
|
|
if node.attributes.getNamedItem('PdfDocTitle') <> nil then
|
||
|
|
gDcmFileInfo.PdfDocTitle := Trim(node.attributes.getNamedItem('PdfDocTitle').Text);
|
||
|
|
end;
|
||
|
|
|
||
|
|
if (gDcmFileInfo.DICOMType = 3010) then //����
|
||
|
|
begin
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/ExamData/VisionL'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('VAN') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.VisionDataAvgL.VAN := Trim(node.attributes.getNamedItem('VAN').Text);
|
||
|
|
if node.attributes.getNamedItem('VAG') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.VisionDataAvgL.VAG := Trim(node.attributes.getNamedItem('VAG').Text);
|
||
|
|
end;
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/ExamData/VisionR'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('VAN') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.VisionDataAvgR.VAN := Trim(node.attributes.getNamedItem('VAN').Text);
|
||
|
|
if node.attributes.getNamedItem('VAG') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.VisionDataAvgR.VAG := Trim(node.attributes.getNamedItem('VAG').Text);
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
if (gDcmFileInfo.DICOMType = 3020) then //��ѹ
|
||
|
|
begin
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/ExamData/IOPL'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('Pressure') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.IOPDataAvgL.Pressure := Trim(node.attributes.getNamedItem('Pressure').Text);
|
||
|
|
end;
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/ExamData/IOPR'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('Pressure') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.IOPDataAvgR.Pressure := Trim(node.attributes.getNamedItem('Pressure').Text);
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
if (gDcmFileInfo.DICOMType = 3030) then //����
|
||
|
|
begin
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/ExamData/RefractionL'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('SPH') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgL.SPH := Trim(node.attributes.getNamedItem('SPH').Text);
|
||
|
|
if node.attributes.getNamedItem('CYL') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgL.CYL := Trim(node.attributes.getNamedItem('CYL').Text);
|
||
|
|
if node.attributes.getNamedItem('AXIS') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgL.AXIS := Trim(node.attributes.getNamedItem('AXIS').Text);
|
||
|
|
if node.attributes.getNamedItem('SE') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgL.SE := Trim(node.attributes.getNamedItem('SE').Text);
|
||
|
|
if node.attributes.getNamedItem('PD') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgL.PD := Trim(node.attributes.getNamedItem('PD').Text);
|
||
|
|
end;
|
||
|
|
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXEPIN/ExamData/RefractionR'));
|
||
|
|
if node <> nil then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('SPH') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgR.SPH := Trim(node.attributes.getNamedItem('SPH').Text);
|
||
|
|
if node.attributes.getNamedItem('CYL') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgR.CYL := Trim(node.attributes.getNamedItem('CYL').Text);
|
||
|
|
if node.attributes.getNamedItem('AXIS') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgR.AXIS := Trim(node.attributes.getNamedItem('AXIS').Text);
|
||
|
|
if node.attributes.getNamedItem('SE') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgR.SE := Trim(node.attributes.getNamedItem('SE').Text);
|
||
|
|
if node.attributes.getNamedItem('PD') <> nil then
|
||
|
|
gDcmFileInfo.RCExamData.RefractionDataAvgR.PD := Trim(node.attributes.getNamedItem('PD').Text);
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
if (gDcmFileInfo.DICOMType = 3080) then //�ۺ�
|
||
|
|
begin
|
||
|
|
|
||
|
|
end;
|
||
|
|
|
||
|
|
gDcmFileInfo.ImageDate := gDcmFileInfo.SeriesDate;
|
||
|
|
gDcmFileInfo.ImageTime := gDcmFileInfo.SeriesTime;
|
||
|
|
|
||
|
|
Result := True;
|
||
|
|
WriteLogText(44, 'I', 'InitXMLP1Info done');
|
||
|
|
end
|
||
|
|
else
|
||
|
|
begin
|
||
|
|
WriteLogText(0, 'E', 'Load P1 XML string failed');
|
||
|
|
end;
|
||
|
|
except
|
||
|
|
on e:exception do
|
||
|
|
begin
|
||
|
|
WriteLogText(0, 'W', 'Load P1 XML string with error : ' + e.Message);
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
function InitXMLP2Info(aXMLData: string):Boolean;
|
||
|
|
var
|
||
|
|
sTmp, sTaskIDStr : string;
|
||
|
|
node : IXMLDOMElement;
|
||
|
|
vXMLHelper : IXMLDOMDocument;
|
||
|
|
begin
|
||
|
|
Result := False;
|
||
|
|
WriteLogText(44, 'I', 'InitXMLP2Info ' + IntToStr(Length(aXMLData)) + ' bytes');
|
||
|
|
try
|
||
|
|
if Length(aXMLData) < 1 then
|
||
|
|
Exit;
|
||
|
|
|
||
|
|
vXMLHelper := CoDOMDocument.Create;
|
||
|
|
if vXMLHelper.loadXML(aXMLData) then
|
||
|
|
begin
|
||
|
|
sTaskIDStr := '54321';
|
||
|
|
//<XML><ODSP><EXESIN Type="0" ReportFile=".\MOD_Refraction.xml" RSTCFile=".\MOD_Refraction.dat" ImageFile=".\MOD_Refraction.jpg" OutputFile=".\MOD_Refraction.dcm"/></ODSP></XML>
|
||
|
|
node := IXMLDOMElement(vXMLHelper.selectSingleNode('/XML/ODSP/EXESIN'));
|
||
|
|
sTmp := Trim(node.attributes.getNamedItem('Type').Text);
|
||
|
|
if sTmp = '0' then
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('TaskID') <> nil then
|
||
|
|
sTaskIDStr := Trim(node.attributes.getNamedItem('TaskID').Text);
|
||
|
|
|
||
|
|
//�Ա���ͼ���ļ�ת���ļ� ����������ѹ�����������ṩԭʼ�����ļ���
|
||
|
|
//if node.attributes.getNamedItem('ImageFile') <> nil then
|
||
|
|
//gSourceImgFile := Trim(node.attributes.getNamedItem('ImageFile').Text);
|
||
|
|
//if node.attributes.getNamedItem('ReportFile') <> nil then
|
||
|
|
//gSourceStoreFile := Trim(node.attributes.getNamedItem('ReportFile').Text);
|
||
|
|
|
||
|
|
if Pos('0' + IntToStr(nX1Len), sTaskIDStr) > 1 then
|
||
|
|
begin
|
||
|
|
//ת�������ļ�
|
||
|
|
if node.attributes.getNamedItem('OutputFile') <> nil then
|
||
|
|
gTargetDcmFile := Trim(node.attributes.getNamedItem('OutputFile').Text);
|
||
|
|
gTaskInitP1 := False;
|
||
|
|
gTaskInitP2 := True;
|
||
|
|
end
|
||
|
|
else
|
||
|
|
begin
|
||
|
|
if node.attributes.getNamedItem('OutputFile') <> nil then
|
||
|
|
gTargetDcmFile := Trim(node.attributes.getNamedItem('OutputFile').Text);
|
||
|
|
end;
|
||
|
|
end
|
||
|
|
else if sTmp = '1' then
|
||
|
|
begin
|
||
|
|
//�����ݿ���ȡת����Ϣ���ѽ��ã�
|
||
|
|
end;
|
||
|
|
Result := True;
|
||
|
|
WriteLogText(44, 'I', 'InitXMLP2Info done');
|
||
|
|
end
|
||
|
|
else
|
||
|
|
begin
|
||
|
|
WriteLogText(0, 'E', 'Load P2 XML string failed');
|
||
|
|
end;
|
||
|
|
except
|
||
|
|
on e:exception do
|
||
|
|
begin
|
||
|
|
WriteLogText(0, 'W', 'Load P2 XML string with error : ' + e.Message);
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
function ProcessDataDSP:Boolean;
|
||
|
|
begin
|
||
|
|
Result := False;
|
||
|
|
WriteLogText(44, 'I', 'Start ProcessDataDSP');
|
||
|
|
|
||
|
|
if gDcmFileInfo.ImageNumber < 0 then
|
||
|
|
gDcmFileInfo.ImageNumber := 1;
|
||
|
|
gDcmFileInfo.AcquisitionNumber := IntToStr(gDcmFileInfo.ImageNumber);
|
||
|
|
|
||
|
|
if Length(gDcmFileInfo.Modality) < 1 then
|
||
|
|
begin
|
||
|
|
case gDcmFileInfo.DICOMType of
|
||
|
|
3010:
|
||
|
|
gDcmFileInfo.Modality := 'VA';
|
||
|
|
3020:
|
||
|
|
gDcmFileInfo.Modality := 'IOP';
|
||
|
|
3030:
|
||
|
|
gDcmFileInfo.Modality := 'REF';
|
||
|
|
else
|
||
|
|
gDcmFileInfo.Modality := 'OP';
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
if Length(gDcmFileInfo.StudyDate) < 1 then
|
||
|
|
gDcmFileInfo.StudyDate := FormatDateTime('yyyyMMdd', Now);
|
||
|
|
if Length(gDcmFileInfo.SeriesDate) < 1 then
|
||
|
|
gDcmFileInfo.SeriesDate := gDcmFileInfo.StudyDate;
|
||
|
|
if Length(gDcmFileInfo.ImageDate) < 1 then
|
||
|
|
gDcmFileInfo.ImageDate := gDcmFileInfo.StudyDate;
|
||
|
|
if Length(gDcmFileInfo.StudyTime) < 1 then
|
||
|
|
gDcmFileInfo.StudyTime := FormatDateTime('hhnnss', Now);
|
||
|
|
if Length(gDcmFileInfo.SeriesTime) < 1 then
|
||
|
|
gDcmFileInfo.SeriesTime := gDcmFileInfo.StudyTime;
|
||
|
|
if Length(gDcmFileInfo.ImageTime) < 1 then
|
||
|
|
gDcmFileInfo.ImageTime := gDcmFileInfo.StudyTime;
|
||
|
|
|
||
|
|
//if Length(gDcmFileInfo.PatientName) < 1 then
|
||
|
|
//gDcmFileInfo.PatientName := 'NONAME';
|
||
|
|
//if Length(gDcmFileInfo.PatientID) < 1 then
|
||
|
|
//gDcmFileInfo.PatientID := GetRndStr(10);
|
||
|
|
//if Length(gDcmFileInfo.PatientDOB) < 1 then
|
||
|
|
//gDcmFileInfo.PatientDOB := GetRndDateStr(100);
|
||
|
|
//if Length(gDcmFileInfo.PatientSex) < 1 then
|
||
|
|
//begin
|
||
|
|
// if Odd(Random(10)) then
|
||
|
|
// gDcmFileInfo.PatientSex := 'M'
|
||
|
|
// else
|
||
|
|
// gDcmFileInfo.PatientSex := 'F';
|
||
|
|
//end;
|
||
|
|
|
||
|
|
WriteLogText(44, 'I', 'Start convert target file [' + gTargetDcmFile + ']');
|
||
|
|
if Length(gTargetDcmFile) < 1 then
|
||
|
|
begin
|
||
|
|
if gDebugConvert then
|
||
|
|
Result := SaveDcmFile(gAppPath + 'DCMOUT_' + FormatDateTime('yyyyMMdd_hhnnss_zzz', Now) + '.dcm', gDcmFileInfo);
|
||
|
|
end
|
||
|
|
else
|
||
|
|
begin
|
||
|
|
if FileExists(gTargetDcmFile) then
|
||
|
|
DeleteFile(gTargetDcmFile);
|
||
|
|
Result := SaveDcmFile(gTargetDcmFile, gDcmFileInfo);
|
||
|
|
end;
|
||
|
|
|
||
|
|
WriteLogText(44, 'I', 'ProcessDataDSP done');
|
||
|
|
end;
|
||
|
|
|
||
|
|
procedure ReadConfigFile(aIniFile: string);
|
||
|
|
var
|
||
|
|
iCfg : TIniFile;
|
||
|
|
begin
|
||
|
|
iCfg := TIniFile.Create(aIniFile);
|
||
|
|
try
|
||
|
|
gLogLevel := iCfg.ReadInteger('DfcDatz', 'LogLevel', 0);
|
||
|
|
gDcmCharacterSet := iCfg.ReadString('DfcDatz', 'DcmCharacterSet', gDcmCharacterSet);
|
||
|
|
gDcmUIDPreFix := iCfg.ReadString('DfcDatz', 'DcmUIDPreFix', gDcmUIDPreFix);
|
||
|
|
gDcmWriteNullPIID := Str2BoolDef(iCfg.ReadString('DfcDatz', 'DcmWriteNullPIID', ''), gDcmWriteNullPIID);
|
||
|
|
gDcmWriteSeriesDescription := Str2BoolDef(iCfg.ReadString('DfcDatz', 'DcmWriteSeriesDescription', ''), gDcmWriteSeriesDescription);
|
||
|
|
gDcmMemDump := Str2BoolDef(iCfg.ReadString('DfcDatz', 'MemDump', '0'), gDcmMemDump);
|
||
|
|
except
|
||
|
|
end;
|
||
|
|
iCfg.Free;
|
||
|
|
if gLogLevel < 0 then gLogLevel := 0;
|
||
|
|
if gLogLevel > 100 then gLogLevel := 100;
|
||
|
|
end;
|
||
|
|
|
||
|
|
begin
|
||
|
|
ExitCode := 9999;
|
||
|
|
SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOGPFAULTERRORBOX or SEM_NOOPENFILEERRORBOX);
|
||
|
|
try
|
||
|
|
CoInitialize(nil);
|
||
|
|
gLogLevel := 10;
|
||
|
|
gPSInStr := '';
|
||
|
|
gPPInStr := '';
|
||
|
|
gAppFile := ParamStr(0);
|
||
|
|
gAppPath := ExtractFilePath(gAppFile);
|
||
|
|
gAppFile := ExtractFileName(gAppFile);
|
||
|
|
gLogFile := ChangeFileExt(gAppFile, '.log');
|
||
|
|
gCfgFile := gAppPath + ChangeFileExt(gAppFile, '.ini');
|
||
|
|
gDcmUIDPreFix := DICOM_UIDPRE_HEAD;
|
||
|
|
gDcmWriteSeriesDescription := True;
|
||
|
|
gDcmWriteNullPIID := True;
|
||
|
|
gTaskInitP1 := True;
|
||
|
|
gTaskInitP2 := False;
|
||
|
|
gDcmMemDump := False;
|
||
|
|
gDebugOutput := False;
|
||
|
|
gDebugConvert := False;
|
||
|
|
gTargetDcmFile := '';
|
||
|
|
gDcmCharacterSet := '';
|
||
|
|
gLogWriteMutex := CreateMutex(nil, False, 'hmDfcDatzLogwMutex');
|
||
|
|
ReleaseMutex(gLogWriteMutex);
|
||
|
|
ExitCode := 9000;
|
||
|
|
|
||
|
|
Randomize;
|
||
|
|
if FileExists(gCfgFile) then
|
||
|
|
ReadConfigFile(gCfgFile);
|
||
|
|
WriteLogText(44, 'I', '.');
|
||
|
|
WriteLogText(44, 'I', 'Application started');
|
||
|
|
|
||
|
|
WriteLogText(44, 'I', 'Application ParamCount=' + IntToStr(ParamCount));
|
||
|
|
if ParamCount > 1 then
|
||
|
|
begin
|
||
|
|
ExitCode := 8000;
|
||
|
|
|
||
|
|
//����1��ѡ����Ϣ����
|
||
|
|
//����2���ļ���Ϣ����<XML><ODSP><EXESIN Type="0" OutputFile="D:\Data\OutFile.dcm" TaskID="012345"/></ODSP></XML>
|
||
|
|
gPPInStr := ParamStr(1);
|
||
|
|
gPSInStr := ParamStr(2);
|
||
|
|
|
||
|
|
if ParamCount > 2 then
|
||
|
|
begin
|
||
|
|
for nI := 3 to ParamCount do
|
||
|
|
begin
|
||
|
|
if (UpperCase(ParamStr(nI))='/DEBUGCONVERT') or
|
||
|
|
(UpperCase(ParamStr(nI))='-DEBUGCONVERT') then
|
||
|
|
begin
|
||
|
|
gDebugConvert := True;
|
||
|
|
WriteLogText(44, 'I', 'Application DebugConvert = True');
|
||
|
|
end
|
||
|
|
else if (UpperCase(ParamStr(nI))='/DEBUGOUTPUT') or
|
||
|
|
(UpperCase(ParamStr(nI))='-DEBUGOUTPUT') then
|
||
|
|
begin
|
||
|
|
gDebugOutput := True;
|
||
|
|
WriteLogText(44, 'I', 'Application DebugOutput = True');
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
ClearDcmFileInfo(gDcmFileInfo);
|
||
|
|
if Length(gPPInStr) < 30 then
|
||
|
|
begin
|
||
|
|
InitXMLP1Info('');
|
||
|
|
end
|
||
|
|
else
|
||
|
|
begin
|
||
|
|
if gDebugOutput then
|
||
|
|
begin
|
||
|
|
WriteLogText(44, 'D', DecStr(gPPInStr, ''));
|
||
|
|
WriteLn(DecStr(gPPInStr, ''));
|
||
|
|
end;
|
||
|
|
InitXMLP1Info(DecStr(gPPInStr, ''));
|
||
|
|
ExitCode := 7000;
|
||
|
|
end;
|
||
|
|
|
||
|
|
if Length(gPSInStr) < 30 then
|
||
|
|
begin
|
||
|
|
if gDebugConvert then
|
||
|
|
begin
|
||
|
|
case gDcmFileInfo.DICOMType of
|
||
|
|
3010:
|
||
|
|
gPSInStr := 'OutFileVision.dcm';
|
||
|
|
3020:
|
||
|
|
gPSInStr := 'OutFileIOP.dcm';
|
||
|
|
3030:
|
||
|
|
gPSInStr := 'OutFileRefraction.dcm';
|
||
|
|
else
|
||
|
|
gPSInStr := 'OutFileOther[' + IntToStr(gDcmFileInfo.DICOMType) + '].dcm';
|
||
|
|
end;
|
||
|
|
|
||
|
|
gPSInStr := '<XML><ODSP><EXESIN Type="0" OutputFile="' + gPSInStr + '" TaskID="80130' + IntToStr(nPPLen) + '"/></ODSP></XML>';
|
||
|
|
|
||
|
|
WriteLn(gPSInStr);
|
||
|
|
gPSInStr := EncStr(gPSInStr, '');
|
||
|
|
InitXMLP2Info(DecStr(gPSInStr, ''));
|
||
|
|
end;
|
||
|
|
end
|
||
|
|
else
|
||
|
|
begin
|
||
|
|
if gDebugOutput then
|
||
|
|
begin
|
||
|
|
WriteLogText(44, 'D', DecStr(gPSInStr, ''));
|
||
|
|
WriteLn(DecStr(gPSInStr, ''));
|
||
|
|
end;
|
||
|
|
InitXMLP2Info(DecStr(gPSInStr, ''));
|
||
|
|
ExitCode := 6000;
|
||
|
|
end;
|
||
|
|
|
||
|
|
ExitCode := 2000;
|
||
|
|
if ProcessDataDSP then
|
||
|
|
ExitCode := 1000
|
||
|
|
else
|
||
|
|
ExitCode := 1999;
|
||
|
|
|
||
|
|
CoUnInitialize;
|
||
|
|
WriteLogText(44, 'I', '..');
|
||
|
|
except
|
||
|
|
ExitCode := 9998;
|
||
|
|
end;
|
||
|
|
//Readln;
|
||
|
|
end.
|