Storage on Basis on Institution Name

  • Hi


    Objective: To Store patient images in separate locations on the basis of Institution Name


    I tried to use the old script that was provided in the forum to store images on the basis of Modality type. I used the same code with minor modification but i got error.


    ImportConverter0 = if Data.Institution Name=='Hospital Name A' then Data.Storage='MAG1' end;


    MAG1 is already defined at top. I also tried this


    ImportConverter0 = if Data.Institutio=='Hospital Name A' then Data.Storage='MAG1' end;


    But i got the error appended below:-


    [PACS] *** lua syntax error [string "if Data.Institution Name=='dPJ' then Data.Storage='MAG1' end;"]:1: 'then' expected near 'Name' in 'if Data.Institution Name=='dPJ' then Data.Storage='MAG1' end;'


    Please guide me where i am committing the mistake as the error says its a syntax error and i am beginner in LUA.


    Second Question is If my hospital name is like Hospital Name A (Spaces in Hospital Name) and i defined MAG like E:\Hospital Name A (in windows) will this work or give me error.


    Thirdly, i have 15 hospitals that will connect to this PACS Server and wanted to save images of them in their respected folders whereas conquest only support max 0 to 9 importconvertors how will i manage rest of hospitals.


    --Hammad

  • Thanks Marcel


    I update the lua script but it doesn't work. Conquest doesn't save the file on the require location.I am getting following error in conquest .



    [PACS] Rewritten file: E:\images\20121218\12295-(M_ZEESHAN)\COR_3_MM\010400fb.dcm
    [PACS] Importconverter-1.0: sets preferred storage to MAG1
    [PACS] Rewritten file: E:\images\20121218\12295-(M_ZEESHAN)\COR_3_MM\010400fc.dcm
    [PACS] Importconverter-1.0: sets preferred storage to MAG1
    [PACS] Rewritten file: E:\images\20121218\12295-(M_ZEESHAN)\COR_3_MM\010400fd.dcm


    Whereas my dicom.ini file says


    MAGDevices = 5
    MAGDevice0 = E:\images\
    MAGDevice1 = e:\QIH\
    MAGDevice2 = e:\ct\
    MAGDevice3 = e:\mr\
    MAGDevice4 = e:\mg\


    NightlyCleanThreshhold = 0
    NightlyMoveThreshhold = 0
    NightlyMoveTarget =



    [lua]
    ImportConverter0 = if Data.InstitutionName == 'dPJ' then Data.Storage='MAG1' end;


    Please guide me where i am committing the mistake.


    My other questions remained unanswered. Please answer them also .


    --Hammad

  • Thanks Marcel after deleting the patient and sending it again its saved now. Will now test it again for different hospital names


    1. How many MAG Devices can i add?
    2. I had 15 hospitals now and more will be added in the near future. How i will add more than 9 importconvertors in coquest.
    3. Can i connect unlimited modalities and workstation with conquest.
    4. I want prefetching on the basis of Study Description and only last two studies should be prefetched at a designated workstation. For example a CT Scan chest is performed. then last two CT Chest studies should be fetched if no CT Chest study is found then last two studies with study description Chest should be prefetched. I want this for every study that is retrieved from conquest.


    --Hammad

  • Okie...


    If i use the following commands the images are not stored in the required location.


    dgate.exe -p5678 -q127.0.0.1 --addimagefile:E:\upload\12295-(M_ZEESHAN).zip


    dgate.exe -p5678 -q127.0.0.1 --addlocalfile:E:\upload\12295-(M_ZEESHAN).zip



    Can you guide me how can i use the following command in lua script. That must be executed every time user retrieve images from server


    dgate.exe -p5678 -q127.0.0.1 --prefetch:12-34-56


    I want to add study description option in this.


    --Hammad

  • If i use the following commands the images are not stored in the required location which i configured in the dicom.ini file.


    dgate.exe -p5678 -q127.0.0.1 --addimagefile:E:\upload\12295-(M_ZEESHAN).zip


    dgate.exe -p5678 -q127.0.0.1 --addlocalfile:E:\upload\12295-(M_ZEESHAN).zip


    Secondly, tell me the command you told me servercommand('prefetch ....') please tell me the complete syntax of the command. Should it be like


    dgate,exe servercommand('prefetch ....'). Is this syntax correct.


    --Hammad

  • Hi Marcel


    Can you guide me how can i achieve this :-


    I am saving studies on Patients on basis of Hospital Name in separate folders defined in dicom.ini. Now i want to further drill down and make sub folders on basis of modality. like


    Hospital A
    |_ CT
    |_ MRI
    |_ CR

    Hospital B
    |_ CT
    |_ MRI
    |_ CR


    I tried following import convertor but i got the error
    * lua syntax error [string "if Data.InstitutionName == 'ABC Hospital' then"]:1: 'end' expected near '<eof>' in 'if Data.InstitutionName == 'ABC' then'
    [PACS] Importconverter-1.0: sets preferred storage to MAG6


    my dicom.ini file is :


    MAGDevice0 = E:\images\
    MAGDevice1 = E:\ABC\CT\
    MAGDevice2 = E:\UMC\
    MAGDevice3 = E:\hY9\
    MAGDevice4 = E:\LAT\
    MAGDevice5 = E:\dPJ\
    MAGDevice6 = E:\ABC\



    [lua]
    global = print ('hello world');


    ImportConverter0 = if Data.InstitutionName == 'ABC' then
    if Data.Modality=='CT'
    Data.Storage='MAG1' end;


    and secondly instead of defining separate MAG Devices like MAGDevice1 = E:\ABC\CT\ is it possible that i simple define MAGDevice1 = E:\ABC\ and modality wise folders liek CT, MRI are created runtime.


    Please guide...

  • Thanks...


    MAGDevice1 = E:\QIH\CT\
    .
    .
    MAGDevice6 = E:\QIH\


    ImportConverter0 = if Data.InstitutionName == 'ABC'and Data.Modality=='CT' then Data.Storage='MAG6' end;


    This is working fine with your guidance. Can you guide me how can i add Modality at the end of MAG. Instead of defining MAG1 i will prefer to use MAG6... But you will add CT at the end of MAG6. So that images are saved in E:\QIH\CT\ (Folder CT was already created.)

  • Okie. But can you guide me how can i do the following in lua script .


    MAGDevice1 = E:\QIH\


    I simply want to cat Modality Data Type with MAG Device.


    ImportConverter0 = if Data.InstitutionName == 'ABC' and Data.Modality=='CT' then Data.Storage='MAG1'..'CT' end;


    But this throw error as server takes MAG1 as a string not drive root folder path.

  • You can't. Magdevice is root (fixed path), the rest comes from filenamesyntax. From manual:


    Note: since 1.4.11, FileNameSyntax may also be string containing % that is treated as flexible
    filenamesyntax. e.g., %id\%studyid\%seriesid\%sopuid.dcm.
    This string may contain: %name=(0010,0010), %id=(0010,0020), %modality=(0008,0060),
    %studyid=(0020,0010), %studyuid=(0020,000D), %seriesid=(0020,0011), %series=(0020,0011) with 4
    digits, %seriesuid=(0020,000E), %sopuid=(0008,0018), %imagenum=(0020,0013),
    %image=(0020,0013) as 6 digit integer, %imageid=(0054,0400), %studydesc=(0008,1030), %time,
    %counter = (4 digit hex), %calledae, %callingae, %studydate, %date (current date in yyyymmdd). Any
    of these items can be followed by e.g., [0,3] which is a substring operator, e.g., %studydate[0,3] gives
    the year, %studydate[4,5] gives the month. Also you can use parameter %vggggg,eeee to read any
    dicom element to be used in generating the filename. For the syntax of the %v option (e.g., to read items
    in a sequence), see the description of ImportConverters. Any other text is treaded literally – be careful to
    use only characters allowed in filenames plus the correct path separator: \ for Windows, and / for Linux.

  • Marcel thanks for the prompt reply. I might not be able to explain my question. Filesyntax are working fine for me as you described in your last posting.


    I want to make some things dynamic instead of hard coding just like MAGDevice. With you help i had modified the lua script and now i can save images on the basis of institution and further on Modality. This is working fine. But all these configuration is hard coded and i also have to keep in mind the limitation of MAG devices i can define is 9 whereas Importconvertors are 0 to 99. To overcome this limitation i had configure MAG Devices on the name of hospitals and this is working fine. For my Management i further drill down to sagerate on the basis of modality.


    I am using this lua script in my dicom.ini


    ImportConverter0 = if ( (Data.InstitutionName == 'ABC') and (Data.Modality=='CT')) then Data.Storage='MAG3 'print ('I am in institution name 2 block') else print ('I am in else block') end;


    Here MAG3 is hard coded. I had use everything which i think was logically possible like defining a variable named path and then concat it modality type like


    path = MAG6; and also i use this path = "E:\ABC\";


    ...... Data.Storage=MAG6..'CT' or ...... Data.Storage=MAG6..Data.Modality or...... ...... Data.Storage=path..'CT' or Data.Storage=path..Data.Modality or ..... ...... Data.Storage=MAG6..'%m' or or ..... ...... Data.Storage=path..''%m'

    none of the commands work for me . On debugging it treats MAG6 as string not reading its path it simply prints MAG6/CT.


    Some how you guide me how can i get the value of MAG Device in a lua script. I had read the windows manual and also searched forum but no supportive post was found.

  • Hi,


    you can use a lua script in filenamesyntax to generate the filename. e.g. filenamesyntax = lua:dofile('makefilename.lua'). Then you are totally flexibole, but you need to do all processing (e.g. remove offending characters for a filename) by yourself.


    Marcel

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!