### Exercise draft
In this exercise you will continue with the use case from the [Start Profiling](Startprofiling) module. Use the Patient profile you created in this module or create a new Patient profile if you did not complete this exercise. Start by reading the case description. Here below are a couple of links that you may find useful during this exercise:
* [Download Forge](https://simplifier.net/forge/download "Download Forge")
* [HL7 FHIR downloads page](https://www.hl7.org/fhir/downloads.html)
* [ConceptMap resource](https://www.hl7.org/fhir/conceptmap.html)
* [ConceptMap resource](https://www.hl7.org/fhir/conceptmap.html)
Case description
Hospital X wants to receive patient data from general practitioners. The hospital has decided to build conform the FHIR standard, starting with administrative data of patients and their general practitioner. They want to define a mapping from the local storage of their EHR data to the FHIR standard.
The mapping from FHIR to the data fields in their EHR is as following:
FHIR | EHR |
Patient.name.family | PatientAdmin.Surname |
Patient.name.given | PatientAdmin.Name |
Patient.gender | PatientAdmin.Gender |
Patient.birthDate | PatientExtra.Birthdate |
Patient.deceasedBoolean | PatientExtra.Died |
In addition, gender is stored as M (male), V (female) or U (unknown). These values need to be mapped to the administrative-gender ValueSet in FHIR.
## Steps to follow
### Exercise 1 - Add mappings to Patient profile
1. Open your Patient profile in Forge
2. Add a mapping system at the profile level (you can do so in the Properties tab). Add an Id and a logical name, for example 'Hospital X EHR'.
3. Add the mappings to the elements using the ElementDefinition.mapping element. Select the mapping system you just added at the profile level and add the field of the EHR it maps to.
### Exercise 2 - Create a StructureMap to map the EHR data fields to FHIR elements
1. Create a new XML or JSON file that defines a StructureMap. The easiest way is to take one of the example resources on the HL7 FHIR downloads page as an example.
2. Take a look at the specification and make sure that all mandatory elements are present in your XML or JSON file.
3. Add a `group` element and a `group.name` (for example 'EHR to FHIR mapping').
4. Define your source system in the `group.input` element.
5. Use the `group.rule` element to define each mapping rule. No additional transformations of the data are required, so you can choose the value 'Copy' for the `transform` element.
### Exercise 3 - Create a ConceptMap to map the gender values of the EHR to accepted FHIR codes
1. Create a new XML or JSON file that defines a ConceptMap. The easiest way is to take one of the example resources on the HL7 FHIR downloads page as an example.
2. Take a look at the specification and make sure that all mandatory elements are present in your XML or JSON file.
3. Use the `source` and `target` elements to define the `source` and `target` of your mapping. Note that in this case there is no URL for the EHR data. You can use imaginary URLs.
4. Use the `group.element` element to define each mapping.
### Exercise 4 - Write the FHIR mapping language code for this mapping
1. Give your map a name.
2. Add a reference to your StructureDefinition and import the maps that you want to use.
3. Add groups with transform rules.
4. Suppose the hospital stores a prefix for family name as well in the data field PatientAdmin.PrefixSurname of the EHR. They want to concatenate this field with the PatientAdmin.Surname and add the concatenated value to the FHIR element `Patient.name.family`. Adjust the rule to make this happen.