Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving Measurements via SR from OHIF #89

Open
nutzlastfan opened this issue Mar 8, 2020 · 10 comments
Open

Saving Measurements via SR from OHIF #89

nutzlastfan opened this issue Mar 8, 2020 · 10 comments

Comments

@nutzlastfan
Copy link
Contributor

nutzlastfan commented Mar 8, 2020

Hello,

is it possible at the Moment to save measurements from OHIF Viewer with DicomCloud ?
Currently a least for me it is not working:

POST http://...8081/..WebApi/api/studies 415 (Unsupported Media Type)
dataExchange.js:73 [DICOMSR] Error while saving the measurements: request failed

The Post is send without a studyinstance id.

In DICOMCloud it ends up with a UnsupportedMediaType exception.

public async Task Post(string studyInstanceUID = null)
.....
if (!Request.Content.IsMimeMultipartContent("relate"))
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}

Is my configuration a fault here or something else ?

Thanks in advance.

@Zaid-Safadi
Copy link
Member

Hey @nutzlastfan , can you please attach the request headers from the store request? You can get these from the developer console network tab

@nutzlastfan
Copy link
Contributor Author

Ok, here is an example:

POST /WadoWebApi/api/studies HTTP/1.1 Host: ...:8081 Connection: keep-alive Content-Length: 4661 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Content-Type: multipart/related; type=application/dicom; boundary=64f60944-8be0-f031-3fc5-66eba78f402c Accept: */* Origin: http://..:8081 Referer: http://..:8081/viewer/1.2.276.0.74.1.2.209227.219243.132281559767744872637192791767744 Accept-Encoding: gzip, deflate Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7 Cookie: i18next=de-DE; SAPWP_active=1

@Zaid-Safadi
Copy link
Member

OK, the request looks fine and the content-type header value is correct. What seems to be wrong is the line you posted from DICOMcloud, I am not sure why the code you have has the value "relate" instead of "related":

if (!Request.Content.IsMimeMultipartContent("related"))

            if (!Request.Content.IsMimeMultipartContent("related"))
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

@nutzlastfan
Copy link
Contributor Author

nutzlastfan commented Mar 11, 2020

it was autocorrected from a browser plugin, in the code it is the right spelling
if (!Request.Content.IsMimeMultipartContent("relate"))

@Zaid-Safadi
Copy link
Member

@nutzlastfan, check this: dcmjs-org/dcmjs#113

@nutzlastfan
Copy link
Contributor Author

nutzlastfan commented Mar 18, 2020

Ok, thanks for looking this up, I would have never thought of that as a possibility.

@wangning08115
Copy link

@nutzlastfan Have you solved the problem? I want Saving Measurements via SR from OHIF. And i am research start.
Can you help me provide some information?

@nutzlastfan
Copy link
Contributor Author

nutzlastfan commented Jul 19, 2020

Not recommended just for reference since the problem comes from ohif implementation not dicomcloud:

if (!Request.Content.IsMimeMultipartContent("related"))
        {
            var length = Request.Content.Headers.ContentLength.HasValue ? Request.Content.Headers.ContentLength.Value : -1L;
            byte[] byteBuffer = new byte[Request.Content.Headers.ContentLength.Value];
            byteBuffer = await Request.Content.ReadAsByteArrayAsync();
            string formData = System.Text.Encoding.ASCII.GetString(byteBuffer);
            string boundary = "\r\n" + Request.Content.Headers.ToString().Split(new string[] { "boundary=" }, StringSplitOptions.None)[1];
            string[] parts = System.Text.RegularExpressions.Regex.Split(formData, boundary);
            int dataOffset = 0;
            for (int i = 0; i < parts.Length; i++)
            {
                string header = parts[i].Substring(0, parts[i].IndexOf("\r\n\r\n"));
                dataOffset += header.Length + 4;
                string asciiBody = parts[i].Substring(parts[i].IndexOf("\r\n\r\n") + 4);
                int pos = asciiBody.IndexOf("--");
                byte[] body = new byte[pos-10];
                for (int j = dataOffset, k = 0; j < body.Length + (dataOffset)  ; j++)
                {
                    body[k] = byteBuffer[j];
                    k++;
                }
                return await StorageService.StoreSR(body);      
            }
        }

Body is essentially the structured report in byte[] form that you can just open in fo-dicom or save to disk etc.

@Dev-Now
Copy link
Contributor

Dev-Now commented Sep 28, 2020

@Zaid-Safadi Looks like Dicomcloud has no support for SR... It just treats SR store requests like an image store request.

Any upcoming plans to support SR?

@Zaid-Safadi
Copy link
Member

@Dev-Now responded at your ticket. thanks for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants