Looking the React Image Annotation library as the one I have pulled in the MFE, it seems not to provide drawing function, seemingly thinking about the scope between Clicking & Drawing
Hi
I implemented conditional rendering of an image either as an activeImage from the usercontext or uploading from the users local machine;
About persisting the diagram as a complex obs, I think I can use the exposed endpoints of the attachment-module(though it would requre a functionality within forms)
Any suggestions on improvement of the ui especially before choosing a file to render when no image has been fetched for a specific user context/patient
I was thinking about three workarounds to allow for its use in forms;
Natively supporting the widget in the form engine(one as POC)
Making it as an extension (extension slots in the form)
having it invoked from the workspace tools
The question is how is the feature going to be used?
const handleSaveAnnotations = async (annotations: ImageData[]) => {
// Serialize the annotations to SVG
const serializedSvg = annotationsToSVG(annotations);
try {
const patientUuid = "736e8771-e501-4615-bfa7-570c03f4bef5";
// Make an API request to save the serialized SVG using the custom createAttachment function
await createAttachment(patientUuid, {
file: new File([serializedSvg], "serialized.svg"),
fileName: "serialized.svg",
fileType: "image/svg+xml",
fileDescription: "Serialized SVG",
base64Content: "",
});
//Todo
// Handle errors or show an succes notification to the user
} catch (error) {
//Todo
// Handle errors or show an error notification to the user
}
//TODO
// display the serialized SVG.
};
backend code
The patientUuid seems well passed to the createattachement function
But the response from the server seems not understood
" a patient paramater must be provided to upload attachment"
The Error “must provide patient” was resolved. it turns out that I was using the demo server and the patient was not exixtent on the database.
So an attachment is able to be saved to the server thanks @Heshan Andrews for the pair program
added diagram rendering and preview in the form engine
PR here;
NEXT STEPS;
annotation button on the rendered image/diagram
Integration and opening annotation tool in new tab on clicking annotate
save → original image replaced with new annotated image
The Goal;
embed a diagram/image with some kind of annotation button(onclick(),take the user to the drawing-widget(in new tab using a url paramater to pass info) that has the ability to annotate images).
Saving the annotated image through the drawing-widget would substitute the original diagram with its annotated version.
Whether the annotation button is ever used or not, the diagram is submitted as a complex obs as part of the form’s submission process.
Trigger the drawing widget with state like image path
PR here for details;
Wondering if there could be a util function within the patient-commons-lib to set or make the trigger
The silver lining here is how to effectively communicate between the from and the drawing widget i.e pass on the image picked on the form to the drawing unit and back with annotations