Brian Postlethwaite
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Cross Version FML FHIR Uses a special mapping language to define maps between FHIR versions. * resource map * simple property maps * property renamed * property moved into a backbone element * property moved out of a backbone element * backbone element map * property type changed ## Understanding cross-version mapping ## resource map The resource map has some metadata and a top level group. The metadata is used to assist in tracking the map as a FHIR StructureMap resource, what structure definitions it requires (via `uses`), and other maps (via `imports`) ``` /// url = "http://hl7.org/fhir/uv/xver/StructureMap/Consent3to4" /// name = "Consent3to4" /// title = "Consent Transforms: R3 to R4" /// status = "active" uses "http://hl7.org/fhir/3.0/StructureDefinition/Consent" alias ConsentR3 as source uses "http://hl7.org/fhir/4.0/StructureDefinition/Consent" alias Consent as target imports "http://hl7.org/fhir/uv/xver/StructureMap/*3to4" group Consent(source src : ConsentR3, target tgt : Consent) extends DomainResource <<type+>> { src.identifier -> tgt.identifier; ... } ... ``` There can be other groups in the file too. Resource groups are the first in the file, and can be designated by the `extends DomainResource` marker on the group. If the resource also has the `<<type+>>` indicator this map will be used in maps where a Resource type is encountered, such as in bundles, parameters and contained resources. > **Note:** The canonical URL for the StructureDefinition has the FHIR Version defining format. ## Simple property maps Where the property has been unchanged between the versions, then a simple copy map is used. This is just source -> property ``` src.identifier -> tgt.identifier; src.status -> tgt.status; ``` ## Property renamed This is the same as the simple property map, except use the new name. ``` src.consentingParty -> tgt.performer; ``` > **Note:** If the datatype ## property moved into a backbone element This case saw `dose` and `rate` moved into a new backbone element called `doseAndRate`. ``` group Dosage(source src : DosageR3, target tgt : Dosage) { src where (dose.exists() or rate.exists()) -> tgt.doseAndRate as vt0 then { src.dose as vs -> vt0.dose as vt then Range(vs, vt) "doseRange"; src.rate as vs -> vt0.rate as vt then Ratio(vs, vt) "rateRatio"; } "doserate"; } ``` The source rule does not walk into any properties, just indicates that if there is a source, check for target rules and then call the dependent group. Note the use of a fhirpath where clause to ensure that either of the properties exist before creating the backbone element. If there is a source value, then the target property/backbone element is created, and the dependendt rules are executed. Without the where clause, an empty doseAndRage could be created. If there is only 1 property going into the backbone element, then this could be done in a single rule without the dependent rules. ## property moved out of a backbone element ``` group Dosage(source src : Dosage, target tgt : DosageR3) { src where (dose.exists() or rate.exists()) -> tgt.doseAndRate as vt0 then { src.dose as vs -> vt0.dose as vt then Range(vs, vt) "doseRange"; src.rate as vs -> vt0.rate as vt then Ratio(vs, vt) "rateRatio"; } "doserate"; src.doseAndRate as vs then { vs.dose -> tgt.dose; vs.rate -> tgt.rate; } } ``` > **Note:** When the engine(s) support the a.b.c identifier format, this could be shortened to the simple format `src.dateAndRate.dose -> tgt.dose` ## Mapping a BackboneElement When mapping a backbone element, you can use either: *(noting that you can also change the name at the same time as this too)* ### A dependent group ``` group Consent(source src : ConsentR3, target tgt : Consent) { src.policy as vs -> tgt.policy as vt then ConsentPolicy(vs, vt); } group ConsentPolicy(source src, target tgt) extends BackboneElement { src.authority -> tgt.authority; src.uri -> tgt.uri; ... } ``` ### An inline dependent set of rules This is equivalent to the preceding option, however you need to manually call the dependent group for the BackboneElement to bring any extensions through. ``` group Consent(source src : ConsentR3, target tgt : Consent) { src.policy as vs -> tgt.policy as vt then { vs.authority -> vt.authority; vs.uri -> vt.uri; ... vs -> BackboneElement(vs, vt); }; } ``` ## Property type changed This specific example shows converting a code to a CodeableConcept ``` src.policyRule as v -> tgt.policyRule as cc, cc.coding as c, c.system = 'urn:ietf:rfc:3986', c.code = v; ``` Here the target rules are chained where each one is using an alias (variable) preceding it. Also note that there are no `create()` statements here, as the type of each property has only one valid type. just assigning the variable is enough to add it to the object. In some cases such as a string to a `uri` or `canonical` there are existing maps that cover the type conversion, and in general are found in a map called `promitives.fml`, or alternative use an explicit conversion (that might also be in that file, such as `Identifier2Codeable`) ``` src.identifier as vs -> tgt.code as vt then Identifier2Codeable(vs, vt); ``` Alternatively you could use fhirpath to convert the type ``` // convert the quantity decimal amount to an integer src.amount as sa -> tgt.amount = (sa.amount.ofType(Quantity).value.round().toString().toInteger()) "convertAmount"; ``` ### source/target choice datatype options are changed Each of the datatypes available on the source property should be listed to indicate what should be done for each type. If the list of types hasn't changed, then this splitting of types isn't needed. ``` src.rate : Ratio as vs -> vt0.rate = create('Ratio') as vt then Ratio(vs, vt) "rateRatio"; src.rate : Range as vs -> vt0.rate = create('Range') as vt then Range(vs, vt) "rateRange"; src.rate : Quantity as vs -> vt0.rate = create('Quantity') as vt then Quantity(vs, vt) "rateQuantity"; ``` In this case note that a dependent group is used to create the Ratio/Range/Quantity, though these could also be done explicitly in-place as was done in the policyRule example above. ### Valueset binding changed These could be implied from the source/target property bindings, and locate a conceptmap that applies for that combination. However this can be explicitly declared too. ``` src.criticality as v -> tgt.criticality = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/ait.criticality-2to3', 'code') "AllergyIntolerance-criticality"; ``` ### Setting a primitive value with a fixed value In some cases a simple hard coded value is required, usually these are based on some condition in the source detected via a where clause using fhirpath. In the following example setting a code type property. The engine will then perform type coersion to change the string to a code. ``` src.type as s where (s = 'choice') -> tgt.answerConstraint = 'optionsOnly'; ``` ## Backport extensions! In order not to lose information, backport extensions can be used to retrieve values from an older version. These may be used to hold: * data for a field that did not exist in a previous (or latter) version * data that has a different type that is not compatible with the target version * coded data that is not supported in the target version's valueset definition If the map processes an extension, this should be excluded from copying over to the target resource as an extension. This will mean you should not use the `extends DomainResource` or `extends BackboneElement` as these will blindly copy all the extension over. **TBD:** Instead you should explicitly call the group and provide a parameter to indicate which will exclude the backport extensions. ``` fml group ActivityDefinitionParticipant(source src, target tgt) { src.type as v -> tgt.type ... // The extension processing (including processing backport URLs) src -> ('http://hl7.org/fhir/5.0/StructureDefinition/') as bpUrl, // Regular extensions (and base) BackboneElementXver(src, tgt, bpUrl), // Backport extensions tgt.propA = (src.extension(bpUrl & 'propA').value), tgt.propB = (src.extension(bpUrl & 'propB').value) "Extensions"; } group BackboneElementXver(source src : BackboneElementR4, target tgt : BackboneElementR5, source extBackportUrlBase : string) { // this excludes the cross version extensions src.modifierExtension where (url.startsWith(extBackportUrlBase).not()) -> tgt.modifierExtension; src -> ElementXver(src, tgt, extBackportUrlBase); } group ElementXver(source src : ElementR4, target tgt : ElementR5, source extBackportUrlBase : string) { src.id -> tgt.id; // this excludes the cross version extensions src.extension where (url.startsWith(extBackportUrlBase).not()) -> tgt.extension; } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully