How to convert UUID/GUID to OID/DICOM UID in JavaScript?

前端 未结 3 782
梦毁少年i
梦毁少年i 2021-01-21 09:33

How can I convert an UUID/GUID value like 8348d2c5-0a65-4560-bb24-f4f6bcba601d (that I genreated with uuid v4) in to OID/DICOM UID like 2.25.17450698773882054

3条回答
  •  北海茫月
    2021-01-21 10:08

    Just in case you want library that serves the same purpose, you may use dicomuid.js written by samucs (StackOverflow profile).

    This does not require organization root prefix; this uses "2.25." as prefix. This uses Universally Unique Identifier (UUID). It converts the UUID to a single large decimal number.

    Following is the code copied from github:

    // Create new DICOM UID.
    // Result will be like 2.25.176371623884904210764200284661930180516
    var uid1 = DICOMUID.create();
    
    // Create DICOM UID from a RFC4122 v4 UUID.
    // Result for line below is 2.25.329800735698586629295641978511506172918
    var uid2 = DICOMUID.create("f81d4fae-7dec-11d0-a765-00a0c91e6bf6");
    

提交回复
热议问题