Page Status: updated 2022-10-27

ValueSet - Fetch and extended operations

Page index

Introduction

Sv. Hämta värdemängder.

This page describes how to fetch the resource ValueSet by a few examples.

Value sets can be fetched in different ways. See ValueSet query operations for information about all options.

In short, a query request is either a read, that is, a retrieval via the resource ID, or a search via a search condition. The result differs between a read and a search. A search results in a Bundle being returned containing all matching resources. If there are no hits, an empty Bundle is returned. A read results in the requested resource being returned or an error if no resource with the requested ID exists. If a system error occurs both searches and reads result in an error (i.e. an OperationOutcome).

Fetching one or more value sets is done by one of the following operations.

GET [base]/ValueSet
GET [base]/ValueSet/[id]

It is also possible to run extended operations on the value set resource. It is done in the following way.

GET|POST [base]/ValueSet/$[operation]

See ValueSet for more information about the ValueSet resource.

Examples

HTTP Headers

See HTTP Header and Authorization for generic information about all HTTP headers used by the National Medication List including information about authorization, purpose and access type. The authorization token is translated to an authority role. The authority role together with the purpose and type of access is used by the National Medication List to determine what actions a user may perform and what information the user may access.

Header Comment
authorization The users's security token
prefer Type of returned content
x-access The cause for the call
x-context-id An ID to group a sequence of requests
x-org-info Information about the users's organisation
x-patientref The logical ID of the patient
x-provenance A provenance resource with information about the user interacting with NLL
x-purpose The purpose of the call
x-request-id A random and unique ID
x-user-agent Information about the calling system

Example 1 - Fetch all value sets

This example shows how to fetch the current version of all value sets. The bundle in the example is not complete for readability reasons. Only 4 value sets are included in the example and 2 of those are only represented in part. A true search of this kind would return approximatly 80 value sets.

The request is made as a request of the resource, GET [base]/ValueSet.

HTTP headers

Header Value Comment
authorization
prefer
x-access
x-org-info
x-patientref
x-provenance
x-purpose
x-request-id d4684d85-d4c3-44c1-8f66-8b4854cfe0bc
x-user-agent {"name":"Test system testaren","version":"0.01010101010.1 beta"} Decoded value

HTTP body: Fetch ValueSet by a search

Example 2 - Fetch a specific value set by the ID

This example shows how to fetch the current version of a specific value set, in this case Förmånsval (benefit-choices).

The request is made as a read by the logical id, GET [base]/ValueSet/benefit-choices.

HTTP headers

Header Value Comment
authorization
prefer
x-access
x-org-info
x-patientref
x-provenance
x-purpose
x-request-id a1ef66c3-d6f8-4c68-9f20-a97d81e9f38a
x-user-agent {"name":"Test system testaren","version":"0.01010101010.1 beta"} Decoded value

HTTP body: Förmånsval (benefit-choices)

Example 3 - Fetch all versions of a value set

This example shows how to fetch all versions of a specific value set, in this case nll-snomed-behandlingsorsak.

The history is only available for value sets that are updated on regular basis. See TA 34 – Hämta värdemängder och kodrelationer for information about value sets that must be updated daily.

The request is made as a read by the logical id, GET [base]/ValueSet/nll-snomed-behandlingsorsak/_history.

HTTP headers

Header Value Comment
authorization
prefer
x-access
x-org-info
x-patientref
x-provenance
x-purpose
x-request-id f18f7a84-a196-4058-8b9a-3c3cd11914d2
x-user-agent {"name":"Test system testaren","version":"0.01010101010.1 beta"} Decoded value

HTTP body: Fetch ValueSet by a search

Example 4 - Validate a code

This example shows how to use the operation $validate-code to get the display text of a code from a previous version of the value set. This operation can be useful if for example a code is removed from a value set.

The request is made by calling the extended operation $validate-code.

The first example below is feteched by this call. GET [base]/ValueSet/nll-snomed-behandlingsorsak/$validate-code?code=14175009&date=le2022-06-01. The response shows that the code existed in the value set before 2022-06-01 with the display text "reumatisk ledsjukdom".

The second example below is feteched by this call. GET [base]/ValueSet/nll-snomed-behandlingsorsak/$validate-code?code=14175009. The response shows that the code doesn't exists in the current version of the value set.

HTTP headers

Header Value Comment
authorization
prefer
x-access
x-org-info
x-patientref
x-provenance
x-purpose
x-request-id 50e6f6c4-b10f-45d8-8a25-2d1d687cd797
x-user-agent {"name":"Test system testaren","version":"0.01010101010.1 beta"} Decoded value

HTTP body: Example of validate a code in a ValueSet

HTTP body: Example of validate a code in a ValueSet