共用方式為


Azure Cognitive Services Health Insights Radiology Insights client library for Java - version 1.0.0-beta.1

Health Insights is an Azure Applied AI Service built with the Azure Cognitive Services Framework, that leverages multiple Cognitive Services, Healthcare API services and other Azure resources.

Radiology Insights is a model that aims to provide quality checks as feedback on errors and inconsistencies (mismatches) and ensures critical findings are identified and communicated using the full context of the report. Follow-up recommendations and clinical findings with measurements (sizes) documented by the radiologist are also identified.

Source code | Package (Maven) | API reference documentation | Product Documentation | Samples

Getting started

Prerequisites

For more information about creating the resource or how to get the location and sku information see here.

Include the Package

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-health-insights-radiologyinsights</artifactId>
    <version>1.0.0-beta.1</version>
</dependency>

Authenticate the client

In order to interact with the Health Insights Radiology Insights service, you'll need to create an instance of the RadiologyInsightsClient class. You will need an endpoint and an API key to instantiate a client object.

Get API Key

You can obtain the endpoint and API key from the resource information in the Azure Portal.

Alternatively, you can use the Azure CLI snippet below to get the API key from the Health Insights resource.

az cognitiveservices account keys list --resource-group <your-resource-group-name> --name <your-resource-name>

Create a RadiologyInsightsClient with an API Key Credential

Once you have the value for the API key, you can pass it as a string into an instance of AzureKeyCredential. Use the key as the credential parameter to authenticate the client. You may choose to build a synchronous or asynchronous client.

Build a synchronous client:

String endpoint = Configuration.getGlobalConfiguration().get("AZURE_HEALTH_INSIGHTS_ENDPOINT");
String apiKey = Configuration.getGlobalConfiguration().get("AZURE_HEALTH_INSIGHTS_API_KEY");

RadiologyInsightsClient radiologyInsightsClient = new RadiologyInsightsClientBuilder()
        .endpoint(endpoint).serviceVersion(RadiologyInsightsServiceVersion.getLatest())
        .credential(new AzureKeyCredential(apiKey)).buildClient();

Build an asynchronous client:

String endpoint = Configuration.getGlobalConfiguration().get("AZURE_HEALTH_INSIGHTS_ENDPOINT");
String apiKey = Configuration.getGlobalConfiguration().get("AZURE_HEALTH_INSIGHTS_API_KEY");

RadiologyInsightsAsyncClient radiologyInsightsAsyncClient = new RadiologyInsightsClientBuilder()
        .endpoint(endpoint).serviceVersion(RadiologyInsightsServiceVersion.getLatest())
        .credential(new AzureKeyCredential(apiKey)).buildAsyncClient();

Key concepts

Radiology Insights currently supports one document from one patient. Please take a look here for more detailed information about the inferences this service produces.

Examples

Create a RadiologyInsights request and retrieve the result

Infer radiology insights from a patient's radiology report using a synchronous client.

RadiologyInsightsInferenceResult riResults = radiologyInsightsClient.beginInferRadiologyInsights(createRadiologyInsightsRequest()).getFinalResult();

Infer radiology insights from a patient's radiology report using an asynchronous client.

PollerFlux<PollOperationDetails, RadiologyInsightsInferenceResult> asyncPoller = radiologyInsightsAsyncClient
        .beginInferRadiologyInsights(createRadiologyInsightsRequest());

Create the request.

private static RadiologyInsightsData createRadiologyInsightsRequest() {
    List<PatientRecord> patientRecords = createPatientRecords();
    RadiologyInsightsData radiologyInsightsData = new RadiologyInsightsData(patientRecords);
    RadiologyInsightsModelConfiguration modelConfiguration = createRadiologyInsightsModelConfig();
    radiologyInsightsData.setConfiguration(modelConfiguration);
    return radiologyInsightsData;
}

/**
 * Creates a list of patient records.
 *
 * @return A list of PatientRecord objects that represent patient information.
 */
