Web server

  • Hi,


    I am thinking on expanding the rest api, looking at Orthanc for inspiration. Any ideas? My list sofar:

    Edit: propose to use HTTP commands, make more similar to Orthanc; will implement in Ladle first.


    -- remote server operations

    GET /api/dicom/modalities

    GET /api/dicom/modalities/:id

    PUT /api/dicom/modalities/:id

    POST /api/dicom/modalities

    DEL /api/dicom/modalities/:id

    GET /api/dicom/modalities/:modality/echo

    GET /api/dicom/rs/modalities/:modality/studies

    GET /api/dicom/rs/modalities/:modality/studies/:suid/series

    GET /api/dicom/rs/modalities/:modality/series

    GET /api/dicom/rs/modalities/:modality/studies/:suid/series/:euid/instances

    GET /api/dicom/rs/modalities/:modality/instances

    POST /api/dicom/rs/studies/:suid/series/:euid/instances/:ouid/move?target=AE

    POST /api/dicom/rs/studies/:suid/series/:euid/move?target=AE

    POST /api/dicom/rs/studies/:suid/move?target=AE


    -- delete

    DEL /api/dicom/rs/studies/:suid

    DEL /api/dicom/rs/studies/:suid/series/:euid

    DEL /api/dicom/rs/studies/:suid/series/:euid/instances/:ouid


    -- create zip file (optional anonymisation, parameters in query)

    GET /api/dicom/rs/studies/:suid/series/:euid/instances/:ouid/archive

    GET /api/dicom/rs/studies/:suid/series/:euid/archive

    GET /api/dicom/rs/studies/:suid/archive


    Marcel

  • In what sense? QIDO WADO and STOW are compliant, but I do not think the other items are in the dicom standard.


    Basically I want to create a nice interface for a web-based GUI, so I can also just make these private e.g. /api/conquest/modalities


    Marcel

  • Hi, Marcel


    Some of my users from conquest has no public IP.

    Then, I am trying to use ngrok to manage it.

    I have tried:

    Code
    > ngrok tcp 5678
    Session Status online Account Luiz Oliveira (Plan: Free) Version 2.3.40
    Region United States (us)
    Web Interface http://127.0.0.1:4040
    Forwarding tcp://2.tcp.ngrok.io:18444-> localhost:5678
    Connections ttl opn rt1 rt5 p50 p90 0 0 0.00 0.00 0.00 0.00

    If I use:

    F:\Programas\vuejs\nuxt-iclindoctor\server_iclindoctor\api\dicomapi>servertask -p5678 -hCONQUESTSRV1 -q127.0.0.1 "--dolua:dofile([[./queryfunctions.lua]]);echo([[CONQUESTSRV1]])"

    1

    works well.


    But if I use hostname It doesn´t work:


    F:\Programas\vuejs\nuxt-iclindoctor\server_iclindoctor\api\dicomapi>servertask -p5678 -hCONQUESTSRV1 -qtcp://2.tcp.ngrok.io:18444 "--dolua:dofile([[./queryfunctions.lua]]);echo([[CONQUESTSRV1]])"

    DICOM ERROR connect failed on socket level (called not running)


    F:\Programas\vuejs\nuxt-iclindoctor\server_iclindoctor\api\dicomapi>servertask -p5678 -hCONQUESTSRV1 -q2.tcp.ngrok.io:18444 "--dolua:dofile([[./queryfunctions.lua]]);echo([[CONQUESTSRV1]])"

    DICOM ERROR connect failed on socket level (called not running)



    when ngrok starts, It bind the IP to a port. I think the problem the port is changing from

    Code
    tcp://2.tcp.ngrok.io:18444-> localhost:5678

    Is possible conquest dgate support ngrok syntax "hostname:port" without '-p' parameter? I tried dgate without -p but I had the same problem.

  • Hm,


    I am not sure at all how to do this. The source code of servertask is quite simple. It maps directly to socket::open in socket.cxx. If you have any idea how to adjust it for ngrok that would be great. Socket prpgramming is not my strongest point.


    Marcel


  • Hi,


    I think the problem is here:

    //servertask.cxx

    else if (argv[i][1]=='h') strcpy(MYACRNEMA, argv[i]+2);

    else if (argv[i][1]=='p') strcpy(Port, argv[i]+2);

    else if (argv[i][1]=='q') strcpy(ServerCommandAddress, argv[i]+2);


    The argument hostname:port as "2.tcp.ngrok.io:18444" should be parsed to fill 'MYACRNEMA' and 'Port'


    I am not a C++ programmer and I dont have a PC with a stack dev tools mounted to try change it.

  • Hi, Marcel,


    I think I found the problem.

    If I use a IP all works well.

    But If I use a hostname, conquest is unable to resolve it to a IP and I get an error.


    For sample. This is ok:

    servertask -p10979 -hCONQUESTSRV1 -q3.132.159.158 "--dolua:dofile([[./queryfunctions.lua]]);echo([[CONQUESTSRV1]])"

    returns: 1


    But servertask -p10979 -hCONQUESTSRV1 -q6.tcp.ngrok.io "--dolua:dofile([[./queryfunctions.lua]]);echo([[CONQUESTSRV1]])"

    returns

    "DICOM ERROR connect failed on socket level (called not running)"


    Searching in Stackoverflow(https://stackoverflow.com/ques…ost-ip-address-from-a-url) C++ would need do something as below to get an IP when using hostname :


    On Linux

    C
    #include <stdio.h>
    #include <netdb.h>
    #include <arpa/inet.h>
    int main()
    {
    struct hostent *he=gethostbyname("www.stackoverflow.com");
    char *ip=inet_ntoa(*(struct in_addr*)he->h_addr_list[0]);
    printf(ip);
    }

    On Windows

    C
    #include <stdio.h>
    #include <winsock.h>
    int main()
    {
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2,2),&wsaData);
    struct hostent *he=gethostbyname("www.stackoverflow.com");
    char *ip=inet_ntoa(*(struct in_addr*)he->h_addr_list[0]);
    printf(ip);
    }

    I have tested resolving hostname to IP in node API and it works.

    Here is the node code:

    Code
    const { lookup } = require("dns").promises;
    const resolvehost = async (h) => {
      try {
        const result = await lookup(h);
        return result.address;
      } catch (e) {
        return "";
      }
    };

    What do you think to do it right into servertask?

  • In what sense? QIDO WADO and STOW are compliant, but I do not think the other items are in the dicom standard.


    Basically I want to create a nice interface for a web-based GUI, so I can also just make these private e.g. /api/conquest/modalities


    Marcel

    I can help you with node version if you need.

  • Hi,


    Ah, the problem is that 6.xxx looks like a numeric IP address to Gethostbyname in socket.cxx (it starts with a number and contains a .) I have updated the source to now scan for any character not . and 0-9. Can you try the adapted servertask.exe?


    Marcel

    Files

    • servertask.zip

      (211.54 kB, downloaded 90 times, last: )

    Marcel van Herk is developer of the Conquest DICOM server together with Lambert Zijp.

  • Hi,


    Ah, the problem is that 6.xxx looks like a numeric IP address to Gethostbyname in socket.cxx (it starts with a number and contains a .) I have updated the source to now scan for any character not . and 0-9. Can you try the adapted servertask.exe?


    Marcel

    Hi, Marcel,


    It works like a charm.


    Thanks,


    Luiz

  • Hi, Marcel

    I am back.


    In this route you use:

    -- query all studies on modality

    Code
    routes:get('/api/dicom/rs/modalities/:modality/studies', function (params)
    include('/api/dicom/rquery.lua')
    querystudies(request.query, params.modality)
    end )

    But, in 'querystudies' function you have:

    Code
    function querystudies($query) {
    $defaultTags = [
    "00080005", "00080020", "00080030",
    "00080050", "00080054", "00080056",
    "00080061", "00080090", "00081190",
    "00080201", "00100010", "00100020",
    "00100030", "00100040", "0020000D",
    "00200010", "00201206", "00201208"];
    processData($query, $defaultTags, array("99990C00"=>"PatientName"), "STUDY");
    }

    My question is where params.modality will be used?


    Another question os about 'remoteecho'. Are you executing a echo in a modality or in the server?

Participate now!

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