Use the retrieved instance to write dicom file using DICOMWeb™ Standard APIs

353 views Asked by At

I am new to Azure cloud services, I am using DICOMWeb™ Standard APIs I have an instance of the DICOM service deployed.I am using these APIs in Node js, I have successfully used requests like post (upload dicom image) and get (retrive instance of our uploaded dicom image). Now I want to use this retrived instance and convert it into actual dicom image using Node js.

Can you please guide, how can I save the retrived instance into actual dicom file I uploded earlier using node js?

Here is my node js code

code: `

const express = require('express');
const app = express();
const cors = require('cors');
app.use(express.json());
app.use(cors());
const axios = require('axios');
const fs = require('fs');
const util = require('util');
const writeFile = util.promisify(fs.writeFile);
const fileName = 'instance_file.dcm';

    var config = {
    method: 'get',
    url: '{my service url}/v1/studies/{studyUID}',
    headers: { 
    'Accept': 'multipart/related; type="application/dicom"; transfer-syntax=*', 
    'Authorization': 'Bearer {myToken}'
    }
    };

    axios(config)
    .then(function (response) {
    console.log("original response", response);

    //write file start
    try {
    const fileBytes = Buffer.from(response.data);
    writeFile('./images/red-triangle.dcm', fileBytes);
    console.log("file write successfully");
    } catch (err) {
    console.error("write file error=",err);
    }
    })
    .catch(function (error) {
    console.log(error);
    });
    ```

    \`

I have tried DICOMWeb™ Standard APIs get request and getting response in the form of bytes.
I want to convert this response and save it as actual dicom file which was uploaded first using post mothod.
0

There are 0 answers