private static List<PatientRecord> createPatientRecords() {
    List<PatientRecord> patientRecords = new ArrayList<>();
    // Patients
    PatientRecord patientRecord = new PatientRecord("Sharona");

    PatientDetails patientDetails = new PatientDetails();
    patientDetails.setSex(PatientSex.FEMALE);

    // Use LocalDate to set Date
    patientDetails.setBirthDate(LocalDate.of(1959, 11, 11));
    
    patientRecord.setInfo(patientDetails);

    Encounter encounter = new Encounter("encounterid1");

    TimePeriod period = new TimePeriod();

    OffsetDateTime startTime = OffsetDateTime.parse("2021-08-28T00:00:00Z");
    OffsetDateTime endTime = OffsetDateTime.parse("2021-08-28T00:00:00Z");

    period.setStart(startTime);
    period.setEnd(endTime);

    encounter.setPeriod(period);
    encounter.setClassProperty(EncounterClass.IN_PATIENT);

    patientRecord.setEncounters(Arrays.asList(encounter));

    PatientDocument patientDocument = getPatientDocument();
    patientDocument.setClinicalType(ClinicalDocumentType.RADIOLOGY_REPORT);
    patientDocument.setLanguage("EN");

    DocumentAuthor author = new DocumentAuthor();
    author.setId("authorid1");
    author.setFullName("authorname1");

    patientDocument.setAuthors(Arrays.asList(author));
    patientDocument.setSpecialtyType(SpecialtyType.RADIOLOGY);

    DocumentAdministrativeMetadata adminMetadata = new DocumentAdministrativeMetadata();
    FhirR4Extendible orderedProcedure = new FhirR4Extendible();

    FhirR4CodeableConcept procedureCode = new FhirR4CodeableConcept();
    FhirR4Coding procedureCoding = new FhirR4Coding();
    procedureCoding.setSystem("Http://hl7.org/fhir/ValueSet/cpt-all");
    procedureCoding.setCode("USPELVIS");
    procedureCoding.setDisplay("US PELVIS COMPLETE");

    procedureCode.setCoding(Arrays.asList(procedureCoding));
    orderedProcedure.setCode(procedureCode);
    orderedProcedure.setDescription("US PELVIS COMPLETE");

    adminMetadata.setOrderedProcedures(Arrays.asList(orderedProcedure));
    adminMetadata.setEncounterId("encounterid1");

    patientDocument.setAdministrativeMetadata(adminMetadata);

    // Define a formatter to handle milliseconds
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");

    OffsetDateTime createdDateTime = OffsetDateTime.parse("2021-06-01T00:00:00.000" + "+00:00", formatter);
    patientDocument.setCreatedDateTime(createdDateTime);

    patientRecord.setPatientDocuments(Arrays.asList(patientDocument));
    patientRecords.add(patientRecord);
    return patientRecords;
}

/**
 * Retrieves the patient document.
 *
 * @return The patient document.
 */
private static PatientDocument getPatientDocument() {
    DocumentContent documentContent = new DocumentContent(DocumentContentSourceType.INLINE, DOC_CONTENT);
    return new PatientDocument(DocumentType.NOTE, "docid1", documentContent);
}

/**
 * Creates a RadiologyInsightsModelConfiguration object with the specified
 * configuration settings.
 *
 * @return A new instance of RadiologyInsightsModelConfiguration.
 */
private static RadiologyInsightsModelConfiguration createRadiologyInsightsModelConfig() {
    RadiologyInsightsModelConfiguration configuration = new RadiologyInsightsModelConfiguration();
    RadiologyInsightsInferenceOptions inferenceOptions = getRadiologyInsightsInferenceOptions();
    configuration.setInferenceOptions(inferenceOptions);
    configuration.setInferenceTypes(Arrays.asList(RadiologyInsightsInferenceType.FINDING,
            RadiologyInsightsInferenceType.AGE_MISMATCH, RadiologyInsightsInferenceType.LATERALITY_DISCREPANCY,
            RadiologyInsightsInferenceType.SEX_MISMATCH, RadiologyInsightsInferenceType.COMPLETE_ORDER_DISCREPANCY,
            RadiologyInsightsInferenceType.LIMITED_ORDER_DISCREPANCY,
            RadiologyInsightsInferenceType.CRITICAL_RESULT, RadiologyInsightsInferenceType.FOLLOWUP_RECOMMENDATION,
            RadiologyInsightsInferenceType.FOLLOWUP_COMMUNICATION,
            RadiologyInsightsInferenceType.RADIOLOGY_PROCEDURE));
    configuration.setLocale("en-US");
    configuration.setVerbose(false);
    configuration.setIncludeEvidence(true);
    return configuration;
}

/**
 * Retrieves the RadiologyInsightsInferenceOptions object with the specified
 * options.
 *
 * @return The RadiologyInsightsInferenceOptions object with the specified
 *         options.
 */
private static RadiologyInsightsInferenceOptions getRadiologyInsightsInferenceOptions() {
    RadiologyInsightsInferenceOptions inferenceOptions = new RadiologyInsightsInferenceOptions();
    FollowupRecommendationOptions followupOptions = new FollowupRecommendationOptions();
    FindingOptions findingOptions = new FindingOptions();
    followupOptions.setIncludeRecommendationsWithNoSpecifiedModality(true);
    followupOptions.setIncludeRecommendationsInReferences(true);
    followupOptions.setProvideFocusedSentenceEvidence(true);
    findingOptions.setProvideFocusedSentenceEvidence(true);
    inferenceOptions.setFollowupRecommendationOptions(followupOptions);
    inferenceOptions.setFindingOptions(findingOptions);
    return inferenceOptions;
}

Get Critical Result Inference information

Display critical result inferences from the example request results.

List<RadiologyInsightsPatientResult> patientResults = radiologyInsightsResult.getPatientResults();
for (RadiologyInsightsPatientResult patientResult : patientResults) {
    List<FhirR4Extendible1> inferences = patientResult.getInferences();
    for (FhirR4Extendible1 inference : inferences) {
        if (inference instanceof CriticalResultInference) {
            CriticalResultInference criticalResultInference = (CriticalResultInference) inference;
            String description = criticalResultInference.getResult().getDescription();
            System.out.println("Critical Result Inference found: " + description);
        }
    }
}

Troubleshooting

Next steps

Explore the complete set of sample source code files.

Additional documentation

For more extensive documentation on Azure Health Insights Radiology Insights, see the Radiology Insights documentation on learn.microsoft.com.

Contributing

For details on contributing to this repository, see the contributing guide.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

![Impressions]: https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fhealthinsights%2Fazure-health-insights-radiologyinsights%2FREADME.png