Reformat Patient ID & Patient Name

  • Hi Marchel,


    Thank you for your wonderful server software, we've been using it for nearly 3 months in our hospital with more than 300 radiological examinations a day, and it's still going strong!


    However, in our daily use, we've encountered several problems. When I checked our daily ServerTrouble, they're mainly create Inconsistent Data error... I really hope I could find some help from you here.


    1. Regarding Patient ID, the correct format was 01234567 (8 digit patient ID with no space, no period in between, and a leading 0 if the numbers are only 7). However, some of our technologist/radiographers often input the wrong format such as :
    - Inputting only 7 numbers without the leading 0, ie 1234567
    - Inputting 8 number with the leading 0 but with periods in-between, ie 01.23.45.67
    - Combination of two above, ie 1.23.45.67


    The addition of periods is devastating as it renders our viewer (Radiant) unable to find corresponding patient in the servers. Is there any way to convert the incorrect Patient ID on-the-fly to the correct format. I'm thinking like :
    a. Check whether there's period in-between, if yes then remove all the periods
    b. Then check the numbers, if it's less than 8 numbers then calculate the missing zeroes (ie 12345 then it's missing 8-5 = 3 leading zeroes), and then add a certain amount of leading zeroes


    Is there any correct way to do this? Please shed some light on this..


    2. Regarding patient name, some of our modalities add '^' character to replace spaces between words. I don't know whether this is the standard currently, as most of our newer modalities use this kind of approach. It also doesn't affect the capability of Radiant to search through the database. But for the sake of uniformity, we would like to replace the '^' character with space as we don't use first name-family name in our country. Is it doable on-the-fly also? How can we achieve that?


    I'm sorry for a bit long post, we glad we find your software which does pretty well for what we want to do. Thank you in advance and thank you once again for the wonderful piece of software.

  • Hi,


    you best bet is to use Lua string processing in an ImportConverter. See previous posts with string.gsub. However, if the operators make these kind of mistakes they also might mix up patient ID's. So do be careful.


    This code goes below dicom.ini (first stop the server, edit the file and restart it).


    Code
    [lua]
    ImportConverter0 = Data.PatientID=string.gsub(Data.PatientID, '%.' , ''); if string.len(Data.PatientID)==7 then Data.PatientID = '0' .. Data.PatientID
    ImportConverter1 = Data.Patientname=string.gsub(Data.PatientID, '%^' , ' ')


    Marcel

  • Hello Marchel,


    Sorry for the late reply..


    First of all, I'd like to confirm that you mistyped in your sample code, where you wrote like this :


    ImportConverter1 = Data.Patientname=string.gsub(Data.PatientID, '%^' , ' ')


    in which I think it should be : ImportConverter1 = Data.Patientname=string.gsub(Data.Patientname, '%^' , ' ')


    Then, I tried to insert your code to my Dicom.Ini file but got the following error :


    [SERVER] *** lua syntax error [string "Data.PatientID=string.gsub(Data.PatientID, '%.' , ''); if strin..."]:1: 'end' expected near '<eof>' in 'Data.PatientID=string.gsub(Data.PatientID, '%.' , ''); if string.len(Data.PatientID)==7 then Data.PatientID = '0' .. Data.PatientID'
    [SERVER] *** lua run error [string "Data.Patientname=string.gsub(Data.Patientna..."]:1: bad argument #1 to 'gsub' (string expected, got nil) in 'Data.Patientname=string.gsub(Data.Patientname, '%^' , ' ')'


    Could you please enlighten me where did I get wrong here?


    Thank you very much!

  • Sorry for the typos:


    try:


    Code
    [lua]
    ImportConverter0 = Data.PatientID=string.gsub(Data.PatientID, '%.' , ''); if string.len(Data.PatientID)==7 then Data.PatientID = '0' .. Data.PatientID end
    ImportConverter1 = Data.PatientName=string.gsub(Data.PatientName, '%^' , ' ')


    Lua is case sensitive.


    Marcel

  • Thank you very much Marchel. I've tried your code and it works just as expected!


    One question though, if I have an ExportConverters to forward a study to another machine, will the study undergo ImportConverters first (fix the PatientID and PatientName) before being forwarded to another machine?


    Thank you once again! I may need to start studying Lua in order to fully customized my server..

Participate now!

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