---
title: HKVerifiableClinicalRecordQuery
framework: healthkit
role: symbol
role_heading: Class
path: healthkit/hkverifiableclinicalrecordquery
---

# HKVerifiableClinicalRecordQuery

A query for one-time access to a SMART Health Card or EU Digital COVID Certificate.

## Declaration

```swift
class HKVerifiableClinicalRecordQuery
```

## Overview

Overview note: To use Swift concurrency when reading verifiable clinical records, see HKVerifiableClinicalRecordQueryDescriptor. Use an HKVerifiableClinicalRecordQuery object to request one-time access to a SMART Health Card or EU Digital COVID Certificate. For example, the following code requests cards that represent immunizations within the last six months. // Calculate the start and end dates. var sixMonthsAgo = DateComponents() sixMonthsAgo.month = -6

let end = Date() guard let start = Calendar.current.date(byAdding: sixMonthsAgo, to: end) else {     fatalError("*** Unable to calculate a date using \(end) and \(sixMonthsAgo) ***") }

// Create the predicate. let lastSixMonthsPredicate = HKQuery.predicateForVerifiableClinicalRecords(withRelevantDateWithin: DateInterval(start: start, end: end))

// Create the query for immunization cards. let query = HKVerifiableClinicalRecordQuery(     recordTypes: [HKVerifiableClinicalRecordCredentialType.covid19.rawValue,                   HKVerifiableClinicalRecordCredentialType.immunization.rawValue],     sourceTypes: [.smartHealthCard, .euDigitalCOVIDCertificate],     predicate: lastSixMonthsPredicate) { query, records, error in                  if let error = error {             // Handle errors here.             fatalError("*** An error occurred: \(error.localizedDescription)***")         }                  if let records = records {                          // Use the records here.             for record in records {                 print(record.recordTypes)                 print(record.itemNames)                 print(record.issuedDate)                 print(record.expirationDate ?? "No expiration date.")             }         }     }

// Run the query. store.execute(query) Unlike other HealthKit queries, you don’t need to request permission to read verifiable health records before running this query. HealthKit prompts the user for permission to read the records each time you run the query. note: Running an HKVerifiableClinicalRecordQuery requires a special entitlement from Apple, or the query fails with an HKError.Code.errorAuthorizationDenied error. To request the entitlement, see Request Access to the Verifiable Health Records Entitlement.

## Topics

### Creating Queries

- [init(recordTypes:sourceTypes:predicate:resultsHandler:)](healthkit/hkverifiableclinicalrecordquery/init(recordtypes:sourcetypes:predicate:resultshandler:).md)
- [init(recordTypes:predicate:resultsHandler:)](healthkit/hkverifiableclinicalrecordquery/init(recordtypes:predicate:resultshandler:).md)

### Accessing the Metadata

- [recordTypes](healthkit/hkverifiableclinicalrecordquery/recordtypes.md)
- [sourceTypes](healthkit/hkverifiableclinicalrecordquery/sourcetypes.md)

## Relationships

### Inherits From

- [HKQuery](healthkit/hkquery.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Clinical record queries

- [HKVerifiableClinicalRecordQueryDescriptor](healthkit/hkverifiableclinicalrecordquerydescriptor.md)
- [HKVerifiableClinicalRecordSourceType](healthkit/hkverifiableclinicalrecordsourcetype.md)
- [HKVerifiableClinicalRecordCredentialType](healthkit/hkverifiableclinicalrecordcredentialtype.md)
- [HKDocumentQuery](healthkit/hkdocumentquery.md)
