Help Required in Import Convertors and Lua

  • Hi


    I am using Lua script to modify the Patient ID. This part is working. But when the images are saved on the disk they are saved with the old Patient ID.


    For example : If my DR machine is sending the DICOM Data with the Patient ID:: AA_BCDE_123 or AA-BCD-12. Whereas in our EMR we have PatientID as AA/BCDE/123 or AA/BCD/12.

    The images are saved with the Patient ID AA/BCDE/123 or AA/BCD/12 in Database but physically they are saved as AA_BCDE_123 or AA-BCD-12.

    The File Name Syntax i am using is as follow:-

    FileNameSyntax = %studydate[6,7]-%studydate[4,5]-%studydate[0,3]\%id-(%name)\%VSeriesDescription\%series%counter.dcm


    [lua]

    ImportConverter0 = dofile(updatepatid.lua')


    patid.lua


    PatientID= Data.PatientID

    Data.PatientID = string.gsub(Data.PatientID, '_', '/')

    Data.PatientID = string.gsub(Data.PatientID, '-', '/')


    And secondly, if i want to modify already saved data (there are around 25,000 studies), please also guide in this regard also.


    --HM

  • hammad I've had a similar challenge in the past and was never quite able to come to the right workable solution. Marcel has a stickied post on the forum about not changing patient IDs in this manner. I didn't like the UID regeneration so I never actually went through with it.


    Why not to change patientID of a dicom image


    Adding to the complexity depending on your use-case, you end up also with the object in memory with metadata different than the object on disk.

    I really would like the ability to control the data like you, but cq's architecture doesn't support it.


    You could update the Lua (or call another) and have it rename the folders as it updates the objects.


    I've not tried it and the idea only came to me while writing this, but you may be able to have the ImportConverter do something a bit tricky.


    pseudo

    ImportConverter0 = Update Patient ID, Delete stored study(not destroy!), forward study-level to ImportConverter1

    ImportConverter1 = Whatever your normal importconverter rule would be



    As for modifying your saved data, I've got no experience there so I'd be hacking it together probably with an OS-hosted script.

  • Thanks Garlicknots


    For your prompt reply . I am not that much into programming now a days.


    I decided go leave it as it is as my end user was able to query the study on new patient id.


    As far as your guidance is concerned i never used SQL Update command in lua. If you can share a sample of it i can play around and share the finalized version of the script if i get it.


    --HM

  • Hi Marcel


    I totally agree with your stance of not changing the Patient ID. But if you are facing problem in integrating PACS Server with your HIMS then you have to do so. My question was , as mentioned in the manual and on forums in number of posts that ImportConvertor runs first before saving any data on the hard disk. The ImportConvertor works fine as per our desire but the folder name is not update as per new Patient ID. In this case (i might be wrong), the incoming images are saved first and then import convertor runs??


    Please guide me.


    --HM

  • Hi,


    the filename is generated for each image UID once. When an image with the same UID is stored again it goes to the same folder. Delete the patient and then reimport to change the folder.


    regards


    Marcel

Participate now!

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