Data map API: Difference between revisions

From Discovery Data Service
Jump to navigation Jump to search
Line 71: Line 71:
The mapping document response also contains the source and target context object as well as the relevant maps, modified by the server.
The mapping document response also contains the source and target context object as well as the relevant maps, modified by the server.


If the requester knows that the map is provider independent and  they do not need to pass in the provider, then they need not populate the source provider property. If they do not know whether it is relevant or not, and they populate the property with the provider identifier,  then the mapping server may choose to ignore that property if not relevant
If the requester knows that the map is provider independent and  they do not need to pass in the provider, then they need not populate the source provider property. If they do not know whether it is relevant or not, and they populate the property with the provider identifier,  then the mapping server may choose to ignore that property if not relevantThe mapping document, when returned, also confirms the source and target and in addition a context IRI that can be used for future calls to the API.<syntaxhighlight lang="json">
 
 
 
The mapping document, if returned, also confirms the source and destination and in addition a context IRI that can be used for future calls to the API.<syntaxhighlight lang="json">
{"contextIRI":":MDC_BartsAPCIM"}
{"contextIRI":":MDC_BartsAPCIM"}
</syntaxhighlight>
</syntaxhighlight>

Revision as of 10:49, 30 May 2020

This page is under review

Information model packages - mappings.png

The mappings package is one of the 5 main component categories in the information model.

The data map APIs are a set of APIs provided by the information model server to aid with the transfer of data between two data sets, where the source and destination data sets conform to a data model. Either the source or the destination data models (or both) may be implemented as either relational or graph or both.

The APIs cover two main types of activities:

  1. The retrieval of mapping files for use by a transform module client set in the context of a known source type and destination type.
  2. The mapping of values between source and destination concepts, terms or codes, set in the context of known source properties and destination properties obtained from the mapping files generated as above.

Use cases

The use of a mapping server enables the separation of concern between the maintenance of data maps and the application that transforms data.

The mapping server is used by a transform module operating as a client.

It is designed to be used as an assistance to a code based ORM like transform, and can thus be used for some or all of the process, depending on the requirements of the transform client. In other words, the use of the APIs is a pick and mix approach, making it possible to introduce it into currently operating transformations without disruption.

The map operates as a map with a navigator issuing a set of instructions to the client, but keeps the control of the process within the code space of the transformation module.

Use of the two mapping APIs

There are 3 main uses of the get map API:

  • Relational to object mapping (MR2O) For a particular source system, obtain a map for each table and field in the source, and any source RDB retrieval logic, obtain the classes and properties of the target and any transformation logic required in between.
  • Object to relational mapping (MO2R). For a particular source object store, obtain a map for each class and property in the source, and any object manipulation logic, obtain the tables and fields of the target and any RDB update logic required.
  • Object to Object mapping (MO2O). For a particular source object store, obtain a map for each class and property in the source, and any object manipulation logic, obtain the classes and properties of the target and any object manipulation logic required.

It should be noted that these are conceptually the same at an abstract level and vary only because of terminology. The use of different terminology helps in order to make the mapping logic clearer. For example a table join operation is logically the same as a graph traversal and a dependent table row generation is logically the same as an inverse relationship to an object creation.

There is one main use of the Get mapped value API

  • For a codeable value in the source (e.g. a code or text), when taken together with the context of that value, obtain the common information model target concept (or code).

General approach to mapping

Choice of mapping steps

Unlike a generic approach to mappings, which normally support many to many mappings, Discovery maps from a source only to the common information model's data model, and from the common data model to a target i.e. two mapping steps.

The benefit of this approach is that only one outbound map is required for each target (from the common model) and only one for each source (to the common model) with the common data model acting as the hub that can "clean" and organise the data in a standardised way.

This approach also enables mapping clients to make use of either or both mapping steps separately or grouped depending on the use case. For example it would be quite common to use the output from a relational source to the common data model target, as a means of eventually mapping to FHIR, whether or not the mapping server supports the full relational to FHIR 2 step map. This is because currently implemented mapping process that map to and from FHIR, may only require additional IM facilities, such as what to do with new publisher fields and what to put in a generic FHIR name/ value pair extension.

A further optimisation occurs within the mapping server, that of convergence, whereby map fragments are authored as re-usable mapping nodes.

The underlying approach to authoring the maps themselves is described in the article Map maker manager which describes the fundamental concepts involved in making the maps for the server to deliver.

Request mapping document

A mapping document is an information model document subtype returned by the Mapping server on request from a transform client via the mapping REST API.

The mapping server contains a repository of Mapping documents, previously authored by the map authors.

The following example request body requests the map between the Barts trust CDS Admitted patient care schema and the discovery information model

{ "sourceContext":{
         "provider": {
              "value":"H12345","display": "BartsNHSTrust","codeScheme":"https://FHIR.nhs.uk/ods"},
          "system":{ 
              "value":":CM_System_CernerMillenium",
                   "scheme":"https://DiscoveryDataService.org/InformationModel"},
          "schema": {"value": "CM_Schema_CDS-APC",
                     "codeScheme": "https://DiscoveryDataService.org/InformationModel"}},
   "targetContext":{
        "system": {
              "value":":CM_System_DiscoveryCore", 
                    "codeScheme": "https://DiscoveryDataService.org/InformationModel"},
         "schema": {
               "value":"CM_Schema_DiscoveryInformationModel_V1",
                       "codeScheme": "https://DiscoveryDataService.org/InformationModel"}} }

The mapping document response also contains the source and target context object as well as the relevant maps, modified by the server.

If the requester knows that the map is provider independent and they do not need to pass in the provider, then they need not populate the source provider property. If they do not know whether it is relevant or not, and they populate the property with the provider identifier, then the mapping server may choose to ignore that property if not relevantThe mapping document, when returned, also confirms the source and target and in addition a context IRI that can be used for future calls to the API.

{"contextIRI":":MDC_BartsAPCIM"}

The C2C mapping process assumes the interposition of the data model between the source and the destination. In other words the mapping "passes through" the information model. In practice this means that the common data model is mapped only once to the target schema and each source need only be mapped to the information model's data model.

The object value mapping process involves a one, two or three step mapping between a source code or text and a target concept. The first step is optional and is only used when a source code can be first mapped to a known classification code, and the second step takes the mapping to create a concept. A further map occurs when the target itself is a legacy concept i.e. a non core concept, and the core concept is also generated.

Context dependency

For a source value to be understood, it is necessary to provide some context to it. All values are therefore set in some form of context. As a minimum this context would be the source property i.e. the property for which the value is a value of. In many cases though, the context will be much more extensive.

For example, in a source system, the word 'negative, a value of the field 'result text' associated with a code value '12345', a value in the field 'test', which is a field of the table of 'clinical events', used by the system 'Cerner Millennium', in the hospital 'Barts NHS trust', may mean something completely different to 'negative' with the code '12345' set in another hospital, even with the same system.

A further layer of context includes the Domain in which the mapping takes place. A map generated for one purpose may be different when generated for another purpose.

For example, when process

Two mapping routes

ing published data into Discovery, the domain in question could be described as the 'inbound publisher mapping domain'.

Consequently, the implicit idea of a context and a domain, is explicitly modelled as a 'Domain mapping node' object. The class, and the various supporting classes are described in the following sections.

DB Schema class

Before doing any mappings, it is necessary to model a target schema in order to map to it.

Implementation schema resources are a set of objects of the class DBSchema (to the right)

The class is designed as a simple entity relationship class with 2 additional properties:

  1. The name of the table's extension tables. These are optional triple tables designed so that a schema can continue to extend to additional properties and values using the information model to determine the properties and data types. This avoids the need to continually change the relational schema with new data items.
  2. The name of the field holding the subtype indicator. This is described as the entity subtype attribute.

The following is an example of a snippet from an encounter table:

A schema table example showing extension table and subtype field

{"DBSchema": {
      "DBSchemaName": "Compass_version_1",
      "DBTable": {
        "DBTableName": "encounter",
        "DBExtensionTable": {
          "DBTableName": "encounter_extension"
        },
        "DBSubTypeField": "type" } } }

The encounter table is expecting subtypes to be authored and therefore has a "subtype" field authored in the table in order to avoid generating many subtype tables.

Original source Resources

Every map has a source and target. From the perspective of the information model an 'original source' represents a data model created from a publisher's source data i.e. is likely to be a relational or json representation of publisher data that might have been originally delivered as HL7 V2, XML, JSON, CSV or pipe delimited flat files. Source resources are therefore not representations of the actual data, but representations of a model that would be used when transforming to the common model. An example of this is a staging table.

Source resource description

It is assumed that a source may contain many tables, each with many fields, each with many values including text. It is not necessary for there to be actual tables, and fields and any object structure, masquerading as such, can be used. The terms 'table' and 'field' are used for convenience and refer to objects and properties just as well.

There many be differences between one provider and another using the same system, and different versions of the system. Thus there is a need to provide context for each source resource.

Each element of source data must explicitly inherit the context so that the mapping API can recognise the context with each request.

The Original source resource object reflects a single logical thing to map. In most cases this will be a single field and single value. However, in some cases (such as free text sources), the source is derived from a list of fields, each with certain values.


For example, a piece of text saying "negative", when contextualised as a result against a test for 'Hepatitis B surface antigen' would use compound context consisting of the table, the test field, the test code, the result field and the result text of negative.

An example original source object from a CDS admitted patient care record with a value of '1' for the admitted patient classification

 { "OriginalSource": {
          "Provider": "Barts",
          "System": "CernerMillenium",
          "Context": {
            "id": 1,
            "Table": "APC",
            "Field": "PATIENT_CLASSIFICATION_CODE",
            "Value": 1 } }

The original source resource would be used as part of a mapping request submitted via the API

Information model target resource

The common information model target resource is the target of a map from an original source.

The resource is delivered as part of the IM mapping API response.

Target resource for a map

The target resource indicates the class and properties of the target object, the object may need creating or adding to with the target property, and the target value.

In some cases multiple sources may link to one target and in other cases multiple targets may link to one source, the link item being the "from id" link fro the target.


An example target resource from a request containing an original source object

  {"IMTarget": {
          "Fromid": 1,
          "Class": ":CM_HospitalInpAdmitEncounter",
          "DependentRelationship": {
            "Relationship": ":RM_isComponentOf",
            "Class": ":DM_HospitalInpEntry"
          },
          "PropertyValue": {
            "Property": ":DM_admissionPatientClassification",
            "Value": ":CM_AdmClassOrdinary"  } }}

The class, properties and values of the IM resource all reference IM concepts.

This resource says that the target IM class is a "hospital inpatient admission encounter type". This object is dependent on the presence of a container encounter, in this case of type "hospital in patient stay" and the relationship between them is 'is subcomponent of' . The field value source results in the property of 'admission patient classification; and the value being 'Ordinary admission'.

Note that the information model resource uses subtypes as classes, in line with the ontology. It avoids the complexity involved in populating database schemas. However, the DB target resource does include the specific instructions as to how to populate the types.

Map Request

For a map to be provided it needs to be requested and it is the job of the IM mapping API to respond to a request.

Mapping resource with 3 map optoins

A mapping resource is used both as a request and a reference i.e. can be exported as a set of maps or mapped on request.

Note that as the mapping API is designed to be used as individual requests for individual values, this class does not inherit properties or classes in the source or target. A typical map request using the above example could be:


An example request from a source system to a DB target

 {"Mapping":[   {
        "Request": "SourcetoDB",
        "OriginalSource": {
          "Provider": "Barts",
          "System": "CernerMillenium",
          "Context": {
            "id": 1,
            "Table": "AdmittedPatientCare",
            "Field": "PatientClassificationCode",
            "Value": 1
          }
        },
        "TargetDBSchema": "Compass_version1" } ] }

Bringing it all together

A working example of the above is illustrated as a mapping working example for a client wishing to go from a source to a database target

{
 "MapResultSet": {
  "Result": [
   {
    "Class": ":DM_MedicationRequest"},
   {
    "Property": ":DM_RequestedMedication" },
   {
    "ContextNode": ":GPMedRequests" },
   {
    "Value": ":SN_123300212120" } ]}}