Merge branch 'master' into observastion-tests

This commit is contained in:
ItayGoren 2021-02-04 16:33:23 +02:00 committed by GitHub
commit ad8fbb87df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
320 changed files with 43203 additions and 42416 deletions

View File

@ -4,9 +4,22 @@
| :---: |
| [![Build Status][Badge-BuildPipeline]][Link-BuildPipeline] |
This is the core object handling code, with utilities (including validator), for the FHIR specification.
included in this repo:
* org.fhir.fhir.utilities: Shared code used by all the other projects - including the internationalization code
* org.fhir.fhir.r5: Object models and utilities for R5 candidate (will change regularly as new R5 candidates are released)
* org.fhir.fhir.r4: Object models and utilities for R4
* org.fhir.fhir.dstu3: Object models and utilities for STU3
* org.fhir.fhir.dstu2: Object models and utilities for STU2
* org.fhir.fhir.dstu2016may: Object models and utilities for an early STU3 candidate used by some implementers
* org.fhir.fhir.convertors: Code to convert between versions, and other version indepedence code - uses all the above projects
* org.fhir.fhir.validation: The FHIR Java validator
* org.fhir.fhir.validation.cli: Holder project for releasing the FHIR validator as as single fat jar (will be removed in the future)
### CI/CD
All intergration and delivery done on Azure pipelines. Azure project can be viewed [here][Link-AzureProject].
All integration and delivery done on Azure pipelines. Azure project can be viewed [here][Link-AzureProject].
### Current Versions
| Project | Current Release | Latest SNAPSHOT |
@ -113,7 +126,7 @@ compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r5', version: '(l
```
### Maintenance
This project is maintained by [Grahame Grieve][Link-grahameGithub] and [James Agnew][Link-jamesGithub] on behalf of the FHIR community.
This project is maintained by [Grahame Grieve][Link-grahameGithub], [James Agnew][Link-jamesGithub] and [Mark Iantorno][Link-markGithub] on behalf of the FHIR community.
[Link-AzureProject]: https://dev.azure.com/fhir-pipelines/fhir-core-library
[Link-BuildPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_build/latest?definitionId=29&branchName=master
@ -134,6 +147,7 @@ This project is maintained by [Grahame Grieve][Link-grahameGithub] and [James Ag
[Link-validationSonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.validation&v=LATEST "Sonatype Release"
[Link-grahameGithub]: https://github.com/grahamegrieve
[Link-jamesGithub]: https://github.com/jamesagnew
[Link-markGithub]: https://github.com/markiantorno
[Link-Publishing]: https://github.com/FHIR/fhir-test-cases/wiki/Publishing-Binaries
[Link-PublishingRelease]: https://github.com/FHIR/fhir-test-cases/wiki/Detailed-Release-Instructions

View File

@ -1 +1,3 @@
add test for Observation conversion from 10 to 40
* add test for Observation conversion from 10 to 40
* add procedures conversion form dstu2 to r4
* add medication conversion from dstu2 to r4

View File

@ -11,6 +11,7 @@ pool:
variables:
- group: PGP_VAR_GROUP
- group: SONATYPE_VAR_GROUP
- group: GIT_VAR_GROUP
steps:
# We need a valid signing key.
@ -43,24 +44,24 @@ steps:
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>$(GIT_USER_NAME)</username>
<password>$(GIT_PAT)</password>
</server>
<server>
<id>ossrh</id>
<username>$(SONATYPE_USER)</username>
<password>$(SONATYPE_PASS)</password>
</server>
<server>
<id>sonatype-nexus-snapshots</id>
<username>$(SONATYPE_USER)</username>
<password>$(SONATYPE_PASS)</password>
<id>$(PGP_KEYNAME)</id>
<passphrase>$(PGP_PASSPHRASE)</passphrase>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>$(SONATYPE_USER)</username>
<password>$(SONATYPE_PASS)</password>
</server>
<server>
<id>$(PGP_KEYNAME)</id>
<passphrase>$(PGP_PASSPHRASE)</passphrase>
<id>github-releases</id>
<username>markiantorno</username>
<password>$(GIT_PACKAGE_PAT)</password>
</server>
</servers>
<profiles>
@ -81,9 +82,19 @@ steps:
# Deploy the SNAPSHOT artifact to sonatype nexus.
# This is done for the master branch merges only.
- task: Maven@3
displayName: 'Deploy $(module) to Sonatype staging'
displayName: 'Deploy to Sonatype staging'
inputs:
mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml'
goals: deploy
options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -Pdeploy'
options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -pl "!org.hl7.fhir.report, !org.hl7.fhir.validation.cli" -DdeployToSonatype'
publishJUnitResults: false
# Deploy the SNAPSHOT artifact to GitHub packages.
# This is done for the master branch merges only.
- task: Maven@3
displayName: 'Deploy to GitHub packages'
inputs:
mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml'
goals: deploy
options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -pl "!org.hl7.fhir.report, !org.hl7.fhir.validation.cli" -Dmaven.test.skip -DdeployToGitHub'
publishJUnitResults: false

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.1.8-SNAPSHOT</version>
<version>5.2.21-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -65,10 +65,10 @@ import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.utils.NPMPackageGenerator;
import org.hl7.fhir.r4.utils.NPMPackageGenerator.Category;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.cache.PackageGenerator.PackageType;
import org.hl7.fhir.utilities.cache.ToolsVersion;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.hl7.fhir.utilities.npm.PackageGenerator.PackageType;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

View File

@ -41,6 +41,8 @@ public class Procedure10_30 {
if (src.hasBasedOn())
tgt.setRequest(VersionConvertor_10_30.convertReference(src.getBasedOnFirstRep()));
for (org.hl7.fhir.dstu3.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice()) tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
for (org.hl7.fhir.dstu3.model.Annotation note : src.getNote()) tgt.addNotes(VersionConvertor_10_30.convertAnnotation(note));
for (org.hl7.fhir.dstu3.model.Reference r : src.getUsedReference()) tgt.addUsed(VersionConvertor_10_30.convertReference(r));
return tgt;
}
@ -80,6 +82,8 @@ public class Procedure10_30 {
if (src.hasRequest())
tgt.addBasedOn(VersionConvertor_10_30.convertReference(src.getRequest()));
for (org.hl7.fhir.dstu2.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice()) tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
for (org.hl7.fhir.dstu2.model.Annotation note : src.getNotes()) tgt.addNote(VersionConvertor_10_30.convertAnnotation(note));
for (org.hl7.fhir.dstu2.model.Reference r : src.getUsed()) tgt.addUsedReference(VersionConvertor_10_30.convertReference(r));
return tgt;
}

View File

@ -9,6 +9,7 @@ public class AllergyIntolerance10_40 {
if (src == null)
return null;
org.hl7.fhir.r4.model.AllergyIntolerance tgt = new org.hl7.fhir.r4.model.AllergyIntolerance();
VersionConvertor_10_40.copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasOnset())
tgt.setOnset(VersionConvertor_10_40.convertType(src.getOnsetElement()));

View File

@ -0,0 +1,92 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Extension;
import org.hl7.fhir.r4.model.Medication;
import org.hl7.fhir.r4.model.Type;
import java.util.List;
public class Medication10_40 {
public static org.hl7.fhir.r4.model.Medication convertMedication(org.hl7.fhir.dstu2.model.Medication src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Medication tgt = new org.hl7.fhir.r4.model.Medication();
VersionConvertor_10_40.copyDomainResource(src, tgt);
if (src.hasCode())
tgt.setCode(VersionConvertor_10_40.convertCodeableConcept(src.getCode()));
if (src.hasIsBrandElement())
tgt.addExtension(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-Medication.isBrand",
VersionConvertor_10_40.convertBoolean(src.getIsBrandElement())
);
if (src.hasManufacturer())
tgt.setManufacturer(VersionConvertor_10_40.convertReference(src.getManufacturer()));
if (src.hasProduct()) {
if (src.getProduct().hasForm())
tgt.setForm(VersionConvertor_10_40.convertCodeableConcept(src.getProduct().getForm()));
for (org.hl7.fhir.dstu2.model.Medication.MedicationProductIngredientComponent ingridient : src.getProduct().getIngredient())
tgt.addIngredient(convertMedicationIngridient(ingridient));
if (src.getProduct().hasBatch())
tgt.setBatch(batch(src.getProduct().getBatch().get(0)));
}
if (src.hasPackage()) {
org.hl7.fhir.dstu2.model.Medication.MedicationPackageComponent package_ = src.getPackage();
if (package_.hasContainer())
tgt.addExtension(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-Medication.package.container",
VersionConvertor_10_40.convertCodeableConcept(package_.getContainer())
);
for (org.hl7.fhir.dstu2.model.Medication.MedicationPackageContentComponent c : package_.getContent())
tgt.addExtension(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-Medication.package.content",
content(c)
);
}
return tgt;
}
private static org.hl7.fhir.r4.model.Medication.MedicationBatchComponent batch(org.hl7.fhir.dstu2.model.Medication.MedicationProductBatchComponent src) {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Medication.MedicationBatchComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationBatchComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLotNumber())
tgt.setLotNumber(src.getLotNumber());
if (src.hasExpirationDate())
tgt.setExpirationDate(src.getExpirationDate());
return tgt;
}
private static org.hl7.fhir.r4.model.Extension content(org.hl7.fhir.dstu2.model.Medication.MedicationPackageContentComponent src) {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasItem())
tgt.addExtension(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-Medication.package.content",
VersionConvertor_10_40.convertReference(src.getItem())
);
if (src.hasAmount())
tgt.addExtension(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-Medication.package.content.amount",
VersionConvertor_10_40.convertSimpleQuantity(src.getAmount())
);
return tgt;
}
private static org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent convertMedicationIngridient(org.hl7.fhir.dstu2.model.Medication.MedicationProductIngredientComponent src) {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasItem())
tgt.setItem(VersionConvertor_10_40.convertReference(src.getItem()));
if (src.hasAmount())
tgt.setStrength(VersionConvertor_10_40.convertRatio(src.getAmount()));
return tgt;
}
}

View File

@ -0,0 +1,94 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Procedure;
public class Procedure10_40 {
public static org.hl7.fhir.r4.model.Procedure convertProcedure(org.hl7.fhir.dstu2.model.Procedure src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Procedure tgt = new org.hl7.fhir.r4.model.Procedure();
VersionConvertor_10_40.copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasSubject())
tgt.setSubject(VersionConvertor_10_40.convertReference(src.getSubject()));
if (src.hasStatus() && src.hasNotPerformed()) {
if (src.getNotPerformed()) {
tgt.setStatus(Procedure.ProcedureStatus.NOTDONE);
} else {
tgt.setStatus(convertProcedureStatus(src.getStatus()));
}
}
if (src.hasCategory())
tgt.setCategory(VersionConvertor_10_40.convertCodeableConcept(src.getCategory()));
if (src.hasCode())
tgt.setCode(VersionConvertor_10_40.convertCodeableConcept(src.getCode()));
if (src.hasReasonNotPerformed())
tgt.setStatusReason(VersionConvertor_10_40.convertCodeableConcept(src.getReasonNotPerformed().get(0)));
for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getBodySite()) tgt.addBodySite(VersionConvertor_10_40.convertCodeableConcept(t));
if (src.hasReasonCodeableConcept())
tgt.addReasonCode(VersionConvertor_10_40.convertCodeableConcept(src.getReasonCodeableConcept()));
if (src.hasReasonReference())
tgt.addReasonReference(VersionConvertor_10_40.convertReference(src.getReasonReference()));
if (src.hasPerformed())
tgt.setPerformed(VersionConvertor_10_40.convertType(src.getPerformed()));
for (org.hl7.fhir.dstu2.model.Procedure.ProcedurePerformerComponent t : src.getPerformer()) tgt.addPerformer(convertProcedurePerformerComponent(t));
if (src.hasEncounter())
tgt.setEncounter(VersionConvertor_10_40.convertReference(src.getEncounter()));
if (src.hasLocation())
tgt.setLocation(VersionConvertor_10_40.convertReference(src.getLocation()));
if (src.hasOutcome())
tgt.setOutcome(VersionConvertor_10_40.convertCodeableConcept(src.getOutcome()));
for (org.hl7.fhir.dstu2.model.Reference t : src.getReport()) tgt.addReport(VersionConvertor_10_40.convertReference(t));
for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getComplication()) tgt.addComplication(VersionConvertor_10_40.convertCodeableConcept(t));
for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getFollowUp()) tgt.addFollowUp(VersionConvertor_10_40.convertCodeableConcept(t));
if (src.hasRequest())
tgt.addBasedOn(VersionConvertor_10_40.convertReference(src.getRequest()));
for (org.hl7.fhir.dstu2.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice()) tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
for (org.hl7.fhir.dstu2.model.Annotation note : src.getNotes()) tgt.addNote(VersionConvertor_10_40.convertAnnotation(note));
for (org.hl7.fhir.dstu2.model.Reference r : src.getUsed()) tgt.addUsedReference(VersionConvertor_10_40.convertReference(r));
return tgt;
}
private static org.hl7.fhir.r4.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.dstu2.model.Procedure.ProcedureStatus src) {
switch(src) {
case ENTEREDINERROR:
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ENTEREDINERROR;
case INPROGRESS:
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.INPROGRESS;
case ABORTED:
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.STOPPED;
case COMPLETED:
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED;
default:
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.NULL;
}
}
public static org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent convertProcedurePerformerComponent(org.hl7.fhir.dstu2.model.Procedure.ProcedurePerformerComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasActor())
tgt.setActor(VersionConvertor_10_40.convertReference(src.getActor()));
if (src.hasRole())
tgt.setFunction(VersionConvertor_10_40.convertCodeableConcept(src.getRole()));
return tgt;
}
public static org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.dstu2.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasAction())
tgt.setAction(VersionConvertor_10_40.convertCodeableConcept(src.getAction()));
if (src.hasManipulated())
tgt.setManipulated(VersionConvertor_10_40.convertReference(src.getManipulated()));
return tgt;
}
}

View File

@ -0,0 +1,258 @@
package org.hl7.fhir.convertors.conv30_40;
import org.hl7.fhir.convertors.VersionConvertor_30_40;
import org.hl7.fhir.dstu3.model.Device;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Patient;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
public class Device30_40 extends VersionConvertor_30_40 {
public static org.hl7.fhir.r4.model.Device convertDevice(org.hl7.fhir.dstu3.model.Device src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r4.model.Device tgt = new org.hl7.fhir.r4.model.Device();
copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t));
if (src.hasUdi()) {
org.hl7.fhir.r4.model.Device.DeviceUdiCarrierComponent carrierComponent = tgt.getUdiCarrierFirstRep();
carrierComponent.setDeviceIdentifierElement(VersionConvertor_30_40.convertString(src.getUdi().getDeviceIdentifierElement()));
carrierComponent.setJurisdictionElement(VersionConvertor_30_40.convertUri(src.getUdi().getJurisdictionElement()));
carrierComponent.setCarrierHRFElement(VersionConvertor_30_40.convertString(src.getUdi().getCarrierHRFElement()));
carrierComponent.setCarrierAIDCElement(VersionConvertor_30_40.convertBase64Binary(src.getUdi().getCarrierAIDCElement()));
carrierComponent.setIssuerElement(VersionConvertor_30_40.convertUri(src.getUdi().getIssuerElement()));
carrierComponent.setEntryTypeElement(convertUDIEntryType(src.getUdi().getEntryTypeElement()));
tgt.setUdiCarrier(Collections.singletonList(carrierComponent));
org.hl7.fhir.r4.model.Device.DeviceDeviceNameComponent nameComponent = tgt.getDeviceNameFirstRep();
nameComponent.setNameElement(VersionConvertor_30_40.convertString(src.getUdi().getNameElement()));
nameComponent.setType(org.hl7.fhir.r4.model.Device.DeviceNameType.UDILABELNAME);
}
if (src.hasStatus())
tgt.setStatusElement(convertFHIRDeviceStatus(src.getStatusElement()));
if (src.hasType())
tgt.setType(convertCodeableConcept(src.getType()));
if (src.hasLotNumber())
tgt.setLotNumberElement(convertString(src.getLotNumberElement()));
if (src.hasManufacturer())
tgt.setManufacturerElement(convertString(src.getManufacturerElement()));
if (src.hasManufactureDate())
tgt.setManufactureDateElement(convertDateTime(src.getManufactureDateElement()));
if (src.hasExpirationDate())
tgt.setExpirationDateElement(convertDateTime(src.getExpirationDateElement()));
if (src.hasModelElement())
tgt.setModelNumberElement(VersionConvertor_30_40.convertString(src.getModelElement()));
if (src.hasVersionElement())
tgt.setVersion(Collections.singletonList(tgt.getVersionFirstRep().setValueElement(VersionConvertor_30_40.convertString(src.getVersionElement()))));
if (src.hasPatient())
tgt.setPatient(convertReference(src.getPatient()));
if (src.hasOwner())
tgt.setOwner(convertReference(src.getOwner()));
if (src.hasContact())
tgt.setContact(src.getContact().stream().map(VersionConvertor_30_40::convertContactPoint).collect(Collectors.toList()));
if (src.hasLocation())
tgt.setLocation(convertReference(src.getLocation()));
if (src.hasUrl())
tgt.setUrlElement(convertUri(src.getUrlElement()));
for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(convertAnnotation(t));
for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSafety()) tgt.addSafety(convertCodeableConcept(t));
return tgt;
}
public static org.hl7.fhir.dstu3.model.Device convertDevice(org.hl7.fhir.r4.model.Device src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu3.model.Device tgt = new org.hl7.fhir.dstu3.model.Device();
copyDomainResource(src, tgt);
for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t));
if (src.hasUdiCarrier()) {
Device.DeviceUdiComponent udi = tgt.getUdi();
udi.setDeviceIdentifierElement(VersionConvertor_30_40.convertString(src.getUdiCarrierFirstRep().getDeviceIdentifierElement()));
udi.setJurisdictionElement(VersionConvertor_30_40.convertUri(src.getUdiCarrierFirstRep().getJurisdictionElement()));
udi.setCarrierHRFElement(VersionConvertor_30_40.convertString(src.getUdiCarrierFirstRep().getCarrierHRFElement()));
udi.setCarrierAIDCElement(VersionConvertor_30_40.convertBase64Binary(src.getUdiCarrierFirstRep().getCarrierAIDCElement()));
udi.setIssuerElement(VersionConvertor_30_40.convertUri(src.getUdiCarrierFirstRep().getIssuerElement()));
udi.setEntryTypeElement(convertUDIEntryType(src.getUdiCarrierFirstRep().getEntryTypeElement()));
tgt.setUdi(udi);
}
if (src.hasStatus())
tgt.setStatusElement(convertFHIRDeviceStatus(src.getStatusElement()));
if (src.hasType())
tgt.setType(convertCodeableConcept(src.getType()));
if (src.hasLotNumber())
tgt.setLotNumberElement(convertString(src.getLotNumberElement()));
if (src.hasManufacturer())
tgt.setManufacturerElement(convertString(src.getManufacturerElement()));
if (src.hasManufactureDate())
tgt.setManufactureDateElement(convertDateTime(src.getManufactureDateElement()));
if (src.hasExpirationDate())
tgt.setExpirationDateElement(convertDateTime(src.getExpirationDateElement()));
if (src.hasModelNumber())
tgt.setModel(src.getModelNumber());
if (src.hasVersion())
tgt.setVersionElement(VersionConvertor_30_40.convertString(src.getVersion().get(0).getValueElement()));
if (src.hasDeviceName())
tgt.setUdi(tgt.getUdi().setName(src.getDeviceName().get(0).getName()));
if (src.hasPatient())
tgt.setPatient(convertReference(src.getPatient()));
if (src.hasOwner())
tgt.setOwner(convertReference(src.getOwner()));
if (src.hasContact())
tgt.setContact(src.getContact().stream().map(VersionConvertor_30_40::convertContactPoint).collect(Collectors.toList()));
if (src.hasLocation())
tgt.setLocation(convertReference(src.getLocation()));
for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact()) tgt.addContact(convertContactPoint(t));
if (src.hasLocation())
tgt.setLocation(VersionConvertor_30_40.convertReference(src.getLocation()));
if (src.hasUrl())
tgt.setUrlElement(convertUri(src.getUrlElement()));
for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(convertAnnotation(t));
for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSafety()) tgt.addSafety(convertCodeableConcept(t));
return tgt;
}
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Device.FHIRDeviceStatus> convertFHIRDeviceStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Device.FHIRDeviceStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Device.FHIRDeviceStatusEnumFactory());
VersionConvertor_30_40.copyElement(src, tgt);
switch (src.getValue()) {
case ACTIVE:
tgt.setValue(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ACTIVE);
break;
case INACTIVE:
tgt.setValue(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.INACTIVE);
break;
case ENTEREDINERROR:
tgt.setValue(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ENTEREDINERROR);
break;
case UNKNOWN:
tgt.setValue(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.UNKNOWN);
break;
default:
tgt.setValue(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.NULL);
break;
}
return tgt;
}
static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus> convertFHIRDeviceStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Device.FHIRDeviceStatus> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatusEnumFactory());
VersionConvertor_30_40.copyElement(src, tgt);
switch (src.getValue()) {
case ACTIVE:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.ACTIVE);
break;
case INACTIVE:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.INACTIVE);
break;
case ENTEREDINERROR:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.ENTEREDINERROR);
break;
case UNKNOWN:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.UNKNOWN);
break;
default:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus.NULL);
break;
}
return tgt;
}
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Device.UDIEntryType> convertUDIEntryType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.UDIEntryType> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Device.UDIEntryType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Device.UDIEntryTypeEnumFactory());
VersionConvertor_30_40.copyElement(src, tgt);
switch (src.getValue()) {
case BARCODE:
tgt.setValue(org.hl7.fhir.r4.model.Device.UDIEntryType.BARCODE);
break;
case RFID:
tgt.setValue(org.hl7.fhir.r4.model.Device.UDIEntryType.RFID);
break;
case MANUAL:
tgt.setValue(org.hl7.fhir.r4.model.Device.UDIEntryType.MANUAL);
break;
case CARD:
tgt.setValue(org.hl7.fhir.r4.model.Device.UDIEntryType.CARD);
break;
case SELFREPORTED:
tgt.setValue(org.hl7.fhir.r4.model.Device.UDIEntryType.SELFREPORTED);
break;
case UNKNOWN:
tgt.setValue(org.hl7.fhir.r4.model.Device.UDIEntryType.UNKNOWN);
break;
default:
tgt.setValue(org.hl7.fhir.r4.model.Device.UDIEntryType.NULL);
break;
}
return tgt;
}
static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.UDIEntryType> convertUDIEntryType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Device.UDIEntryType> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.UDIEntryType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Device.UDIEntryTypeEnumFactory());
VersionConvertor_30_40.copyElement(src, tgt);
switch (src.getValue()) {
case BARCODE:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.UDIEntryType.BARCODE);
break;
case RFID:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.UDIEntryType.RFID);
break;
case MANUAL:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.UDIEntryType.MANUAL);
break;
case CARD:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.UDIEntryType.CARD);
break;
case SELFREPORTED:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.UDIEntryType.SELFREPORTED);
break;
case UNKNOWN:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.UDIEntryType.UNKNOWN);
break;
default:
tgt.setValue(org.hl7.fhir.dstu3.model.Device.UDIEntryType.NULL);
break;
}
return tgt;
}
}

View File

@ -3,6 +3,7 @@ package org.hl7.fhir.convertors.conv40_50;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode;
import java.util.stream.Collectors;
@ -220,8 +221,11 @@ public class StructureMap40_50 extends VersionConvertor_40_50 {
tgt.setNameElement(convertId(src.getNameElement()));
if (src.hasExtends())
tgt.setExtendsElement(convertId(src.getExtendsElement()));
if (src.hasTypeMode())
if (src.hasTypeMode()) {
tgt.setTypeModeElement(convertStructureMapGroupTypeMode(src.getTypeModeElement()));
} else {
tgt.setTypeMode(StructureMapGroupTypeMode.NONE);
}
if (src.hasDocumentation())
tgt.setDocumentationElement(convertString(src.getDocumentationElement()));
for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent t : src.getInput()) tgt.addInput(convertStructureMapGroupInputComponent(t));

View File

@ -5,7 +5,7 @@ import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.ElementDefinition;
import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage;
import java.util.ArrayList;
import java.util.List;

View File

@ -6,7 +6,7 @@ import org.hl7.fhir.r4.model.CanonicalType;
import org.hl7.fhir.r4.model.ElementDefinition;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage;
import java.util.ArrayList;
import java.util.List;

View File

@ -8,7 +8,7 @@ import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage;
import com.google.gson.JsonSyntaxException;

View File

@ -55,9 +55,9 @@ import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.utilities.cache.NpmPackage;
import com.google.gson.JsonSyntaxException;

View File

@ -56,9 +56,9 @@ import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.utilities.cache.NpmPackage;
import com.google.gson.JsonSyntaxException;

View File

@ -56,9 +56,9 @@ import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.utilities.cache.NpmPackage;
import com.google.gson.JsonSyntaxException;

View File

@ -56,9 +56,9 @@ import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.utilities.cache.NpmPackage;
import com.google.gson.JsonSyntaxException;

View File

@ -55,9 +55,9 @@ import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.utilities.cache.NpmPackage;
import com.google.gson.JsonSyntaxException;

View File

@ -35,30 +35,31 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.hl7.fhir.dstu3.formats.IParser.OutputStyle;
import org.hl7.fhir.dstu3.formats.XmlParser;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemHierarchyMeaning;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.DateTimeType;
import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus;
import org.hl7.fhir.dstu3.terminologies.CodeSystemUtilities;
import org.hl7.fhir.dstu3.utils.ToolingExtensions;
import org.hl7.fhir.r4.formats.IParser.OutputStyle;
import org.hl7.fhir.r4.formats.XmlParser;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode;
import org.hl7.fhir.r4.model.CodeSystem.CodeSystemHierarchyMeaning;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r4.model.CodeSystem.PropertyType;
import org.hl7.fhir.r4.model.DateTimeType;
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.terminologies.CodeSystemUtilities;
import org.hl7.fhir.r4.utils.ToolingExtensions;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r4.formats.JsonParser;
import org.hl7.fhir.utilities.CSVReader;
import org.hl7.fhir.utilities.Utilities;
public class NUCCConvertor {
private String[] last = new String[2];
private ConceptDefinitionComponent[] concepts = new ConceptDefinitionComponent[2];
public static void main(String[] args) throws Exception {
new NUCCConvertor().execute();
}
public void execute() throws IOException, FHIRException {
public void execute() throws IOException, FHIRException {
CSVReader csv = new CSVReader(new FileInputStream("c:\\temp\\nucc.csv"));
CodeSystem cs = new CodeSystem();
cs.setId("nucc-provider-taxonomy");
@ -66,50 +67,41 @@ public class NUCCConvertor {
cs.setName("NUCC Provider Taxonomy");
cs.setDateElement(new DateTimeType());
cs.setDescription("The Health Care Provider Taxonomy code is a unique alphanumeric code, ten characters in length. The code set is structured into three distinct 'Levels' including Provider Type, Classification, and Area of Specialization");
cs.setCopyright("See NUCC copyright statement");
cs.setCopyright("Vendors must request a license to include this in a product per the following: 'Vendors interested in incorporating the Health Care Provider Taxonomy code set into their commercial products must complete the license request form found on the CSV page.' Using the form at the url listed. The preamble is reproduced below: http://www.nucc.org/index.php?option=com_content&view=article&id=111&Itemid=110");
cs.setStatus(PublicationStatus.ACTIVE);
cs.setContent(CodeSystemContentMode.COMPLETE);
cs.setExperimental(false);
cs.setValueSet("http://hl7.org/fhir/ValueSet/nucc-provider-taxonomy");
cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.CLASSIFIEDWITH);
cs.addProperty().setCode("grouping").setType(PropertyType.STRING).setDescription("A major grouping of service(s) or occupation(s) of health care providers. For example: Allopathic & Osteopathic Physicians, Dental Providers, Hospitals, etc");
cs.addProperty().setCode("classification").setType(PropertyType.STRING).setDescription("A more specific service or occupation related to the Provider Grouping.e");
cs.addProperty().setCode("specialization").setType(PropertyType.STRING).setDescription("A more specialized area of the Classification in which a provider chooses to practice or make services available.");
csv.parseLine();
while (csv.ready())
{
while (csv.ready()) {
String[] values = csv.parseLine();
processLine(cs, values);
}
csv.close();
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\nucc.xml"), cs);
cs.sort();
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\nucc.json"), cs);
}
private void processLine(CodeSystem cs, String[] values) throws FHIRFormatError {
if (!values[1].equals(last[0])) {
last[1] = "";
last[0] = values[1];
concepts[0] = new ConceptDefinitionComponent();
cs.getConcept().add(concepts[0]);
concepts[0].setDisplay(values[1]);
concepts[0].setCode("base-"+Integer.toString(cs.getConcept().size()));
CodeSystemUtilities.setNotSelectable(cs, concepts[0]);
ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
cs.getConcept().add(cc);
cc.setCode(values[0]);
cc.setDisplay(values[4]);
if (!Utilities.noString(values[1])) {
cc.addProperty().setCode("grouping").setValue(new StringType(values[1]));
}
if (!values[2].equals(last[1])) {
last[1] = values[2];
concepts[1] = new ConceptDefinitionComponent();
concepts[0].getConcept().add(concepts[1]);
concepts[1].setCode(values[0]);
concepts[1].setDisplay(values[2]);
concepts[1].setDefinition(values[4]);
if (values.length > 5 && !Utilities.noString(values[5]))
ToolingExtensions.addCSComment(concepts[1], values[5]);
} else if (!Utilities.noString(values[3])) {
ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
concepts[1].getConcept().add(cc);
cc.setCode(values[0]);
cc.setDisplay(values[3]);
cc.setDefinition(values[4]);
if (values.length > 5 && !Utilities.noString(values[5]))
ToolingExtensions.addCSComment(cc, values[5]);
if (!Utilities.noString(values[2])) {
cc.addProperty().setCode("classification").setValue(new StringType(values[2]));
}
if (!Utilities.noString(values[3])) {
cc.addProperty().setCode("specialization").setValue(new StringType(values[3]));
}
if (values.length > 5 && !Utilities.noString(values[5]))
cc.setDefinition(values[5]);
}
}

View File

@ -33,9 +33,9 @@ import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.cache.NpmPackageIndexBuilder;
import org.hl7.fhir.utilities.json.JSONUtil;
import org.hl7.fhir.utilities.json.JsonTrackingParser;
import org.hl7.fhir.utilities.npm.NpmPackageIndexBuilder;
import com.google.common.base.Charsets;
import com.google.gson.JsonArray;

View File

@ -12,9 +12,9 @@ import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.cache.ToolsVersion;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.w3c.dom.Document;
public class OIDBasedValueSetImporter {

View File

@ -19,9 +19,9 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.utilities.CSVReader;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.cache.ToolsVersion;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.ToolsVersion;
public class PhinVadsImporter extends OIDBasedValueSetImporter {

View File

@ -0,0 +1,252 @@
package org.hl7.fhir.convertors.misc;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.time.DateUtils;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.VersionConvertor_30_50;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.Provenance;
import org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import org.hl7.fhir.utilities.npm.ToolsVersion;
public class UTGVersionSorter {
private FilesystemPackageCacheManager pcm;
public class CanonicalResourceAnalysis {
private CanonicalResource resource;
private CanonicalResource r2;
private CanonicalResource r3;
private CanonicalResource r4;
private String fmm;
private boolean normative;
private String recommendation;
private String filename;
public CanonicalResourceAnalysis(CanonicalResource cr, String filename) {
this.resource = cr;
this.filename = filename;
}
public String summary() {
// return "Relevant: "+resource.getUrl()+" [r2: "+r2Ver+"/"+r2Fmm+"]"+" [r3: "+r3Ver+"/"+r3Fmm+"]"+" [r4: "+r4Ver+"/"+r4Fmm+"/"+r4Normative+"] ---> "+recommendation;
return resource.getUrl()+" ---> "+recommendation+" in "+filename;
}
public void analyse(Map<String, CanonicalResource> r2l, Map<String, CanonicalResource> r3l, Map<String, CanonicalResource> r4l) {
r2 = findMatch(r2l);
r3 = findMatch(r3l);
r4 = findMatch(r4l);
fmm = r4 != null ? ToolingExtensions.readStringExtension(r4, ToolingExtensions.EXT_FMM_LEVEL) : null;
normative = (r4 != null) && ToolingExtensions.readStringExtension(r4, ToolingExtensions.EXT_NORMATIVE_VERSION) != null;
if (normative) {
recommendation = "1.0.0";
} else if (Utilities.existsInList(fmm,"3", "4", "5")) {
recommendation = "0.5.0";
} else {
int i = 1;
if (r2 != null && r3 != null && !match(r2, r3, r2l, r3l)) {
i++;
}
if (r3 != null && r4 != null && !match(r3, r4, r3l, r4l)) {
i++;
}
recommendation = "0."+i+".0";
}
}
private boolean match(CanonicalResource l, CanonicalResource r, Map<String, CanonicalResource> ll, Map<String, CanonicalResource> rl) {
if (l instanceof CodeSystem && r instanceof CodeSystem) {
return matchCS((CodeSystem) l, (CodeSystem) r);
} else if (l instanceof ValueSet && r instanceof ValueSet) {
return matchVS((ValueSet) l, (ValueSet) r, ll, rl);
} else {
return false;
}
}
private boolean matchVS(ValueSet l, ValueSet r, Map<String, CanonicalResource> ll, Map<String, CanonicalResource> rl) {
if (l.getCompose().getInclude().size() == 1 && l.getCompose().getExclude().isEmpty() && l.getCompose().getIncludeFirstRep().hasSystem() && !l.getCompose().getIncludeFirstRep().hasConcept() && !l.getCompose().getIncludeFirstRep().hasFilter() &&
r.getCompose().getInclude().size() == 1 && r.getCompose().getExclude().isEmpty() && r.getCompose().getIncludeFirstRep().hasSystem() && !r.getCompose().getIncludeFirstRep().hasConcept() && !r.getCompose().getIncludeFirstRep().hasFilter()) {
CodeSystem lc = (CodeSystem) ll.get(l.getCompose().getIncludeFirstRep().getSystem());
CodeSystem rc = (CodeSystem) rl.get(l.getCompose().getIncludeFirstRep().getSystem());
if (lc != null && rc != null) {
return matchCS(lc, rc);
}
}
return false;
}
private boolean matchCS(CodeSystem l, CodeSystem r) {
return Base.compareDeep(l.getConcept(), r.getConcept(), false);
}
public CanonicalResource findMatch(Map<String, CanonicalResource> r2) {
CanonicalResource r = r2.get(resource.getUrl());
if (r == null) {
r = r2.get(resource.getUrl().replaceAll("http://terminology.hl7.org/", "http://hl7.org/fhir/"));
}
if (r == null) {
r = r2.get(resource.getUrl().replaceAll("http://terminology.hl7.org/CodeSystem", "http://hl7.org/fhir/"));
}
return r;
}
public String getId() {
return resource.getId();
}
public String fhirType() {
return resource.fhirType();
}
}
private Date runTime = new Date();
public static void main(String[] args) throws FileNotFoundException, FHIRException, IOException, ParseException, URISyntaxException {
new UTGVersionSorter().execute("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth");
}
private void execute(String source) throws IOException {
List<CanonicalResourceAnalysis> list = new ArrayList<>();
System.out.println("Loading UTG");
loadFromSource(list, new File(source));
Map<String, CanonicalResource> r2 = loadPackageR2("hl7.fhir.r2.core");
Map<String, CanonicalResource> r3 = loadPackageR3("hl7.fhir.r3.core");
Map<String, CanonicalResource> r4 = loadPackageR4("hl7.fhir.r4.core");
System.out.println("Processing");
for (CanonicalResourceAnalysis cr : list) {
cr.analyse(r2,r3,r4);
}
Bundle b = (Bundle) new JsonParser().parse(new FileInputStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"));
System.out.println("Summary");
for (CanonicalResourceAnalysis cr : list) {
System.out.println(cr.summary());
Provenance p = new Provenance();
b.addEntry().setResource(p).setFullUrl("http://terminology.hl7.org/fhir/Provenance/fhir-1.0.51-"+cr.getId());
p.setId("hx-fhir-1.0.51-"+cr.getId());
p.addTarget().setReference(cr.fhirType()+"/"+cr.getId());
p.getOccurredPeriod().setEnd(runTime, TemporalPrecisionEnum.DAY);
p.setRecorded(runTime);
p.addReason().setText("Reset Version after migration to UTG").addCoding("http://terminology.hl7.org/CodeSystem/v3-ActReason","METAMGT", null);
p.getActivity().addCoding("http://terminology.hl7.org/CodeSystem/v3-DataOperation", "UPDATE", null);
ProvenanceAgentComponent pa = p.addAgent();
pa.getType().addCoding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "author", null);
pa.getWho().setDisplay("Grahame Grieve");
pa = p.addAgent();
pa.getType().addCoding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "custodian", null);
pa.getWho().setDisplay("Vocabulary WG");
CanonicalResource res = cr.resource;
res.setVersion(cr.recommendation);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(cr.filename), res);
}
System.out.println();
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"), b);
System.out.println("Done");
}
private Map<String, CanonicalResource> loadPackageR2(String id) throws IOException {
Map<String, CanonicalResource>res = new HashMap<>();
if (pcm == null) {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
}
System.out.println("Load "+id);
NpmPackage npm = pcm.loadPackage(id);
for (PackageResourceInformation p : npm.listIndexedResources("CodeSystem", "ValueSet")) {
CanonicalResource r = (CanonicalResource) VersionConvertor_10_50.convertResource(new org.hl7.fhir.dstu2.formats.JsonParser().parse(npm.load(p)));
res.put(r.getUrl(), r);
}
return res;
}
private Map<String, CanonicalResource> loadPackageR3(String id) throws IOException {
Map<String, CanonicalResource>res = new HashMap<>();
if (pcm == null) {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
}
System.out.println("Load "+id);
NpmPackage npm = pcm.loadPackage(id);
for (PackageResourceInformation p : npm.listIndexedResources("CodeSystem", "ValueSet")) {
CanonicalResource r = (CanonicalResource) VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(npm.load(p)), false);
res.put(r.getUrl(), r);
}
return res;
}
private Map<String, CanonicalResource> loadPackageR4(String id) throws IOException {
Map<String, CanonicalResource>res = new HashMap<>();
if (pcm == null) {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
}
System.out.println("Load "+id);
NpmPackage npm = pcm.loadPackage(id);
for (PackageResourceInformation p : npm.listIndexedResources("CodeSystem", "ValueSet")) {
CanonicalResource r = (CanonicalResource) VersionConvertor_40_50.convertResource(new org.hl7.fhir.r4.formats.JsonParser().parse(npm.load(p)));
res.put(r.getUrl(), r);
}
return res;
}
private void loadFromSource(List<CanonicalResourceAnalysis> list, File source) {
for (File f : source.listFiles()) {
if (f.isDirectory()) {
loadFromSource(list, f);
} else if (f.getName().endsWith(".xml")) {
try {
Resource r = new XmlParser().parse(new FileInputStream(f));
if (r instanceof CanonicalResource) {
CanonicalResource cr = (CanonicalResource) r;
cr.setUserData("path", f.getAbsolutePath());
if (cr.hasVersion() && cr.getVersion().startsWith("4.") && !Utilities.existsInList(cr.getId(), "v3-DataOperation", "v3-KnowledgeSubjectObservationValue")) {
list.add(new CanonicalResourceAnalysis(cr, f.getAbsolutePath()));
}
}
} catch (Exception e) {
System.out.println(f.getAbsolutePath()+" not a resource? "+e.getMessage());
}
}
}
}
}

View File

@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map.Entry;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

View File

@ -36,6 +36,7 @@ import java.net.URISyntaxException;
import org.hl7.fhir.r5.model.FhirPublication;
import org.hl7.fhir.r5.terminologies.TerminologyClient;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
public class TerminologyClientFactory {
@ -53,6 +54,20 @@ public class TerminologyClientFactory {
}
}
public static TerminologyClient makeClient(String url, String v) throws URISyntaxException {
if (v == null)
return new TerminologyClientR5(checkEndsWith("/r4", url));
v = VersionUtilities.getMajMin(v);
switch (v) {
case "1.0": return new TerminologyClientR2(checkEndsWith("/r2", url));
case "1.4": return new TerminologyClientR3(checkEndsWith("/r3", url)); // r3 is the least worst match
case "3.0": return new TerminologyClientR3(checkEndsWith("/r3", url));
case "4.0": return new TerminologyClientR4(checkEndsWith("/r4", url));
case "4.5": return new TerminologyClientR5(checkEndsWith("/r4", url)); // r4 for now, since the terminology is currently the same
default: throw new Error("The version "+v.toString()+" is not currently supported");
}
}
private static String checkEndsWith(String term, String url) {
if (url.endsWith(term))
return url;

View File

@ -36,15 +36,19 @@ import java.util.Map;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.dstu2.model.Resource;
import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.TerminologyServiceException;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CapabilityStatement;
import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.model.TerminologyCapabilities;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.terminologies.TerminologyClient;
import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.Utilities;
public class TerminologyClientR2 implements TerminologyClient {
@ -124,5 +128,27 @@ public class TerminologyClientR2 implements TerminologyClient {
return (Bundle) VersionConvertor_10_50.convertResource(client.transaction((org.hl7.fhir.dstu2.model.Bundle) VersionConvertor_10_50.convertResource(batch)));
}
@Override
public CanonicalResource read(String type, String id) {
Class<Resource> t;
try {
t = (Class<Resource>) Class.forName("org.hl7.fhir.dstu2.model."+type);// todo: do we have to deal with any resource renaming? Use cases are limited...
} catch (ClassNotFoundException e) {
throw new FHIRException("Unable to fetch resources of type "+type+" in R2");
}
org.hl7.fhir.dstu2.model.Resource r2 = client.read(t, id);
if (r2 == null) {
throw new FHIRException("Unable to fetch resource "+Utilities.pathURL(getAddress(), type, id));
}
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_10_50.convertResource(r2);
if (r5 != null) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 (internal representation)");
}
if (!(r5 instanceof CanonicalResource)) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 canonical resource (internal representation)");
}
return (CanonicalResource) r5;
}
}

View File

@ -34,17 +34,21 @@ package org.hl7.fhir.convertors.txClient;
import java.net.URISyntaxException;
import java.util.Map;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.VersionConvertor_30_50;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.dstu3.utils.client.FHIRToolingClient;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CapabilityStatement;
import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.model.TerminologyCapabilities;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.terminologies.TerminologyClient;
import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.Utilities;
public class TerminologyClientR3 implements TerminologyClient {
@ -124,5 +128,27 @@ public class TerminologyClientR3 implements TerminologyClient {
return (Bundle) VersionConvertor_30_50.convertResource(client.transaction((org.hl7.fhir.dstu3.model.Bundle) VersionConvertor_30_50.convertResource(batch, false)), false);
}
@Override
public CanonicalResource read(String type, String id) {
Class<Resource> t;
try {
t = (Class<Resource>) Class.forName("org.hl7.fhir.dstu3.model."+type);// todo: do we have to deal with any resource renaming? Use cases are limited...
} catch (ClassNotFoundException e) {
throw new FHIRException("Unable to fetch resources of type "+type+" in R2");
}
org.hl7.fhir.dstu3.model.Resource r3 = client.read(t, id);
if (r3 == null) {
throw new FHIRException("Unable to fetch resource "+Utilities.pathURL(getAddress(), type, id));
}
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_30_50.convertResource(r3, false);
if (r5 != null) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 (internal representation)");
}
if (!(r5 instanceof CanonicalResource)) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 canonical resource (internal representation)");
}
return (CanonicalResource) r5;
}
}

View File

@ -34,17 +34,21 @@ package org.hl7.fhir.convertors.txClient;
import java.net.URISyntaxException;
import java.util.Map;
import org.hl7.fhir.convertors.VersionConvertor_30_50;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.convertors.conv40_50.TerminologyCapabilities40_50;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.utils.client.FHIRToolingClient;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CapabilityStatement;
import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.model.TerminologyCapabilities;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.terminologies.TerminologyClient;
import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.Utilities;
public class TerminologyClientR4 implements TerminologyClient {
@ -124,4 +128,26 @@ public class TerminologyClientR4 implements TerminologyClient {
return (Bundle) VersionConvertor_40_50.convertResource(client.transaction((org.hl7.fhir.r4.model.Bundle) VersionConvertor_40_50.convertResource(batch)));
}
@Override
public CanonicalResource read(String type, String id) {
Class<Resource> t;
try {
t = (Class<Resource>) Class.forName("org.hl7.fhir.r4.model."+type);// todo: do we have to deal with any resource renaming? Use cases are limited...
} catch (ClassNotFoundException e) {
throw new FHIRException("Unable to fetch resources of type "+type+" in R2");
}
org.hl7.fhir.r4.model.Resource r4 = client.read(t, id);
if (r4 == null) {
throw new FHIRException("Unable to fetch resource "+Utilities.pathURL(getAddress(), type, id));
}
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_40_50.convertResource(r4);
if (r5 != null) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 (internal representation)");
}
if (!(r5 instanceof CanonicalResource)) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 canonical resource (internal representation)");
}
return (CanonicalResource) r5;
}
}

View File

@ -34,8 +34,11 @@ package org.hl7.fhir.convertors.txClient;
import java.net.URISyntaxException;
import java.util.Map;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CapabilityStatement;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.Parameters;
@ -44,6 +47,7 @@ import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.terminologies.TerminologyClient;
import org.hl7.fhir.r5.utils.client.FHIRToolingClient;
import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.Utilities;
public class TerminologyClientR5 implements TerminologyClient {
@ -116,4 +120,22 @@ public class TerminologyClientR5 implements TerminologyClient {
return client.transaction(batch);
}
@Override
public CanonicalResource read(String type, String id) {
Class<Resource> t;
try {
t = (Class<Resource>) Class.forName("org.hl7.fhir.r5.model."+type);// todo: do we have to deal with any resource renaming? Use cases are limited...
} catch (ClassNotFoundException e) {
throw new FHIRException("Unable to fetch resources of type "+type+" in R5");
}
org.hl7.fhir.r5.model.Resource r5 = client.read(t, id);
if (r5 != null) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 (internal representation)");
}
if (!(r5 instanceof CanonicalResource)) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 canonical resource (internal representation)");
}
return (CanonicalResource) r5;
}
}

View File

@ -0,0 +1,27 @@
package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.loaders.R2ToR3Loader;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class AdministrativeGender10_30Test {
@Test
@DisplayName("Test 10_30 extension present, value is not")
public void testMedicationRequestConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/administrative_gender_null.json");
org.hl7.fhir.dstu2.model.Patient dstu2 = (org.hl7.fhir.dstu2.model.Patient) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor30 advisor = new R2ToR3Loader();
org.hl7.fhir.dstu3.model.Resource stu_actual = VersionConvertor_10_30.convertResource(dstu2, advisor);
}
}

View File

@ -0,0 +1,24 @@
package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class TimingRepeatComponent10_30Test {
@Test
@DisplayName("Issue #383 - Test 10_30 TimingRepeatComponent with Timing.when as null")
public void testMedicationRequestConversion() {
final int SET_COUNT = 11;
org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent();
src.setCount(SET_COUNT);
org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = VersionConvertor_10_30.convertTimingRepeatComponent(src);
Assertions.assertEquals(SET_COUNT, tgt.getCount(), "Count field not preserved through version conversion.");
Assertions.assertFalse(tgt.hasWhen(), "hasWhen() should return false for this conversion.");
Assertions.assertTrue(tgt.getWhen().isEmpty(), "When no _when time_ is provided, getWhen() should return an empty list.");
}
}

View File

@ -0,0 +1,31 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Medication10_40Test {
@Test
@DisplayName("Test 10_40 Medication conversion")
public void testMedicationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_medication_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_medication_40.json");
org.hl7.fhir.dstu2.model.Medication dstu2 = (org.hl7.fhir.dstu2.model.Medication) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
}

View File

@ -0,0 +1,31 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Procedure10_40Test {
@Test
@DisplayName("Test 10_40 Procedure conversion")
public void testProcedureConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_procedure_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_procedure_40.json");
org.hl7.fhir.dstu2.model.Procedure dstu2 = (org.hl7.fhir.dstu2.model.Procedure) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
}

View File

@ -0,0 +1,43 @@
package org.hl7.fhir.convertors.conv30_40;
import org.hl7.fhir.convertors.VersionConvertor_30_40;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Device30_40Test {
@Test
@DisplayName("Test r4 -> dstu3 device conversion.")
public void test1() throws IOException {
InputStream r4_input = this.getClass().getResourceAsStream("/0_device_40.json");
InputStream dstu3_expected_output = this.getClass().getResourceAsStream("/0_device_30.json");
org.hl7.fhir.r4.model.Device r4_actual = (org.hl7.fhir.r4.model.Device) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_input);
org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertor_30_40.convertResource(r4_actual, true);
org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
Assertions.assertTrue(dstu3_expected.equalsDeep(dstu3_conv),
"Failed comparing\n" + dstu3_parser.composeString(dstu3_expected) + "\nand\n" + dstu3_parser.composeString(dstu3_conv));
}
@Test
@DisplayName("Test r4 -> dstu3 device conversion, part 2.")
public void test2() throws IOException {
InputStream r4_input = this.getClass().getResourceAsStream("/1_device_40.json");
InputStream dstu3_expected_output = this.getClass().getResourceAsStream("/1_device_30.json");
org.hl7.fhir.r4.model.Device r4_actual = (org.hl7.fhir.r4.model.Device) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_input);
org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertor_30_40.convertResource(r4_actual, true);
org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
Assertions.assertTrue(dstu3_expected.equalsDeep(dstu3_conv),
"Failed comparing\n" + dstu3_parser.composeString(dstu3_expected) + "\nand\n" + dstu3_parser.composeString(dstu3_expected));
}
}

View File

@ -1,5 +1,6 @@
{
"resourceType" : "AllergyIntolerance",
"id" : "TBwnNbrAqC0Qw5Ha7AFT-2AB",
"clinicalStatus" : {
"coding" : [
{

View File

@ -0,0 +1,13 @@
{
"resourceType": "Device",
"id": "DEV000000000872",
"identifier": [
{
"system": "https://fresenius.org/device",
"value": "DEV000000000872"
}
],
"udi": {
"name": "LC021691"
}
}

View File

@ -0,0 +1,20 @@
{
"resourceType": "Device",
"id": "DEV000000000872",
"identifier": [
{
"system": "https://fresenius.org/device",
"value": "DEV000000000872"
}
],
"definition": {
"reference": "Dialysis"
},
"serialNumber": "LC021691",
"deviceName": [
{
"name": "LC021691",
"type": "manufacturer-name"
}
]
}

View File

@ -0,0 +1,24 @@
{
"resourceType": "Medication",
"id": "FOBAfoba",
"code": {
"coding": [
{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "309309",
"display": "CIPROFLOXACIN 500 MG TABLET"
}
],
"text": "CIPROFLOXACIN 500 MG TABLET"
},
"form": {
"coding": [
{
"system": "urn:oid:1.2.840.114350.1.13.331.2.7.4.698288.310",
"code": "81",
"display": "Tablet"
}
],
"text": "Tablet"
}
}

View File

@ -0,0 +1,26 @@
{
"resourceType": "Medication",
"id": "FOBAfoba",
"code": {
"coding": [
{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "309309",
"display": "CIPROFLOXACIN 500 MG TABLET"
}
],
"text": "CIPROFLOXACIN 500 MG TABLET"
},
"product": {
"form": {
"coding": [
{
"system": "urn:oid:1.2.840.114350.1.13.331.2.7.4.698288.310",
"code": "81",
"display": "Tablet"
}
],
"text": "Tablet"
}
}
}

View File

@ -18,9 +18,7 @@
"dosageInstruction": [{"text": "Take 10 mg by mouth nightly.",
"timing": {"repeat": {"boundsPeriod": {"start": "2016-11-15T00:00:00Z",
"end": "2016-11-23T00:00:00Z"},
"count": 0,
"frequency": 1,
"frequencyMax": 0,
"period": 1.0,
"periodUnit": "d"}},
"asNeededBoolean": "False",

View File

@ -0,0 +1,39 @@
{
"resourceType": "Procedure",
"id": "MrShokoProcedure",
"identifier": [
{
"use": "usual",
"type": {
"text": "ORD"
},
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.798268",
"value": "1158800385"
},
{
"use": "usual",
"type": {
"text": "EAP"
},
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
"value": "183667"
}
],
"subject": {
"display": "Mr Shoko",
"reference": "Mr Shoko"
},
"status": "completed",
"code": {
"coding": [
{
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
"code": "183667",
"display": "COLONOSCOPY "
}
],
"text": "Colonoscopy"
},
"notPerformed": false,
"performedDateTime": "2010-01-01T01:01:01Z"
}

View File

@ -0,0 +1,38 @@
{
"resourceType": "Procedure",
"id": "MrShokoProcedure",
"identifier": [
{
"use": "usual",
"type": {
"text": "ORD"
},
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.798268",
"value": "1158800385"
},
{
"use": "usual",
"type": {
"text": "EAP"
},
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
"value": "183667"
}
],
"subject": {
"display": "Mr Shoko",
"reference": "Mr Shoko"
},
"status": "completed",
"code": {
"coding": [
{
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
"code": "183667",
"display": "COLONOSCOPY "
}
],
"text": "Colonoscopy"
},
"performedDateTime": "2010-01-01T01:01:01Z"
}

View File

@ -1,5 +1,6 @@
{
"resourceType" : "AllergyIntolerance",
"id": "TKebKfLXzu6Sp.LY-IpvpmQB",
"clinicalStatus" : {
"coding" : [
{

View File

@ -0,0 +1,13 @@
{
"resourceType": "Device",
"id": "DEV000000000873",
"identifier": [
{
"system": "https://fresenius.org/device",
"value": "DEV000000000873"
}
],
"udi": {
"name": "LC020678"
}
}

View File

@ -0,0 +1,20 @@
{
"resourceType": "Device",
"id": "DEV000000000873",
"identifier": [
{
"system": "https://fresenius.org/device",
"value": "DEV000000000873"
}
],
"definition": {
"reference": "Dialysis"
},
"serialNumber": "LC020678",
"deviceName": [
{
"name": "LC020678",
"type": "manufacturer-name"
}
]
}

View File

@ -0,0 +1,94 @@
{
"resourceType": "Patient",
"id": "12743884",
"meta": {
"versionId": "0",
"lastUpdated": "2020-09-15T06:35:01.000Z"
},
"text": {
"status": "generated",
"div": "<div><p><b>Patient</b></p><p><b>Name</b>: Dawg, Joel</p><p><b>DOB</b>: Nov 11, 1991</p><p><b>Status</b>: Active</p></div>"
},
"identifier": [
{
"use": "usual",
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/v2/0203",
"code": "MR",
"display": "Medical record number",
"userSelected": false
}
],
"text": "MRN"
},
"system": "urn:oid:2.16.840.1.113883.6.1000",
"value": "7690",
"_value": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/rendered-value",
"valueString": "00000007690"
}
]
},
"period": {
"start": "2020-09-15T06:35:01.000Z"
}
},
{
"use": "usual",
"type": {
"text": "Military Id"
},
"system": "urn:oid:2.16.840.1.113883.3.42.10001.100001.12",
"value": "10050007740",
"_value": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/rendered-value",
"valueString": "10050007740"
}
]
},
"period": {
"start": "2020-09-15T06:35:01.000Z"
}
}
],
"active": true,
"name": [
{
"use": "official",
"text": "Dawg, Joel",
"family": [
"Dawg"
],
"given": [
"Joel"
]
}
],
"telecom": [
{
"system": "phone",
"value": "3075557575",
"use": "home"
},
{
"system": "email",
"value": "amitabhp@mindfiresolutions.com",
"use": "work"
}
],
"_gender": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason",
"valueCode": "unknown"
}
]
},
"birthDate": "1991-11-11"
}

View File

@ -1,16 +1,21 @@
@Override
public String toString() {
return fhirType()+"["+getUrl()+"]";
}
public String present() {
if (hasTitle())
return getTitle();
if (hasName())
return getName();
return toString();
}
public String getVUrl() {
return getUrl() + (hasVersion() ? "|"+getVersion() : "");
}
public String toString() {
return fhirType()+"["+getUrl()+"]";
}
public String present() {
if (hasTitle())
return getTitle();
if (hasName())
return getName();
return toString();
}
public String getVUrl() {
return getUrl() + (hasVersion() ? "|"+getVersion() : "");
}
public boolean supportsCopyright() {
return true;
}

View File

@ -0,0 +1,26 @@
public ContactPoint getEmail() {
for (ContactPoint cp : getTelecom()) {
if (cp.getSystem() == ContactPointSystem.EMAIL) {
return cp;
}
}
return null;
}
public ContactPoint getPhone() {
for (ContactPoint cp : getTelecom()) {
if (cp.getSystem() == ContactPointSystem.PHONE) {
return cp;
}
}
return null;
}
public ContactPoint getUrl() {
for (ContactPoint cp : getTelecom()) {
if (cp.getSystem() == ContactPointSystem.URL) {
return cp;
}
}
return null;
}

View File

@ -0,0 +1,3 @@
public boolean supportsCopyright() {
return false;
}

View File

@ -0,0 +1,3 @@
public boolean supportsCopyright() {
return false;
}

View File

@ -30,7 +30,7 @@ Resource = org.hl7.fhir.instance.model.api.IAnyResource
Period = ca.uhn.fhir.model.api.TemporalPrecisionEnum
Extension = org.hl7.fhir.instance.model.api.IBaseExtension, org.hl7.fhir.instance.model.api.IBaseDatatype, org.hl7.fhir.instance.model.api.IBaseHasExtensions
HumanName = ca.uhn.fhir.util.DatatypeUtil, org.hl7.fhir.instance.model.api.IPrimitiveType
StructureMap = org.hl7.fhir.r5.utils.StructureMapUtilities
StructureMap = org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities
Narrative = org.hl7.fhir.instance.model.api.INarrative
Coding = org.hl7.fhir.instance.model.api.IBaseCoding
OperationOutcome = org.hl7.fhir.instance.model.api.IBaseOperationOutcome

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.1.8-SNAPSHOT</version>
<version>5.2.21-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.dstu2.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.TemporalPrecisionEnum;
@ -39,6 +39,7 @@ import org.hl7.fhir.utilities.DateTimeUtil;
import java.text.ParseException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.*;
@ -74,6 +75,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM);
private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(FastDateFormat.MEDIUM);
private static final Map<String, TimeZone> timezoneCache = new ConcurrentHashMap<>();
static {
ArrayList<FastDateFormat> formatters = new ArrayList<FastDateFormat>();
@ -159,7 +161,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
return ourYearFormat.format(theValue);
case MINUTE:
if (myTimeZoneZulu) {
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
GregorianCalendar cal = new GregorianCalendar(getTimeZone("GMT"));
cal.setTime(theValue);
return ourYearMonthDayTimeMinsFormat.format(cal) + "Z";
} else if (myTimeZone != null) {
@ -171,7 +173,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
}
case SECOND:
if (myTimeZoneZulu) {
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
GregorianCalendar cal = new GregorianCalendar(getTimeZone("GMT"));
cal.setTime(theValue);
return ourYearMonthDayTimeFormat.format(cal) + "Z";
} else if (myTimeZone != null) {
@ -183,7 +185,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
}
case MILLI:
if (myTimeZoneZulu) {
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
GregorianCalendar cal = new GregorianCalendar(getTimeZone("GMT"));
cal.setTime(theValue);
return ourYearMonthDayTimeMilliFormat.format(cal) + "Z";
} else if (myTimeZone != null) {
@ -410,9 +412,9 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
if (theValueString.endsWith("Z")) {
setTimeZoneZulu(true);
} else if (theValueString.indexOf("GMT", timeZoneStart) != -1) {
setTimeZone(TimeZone.getTimeZone(theValueString.substring(timeZoneStart)));
setTimeZone(getTimeZone(theValueString.substring(timeZoneStart)));
} else if (theValueString.indexOf('+', timeZoneStart) != -1 || theValueString.indexOf('-', timeZoneStart) != -1) {
setTimeZone(TimeZone.getTimeZone("GMT" + theValueString.substring(timeZoneStart)));
setTimeZone(getTimeZone("GMT" + theValueString.substring(timeZoneStart)));
}
}
@ -528,9 +530,9 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
int hours = offsetAbs / 60;
if (theZoneOffsetMinutes < 0) {
setTimeZone(TimeZone.getTimeZone("GMT-" + hours + ":" + mins));
setTimeZone(getTimeZone("GMT-" + hours + ":" + mins));
} else {
setTimeZone(TimeZone.getTimeZone("GMT+" + hours + ":" + mins));
setTimeZone(getTimeZone("GMT+" + hours + ":" + mins));
}
}
@ -618,4 +620,8 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
}
}
private TimeZone getTimeZone(String offset) {
return timezoneCache.computeIfAbsent(offset, TimeZone::getTimeZone);
}
}

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.dstu2.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
@ -152,6 +152,9 @@ public class UriType extends PrimitiveType<String> {
if (getValue() == null || other.getValue() == null) {
return false;
}
if (getValue().equals(other.getValue())) {
return true;
}
String normalize = normalize(getValue());
String normalize2 = normalize(other.getValue());

View File

@ -516,7 +516,7 @@ public class FHIRToolingClient {
return p_out;
}
} catch (Exception e) {
handleException("Error performing operation '"+name+"' with parameters " + ps, e);
handleException("Error performing operation '"+name+": "+e.getMessage()+"' (parameters = \"" + ps+"\")", e);
}
return null;
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.1.8-SNAPSHOT</version>
<version>5.2.21-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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 static org.apache.commons.lang3.StringUtils.isBlank;
@ -35,7 +35,9 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import org.apache.commons.lang3.StringUtils;
@ -52,6 +54,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
static final long NANOS_PER_MILLIS = 1000000L;
static final long NANOS_PER_SECOND = 1000000000L;
private static final Map<String, TimeZone> timezoneCache = new ConcurrentHashMap<>();
private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(FastDateFormat.MEDIUM);
private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM);
@ -114,7 +117,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
} else {
GregorianCalendar cal;
if (myTimeZoneZulu) {
cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
cal = new GregorianCalendar(getTimeZone("GMT"));
} else if (myTimeZone != null) {
cal = new GregorianCalendar(myTimeZone);
} else {
@ -209,7 +212,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
*/
public TimeZone getTimeZone() {
if (myTimeZoneZulu) {
return TimeZone.getTimeZone("GMT");
return getTimeZone("GMT");
}
return myTimeZone;
}
@ -414,7 +417,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
parseInt(theWholeValue, theValue.substring(1, 3), 0, 23);
parseInt(theWholeValue, theValue.substring(4, 6), 0, 59);
myTimeZoneZulu = false;
myTimeZone = TimeZone.getTimeZone("GMT" + theValue);
myTimeZone = getTimeZone("GMT" + theValue);
}
return this;
@ -750,4 +753,8 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
}
}
private TimeZone getTimeZone(String offset) {
return timezoneCache.computeIfAbsent(offset, TimeZone::getTimeZone);
}
}

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
@ -153,6 +153,9 @@ public class UriType extends PrimitiveType<String> {
if (getValue() == null || other.getValue() == null) {
return false;
}
if (getValue().equals(other.getValue())) {
return true;
}
String normalize = normalize(getValue());
String normalize2 = normalize(other.getValue());

View File

@ -517,7 +517,7 @@ public class FHIRToolingClient {
return p_out;
}
} catch (Exception e) {
handleException("Error performing operation '"+name+"' with parameters " + ps, e);
handleException("Error performing operation '"+name+": "+e.getMessage()+"' (parameters = \"" + ps+"\")", e);
}
return null;
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.1.8-SNAPSHOT</version>
<version>5.2.21-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -89,7 +89,7 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.utilities.CSFileInputStream;
import org.hl7.fhir.utilities.OIDUtils;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.dstu3.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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 static org.apache.commons.lang3.StringUtils.isBlank;
@ -35,7 +35,9 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
@ -51,6 +53,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
static final long NANOS_PER_MILLIS = 1000000L;
static final long NANOS_PER_SECOND = 1000000000L;
private static final Map<String, TimeZone> timezoneCache = new ConcurrentHashMap<>();
private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(FastDateFormat.MEDIUM);
private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM);
@ -171,7 +174,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
} else {
GregorianCalendar cal;
if (myTimeZoneZulu) {
cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
cal = new GregorianCalendar(getTimeZone("GMT"));
} else if (myTimeZone != null) {
cal = new GregorianCalendar(myTimeZone);
} else {
@ -336,7 +339,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
*/
public TimeZone getTimeZone() {
if (myTimeZoneZulu) {
return TimeZone.getTimeZone("GMT");
return getTimeZone("GMT");
}
return myTimeZone;
}
@ -646,7 +649,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
parseInt(theWholeValue, theValue.substring(1, 3), 0, 23);
parseInt(theWholeValue, theValue.substring(4, 6), 0, 59);
myTimeZoneZulu = false;
myTimeZone = TimeZone.getTimeZone("GMT" + theValue);
myTimeZone = getTimeZone("GMT" + theValue);
}
return this;
@ -841,4 +844,8 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
}
}
private TimeZone getTimeZone(String offset) {
return timezoneCache.computeIfAbsent(offset, TimeZone::getTimeZone);
}
}

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.dstu3.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
@ -153,6 +153,9 @@ public class UriType extends PrimitiveType<String> {
if (getValue() == null || other.getValue() == null) {
return false;
}
if (getValue().equals(other.getValue())) {
return true;
}
String normalize = normalize(getValue());
String normalize2 = normalize(other.getValue());

View File

@ -504,7 +504,7 @@ public class FHIRToolingClient {
return p_out;
}
} catch (Exception e) {
handleException("Error performing operation '"+name+"' with parameters " + ps, e);
handleException("Error performing operation '"+name+": "+e.getMessage()+"' (parameters = \"" + ps+"\")", e);
}
return null;
}

View File

@ -8,7 +8,7 @@ import org.hl7.fhir.dstu3.test.support.TestingUtilities;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.junit.jupiter.api.Test;
class JsonParserTestCase {
class JsonParserTest {
@Test
void testParseJsonNull() throws FHIRFormatError, IOException {

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.1.8-SNAPSHOT</version>
<version>5.2.21-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -79,7 +79,7 @@ import org.hl7.fhir.r4.utils.IResourceValidator;
import org.hl7.fhir.r4.utils.NarrativeGenerator;
import org.hl7.fhir.utilities.CSFileInputStream;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.r4.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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 static org.apache.commons.lang3.StringUtils.isBlank;
@ -35,7 +35,9 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import org.apache.commons.lang3.StringUtils;
@ -51,6 +53,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
static final long NANOS_PER_MILLIS = 1000000L;
static final long NANOS_PER_SECOND = 1000000000L;
private static final Map<String, TimeZone> timezoneCache = new ConcurrentHashMap<>();
private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(FastDateFormat.MEDIUM);
private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM);
@ -174,7 +177,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
} else {
GregorianCalendar cal;
if (myTimeZoneZulu) {
cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
cal = new GregorianCalendar(getTimeZone("GMT"));
} else if (myTimeZone != null) {
cal = new GregorianCalendar(myTimeZone);
} else {
@ -339,7 +342,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
*/
public TimeZone getTimeZone() {
if (myTimeZoneZulu) {
return TimeZone.getTimeZone("GMT");
return getTimeZone("GMT");
}
return myTimeZone;
}
@ -645,7 +648,7 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
parseInt(theWholeValue, theValue.substring(1, 3), 0, 23);
parseInt(theWholeValue, theValue.substring(4, 6), 0, 59);
myTimeZoneZulu = false;
myTimeZone = TimeZone.getTimeZone("GMT" + theValue);
myTimeZone = getTimeZone("GMT" + theValue);
}
return this;
@ -939,4 +942,13 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
}
@Override
public String fpValue() {
return "@"+primitiveValue();
}
private TimeZone getTimeZone(String offset) {
return timezoneCache.computeIfAbsent(offset, TimeZone::getTimeZone);
}
}

View File

@ -37,6 +37,7 @@ package org.hl7.fhir.r4.model;
import java.util.*;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponentSorter;
import org.hl7.fhir.r4.model.Enumerations.*;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
@ -5049,6 +5050,30 @@ public class CodeSystem extends MetadataResource {
return null;
}
public class ConceptDefinitionComponentSorter implements Comparator<ConceptDefinitionComponent> {
@Override
public int compare(ConceptDefinitionComponent l, ConceptDefinitionComponent r) {
return l.getCode().compareTo(r.getCode());
}
}
public void sort() {
sort(getConcept(), new ConceptDefinitionComponentSorter());
}
public void sort(List<ConceptDefinitionComponent> list, Comparator<ConceptDefinitionComponent> comp) {
Collections.sort(list, comp);
for (ConceptDefinitionComponent def : list) {
if (def.hasConcept()) {
sort (def.getConcept(), comp);
}
}
}
public void sort(Comparator<ConceptDefinitionComponent> comp) {
sort(getConcept(), comp);
}
// end addition
}

View File

@ -34,6 +34,7 @@ package org.hl7.fhir.r4.model;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.utilities.SourceLocation;
import org.hl7.fhir.utilities.Utilities;
public class ExpressionNode {
@ -41,31 +42,6 @@ public class ExpressionNode {
public enum Kind {
Name, Function, Constant, Group, Unary
}
public static class SourceLocation {
private int line;
private int column;
public SourceLocation(int line, int column) {
super();
this.line = line;
this.column = column;
}
public int getLine() {
return line;
}
public int getColumn() {
return column;
}
public void setLine(int line) {
this.line = line;
}
public void setColumn(int column) {
this.column = column;
}
public String toString() {
return Integer.toString(line)+", "+Integer.toString(column);
}
}
public enum Function {
Custom,

View File

@ -249,4 +249,7 @@ public abstract class PrimitiveType<T> extends Type implements IPrimitiveType<T>
return StringUtils.isNotBlank(getValueAsString());
}
public String fpValue() {
return primitiveValue();
}
}

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.r4.model;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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 HOLDER 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.
*/
@ -155,6 +155,9 @@ public class UriType extends PrimitiveType<String> {
if (getValue() == null || other.getValue() == null) {
return false;
}
if (getValue().equals(other.getValue())) {
return true;
}
String normalize = normalize(getValue());
String normalize2 = normalize(other.getValue());

View File

@ -67,7 +67,7 @@ public class CodeSystemUtilities {
public static void setNotSelectable(CodeSystem cs, ConceptDefinitionComponent concept) throws FHIRFormatError {
defineNotSelectableProperty(cs);
ConceptPropertyComponent p = getProperty(concept, "notSelectable");
ConceptPropertyComponent p = getProperty(concept, "abstract");
if (p != null)
p.setValue(new BooleanType(true));
else

View File

@ -50,8 +50,8 @@ import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.utilities.CSFile;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.cache.ToolsVersion;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

View File

@ -34,7 +34,7 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.ExpressionNode;
import org.hl7.fhir.r4.model.ExpressionNode.SourceLocation;
import org.hl7.fhir.utilities.SourceLocation;
import org.hl7.fhir.utilities.Utilities;
// shared lexer for concrete syntaxes
@ -146,23 +146,8 @@ public class FHIRLexer {
}
public void next() throws FHIRLexerException {
skipWhitespaceAndComments();
current = null;
boolean last13 = false;
while (cursor < source.length() && Character.isWhitespace(source.charAt(cursor))) {
if (source.charAt(cursor) == '\r') {
currentLocation.setLine(currentLocation.getLine() + 1);
currentLocation.setColumn(1);
last13 = true;
} else if (!last13 && (source.charAt(cursor) == '\n')) {
currentLocation.setLine(currentLocation.getLine() + 1);
currentLocation.setColumn(1);
last13 = false;
} else {
last13 = false;
currentLocation.setColumn(currentLocation.getColumn() + 1);
}
cursor++;
}
currentStart = cursor;
currentStartLocation = currentLocation;
if (cursor < source.length()) {
@ -208,9 +193,8 @@ public class FHIRLexer {
} else if (ch == '/') {
cursor++;
if (cursor < source.length() && (source.charAt(cursor) == '/')) {
cursor++;
while (cursor < source.length() && !((source.charAt(cursor) == '\r') || source.charAt(cursor) == '\n'))
cursor++;
// this is en error - should already have been skipped
error("This shoudn't happen?");
}
current = source.substring(currentStart, cursor);
} else if (ch == '$') {
@ -297,6 +281,33 @@ public class FHIRLexer {
}
private void skipWhitespaceAndComments() {
boolean last13 = false;
boolean done = false;
while (cursor < source.length() && !done) {
if (cursor < source.length() -1 && "//".equals(source.substring(cursor, cursor+2))) {
while (cursor < source.length() && !((source.charAt(cursor) == '\r') || source.charAt(cursor) == '\n'))
cursor++;
} else if (cursor < source.length() - 1 && "/*".equals(source.substring(cursor, cursor+2))) {
while (cursor < source.length() - 1 && !"*/".equals(source.substring(cursor, cursor+2))) {
last13 = currentLocation.checkChar(source.charAt(cursor), last13);
cursor++;
}
if (cursor >= source.length() -1) {
error("Unfinished comment");
} else {
cursor = cursor + 2;
}
} else if (Character.isWhitespace(source.charAt(cursor))) {
last13 = currentLocation.checkChar(source.charAt(cursor), last13);
cursor++;
} else {
done = true;
}
}
}
private boolean isDateChar(char ch,int start) {
int eot = source.charAt(start+1) == 'T' ? 10 : 20;

View File

@ -405,11 +405,11 @@ public class LiquidEngine implements IEvaluationContext {
}
@Override
public List<Base> executeFunction(Object appContext, String functionName, List<List<Base>> parameters) {
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
if (externalHostServices == null)
return null;
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
return externalHostServices.executeFunction(ctxt.externalContext, functionName, parameters);
return externalHostServices.executeFunction(ctxt.externalContext, focus, functionName, parameters);
}
@Override

View File

@ -58,8 +58,8 @@ import org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDependsOnCom
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.cache.PackageGenerator.PackageType;
import org.hl7.fhir.utilities.cache.ToolsVersion;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.hl7.fhir.utilities.npm.PackageGenerator.PackageType;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

View File

@ -202,7 +202,7 @@ public class StructureMapUtilities {
}
@Override
public List<Base> executeFunction(Object appContext, String functionName, List<List<Base>> parameters) {
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
throw new Error("Not Implemented Yet");
}

View File

@ -507,7 +507,7 @@ public class FHIRToolingClient {
return p_out;
}
} catch (Exception e) {
handleException("Error performing operation '"+name+"' with parameters " + ps, e);
handleException("Error performing operation '"+name+": "+e.getMessage()+"' (parameters = \"" + ps+"\")", e);
}
return null;
}

View File

@ -8,8 +8,8 @@ import org.hl7.fhir.r4.elementmodel.Element;
import org.hl7.fhir.r4.elementmodel.Manager;
import org.hl7.fhir.r4.elementmodel.Manager.FhirFormat;
import org.hl7.fhir.r4.formats.IParser.OutputStyle;
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.cache.ToolsVersion;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

View File

@ -64,7 +64,7 @@ public class FHIRPathTests {
}
@Override
public List<Base> executeFunction(Object appContext, String functionName, List<List<Base>> parameters) {
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
throw new NotImplementedException("Not done yet (FHIRPathTestEvaluationServices.executeFunction), when item is element");
}
@ -205,7 +205,7 @@ public class FHIRPathTests {
Assertions.assertTrue(outcome.get(i).equalsDeep(q), String.format("Outcome %d: Value should be %s but was %s", i, v, outcome.get(i).toString()));
} else {
Assertions.assertTrue(outcome.get(i) instanceof PrimitiveType, String.format("Outcome %d: Value should be a primitive type but was %s", i, outcome.get(i).fhirType()));
Assertions.assertEquals(v, ((PrimitiveType) outcome.get(i)).asStringValue(), String.format("Outcome %d: Value should be %s but was %s for expression %s", i, v, outcome.get(i).toString(), expression));
Assertions.assertEquals(v, ((PrimitiveType) outcome.get(i)).fpValue(), String.format("Outcome %d: Value should be %s but was %s for expression %s", i, v, ((PrimitiveType) outcome.get(i)).fpValue(), expression));
}
}
}

View File

@ -316,7 +316,7 @@ public class SnapShotGenerationTests {
}
@Override
public List<Base> executeFunction(Object appContext, String functionName, List<List<Base>> parameters) {
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
if ("fixture".equals(functionName)) {
String id = fp.convertToString(parameters.get(0));
Resource res = fetchFixture(id);

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.1.8-SNAPSHOT</version>
<version>5.2.21-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -101,6 +101,12 @@
<artifactId>httpclient</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
<optional>true</optional>
</dependency>
<!-- Test dependencies -->
<dependency>
@ -119,6 +125,14 @@
<version>${validator_test_case_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>4.9.0</version>
<optional>true</optional>
<scope>test</scope>
</dependency>
<!-- JUnit Jupiter -->
<dependency>

View File

@ -242,7 +242,7 @@ public class ComparisonRenderer implements IEvaluationContext {
}
@Override
public List<Base> executeFunction(Object appContext, String functionName, List<List<Base>> parameters) {
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
return null;
}

View File

@ -49,6 +49,7 @@ import org.apache.commons.lang3.StringUtils;
import org.fhir.ucum.UcumService;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.NoTerminologyServiceException;
import org.hl7.fhir.exceptions.TerminologyServiceException;
import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
@ -192,6 +193,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
private boolean allowLoadingDuplicates;
protected TerminologyClient txClient;
private Set<String> codeSystemsUsed = new HashSet<>();
protected ToolingClientLogger txLog;
private TerminologyCapabilities txcaps;
private boolean canRunWithoutTerminology;
@ -596,10 +598,17 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
Parameters p = expParameters.copy();
p.setParameter("includeDefinition", false);
p.setParameter("excludeNested", !hierarchical);
if (isTxCaching && cacheId != null) {
boolean cached = addDependentResources(p, vs);
if (cached) {
p.addParameter().setName("cache-id").setValue(new StringType(cacheId));
}
addDependentResources(p, vs);
for (ConceptSetComponent incl : vs.getCompose().getInclude()) {
codeSystemsUsed.add(incl.getSystem());
}
for (ConceptSetComponent incl : vs.getCompose().getExclude()) {
codeSystemsUsed.add(incl.getSystem());
}
if (noTerminologyServer) {
return new ValueSetExpansionOutcome(formatMessage(I18nConstants.ERROR_EXPANDING_VALUESET_RUNNING_WITHOUT_TERMINOLOGY_SERVICES), TerminologyServiceErrorClass.NOSERVICE);
@ -639,6 +648,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
if (!vs.hasUrl()) {
throw new Error(formatMessage(I18nConstants.NO_VALUE_SET_IN_URL));
}
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
codeSystemsUsed.add(inc.getSystem());
}
for (ConceptSetComponent inc : vs.getCompose().getExclude()) {
codeSystemsUsed.add(inc.getSystem());
}
CacheToken cacheToken = txCache.generateExpandToken(vs, heirarchical);
ValueSetExpansionOutcome res;
@ -671,10 +686,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
// if that failed, we try to expand on the server
if (isTxCaching && cacheId != null) {
if (addDependentResources(p, vs)) {
p.addParameter().setName("cache-id").setValue(new StringType(cacheId));
}
addDependentResources(p, vs);
if (noTerminologyServer) {
return new ValueSetExpansionOutcome(formatMessage(I18nConstants.ERROR_EXPANDING_VALUESET_RUNNING_WITHOUT_TERMINOLOGY_SERVICES), TerminologyServiceErrorClass.NOSERVICE, allErrors);
}
@ -735,6 +750,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
// 3rd pass: hit the server
for (CodingValidationRequest t : codes) {
t.setCacheToken(txCache != null ? txCache.generateValidationToken(options, t.getCoding(), vs) : null);
codeSystemsUsed.add(t.getCoding().getSystem());
if (txCache != null) {
t.setResult(txCache.getValidation(t.getCacheToken()));
}
@ -807,6 +823,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
BundleEntryComponent r = resp.getEntry().get(i);
if (r.getResource() instanceof Parameters) {
t.setResult(processValidationResult((Parameters) r.getResource()));
if (txCache != null) {
txCache.cacheValidation(t.getCacheToken(), t.getResult(), TerminologyCache.PERMANENT);
}
} else {
t.setResult(new ValidationResult(IssueSeverity.ERROR, getResponseText(r.getResource())).setTxLink(txLog == null ? null : txLog.getLastId()));
}
@ -827,6 +846,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
options = ValidationOptions.defaults();
}
codeSystemsUsed.add(code.getSystem());
CacheToken cacheToken = txCache != null ? txCache.generateValidationToken(options, code, vs) : null;
ValidationResult res = null;
if (txCache != null) {
@ -901,6 +921,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
if (res != null) {
return res;
}
for (Coding c : code.getCoding()) {
codeSystemsUsed.add(c.getSystem());
}
if (options.isUseClient()) {
// ok, first we try to validate locally
@ -910,6 +933,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
txCache.cacheValidation(cacheToken, res, TerminologyCache.TRANSIENT);
return res;
} catch (Exception e) {
if (e instanceof NoTerminologyServiceException) {
return new ValidationResult(IssueSeverity.ERROR, "No Terminology Service", TerminologyServiceErrorClass.NOSERVICE);
}
}
}
@ -935,8 +961,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
private ValidationResult validateOnServer(ValueSet vs, Parameters pin) throws FHIRException {
if (isTxCaching && cacheId != null) {
pin.addParameter().setName("cache-id").setValue(new StringType(cacheId));
boolean cache = false;
if (vs != null) {
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
codeSystemsUsed.add(inc.getSystem());
}
for (ConceptSetComponent inc : vs.getCompose().getExclude()) {
codeSystemsUsed.add(inc.getSystem());
}
}
if (vs != null) {
if (isTxCaching && cacheId != null && cached.contains(vs.getUrl()+"|"+vs.getVersion())) {
@ -945,8 +977,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
pin.addParameter().setName("valueSet").setResource(vs);
cached.add(vs.getUrl()+"|"+vs.getVersion());
}
cache = true;
addDependentResources(pin, vs);
}
if (cache) {
pin.addParameter().setName("cache-id").setValue(new StringType(cacheId));
}
for (ParametersParameterComponent pp : pin.getParameter()) {
if (pp.getName().equals("profile")) {
throw new Error(formatMessage(I18nConstants.CAN_ONLY_SPECIFY_PROFILE_IN_THE_CONTEXT));
@ -971,22 +1007,26 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return processValidationResult(pOut);
}
private void addDependentResources(Parameters pin, ValueSet vs) {
private boolean addDependentResources(Parameters pin, ValueSet vs) {
boolean cache = false;
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
addDependentResources(pin, inc);
cache = addDependentResources(pin, inc) || cache;
}
for (ConceptSetComponent inc : vs.getCompose().getExclude()) {
addDependentResources(pin, inc);
cache = addDependentResources(pin, inc) || cache;
}
return cache;
}
private void addDependentResources(Parameters pin, ConceptSetComponent inc) {
private boolean addDependentResources(Parameters pin, ConceptSetComponent inc) {
boolean cache = false;
for (CanonicalType c : inc.getValueSet()) {
ValueSet vs = fetchResource(ValueSet.class, c.getValue());
if (vs != null) {
if (isTxCaching && cacheId == null || !cached.contains(vs.getVUrl())) {
pin.addParameter().setName("tx-resource").setResource(vs);
cached.add(vs.getVUrl());
cache = true;
}
addDependentResources(pin, vs);
}
@ -996,9 +1036,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
if (isTxCaching && cacheId == null || !cached.contains(cs.getVUrl())) {
pin.addParameter().setName("tx-resource").setResource(cs);
cached.add(cs.getVUrl());
cache = true;
}
// todo: supplements
}
}
return cache;
}
public ValidationResult processValidationResult(Parameters pOut) {
@ -1007,23 +1049,25 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
String display = null;
TerminologyServiceErrorClass err = TerminologyServiceErrorClass.UNKNOWN;
for (ParametersParameterComponent p : pOut.getParameter()) {
if (p.getName().equals("result")) {
ok = ((BooleanType) p.getValue()).getValue().booleanValue();
} else if (p.getName().equals("message")) {
message = ((StringType) p.getValue()).getValue();
} else if (p.getName().equals("display")) {
display = ((StringType) p.getValue()).getValue();
} else if (p.getName().equals("cause")) {
try {
IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue());
if (it == IssueType.UNKNOWN) {
err = TerminologyServiceErrorClass.UNKNOWN;
} else if (it == IssueType.NOTFOUND) {
err = TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED;
} else if (it == IssueType.NOTSUPPORTED) {
err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED;
if (p.hasValue()) {
if (p.getName().equals("result")) {
ok = ((BooleanType) p.getValue()).getValue().booleanValue();
} else if (p.getName().equals("message")) {
message = ((StringType) p.getValue()).getValue();
} else if (p.getName().equals("display")) {
display = ((StringType) p.getValue()).getValue();
} else if (p.getName().equals("cause")) {
try {
IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue());
if (it == IssueType.UNKNOWN) {
err = TerminologyServiceErrorClass.UNKNOWN;
} else if (it == IssueType.NOTFOUND) {
err = TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED;
} else if (it == IssueType.NOTSUPPORTED) {
err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED;
}
} catch (FHIRException e) {
}
} catch (FHIRException e) {
}
}
}
@ -1928,5 +1972,22 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
guides.size() + capstmts.size() + searchParameters.size() + questionnaires.size() + operations.size() + plans.size() + systems.size();
}
public Set<String> getCodeSystemsUsed() {
return codeSystemsUsed ;
}
public String getSpecUrl() {
String v = getVersion();
switch (VersionUtilities.getMajMin(v)) {
case "1.0" : return "http://hl7.org/fhir/DSTU1";
case "1.4" : return "http://hl7.org/fhir/DSTU2";
case "3.0" : return "http://hl7.org/fhir/STU3";
case "4.0" : return "http://hl7.org/fhir/R4";
case "4.5" : return "http://build.fhir.org";
case "5.0" : return "http://build.fhir.org";
default:
return "http://hl7.org/fhir";
}
}
}

View File

@ -220,6 +220,7 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
if (enforceUniqueId && map.containsKey(cr.getId())) {
drop(cr.getId());
}
// special case logic for UTG support prior to version 5
if (cr.getPackageInfo() != null && cr.getPackageInfo().getId().startsWith("hl7.terminology")) {
List<CachedCanonicalResource<T>> toDrop = new ArrayList<>();

View File

@ -67,8 +67,8 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.hl7.fhir.utilities.TimeTracker;
import org.hl7.fhir.utilities.TranslationServices;
import org.hl7.fhir.utilities.cache.BasePackageCacheManager;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.npm.BasePackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationOptions;
@ -222,7 +222,12 @@ public interface IWorkerContext {
* Get the versions of the definitions loaded in context
* @return
*/
public String getVersion();
public String getVersion();
/**
* return the link to the base of the specification for the loaded version e.g. http://hl7.org/fhir/R4
*/
public String getSpecUrl();
// get the UCUM service (might not be available)
public UcumService getUcumService();
@ -710,7 +715,7 @@ public interface IWorkerContext {
public ILoggingService getLogger();
public boolean isNoTerminologyServer();
public Set<String> getCodeSystemsUsed();
public TranslationServices translator();
public List<StructureMap> listTransforms();
public StructureMap getTransform(String url);

View File

@ -76,16 +76,17 @@ import org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode;
import org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent;
import org.hl7.fhir.r5.terminologies.TerminologyClient;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.utilities.CSFileInputStream;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.TimeTracker;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.cache.BasePackageCacheManager;
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.cache.NpmPackage;
import org.hl7.fhir.utilities.cache.NpmPackage.PackageResourceInformation;
import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.npm.BasePackageCacheManager;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
@ -138,7 +139,8 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
}
public interface IValidatorFactory {
IResourceValidator makeValidator(IWorkerContext ctxts) throws FHIRException;
IResourceValidator makeValidator(IWorkerContext ctxt) throws FHIRException;
IResourceValidator makeValidator(IWorkerContext ctxts, XVerExtensionManager xverManager) throws FHIRException;
}
private Questionnaire questionnaire;
@ -148,6 +150,8 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
private boolean ignoreProfileErrors;
private boolean progress;
private List<String> loadedPackages = new ArrayList<String>();
private boolean canNoTS;
private XVerExtensionManager xverManager;
public SimpleWorkerContext() throws FileNotFoundException, IOException, FHIRException {
super();
@ -242,19 +246,15 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
}
public static SimpleWorkerContext fromClassPath(String name) throws IOException, FHIRException {
InputStream s = SimpleWorkerContext.class.getResourceAsStream("/"+name);
SimpleWorkerContext res = new SimpleWorkerContext();
res.loadFromStream(s, null);
return res;
return fromClassPath(name, false);
}
public static SimpleWorkerContext fromClassPath(String name, boolean allowDuplicates) throws IOException, FHIRException {
InputStream s = SimpleWorkerContext.class.getResourceAsStream("/" + name);
SimpleWorkerContext res = new SimpleWorkerContext();
res.setAllowLoadingDuplicates(allowDuplicates);
res.loadFromStream(s, null);
return res;
}
// public static SimpleWorkerContext fromDefinitions(Map<String, byte[]> source) throws IOException, FHIRException {
// SimpleWorkerContext res = new SimpleWorkerContext();
// for (String name : source.keySet()) {
// res.loadDefinitionItem(name, new ByteArrayInputStream(source.get(name)), null, null);
// }
// return res;
// }
public static SimpleWorkerContext fromDefinitions(Map<String, byte[]> source, IContextResourceLoader loader, PackageVersion pi) throws FileNotFoundException, IOException, FHIRException {
SimpleWorkerContext res = new SimpleWorkerContext();
@ -299,7 +299,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
setTxCaps(txClient.getTerminologyCapabilities());
return cps.getSoftware().getVersion();
} catch (Exception e) {
throw new FHIRException(formatMessage(I18nConstants.UNABLE_TO_CONNECT_TO_TERMINOLOGY_SERVER_USE_PARAMETER_TX_NA_TUN_RUN_WITHOUT_USING_TERMINOLOGY_SERVICES_TO_VALIDATE_LOINC_SNOMED_ICDX_ETC_ERROR__, e.getMessage()), e);
throw new FHIRException(formatMessage(canNoTS ? I18nConstants.UNABLE_TO_CONNECT_TO_TERMINOLOGY_SERVER_USE_PARAMETER_TX_NA_TUN_RUN_WITHOUT_USING_TERMINOLOGY_SERVICES_TO_VALIDATE_LOINC_SNOMED_ICDX_ETC_ERROR__ : I18nConstants.UNABLE_TO_CONNECT_TO_TERMINOLOGY_SERVER, e.getMessage()), e);
}
}
@ -538,7 +538,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
public IResourceValidator newValidator() throws FHIRException {
if (validatorFactory == null)
throw new Error(formatMessage(I18nConstants.NO_VALIDATOR_CONFIGURED));
return validatorFactory.makeValidator(this);
return validatorFactory.makeValidator(this, xverManager);
}
@ -769,6 +769,10 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
ProfileUtilities pu = new ProfileUtilities(this, msgs, this);
pu.setAutoFixSliceNames(true);
pu.setThrowException(false);
if (xverManager == null) {
xverManager = new XVerExtensionManager(this);
}
pu.setXver(xverManager);
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
pu.sortDifferential(sd, p, p.getUrl(), errors, true);
}
@ -811,8 +815,28 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
return loadedPackages.contains(id+"#"+ver);
}
public boolean hasPackage(String idAndver) {
return loadedPackages.contains(idAndver);
}
public void setClock(TimeTracker tt) {
clock = tt;
}
}
public boolean isCanNoTS() {
return canNoTS;
}
public void setCanNoTS(boolean canNoTS) {
this.canNoTS = canNoTS;
}
public XVerExtensionManager getXVer() {
if (xverManager == null) {
xverManager = new XVerExtensionManager(this);
}
return xverManager;
}
}

Some files were not shown because too many files have changed in this diff Show More