-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds value type extension for Questionnaire items.
- Loading branch information
Showing
14 changed files
with
463 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
docs/fhir/profiles/ValueTypeExtension.StructureDefinition.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright (c) 2004-2019, University of Oslo | ||
~ All rights reserved. | ||
~ | ||
~ Redistribution and use in source and binary forms, with or without | ||
~ modification, are permitted provided that the following conditions are met: | ||
~ Redistributions of source code must retain the above copyright notice, this | ||
~ list of conditions and the following disclaimer. | ||
~ | ||
~ Redistributions in binary form must reproduce the above copyright notice, | ||
~ this list of conditions and the following disclaimer in the documentation | ||
~ and/or other materials provided with the distribution. | ||
~ Neither the name of the HISP project nor the names of its contributors may | ||
~ be used to endorse or promote products derived from this software without | ||
~ specific prior written permission. | ||
~ | ||
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
~ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
~ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
~ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
~ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
~ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
~ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
--> | ||
|
||
<StructureDefinition xmlns="http://hl7.org/fhir"> | ||
<url value="http://www.dhis2.org/dhis2-fhir-adapter/fhir/extensions/value-type" /> | ||
<name value="ValueTypeExtension" /> | ||
<status value="active" /> | ||
<experimental value="false" /> | ||
<fhirVersion value="4.0.0" /> | ||
<kind value="complex-type" /> | ||
<abstract value="false" /> | ||
<context> | ||
<type value="fhirpath" /> | ||
<expression value="Questionnaire.item" /> | ||
</context> | ||
<type value="Extension" /> | ||
<baseDefinition value="http://hl7.org/fhir/StructureDefinition/Extension" /> | ||
<derivation value="constraint" /> | ||
<differential> | ||
<element id="Extension.value[x]"> | ||
<path value="Extension.value[x]" /> | ||
<label value="FHIR Resource Type" /> | ||
<short value="DHIS2 Value Type" /> | ||
<definition value="Must be a valid DHIS2 value type (like INTEGER_POSITIVE)." /> | ||
<min value="1" /> | ||
<type> | ||
<code value="string" /> | ||
</type> | ||
</element> | ||
</differential> | ||
</StructureDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
fhir/src/main/java/org/dhis2/fhir/adapter/fhir/extension/BaseExtensionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.dhis2.fhir.adapter.fhir.extension; | ||
|
||
/* | ||
* Copyright (c) 2004-2019, University of Oslo | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the HISP project nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import ca.uhn.fhir.model.api.IElement; | ||
import org.hl7.fhir.instance.model.api.IBaseExtension; | ||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions; | ||
import org.hl7.fhir.instance.model.api.IPrimitiveType; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Utility class to process FHIR resource extensions. | ||
* | ||
* @author volsch | ||
*/ | ||
abstract class BaseExtensionUtils | ||
{ | ||
@SuppressWarnings( "unchecked" ) | ||
protected static void setStringValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable String value, @Nonnull Function<String, IElement> typeFactory ) | ||
{ | ||
resource.getExtension().removeIf( e -> url.equals( e.getUrl() ) ); | ||
|
||
if ( value != null ) | ||
{ | ||
final IBaseExtension<?, ?> extension = resource.addExtension(); | ||
|
||
extension.setUrl( url ); | ||
extension.setValue( ( (IPrimitiveType<String>) typeFactory.apply( "string" ) ).setValue( value ) ); | ||
} | ||
} | ||
|
||
private BaseExtensionUtils() | ||
{ | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
fhir/src/main/java/org/dhis2/fhir/adapter/fhir/extension/ValueTypeExtensionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.dhis2.fhir.adapter.fhir.extension; | ||
|
||
/* | ||
* Copyright (c) 2004-2019, University of Oslo | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the HISP project nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import ca.uhn.fhir.model.api.IElement; | ||
import org.dhis2.fhir.adapter.model.ValueType; | ||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Utility class to process FHIR value type extension. | ||
* | ||
* @author volsch | ||
*/ | ||
public abstract class ValueTypeExtensionUtils | ||
{ | ||
public static final String URL = "http://www.dhis2.org/dhis2-fhir-adapter/fhir/extensions/value-type"; | ||
|
||
public static void setValue( @Nonnull IBaseHasExtensions resource, @Nonnull ValueType valueType, @Nonnull Function<String, IElement> typeFactory ) | ||
{ | ||
BaseExtensionUtils.setStringValue( URL, resource, valueType.name(), typeFactory ); | ||
} | ||
|
||
private ValueTypeExtensionUtils() | ||
{ | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.