edit ip pdf dan cloud
This commit is contained in:
@@ -26,6 +26,15 @@ const CornerstoneViewportDownloadForm = ({
|
||||
const activeViewportElement = enabledElement?.element;
|
||||
const activeViewportEnabledElement = getEnabledElement(activeViewportElement);
|
||||
|
||||
// console.log('cornerstoneViewportService', cornerstoneViewportService);
|
||||
const viewportInfo = cornerstoneViewportService.getViewportInfo("default");
|
||||
// console.log('viewportInfo', viewportInfo);
|
||||
|
||||
// Retrieve StudyInstanceUID from viewportInfo
|
||||
const StudyInstanceUID = viewportInfo.getViewportData().data[0].StudyInstanceUID;
|
||||
const SetInstanceUID = viewportInfo.getViewportData().data[0].displaySetInstanceUID;
|
||||
// console.log('StudyInstanceUID', StudyInstanceUID);
|
||||
// console.log('SetInstanceUID', SetInstanceUID);
|
||||
const {
|
||||
viewportId: activeViewportId,
|
||||
renderingEngineId,
|
||||
@@ -108,6 +117,10 @@ const CornerstoneViewportDownloadForm = ({
|
||||
|
||||
const downloadCanvas = getOrCreateCanvas(element);
|
||||
|
||||
// Log the canvas content before conversion
|
||||
const context = downloadCanvas.getContext('2d');
|
||||
const imageData = context.getImageData(0, 0, downloadCanvas.width, downloadCanvas.height);
|
||||
|
||||
const type = 'image/' + fileType;
|
||||
const dataUrl = downloadCanvas.toDataURL(type, 1);
|
||||
|
||||
@@ -214,6 +227,43 @@ const CornerstoneViewportDownloadForm = ({
|
||||
});
|
||||
};
|
||||
|
||||
// New function to send annotation data
|
||||
const sendAnnotationData = async (base64Image, activeViewportElement) => {
|
||||
try {
|
||||
// Get the SOPInstanceUID from the active viewport
|
||||
const activeViewportEnabledElement = getEnabledElement(activeViewportElement);
|
||||
const imageId = activeViewportEnabledElement?.viewport?.getCurrentImageId();
|
||||
|
||||
if (!base64Image || !StudyInstanceUID) {
|
||||
throw new Error('Missing required data');
|
||||
}
|
||||
|
||||
const payload = {
|
||||
image: base64Image,
|
||||
StudyInstanceUID: StudyInstanceUID
|
||||
};
|
||||
|
||||
const response = await fetch('http://host:port/one-api/tools/annotation/store', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('Annotation data sent successfully:', data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error sending annotation data:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const downloadBlob = (filename, fileType) => {
|
||||
const file = `${filename}.${fileType}`;
|
||||
const divForDownloadViewport = document.querySelector(
|
||||
@@ -221,9 +271,16 @@ const CornerstoneViewportDownloadForm = ({
|
||||
);
|
||||
|
||||
html2canvas(divForDownloadViewport).then(canvas => {
|
||||
const dataUrl = canvas.toDataURL(fileType, 1.0);
|
||||
const base64Image = dataUrl.split(',')[1]; // Remove prefix 'data:image/png;base64,'
|
||||
|
||||
// Send annotation data
|
||||
sendAnnotationData(base64Image, activeViewportElement)
|
||||
.catch(error => console.error('Annotation data sending failed:', error));
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.download = file;
|
||||
link.href = canvas.toDataURL(fileType, 1.0);
|
||||
link.href = dataUrl;
|
||||
link.click();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,7 +6,8 @@ function OHIFCornerstonePdfViewport({ displaySets }) {
|
||||
var [url, setUrl] = useState(null);
|
||||
|
||||
const sopInstanceUid = displaySets[0].SOPInstanceUID;
|
||||
url = `http://128.199.154.150:8080/rid/IHERetrieveDocument?requestType=DOCUMENT&documentUID=${sopInstanceUid}&preferredContentType=application%2Fpdf`;
|
||||
url = `http://${window.config.pacs_document_host}:${window.config.pacs_document_port}/rid/IHERetrieveDocument?requestType=DOCUMENT&documentUID=${sopInstanceUid}&preferredContentType=application%2Fpdf`;
|
||||
console.log("URL PDF", url);
|
||||
|
||||
useEffect(() => {
|
||||
document.body.addEventListener('drag', makePdfDropTarget);
|
||||
|
||||
Reference in New Issue
Block a user