Repository navigation
Read CDA documents and stage clinical records with their source document time - #206
Draft
PSchmiedmayer wants to merge 11 commits into
Draft
PSchmiedmayer wants to merge 11 commits into
PSchmiedmayer wants to merge 11 commits into
Conversation
GroveHealthKit queries CDA document samples with HealthKit.queryCDADocuments, an anchored query without the document contents, and reads one document with its bytes with HealthKit.readCDADocument, which stops its query when the task is cancelled. HealthKitRecordingFile stages a clinical record's FHIR resource and a CDA document's bytes unchanged. The conversion Provenance of either states the sample dates as the source document time, with the time zone the sample names, since no element of the document states them. The generator emits the source document time extension of the pinned guide.
HealthKit validates a new CDA document with libxml2, whose schema setup crashes when it runs concurrently, so the tests that run in parallel create their validated documents under one lock.
Pins grove-fhir to the clinical source time guide branch at 59b4ece, which contains grove-fhir 0.9.0, and regenerates the contracts from it. Clinical documents keep this branch's payload staging beside the clinical record attachments: the attachment document sits with the clinical payload functions, and the documentation names both the file recordings and the attachments. The clinical goldens and content corpus vectors are regenerated: the clinical record attachment golden now also states the source document time on its conversion Provenance instead of the time zone in its metadata. The clinical recording file test uses the renamed provider-issued-fhir-json and cda-document formats.
A clinical record staged as a file recording carries only its resource, so its documentation directs a record with files to the clinical record export with attachments, and the article states the sample export for a record without files.
A file recording carries only the clinical record's resource, so staging a record that HealthKit stores files with would drop them. Staging now takes the health store, lists the record's attachments, and refuses a record with any as RecordingError.clinicalRecordHasAttachments; a failure to list them throws.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
♻️ Current situation & Problem
This replaces #196, which closed when its branch was merged into the integration branch; the branch and commits are unchanged.
GroveHealthKitFHIR exports a clinical record or CDA document sample inline, but GroveHealthKit offered no way to query CDA documents or read their bytes.
HealthKit returns a CDA document's bytes only from an
HKDocumentQuerythat asks for them, and reading them needs its own authorization.A clinical record's resource or a CDA document could also only be embedded in the record, while Grove already stages workout routes and heartbeat series in files that the record references.
The sample dates of both classes do not state the time of care.
A clinical record's dates state when HealthKit downloaded it, and a CDA document's dates are whatever the creating app supplied.
Grove dropped them, and a sample's time zone stayed in the source metadata without a time it belonged to.
SchmiedmayerLab/grove-fhir#88 adds a source document time extension on the conversion Provenance for these dates.
⚙️ Release Notes
HealthKit.queryCDADocuments(timeRange:anchor:source:limit:predicate:)runs an anchored query of CDA document samples without their contents.HealthKit.readCDADocument(_:)reads one document with its bytes and stops its query when the task is cancelled.readCDADocument(_:)throwsHealthKit.CDADocumentError.unavailablewhen HealthKit returns no document, another document, or one without bytes.queryCDADocumentsthrowsHealthKit.CDADocumentError.unexpectedSamplewhen HealthKit returns a sample that is not a CDA document.HealthKitRecordingFile.clinicalRecord(_:relativePath:maximumByteCount:)stages a clinical record's FHIR resource byte for byte under its release's media type.HealthKitRecordingFile.cdaDocument(_:relativePath:maximumByteCount:)stages a CDA document's bytes unchanged under the title the document states, else the default title..fileRecording(_:)record, whose DocumentReference references the file.RecordingFile.stage(data:maximumByteCount:)stages bytes already in memory.healthkit-source-document-timeextension.clinical-record-downloadorcda-document-app-supplied, and its period names the sample's time zone on both endpoints when the sample states one.HealthKitRecordingFilefactories are not available on watchOS.HealthKitSourceDocumentTimewith the extension URL and its two bases.7a388c126e84554a91cd4c794a2e9ad0d63ddb84, the head of Carry HealthKit clinical document dates on Provenance grove-fhir#88, whichScripts/validate-fhir-conformance.shand the test workflow pin by commit.📚 Documentation
HealthKittopics list the two CDA document operations.✅ Testing
CDADocumentReadTestsis new and covers delivery of the requested document with its bytes, a missing or foreign document, a query error, cancellation before the read starts, between registering and running its query, and while it runs, and the anchored query's descriptor.HealthKitClinicalRecordingFileTestsis new and covers staging both classes unchanged, refusal of what the inline export refuses, and the default title of a CDA document without one.HealthKitSourceDocumentTimeTestsis new and covers the basis and period of each class with and without a time zone, an unreadable time zone, and samples of other classes.HealthKitDisclosureOptionsTestsadds clinical record and CDA document file recordings to the disclosure presets.RecordingFileStreamingTestsadds a case for staging bytes from memory within and beyond the byte limit.test_generate_grove_fhir_swift_contract.pycovers the generated source document time bases and refuses a source document time the generator does not emit.Code of Conduct & Contributing Guidelines
By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: