********** ## Reading material ********** Profiling is often explained by constraining core FHIR resources. For example, you can create a Patient profile by constraining the Patient resource. But it is also possible to use an existing profile as your base profile and make additional constraints to it. The resulting profile is called a derived profile. When an element is already sliced in a base profile, it is possible to change the slicing in a derived profile. ### 1. Change existing slices The following changes can be made to existing slices: - Extending the discriminator - Changing slicing rules - Adding new slices - Creating new slices inside existing slices (re-slicing) When profiling you can only add constraints, you can never remove them. The same applies to changing the slicing in a derived profiling. You may further constrain the slicing, but you cannot release constraints. In a derived profile, the discriminator should have the same content as in the base profile. This means that additional paths can be added, but existing paths cannot be removed. You can either use the same discriminator as in the base profile or add a new one, as long as you conform to this rule. Open slicing rules can be changed to closed and unordered to ordered, but not vice versa. Adding new slices is only allowed when the slices are not closed. ### 2. Re-slicing In a derived profile, you can re-slice an element that is already sliced in the base profile. For each new slice, you have to define a unique slice name. Note that it is also possible to re-slice within the original profile, but it is often meaningless to do so. #### 2.1 Process of re-slicing To explain how the process of re-slicing works, suppose we have created a profile on Patient called FirelyPatient. In this profile, we have sliced the element `Identifier`. We have a slice called `NationalSecurityNumber` and a slice called `HospitalPatientNumber`. Now suppose we wish to create a derived profile on FirelyPatient, let’s call it MyFirelyPatient. We can choose to do the following: 1. Constrain the `Identifier` element. This constraint will have no name and will apply to both slices of `Identifier` defined in FirelyPatient (i.e. `NationalSecurityNumber` and `HospitalPatientNumber`). 2. Constrain one of the slices of `Identifier`. In this case the name of the slice needs to be specified and the constraint will only apply to that specific slice. 3. Add a new slice on `Identifier` with its own constraint(s). In this case a unique name for the slice needs to be defined and the constraint(s) will only apply to the new slice. 4. Add a new slice on an existing slice. For example, we could add a slice on `HospitalPatientNumber` called `EpicPatientNumber`. In this case both the name of the original slice as well as a unique name for the slice need to be defined. The original name and the name of the new slice are separated by “/”. In this example we would get `HospitalPatientNumber/EpicPatientNumber`. Any constraints we add at this level will only apply to the new slice. 5. Do a combination of the above. #### 2.2 Re-slicing in Forge Note that although re-slicing is supported by the FHIR .NET API (snapshot generator), Forge does not support this (yet). The slice command is currently disabled for existing slices. So the UI does not let you define re-slicing. Forge should be able to open existing profiles with re-slices. So in theory, you could add re-slicing constraints by manually editing the XML and reload it in Forge. However, this has not been tested and is unsupported. The reason that this feature is not implemented yet, is because it is quite easy to shoot yourself in the foot and break the profile (i.e. cannot reload). So it needs additional validation to protect users against possible corruption. ### 3. Nested slicing People often confuse re-slicing with nested slicing. The difference between them is that nested slices are not related to their parent element, while re-sliced elements are. In order words, a re-sliced element will have the same path as their parent element, while a nested slice will have a different one. For example, suppose we want to add a slice to the `system` element of the `NationalSecurityNumber` slice of our FirelyPatient profile. The slice on the `system` element is called a nested slice as the `system` element is a child element of the `NationalSecurityNumber` slice. The new slice on `system` is however not related to the `NationalSecurityNumber` slice and they both have a different path. ||Path|SliceName| |- |Slice 1|Identifier|HospitalPatientNumber| |Re-slice|Identifier|HospitalPatientNumber/EpicPatientNumber| |Slice 2|Identifier|NationalSecurityNumber| |Nested slice|Identifier.System|BSN|