Report Generation API
The Report Generation API is designed to facilitate the creation of secure, encrypted links and optionally QR codes for accessing clinical reports within the MD.ai reporting application. By sending a POST request with the necessary clinical tags, users can quickly generate the required report links. Additionally, a QR code image can also be generated for easy sharing and scanning. It is designed to be straightforward and flexible, enabling seamless integration into various applications and workflows.
To integrate and generate new reports using our API, you will need a SiteID
specific to your organization that will be provided to you by MD.ai. Ensure you have this identifier before proceeding.
Method: POST
API endpoint: https://chat.md.ai/api/report/launch/clinical
Request Header
Generating MD.ai access tokens
The MD.ai access token can be generated by logging in to chat.md.ai, clicking your user avatar on the top right corner, and going to User Settings -> Access tokens. Make sure to add this token to the header as x-access-token
for authentication, otherwise the request will fail.
Request Body
- clinicalInfo: A dictionary object that stores the clinical information/tags required for report creation that are related to the exam/study. The list of supported tags is given below - (required)
clinicalInfo:
SiteID: Unique identifier for your organization (will be provided by MD.ai)
PatientMRN: Unique patient identifier or Patient MRN
Accession: Unique report identifier or Accession Number
PatientName: Name of the patient
PatientBirthDate: DOB of the patient
PatientAge: Age of the patient
PatientSex: Sex of the patient
Modality: Modality of the study eg. CT, MR etc
BodyPartExamined: Body part of interest for the report
StudyDescription: Brief description of the study
StudyDate: Date when the study was performed
StudyTime: Time of the study
StudyInstanceUID: Study UID of the imaging study related to the report
ReasonForExam: Reason for ordering the exam or patient history/symptoms.
KeyFindings: Draft report or text that you want to pre-populate the report with.
ReferringPhysician: Name/Credentials of the patient's referring physician
ReportingPhysician: Name/Credentials of the patient's reporting physician
- reportingApp: A dictionary object that stores parameters related to configuring the MD.ai reporting application such as defining the format in which the final report needs to be sent back (eg. HL7) or setting the speech-to-text and UI language. The list of parameters is given below - (required)
reportingApp:
ReturnFormat: Format for returning the report back to your system. "HL7" is supported.
SpeechLanguage: Language used for dictation and speech recognition. Ensures the speech-to-text system processes spoken inputs in the correct language.
AppLanguage: Language for UI localization. The application interface will render in the specified langauge.
SyncLaunch: Boolean parameter to keep the report window synced for new report launches. If someone opens a new image or item in the worklist, the new launched report will automatically sync and open in the same window.
ApplyTemplate: Optional number to automatically map dictated key findings to this template number when using our AI apply key findings mode.
Language Settings for Non-English Usage
Many of our AI features rely on the language settings, so for non-English usage the AppLanguage
and SpeechLanguage
tags in the request are required. If not provided, both tags will default to English.
Currently supported languages include: en
(English), es
(Spanish), fr
(French), ja
(Japanese), de
(German), nl
(Dutch), ko
(Korean), pl
(Polish), ro
(Romanian), id
(Indonesian), pt
(Portugese - Brazil), zh-CN
(Chinese Simplified) and zh-Hant
(Chinese Traditional)
- response: A dictionary object that specifies the type of output to be returned by the API, whether it's just the encrypted report URL, the QR code image URL, or both. It also includes options to control the size and mode of the QR code. (required)
response:
type:
link: Returns only the encrypted report URL
qrcode: Returns only the QR code image URL
all: Returns both the encrypted report URL and the QR code image URL
# If 'qrcode' or 'all' was used in 'response: {type: }' to return a QR code, use this parameter to control the size of the QR code returned. (**optional**)
qrCodeOptions:
size:
standard: The width of the QR code will be 400 pixels. (default)
mini: The width of the QR code will be 80 pixels.
mode:
light: Suitable for light mode/white backgrounds. (default)
dark: Suitable for dark mode/black backgrounds.
- userInfo: A dictionary object used to assign reports to a specific user. By default reports are assigned to the user making the API call based on the access token used, except for iframe integrations where this tag is required.(optional, but required for iframe integration)
userInfo:
UserEmail: Email of the user you want to assign the report to
UserName: Name of the user you want to assign the report to
Auth: Access token from one of the site administrators
- lazyLaunch: A boolean value that determines when the report is actually created and assigned. (optional)
lazyLaunch:
false: The report is created, assigned, and saved in the backend immediately when the API request is made. (default)
true: The API will generate and return a link to the report and/or QR code without immediately creating the actual report in the backend. The report will only be created, assigned, and saved when the generated link is accessed for the first time. This can be useful for scenarios where you want to defer the creation of the report until it is actually needed.
- dicomSR: A dictionary object that contains the base64 encoded representation of the DICOM SR file to be imported as the report. The clinical information will be read from the DICOM SR and added to the respective locations. In case both
clinicalInfo
anddicomSR
are provided in the API call, then values from theclinicalInfo
will take precendence. (optional)
- keyImages: A list of dictionary objects that contains key images to be attached to the report. (optional)
keyImages:
imageData: Base64 encoded representation of the image file to be imported
contentType: MIME type of the image file (eg. image/png, image/jpeg etc)
fileName: Name of the image file (optional)
HL7 Integration
For receiving reports back as HL7 or for any custom integration, we’ll work with your team to configure the system/endpoint details. This workflow will only be triggered after the report is signed/finalized by the user.
Example request
Here is an example of the request body with all the tags described above -
{
"clinicalInfo": {
"SiteID": "test",
"PatientMRN": "test-mrn",
"Accession": "test-accession",
"PatientName": "John Doe",
"PatientBirthDate": "01021975",
"PatientAge": "50",
"PatientSex": "M",
"Modality": "CT",
"BodyPartExamined": "Abdomen",
"StudyDescription": "CT abdomen w/wo contrast",
"StudyDate": "05022024",
"StudyTime": "122009",
"StudyInstanceUID": "1.2.1.2",
"ReasonForExam": "History of colon cancer and new onset abdominal pain.",
"KeyFindings": "This is a test report",
"ReferringPhysician": "Dr. Kelsey, M.D.",
"ReportingPhysician": "Dr. Jane Doe, M.D."
},
"reportingApp": {
"ReturnFormat": "HL7",
"SpeechLanguage": "en",
"AppLanguage": "en",
"SyncLaunch": true
},
"response": {
"type": "all",
"qrCodeOptions": {
"size": "mini",
"mode": "dark"
}
},
"lazyLaunch": false,
"dicomSR": {
"fileData": "9j/4AAQSkZJRgABAQAASABIAA"
},
"keyImages": [
{
"imageData": "9j/4AAQSkZJRgABAQAASABIAA",
"contentType": "image/jpeg",
"fileName": "first.jpeg"
},
{
"imageData": "9j/4AAQSkZJRgABAQAASABIAA",
"contentType": "image/jpeg",
"fileName": "second.jpeg"
}
]
}
Response
The response for this POST request will be a JSON object that contains the following keys -
- status: Indicates the current status of the report, allowing users to determine whether the report is finalized, still being edited, or pending creation.
Final: The report is finalized and signed. No further changes can be made.
Draft: The report is still being edited and has not been signed or finalized.
PreLaunch: This special status is returned when `lazyLaunch` is set to `true`. It indicates that the report has not yet been created or assigned; only the link has been generated.
- owner: Contains information about the owner of the report - name and email.
- reportLink: Contains the URL for the generated report based on the
tags
provided. This link is encrypted and does not display the actual tags that were sent, to ensure secure access to the report. - reportQrCode: If
qrcode
orall
was used inresponse
to return a QR code, this field contains a base64-encoded string representing the QR code image to access the report. The base64 string starts withdata:image/png;base64,
followed by the encoded image data.
Example response
- If the report already exists and is signed/finalized with
response: {"type": “link”}
:
{
"status": "Final",
"owner": {
"name": "Test User",
"email": "test-user@md.ai"
},
"reportLink": "https://chat.md.ai/chat/launch-report/clinical?token=8ojevgk4rr"
}
- For
“response”: {"type": “all”}
and“lazyLaunch”: “false”
:
{
"status": "Draft",
"owner": {
"name": "Test User",
"email": "test-user@md.ai"
},
"reportLink": "https://chat.md.ai/chat/launch-report/clinical?token=8ojevgk4rr",
"reportQRCode": "data:image/png;base64,iVBOR"
}
- For
“response”: {"type": "link"}
and“lazyLaunch”: “True”
:
{
"status": "PreLaunch",
"owner": {},
"reportLink": "https://chat.md.ai/chat/launch-report/clinical?token=8ojevgk4rr"
}
Note that there is no owner
here since we are just generating a link in advance without actually assigning or launching the report.