Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core
This commit is contained in:
commit
d99592416e
|
@ -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,19 @@ 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>
|
||||
</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>$(PGP_KEYNAME)</id>
|
||||
<passphrase>$(PGP_PASSPHRASE)</passphrase>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
|
@ -81,9 +77,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 -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 -Dmaven.test.skip -DdeployToGitHub'
|
||||
publishJUnitResults: false
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -2023,15 +2023,18 @@ public class VersionConvertor_10_40 {
|
|||
copyElement(src, tgt);
|
||||
if (src.hasBounds())
|
||||
tgt.setBounds(convertType(src.getBounds()));
|
||||
tgt.setCount(src.getCount());
|
||||
if (src.hasCount())
|
||||
tgt.setCount(src.getCount());
|
||||
if (src.hasDurationElement())
|
||||
tgt.setDurationElement(convertDecimal(src.getDurationElement()));
|
||||
if (src.hasDurationMaxElement())
|
||||
tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement()));
|
||||
if (src.hasDurationUnits())
|
||||
tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement()));
|
||||
tgt.setFrequency(src.getFrequency());
|
||||
tgt.setFrequencyMax(src.getFrequencyMax());
|
||||
if (src.hasFrequency())
|
||||
tgt.setFrequency(src.getFrequency());
|
||||
if (src.hasFrequencyMax())
|
||||
tgt.setFrequencyMax(src.getFrequencyMax());
|
||||
if (src.hasPeriodElement())
|
||||
tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
|
||||
if (src.hasPeriodMaxElement())
|
||||
|
@ -2051,15 +2054,18 @@ public class VersionConvertor_10_40 {
|
|||
copyElement(src, tgt);
|
||||
if (src.hasBounds())
|
||||
tgt.setBounds(convertType(src.getBounds()));
|
||||
tgt.setCount(src.getCount());
|
||||
if (src.hasCount())
|
||||
tgt.setCount(src.getCount());
|
||||
if (src.hasDurationElement())
|
||||
tgt.setDurationElement(convertDecimal(src.getDurationElement()));
|
||||
if (src.hasDurationMaxElement())
|
||||
tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement()));
|
||||
if (src.hasDurationUnit())
|
||||
tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement()));
|
||||
tgt.setFrequency(src.getFrequency());
|
||||
tgt.setFrequencyMax(src.getFrequencyMax());
|
||||
if (src.hasFrequency())
|
||||
tgt.setFrequency(src.getFrequency());
|
||||
if (src.hasFrequencyMax())
|
||||
tgt.setFrequencyMax(src.getFrequencyMax());
|
||||
if (src.hasPeriodElement())
|
||||
tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
|
||||
if (src.hasPeriodMaxElement())
|
||||
|
|
|
@ -4,90 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hl7.fhir.convertors.conv30_40.Account30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ActivityDefinition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.AllergyIntolerance30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Appointment30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.AppointmentResponse30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.AuditEvent30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Basic30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Binary30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.BodySite30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Bundle30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.CapabilityStatement30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.CarePlan30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.CareTeam30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ClinicalImpression30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.CodeSystem30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Communication30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.CompartmentDefinition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Composition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ConceptMap30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Condition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Consent30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Coverage30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.DataElement30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.DetectedIssue30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.DeviceUseStatement30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.DiagnosticReport30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.DocumentReference30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Encounter30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Endpoint30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.EpisodeOfCare30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ExpansionProfile30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.FamilyMemberHistory30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Flag30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Goal30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.GraphDefinition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Group30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.HealthcareService30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ImagingStudy30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Immunization30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ImplementationGuide30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Library30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Linkage30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.List30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Location30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Media30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Medication30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.MedicationAdministration30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.MedicationDispense30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.MedicationRequest30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.MedicationStatement30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.MessageDefinition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.MessageHeader30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.NamingSystem30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Observation30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.OperationDefinition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.OperationOutcome30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Organization30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Parameters30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Patient30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.PaymentNotice30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Person30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.PlanDefinition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Practitioner30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.PractitionerRole30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Procedure30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ProcedureRequest30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Provenance30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Questionnaire30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.QuestionnaireResponse30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.RelatedPerson30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.RiskAssessment30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Schedule30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.SearchParameter30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Sequence30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Slot30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Specimen30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.StructureDefinition30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.StructureMap30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Subscription30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.Substance30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.SupplyDelivery30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.TestReport30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.TestScript30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.ValueSet30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.*;
|
||||
import org.hl7.fhir.dstu3.model.Parameters;
|
||||
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
@ -5164,6 +5081,8 @@ public class VersionConvertor_30_40 {
|
|||
return Coverage30_40.convertCoverage((org.hl7.fhir.r4.model.Coverage) src);
|
||||
if (src instanceof org.hl7.fhir.r4.model.DetectedIssue)
|
||||
return DetectedIssue30_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src);
|
||||
if (src instanceof org.hl7.fhir.r4.model.Device)
|
||||
return Device30_40.convertDevice((org.hl7.fhir.r4.model.Device) src);
|
||||
if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement)
|
||||
return DeviceUseStatement30_40.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src);
|
||||
if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -35,24 +35,25 @@ 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();
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"resourceType": "Device",
|
||||
"id": "DEV000000000872",
|
||||
"identifier": [
|
||||
{
|
||||
"system": "https://fresenius.org/device",
|
||||
"value": "DEV000000000872"
|
||||
}
|
||||
],
|
||||
"udi": {
|
||||
"name": "LC021691"
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"resourceType": "Device",
|
||||
"id": "DEV000000000873",
|
||||
"identifier": [
|
||||
{
|
||||
"system": "https://fresenius.org/device",
|
||||
"value": "DEV000000000873"
|
||||
}
|
||||
],
|
||||
"udi": {
|
||||
"name": "LC020678"
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -939,4 +939,9 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String fpValue() {
|
||||
return "@"+primitiveValue();
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
|
||||
}
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -249,4 +249,7 @@ public abstract class PrimitiveType<T> extends Type implements IPrimitiveType<T>
|
|||
return StringUtils.isNotBlank(getValueAsString());
|
||||
}
|
||||
|
||||
public String fpValue() {
|
||||
return primitiveValue();
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -3245,14 +3245,22 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
tl = t;
|
||||
if (t.hasTarget()) {
|
||||
c.getPieces().add(gen.new Piece(corePath+"references.html", t.getWorkingCode(), null));
|
||||
if (isMustSupportDirect(t) && e.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
c.getPieces().add(gen.new Piece(null, "(", null));
|
||||
boolean tfirst = true;
|
||||
for (UriType u : t.getTargetProfile()) {
|
||||
for (CanonicalType u : t.getTargetProfile()) {
|
||||
if (tfirst)
|
||||
tfirst = false;
|
||||
else
|
||||
c.addPiece(gen.new Piece(null, " | ", null));
|
||||
genTargetLink(gen, profileBaseFileName, corePath, c, t, u.getValue());
|
||||
if (isMustSupport(u) && e.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This target must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
}
|
||||
c.getPieces().add(gen.new Piece(null, ")", null));
|
||||
if (t.getAggregation().size() > 0) {
|
||||
|
@ -3289,6 +3297,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
} else
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece((p.getValue().startsWith(corePath)? corePath: "")+ref, t.getWorkingCode(), null)));
|
||||
if (isMustSupport(p) && e.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This profile must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String tc = t.getWorkingCode();
|
||||
|
@ -3301,8 +3313,13 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
} else if (pkp != null && pkp.hasLinkFor(tc)) {
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null)));
|
||||
} else
|
||||
} else {
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece(null, tc, null)));
|
||||
}
|
||||
if (isMustSupportDirect(t) && e.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
|
@ -3812,7 +3829,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (element != null && element.getIsSummary()) {
|
||||
checkForNoChange(element.getIsSummaryElement(), gc.addStyledText(translate("sd.table", "This element is included in summaries"), "\u03A3", null, null, null, false));
|
||||
}
|
||||
if (element != null && (!element.getConstraint().isEmpty() || !element.getCondition().isEmpty())) {
|
||||
if (element != null && (hasNonBaseConstraints(element.getConstraint()) || hasNonBaseConditions(element.getCondition()))) {
|
||||
gc.addStyledText(translate("sd.table", "This element has or is affected by some invariants ("+listConstraintsAndConditions(element)+")"), "I", null, null, null, false);
|
||||
}
|
||||
|
||||
|
@ -3860,7 +3877,8 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return res;
|
||||
}
|
||||
|
||||
private Cell addCell(Row row, Cell cell) {
|
||||
|
||||
private Cell addCell(Row row, Cell cell) {
|
||||
row.getCells().add(cell);
|
||||
return (cell);
|
||||
}
|
||||
|
@ -3869,18 +3887,49 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return app == null ? src : src + app;
|
||||
}
|
||||
|
||||
private boolean hasNonBaseConditions(List<IdType> conditions) {
|
||||
for (IdType c : conditions) {
|
||||
if (!isBaseCondition(c)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean hasNonBaseConstraints(List<ElementDefinitionConstraintComponent> constraints) {
|
||||
for (ElementDefinitionConstraintComponent c : constraints) {
|
||||
if (!isBaseConstraint(c)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String listConstraintsAndConditions(ElementDefinition element) {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
for (ElementDefinitionConstraintComponent con : element.getConstraint()) {
|
||||
b.append(con.getKey());
|
||||
if (!isBaseConstraint(con)) {
|
||||
b.append(con.getKey());
|
||||
}
|
||||
}
|
||||
for (IdType id : element.getCondition()) {
|
||||
b.append(id.asStringValue());
|
||||
if (!isBaseCondition(id)) {
|
||||
b.append(id.asStringValue());
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
private boolean isBaseCondition(IdType c) {
|
||||
String key = c.asStringValue();
|
||||
return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-");
|
||||
}
|
||||
|
||||
private boolean isBaseConstraint(ElementDefinitionConstraintComponent con) {
|
||||
String key = con.getKey();
|
||||
return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-");
|
||||
}
|
||||
|
||||
private void makeChoiceRows(List<Row> subRows, ElementDefinition element, HierarchicalTableGenerator gen, String corePath, String profileBaseFileName) {
|
||||
// create a child for each choice
|
||||
|
@ -3899,6 +3948,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
c.getPieces().add(gen.new Piece(corePath+"datatypes.html#canonical", "canonical", null));
|
||||
else
|
||||
c.getPieces().add(gen.new Piece(corePath+"references.html#Reference", "Reference", null));
|
||||
if (isMustSupportDirect(tr) && element.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
c.getPieces().add(gen.new Piece(null, "(", null));
|
||||
}
|
||||
boolean first = true;
|
||||
|
@ -3906,6 +3959,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (!first)
|
||||
c.getPieces().add(gen.new Piece(null, " | ", null));
|
||||
genTargetLink(gen, profileBaseFileName, corePath, c, tr, rt.getValue());
|
||||
if (isMustSupport(rt) && element.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This target must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
if (first)
|
||||
|
@ -3924,20 +3981,23 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
choicerow.getCells().add(gen.new Cell());
|
||||
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
|
||||
choicerow.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
|
||||
choicerow.getCells().add(gen.new Cell(null, corePath+"datatypes.html#"+t, sd.getType(), null, null));
|
||||
// } else if (definitions.getConstraints().contthnsKey(t)) {
|
||||
// ProfiledType pt = definitions.getConstraints().get(t);
|
||||
// choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(pt.getBaseType())), definitions.getTypes().containsKey(t) ? definitions.getTypes().get(t).getDefinition() : null, null));
|
||||
// choicerow.getCells().add(gen.new Cell());
|
||||
// choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
|
||||
// choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
|
||||
// choicerow.getCells().add(gen.new Cell(null, definitions.getSrcFile(t)+".html#"+t.replace("*", "open"), t, null, null));
|
||||
Cell c = gen.new Cell(null, corePath+"datatypes.html#"+t, sd.getType(), null, null);
|
||||
choicerow.getCells().add(c);
|
||||
if (isMustSupport(tr) && element.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
} else {
|
||||
choicerow.getCells().add(gen.new Cell(null, null, tail(element.getPath()).replace("[x]", Utilities.capitalize(t)), sd.getDescription(), null));
|
||||
choicerow.getCells().add(gen.new Cell());
|
||||
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
|
||||
choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
|
||||
choicerow.getCells().add(gen.new Cell(null, pkp.getLinkFor(corePath, t), sd.getType(), null, null));
|
||||
Cell c = gen.new Cell(null, pkp.getLinkFor(corePath, t), sd.getType(), null, null);
|
||||
choicerow.getCells().add(c);
|
||||
if (isMustSupport(tr) && element.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
}
|
||||
if (tr.hasProfile()) {
|
||||
Cell typeCell = choicerow.getCells().get(3);
|
||||
|
@ -3950,6 +4010,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
typeCell.addPiece(gen.new Piece(null, "?gen-e2?", null));
|
||||
else
|
||||
typeCell.addPiece(gen.new Piece(psd.getUserString("path"), psd.getName(), psd.present()));
|
||||
if (isMustSupport(pt) && element.getMustSupport()) {
|
||||
typeCell.addPiece(gen.new Piece(null, " ", null));
|
||||
typeCell.addStyledText(translate("sd.table", "This profile must be supported"), "S", "white", "red", null, false);
|
||||
}
|
||||
|
||||
}
|
||||
typeCell.addPiece(gen.new Piece(null, ")", null));
|
||||
|
@ -6145,6 +6209,32 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return grp;
|
||||
}
|
||||
|
||||
public static boolean isMustSupportDirect(TypeRefComponent tr) {
|
||||
return ("true".equals(ToolingExtensions.readStringExtension(tr, ToolingExtensions.EXT_MUST_SUPPORT)));
|
||||
}
|
||||
|
||||
public static boolean isMustSupport(TypeRefComponent tr) {
|
||||
if ("true".equals(ToolingExtensions.readStringExtension(tr, ToolingExtensions.EXT_MUST_SUPPORT))) {
|
||||
return true;
|
||||
}
|
||||
if (isMustSupport(tr.getProfile())) {
|
||||
return true;
|
||||
}
|
||||
return isMustSupport(tr.getTargetProfile());
|
||||
}
|
||||
|
||||
public static boolean isMustSupport(List<CanonicalType> profiles) {
|
||||
for (CanonicalType ct : profiles) {
|
||||
if (isMustSupport(ct)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isMustSupport(CanonicalType profile) {
|
||||
return "true".equals(ToolingExtensions.readStringExtension(profile, ToolingExtensions.EXT_MUST_SUPPORT));
|
||||
}
|
||||
|
||||
}
|
|
@ -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<>();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -81,11 +81,11 @@ 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;
|
||||
|
|
|
@ -1006,4 +1006,9 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fpValue() {
|
||||
return "@"+primitiveValue();
|
||||
}
|
||||
|
||||
}
|
|
@ -35,6 +35,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem;
|
||||
import org.hl7.fhir.r5.model.Enumerations.*;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
@ -308,6 +309,32 @@ public class ContactDetail extends DataType implements ICompositeType {
|
|||
return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(name, telecom);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.hl7.fhir.r5.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,7 @@ 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,
|
||||
|
||||
|
|
|
@ -248,4 +248,8 @@ public abstract class PrimitiveType<T> extends DataType implements IPrimitiveTyp
|
|||
public boolean hasPrimitiveValue() {
|
||||
return StringUtils.isNotBlank(getValueAsString());
|
||||
}
|
||||
|
||||
public String fpValue() {
|
||||
return primitiveValue();
|
||||
}
|
||||
}
|
|
@ -43,7 +43,9 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
|
||||
@Override
|
||||
public boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
|
||||
return render(x, (Bundle) r);
|
||||
XhtmlNode n = render((Bundle) r);
|
||||
x.addChildren(n.getChildNodes());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -134,6 +134,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
return false;
|
||||
}
|
||||
XhtmlNode t = x.table( "codes");
|
||||
boolean definitions = false;
|
||||
boolean commentS = false;
|
||||
boolean deprecated = false;
|
||||
boolean display = false;
|
||||
|
@ -161,14 +162,15 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
display = display || conceptsHaveDisplay(c);
|
||||
version = version || conceptsHaveVersion(c);
|
||||
hierarchy = hierarchy || c.hasConcept();
|
||||
definitions = definitions || conceptsHaveDefinition(c);
|
||||
}
|
||||
CodeSystemNavigator csNav = new CodeSystemNavigator(cs);
|
||||
hierarchy = hierarchy || csNav.isRestructure();
|
||||
|
||||
List<String> langs = new ArrayList<>();
|
||||
addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, true, commentS, version, deprecated, properties, null, false), maps);
|
||||
addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, definitions, commentS, version, deprecated, properties, null, false), maps);
|
||||
for (ConceptDefinitionComponent c : csNav.getConcepts(null)) {
|
||||
hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, commentS, version, deprecated, maps, cs.getUrl(), cs, properties, csNav, langs) || hasExtensions;
|
||||
hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, definitions, commentS, version, deprecated, maps, cs.getUrl(), cs, properties, csNav, langs) || hasExtensions;
|
||||
}
|
||||
if (langs.size() > 0) {
|
||||
Collections.sort(langs);
|
||||
|
@ -185,6 +187,23 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
return hasExtensions;
|
||||
}
|
||||
|
||||
private boolean conceptsHaveDefinition(ConceptDefinitionComponent c) {
|
||||
if (c.hasDefinition()) {
|
||||
return true;
|
||||
}
|
||||
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
|
||||
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (ConceptDefinitionComponent g : c.getConcept()) {
|
||||
if (conceptsHaveDefinition(g)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean conceptsHaveProperty(ConceptDefinitionComponent c, PropertyComponent cp) {
|
||||
if (CodeSystemUtilities.hasProperty(c, cp.getCode()))
|
||||
return true;
|
||||
|
@ -271,7 +290,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
|
||||
|
||||
|
||||
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean comment, boolean version, boolean deprecated, List<UsedConceptMap> maps, String system, CodeSystem cs, List<PropertyComponent> properties, CodeSystemNavigator csNav, List<String> langs) throws FHIRFormatError, DefinitionException, IOException {
|
||||
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean hasDefinitions, boolean comment, boolean version, boolean deprecated, List<UsedConceptMap> maps, String system, CodeSystem cs, List<PropertyComponent> properties, CodeSystemNavigator csNav, List<String> langs) throws FHIRFormatError, DefinitionException, IOException {
|
||||
boolean hasExtensions = false;
|
||||
XhtmlNode tr = t.tr();
|
||||
XhtmlNode td = tr.td();
|
||||
|
@ -298,35 +317,37 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
td = tr.td();
|
||||
renderDisplayName(c, cs, td);
|
||||
}
|
||||
td = tr.td();
|
||||
if (c != null &&
|
||||
c.hasDefinitionElement()) {
|
||||
if (getContext().getLang() == null) {
|
||||
if (hasMarkdownInDefinitions(cs))
|
||||
addMarkdown(td, c.getDefinition());
|
||||
else
|
||||
if (hasDefinitions) {
|
||||
td = tr.td();
|
||||
if (c != null &&
|
||||
c.hasDefinitionElement()) {
|
||||
if (getContext().getLang() == null) {
|
||||
if (hasMarkdownInDefinitions(cs))
|
||||
addMarkdown(td, c.getDefinition());
|
||||
else
|
||||
td.addText(c.getDefinition());
|
||||
} else if (getContext().getLang().equals("*")) {
|
||||
boolean sl = false;
|
||||
for (ConceptDefinitionDesignationComponent cd : c.getDesignation())
|
||||
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue()))
|
||||
sl = true;
|
||||
td.addText((sl ? cs.getLanguage("en")+": " : "")+c.getDefinition());
|
||||
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
|
||||
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) {
|
||||
td.br();
|
||||
td.addText(cd.getLanguage()+": "+cd.getValue());
|
||||
}
|
||||
}
|
||||
} else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
|
||||
td.addText(c.getDefinition());
|
||||
} else if (getContext().getLang().equals("*")) {
|
||||
boolean sl = false;
|
||||
for (ConceptDefinitionDesignationComponent cd : c.getDesignation())
|
||||
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue()))
|
||||
sl = true;
|
||||
td.addText((sl ? cs.getLanguage("en")+": " : "")+c.getDefinition());
|
||||
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
|
||||
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) {
|
||||
td.br();
|
||||
td.addText(cd.getLanguage()+": "+cd.getValue());
|
||||
} else {
|
||||
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
|
||||
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && cd.getLanguage().equals(getContext().getLang())) {
|
||||
td.addText(cd.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
|
||||
td.addText(c.getDefinition());
|
||||
} else {
|
||||
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
|
||||
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && cd.getLanguage().equals(getContext().getLang())) {
|
||||
td.addText(cd.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (deprecated) {
|
||||
td = tr.td();
|
||||
|
@ -395,15 +416,17 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
for (PropertyComponent pc : properties) {
|
||||
td = tr.td();
|
||||
boolean first = true;
|
||||
ConceptPropertyComponent pcv = CodeSystemUtilities.getProperty(c, pc.getCode());
|
||||
if (pcv != null && pcv.hasValue()) {
|
||||
if (first) first = false; else td.addText(", ");
|
||||
if (pcv.hasValueCoding()) {
|
||||
td.addText(pcv.getValueCoding().getCode());
|
||||
} else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrl(pcv.getValue().primitiveValue())) {
|
||||
td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue());
|
||||
} else {
|
||||
td.addText(pcv.getValue().primitiveValue());
|
||||
List<ConceptPropertyComponent> pcvl = CodeSystemUtilities.getPropertyValues(c, pc.getCode());
|
||||
for (ConceptPropertyComponent pcv : pcvl) {
|
||||
if (pcv.hasValue()) {
|
||||
if (first) first = false; else td.addText(", ");
|
||||
if (pcv.hasValueCoding()) {
|
||||
td.addText(pcv.getValueCoding().getCode());
|
||||
} else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrl(pcv.getValue().primitiveValue())) {
|
||||
td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue());
|
||||
} else {
|
||||
td.addText(pcv.getValue().primitiveValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -427,7 +450,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
}
|
||||
List<ConceptDefinitionComponent> ocl = csNav.getOtherChildren(c);
|
||||
for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) {
|
||||
hasExtensions = addDefineRowToTable(t, cc, level+1, hasHierarchy, hasDisplay, comment, version, deprecated, maps, system, cs, properties, csNav, langs) || hasExtensions;
|
||||
hasExtensions = addDefineRowToTable(t, cc, level+1, hasHierarchy, hasDisplay, hasDefinitions, comment, version, deprecated, maps, system, cs, properties, csNav, langs) || hasExtensions;
|
||||
}
|
||||
for (ConceptDefinitionComponent cc : ocl) {
|
||||
tr = t.tr();
|
||||
|
|
|
@ -168,6 +168,10 @@ public class DataRenderer extends Renderer {
|
|||
}
|
||||
|
||||
protected String describeLang(String lang) {
|
||||
// special cases:
|
||||
if ("fr-CA".equals(lang)) {
|
||||
return "French (Canadian)"; // this one was omitted from the value set
|
||||
}
|
||||
ValueSet v = getContext().getWorker().fetchResource(ValueSet.class, "http://hl7.org/fhir/ValueSet/languages");
|
||||
if (v != null) {
|
||||
ConceptReferenceComponent l = null;
|
||||
|
@ -176,11 +180,22 @@ public class DataRenderer extends Renderer {
|
|||
l = cc;
|
||||
}
|
||||
if (l == null) {
|
||||
if (lang.contains("-"))
|
||||
if (lang.contains("-")) {
|
||||
lang = lang.substring(0, lang.indexOf("-"));
|
||||
}
|
||||
for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
|
||||
if (cc.getCode().equals(lang) || cc.getCode().startsWith(lang+"-"))
|
||||
if (cc.getCode().equals(lang)) {
|
||||
l = cc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l == null) {
|
||||
for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
|
||||
if (cc.getCode().startsWith(lang+"-")) {
|
||||
l = cc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (l != null) {
|
||||
|
@ -236,12 +251,12 @@ public class DataRenderer extends Renderer {
|
|||
} else {
|
||||
return "No display for "+b.fhirType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String display(DataType type) {
|
||||
if (type.isEmpty())
|
||||
if (type == null || type.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (type instanceof Coding) {
|
||||
return displayCoding((Coding) type);
|
||||
|
@ -339,7 +354,6 @@ public class DataRenderer extends Renderer {
|
|||
} else {
|
||||
x.tx("No display for "+type.fhirType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void renderReference(XhtmlNode x, Reference ref) {
|
||||
|
@ -353,15 +367,17 @@ public class DataRenderer extends Renderer {
|
|||
}
|
||||
|
||||
public void renderDateTime(XhtmlNode x, Base e) {
|
||||
if (e.hasPrimitiveValue())
|
||||
if (e.hasPrimitiveValue()) {
|
||||
x.addText(((DateTimeType) e).toHumanDisplay());
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderUri(XhtmlNode x, UriType uri) {
|
||||
if (uri.getValue().startsWith("mailto:"))
|
||||
if (uri.getValue().startsWith("mailto:")) {
|
||||
x.ah(uri.getValue()).addText(uri.getValue().substring(7));
|
||||
else
|
||||
} else {
|
||||
x.ah(uri.getValue()).addText(uri.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderUri(XhtmlNode x, UriType uri, String path, String id) {
|
||||
|
@ -684,9 +700,63 @@ public class DataRenderer extends Renderer {
|
|||
}
|
||||
|
||||
protected void renderContactPoint(XhtmlNode x, ContactPoint contact) {
|
||||
x.addText(displayContactPoint(contact));
|
||||
if (contact != null) {
|
||||
if (!contact.hasSystem()) {
|
||||
x.addText(displayContactPoint(contact));
|
||||
} else {
|
||||
switch (contact.getSystem()) {
|
||||
case EMAIL:
|
||||
x.ah("mailto:"+contact.getValue()).tx(contact.getValue());
|
||||
break;
|
||||
case FAX:
|
||||
x.addText(displayContactPoint(contact));
|
||||
break;
|
||||
case NULL:
|
||||
x.addText(displayContactPoint(contact));
|
||||
break;
|
||||
case OTHER:
|
||||
x.addText(displayContactPoint(contact));
|
||||
break;
|
||||
case PAGER:
|
||||
x.addText(displayContactPoint(contact));
|
||||
break;
|
||||
case PHONE:
|
||||
if (contact.hasValue() && contact.getValue().startsWith("+")) {
|
||||
x.ah("tel:"+contact.getValue().replace(" ", "")).tx(contact.getValue());
|
||||
} else {
|
||||
x.addText(displayContactPoint(contact));
|
||||
}
|
||||
break;
|
||||
case SMS:
|
||||
x.addText(displayContactPoint(contact));
|
||||
break;
|
||||
case URL:
|
||||
x.ah(contact.getValue()).tx(contact.getValue());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void displayContactPoint(XhtmlNode p, ContactPoint c) {
|
||||
if (c != null) {
|
||||
if (c.getSystem() == ContactPointSystem.PHONE) {
|
||||
p.tx("Phone: "+c.getValue());
|
||||
} else if (c.getSystem() == ContactPointSystem.FAX) {
|
||||
p.tx("Fax: "+c.getValue());
|
||||
} else if (c.getSystem() == ContactPointSystem.EMAIL) {
|
||||
p.tx(c.getValue());
|
||||
} else if (c.getSystem() == ContactPointSystem.URL) {
|
||||
if (c.getValue().length() > 30) {
|
||||
p.addText(c.getValue().substring(0, 30)+"...");
|
||||
} else {
|
||||
p.addText(c.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addTelecom(XhtmlNode p, ContactPoint c) {
|
||||
if (c.getSystem() == ContactPointSystem.PHONE) {
|
||||
|
@ -713,7 +783,6 @@ public class DataRenderer extends Renderer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected String displayQuantity(Quantity q) {
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
|
|
|
@ -0,0 +1,533 @@
|
|||
package org.hl7.fhir.r5.renderers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.model.Annotation;
|
||||
import org.hl7.fhir.r5.model.Attachment;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.ContactDetail;
|
||||
import org.hl7.fhir.r5.model.ContactPoint;
|
||||
import org.hl7.fhir.r5.model.DataRequirement;
|
||||
import org.hl7.fhir.r5.model.DomainResource;
|
||||
import org.hl7.fhir.r5.model.Library;
|
||||
import org.hl7.fhir.r5.model.ListResource;
|
||||
import org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent;
|
||||
import org.hl7.fhir.r5.model.ParameterDefinition;
|
||||
import org.hl7.fhir.r5.model.Reference;
|
||||
import org.hl7.fhir.r5.model.RelatedArtifact;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper;
|
||||
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper;
|
||||
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
||||
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
|
||||
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
|
||||
public class LibraryRenderer extends ResourceRenderer {
|
||||
|
||||
private static final int DATA_IMG_SIZE_CUTOFF = 4000;
|
||||
|
||||
public LibraryRenderer(RenderingContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public LibraryRenderer(RenderingContext context, ResourceContext rcontext) {
|
||||
super(context, rcontext);
|
||||
}
|
||||
|
||||
public boolean render(XhtmlNode x, Resource dr) throws FHIRFormatError, DefinitionException, IOException {
|
||||
return render(x, (Library) dr);
|
||||
}
|
||||
|
||||
public boolean render(XhtmlNode x, ResourceWrapper lib) throws FHIRFormatError, DefinitionException, IOException {
|
||||
PropertyWrapper authors = lib.getChildByName("author");
|
||||
PropertyWrapper editors = lib.getChildByName("editor");
|
||||
PropertyWrapper reviewers = lib.getChildByName("reviewer");
|
||||
PropertyWrapper endorsers = lib.getChildByName("endorser");
|
||||
if ((authors != null && authors.hasValues()) || (editors != null && editors.hasValues()) || (reviewers != null && reviewers.hasValues()) || (endorsers != null && endorsers.hasValues())) {
|
||||
boolean email = hasCT(authors, "email") || hasCT(editors, "email") || hasCT(reviewers, "email") || hasCT(endorsers, "email");
|
||||
boolean phone = hasCT(authors, "phone") || hasCT(editors, "phone") || hasCT(reviewers, "phone") || hasCT(endorsers, "phone");
|
||||
boolean url = hasCT(authors, "url") || hasCT(editors, "url") || hasCT(reviewers, "url") || hasCT(endorsers, "url");
|
||||
x.h2().tx("Participants");
|
||||
XhtmlNode t = x.table("grid");
|
||||
if (authors != null) {
|
||||
for (BaseWrapper cd : authors.getValues()) {
|
||||
participantRow(t, "Author", cd, email, phone, url);
|
||||
}
|
||||
}
|
||||
if (authors != null) {
|
||||
for (BaseWrapper cd : editors.getValues()) {
|
||||
participantRow(t, "Editor", cd, email, phone, url);
|
||||
}
|
||||
}
|
||||
if (authors != null) {
|
||||
for (BaseWrapper cd : reviewers.getValues()) {
|
||||
participantRow(t, "Reviewer", cd, email, phone, url);
|
||||
}
|
||||
}
|
||||
if (authors != null) {
|
||||
for (BaseWrapper cd : endorsers.getValues()) {
|
||||
participantRow(t, "Endorser", cd, email, phone, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
PropertyWrapper artifacts = lib.getChildByName("relatedArtifact");
|
||||
if (artifacts != null && artifacts.hasValues()) {
|
||||
x.h2().tx("Related Artifacts");
|
||||
XhtmlNode t = x.table("grid");
|
||||
boolean label = false;
|
||||
boolean display = false;
|
||||
boolean citation = false;
|
||||
for (BaseWrapper ra : artifacts.getValues()) {
|
||||
label = label || ra.has("label");
|
||||
display = display || ra.has("display");
|
||||
citation = citation || ra.has("citation");
|
||||
}
|
||||
for (BaseWrapper ra : artifacts.getValues()) {
|
||||
renderArtifact(t, ra, lib, label, display, citation);
|
||||
}
|
||||
}
|
||||
PropertyWrapper parameters = lib.getChildByName("parameter");
|
||||
if (parameters != null && parameters.hasValues()) {
|
||||
x.h2().tx("Parameters");
|
||||
XhtmlNode t = x.table("grid");
|
||||
boolean doco = false;
|
||||
for (BaseWrapper p : parameters.getValues()) {
|
||||
doco = doco || p.has("documentation");
|
||||
}
|
||||
for (BaseWrapper p : parameters.getValues()) {
|
||||
renderParameter(t, p, doco);
|
||||
}
|
||||
}
|
||||
PropertyWrapper dataRequirements = lib.getChildByName("dataRequirement");
|
||||
if (dataRequirements != null && dataRequirements.hasValues()) {
|
||||
x.h2().tx("Data Requirements");
|
||||
for (BaseWrapper p : dataRequirements.getValues()) {
|
||||
renderDataRequirement(x, (DataRequirement) p.getBase());
|
||||
}
|
||||
}
|
||||
PropertyWrapper contents = lib.getChildByName("content");
|
||||
if (contents != null) {
|
||||
x.h2().tx("Contents");
|
||||
boolean isCql = false;
|
||||
int counter = 0;
|
||||
for (BaseWrapper p : contents.getValues()) {
|
||||
Attachment att = (Attachment) p.getBase();
|
||||
renderAttachment(x, att, isCql, counter, lib.getId());
|
||||
isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasCT(PropertyWrapper prop, String type) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
if (prop != null) {
|
||||
for (BaseWrapper cd : prop.getValues()) {
|
||||
PropertyWrapper telecoms = cd.getChildByName("telecom");
|
||||
if (getContactPoint(telecoms, type) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasCT(List<ContactDetail> list, String type) {
|
||||
for (ContactDetail cd : list) {
|
||||
for (ContactPoint t : cd.getTelecom()) {
|
||||
if (type.equals(t.getSystem().toCode())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean render(XhtmlNode x, Library lib) throws FHIRFormatError, DefinitionException, IOException {
|
||||
if (lib.hasAuthor() || lib.hasEditor() || lib.hasReviewer() || lib.hasEndorser()) {
|
||||
boolean email = hasCT(lib.getAuthor(), "email") || hasCT(lib.getEditor(), "email") || hasCT(lib.getReviewer(), "email") || hasCT(lib.getEndorser(), "email");
|
||||
boolean phone = hasCT(lib.getAuthor(), "phone") || hasCT(lib.getEditor(), "phone") || hasCT(lib.getReviewer(), "phone") || hasCT(lib.getEndorser(), "phone");
|
||||
boolean url = hasCT(lib.getAuthor(), "url") || hasCT(lib.getEditor(), "url") || hasCT(lib.getReviewer(), "url") || hasCT(lib.getEndorser(), "url");
|
||||
x.h2().tx("Participants");
|
||||
XhtmlNode t = x.table("grid");
|
||||
for (ContactDetail cd : lib.getAuthor()) {
|
||||
participantRow(t, "Author", cd, email, phone, url);
|
||||
}
|
||||
for (ContactDetail cd : lib.getEditor()) {
|
||||
participantRow(t, "Editor", cd, email, phone, url);
|
||||
}
|
||||
for (ContactDetail cd : lib.getReviewer()) {
|
||||
participantRow(t, "Reviewer", cd, email, phone, url);
|
||||
}
|
||||
for (ContactDetail cd : lib.getEndorser()) {
|
||||
participantRow(t, "Endorser", cd, email, phone, url);
|
||||
}
|
||||
}
|
||||
if (lib.hasRelatedArtifact()) {
|
||||
x.h2().tx("Related Artifacts");
|
||||
XhtmlNode t = x.table("grid");
|
||||
boolean label = false;
|
||||
boolean display = false;
|
||||
boolean citation = false;
|
||||
for (RelatedArtifact ra : lib.getRelatedArtifact()) {
|
||||
label = label || ra.hasLabel();
|
||||
display = display || ra.hasDisplay();
|
||||
citation = citation || ra.hasCitation();
|
||||
}
|
||||
for (RelatedArtifact ra : lib.getRelatedArtifact()) {
|
||||
renderArtifact(t, ra, lib, label, display, citation);
|
||||
}
|
||||
}
|
||||
if (lib.hasParameter()) {
|
||||
x.h2().tx("Parameters");
|
||||
XhtmlNode t = x.table("grid");
|
||||
boolean doco = false;
|
||||
for (ParameterDefinition p : lib.getParameter()) {
|
||||
doco = doco || p.hasDocumentation();
|
||||
}
|
||||
for (ParameterDefinition p : lib.getParameter()) {
|
||||
renderParameter(t, p, doco);
|
||||
}
|
||||
}
|
||||
if (lib.hasDataRequirement()) {
|
||||
x.h2().tx("Data Requirements");
|
||||
for (DataRequirement p : lib.getDataRequirement()) {
|
||||
renderDataRequirement(x, p);
|
||||
}
|
||||
}
|
||||
if (lib.hasContent()) {
|
||||
x.h2().tx("Contents");
|
||||
boolean isCql = false;
|
||||
int counter = 0;
|
||||
for (Attachment att : lib.getContent()) {
|
||||
renderAttachment(x, att, isCql, counter, lib.getId());
|
||||
isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void renderParameter(XhtmlNode t, BaseWrapper p, boolean doco) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
XhtmlNode tr = t.tr();
|
||||
tr.td().tx(p.has("name") ? p.get("name").primitiveValue() : null);
|
||||
tr.td().tx(p.has("use") ? p.get("use").primitiveValue() : null);
|
||||
tr.td().tx(p.has("min") ? p.get("min").primitiveValue() : null);
|
||||
tr.td().tx(p.has("max") ? p.get("max").primitiveValue() : null);
|
||||
tr.td().tx(p.has("type") ? p.get("type").primitiveValue() : null);
|
||||
if (doco) {
|
||||
tr.td().tx(p.has("documentation") ? p.get("documentation").primitiveValue() : null);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderParameter(XhtmlNode t, ParameterDefinition p, boolean doco) {
|
||||
XhtmlNode tr = t.tr();
|
||||
tr.td().tx(p.getName());
|
||||
tr.td().tx(p.getUse().getDisplay());
|
||||
tr.td().tx(p.getMin());
|
||||
tr.td().tx(p.getMax());
|
||||
tr.td().tx(p.getType().getDisplay());
|
||||
if (doco) {
|
||||
tr.td().tx(p.getDocumentation());
|
||||
}
|
||||
}
|
||||
|
||||
private void renderArtifact(XhtmlNode t, BaseWrapper ra, ResourceWrapper lib, boolean label, boolean display, boolean citation) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
XhtmlNode tr = t.tr();
|
||||
tr.td().tx(ra.has("type") ? ra.get("type").primitiveValue() : null);
|
||||
if (label) {
|
||||
tr.td().tx(ra.has("label") ? ra.get("label").primitiveValue() : null);
|
||||
}
|
||||
if (display) {
|
||||
tr.td().tx(ra.has("display") ? ra.get("display").primitiveValue() : null);
|
||||
}
|
||||
if (citation) {
|
||||
tr.td().markdown(ra.has("citation") ? ra.get("citation").primitiveValue() : null, "Citation");
|
||||
}
|
||||
if (ra.has("resource")) {
|
||||
renderCanonical(lib, tr.td(), ra.get("resource").primitiveValue());
|
||||
} else {
|
||||
tr.td().tx(ra.has("url") ? ra.get("url").primitiveValue() : null);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderArtifact(XhtmlNode t, RelatedArtifact ra, Resource lib, boolean label, boolean display, boolean citation) throws IOException {
|
||||
XhtmlNode tr = t.tr();
|
||||
tr.td().tx(ra.getType().getDisplay());
|
||||
if (label) {
|
||||
tr.td().tx(ra.getLabel());
|
||||
}
|
||||
if (display) {
|
||||
tr.td().tx(ra.getDisplay());
|
||||
}
|
||||
if (citation) {
|
||||
tr.td().markdown(ra.getCitation(), "Citation");
|
||||
}
|
||||
if (ra.hasResource()) {
|
||||
renderCanonical(lib, tr.td(), ra.getResource());
|
||||
} else {
|
||||
tr.td().tx(ra.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
private void participantRow(XhtmlNode t, String label, BaseWrapper cd, boolean email, boolean phone, boolean url) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
XhtmlNode tr = t.tr();
|
||||
tr.td().tx(label);
|
||||
tr.td().tx(cd.get("name") != null ? cd.get("name").primitiveValue() : null);
|
||||
PropertyWrapper telecoms = cd.getChildByName("telecom");
|
||||
if (email) {
|
||||
renderContactPoint(tr.td(), getContactPoint(telecoms, "email"));
|
||||
}
|
||||
if (phone) {
|
||||
renderContactPoint(tr.td(), getContactPoint(telecoms, "phone"));
|
||||
}
|
||||
if (url) {
|
||||
renderContactPoint(tr.td(), getContactPoint(telecoms, "url"));
|
||||
}
|
||||
}
|
||||
|
||||
private ContactPoint getContactPoint(PropertyWrapper telecoms, String value) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
for (BaseWrapper t : telecoms.getValues()) {
|
||||
if (t.has("system")) {
|
||||
String system = t.get("system").primitiveValue();
|
||||
if (value.equals(system)) {
|
||||
return (ContactPoint) t.getBase();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void participantRow(XhtmlNode t, String label, ContactDetail cd, boolean email, boolean phone, boolean url) {
|
||||
XhtmlNode tr = t.tr();
|
||||
tr.td().tx(label);
|
||||
tr.td().tx(cd.getName());
|
||||
if (email) {
|
||||
renderContactPoint(tr.td(), cd.getEmail());
|
||||
}
|
||||
if (phone) {
|
||||
renderContactPoint(tr.td(), cd.getPhone());
|
||||
}
|
||||
if (url) {
|
||||
renderContactPoint(tr.td(), cd.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
public void describe(XhtmlNode x, Library lib) {
|
||||
x.tx(display(lib));
|
||||
}
|
||||
|
||||
public String display(Library lib) {
|
||||
return lib.present();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String display(Resource r) throws UnsupportedEncodingException, IOException {
|
||||
return ((Library) r).present();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String display(ResourceWrapper r) throws UnsupportedEncodingException, IOException {
|
||||
if (r.has("title")) {
|
||||
return r.children("title").get(0).getBase().primitiveValue();
|
||||
}
|
||||
return "??";
|
||||
}
|
||||
|
||||
private void renderAttachment(XhtmlNode x, Attachment att, boolean noShowData, int counter, String baseId) {
|
||||
boolean ref = !att.hasData() && att.hasUrl();
|
||||
if (ref) {
|
||||
XhtmlNode p = x.para();
|
||||
if (att.hasTitle()) {
|
||||
p.tx(att.getTitle());
|
||||
p.tx(": ");
|
||||
}
|
||||
p.code().ah(att.getUrl()).tx(att.getUrl());
|
||||
p.tx(" (");
|
||||
p.code().tx(att.getContentType());
|
||||
p.tx(lang(att));
|
||||
p.tx(")");
|
||||
} else if (!att.hasData()) {
|
||||
XhtmlNode p = x.para();
|
||||
if (att.hasTitle()) {
|
||||
p.tx(att.getTitle());
|
||||
p.tx(": ");
|
||||
}
|
||||
p.code().tx("No Content");
|
||||
p.tx(" (");
|
||||
p.code().tx(att.getContentType());
|
||||
p.tx(lang(att));
|
||||
p.tx(")");
|
||||
} else {
|
||||
String txt = getText(att);
|
||||
if (isImage(att.getContentType())) {
|
||||
XhtmlNode p = x.para();
|
||||
if (att.hasTitle()) {
|
||||
p.tx(att.getTitle());
|
||||
p.tx(": (");
|
||||
p.code().tx(att.getContentType());
|
||||
p.tx(lang(att));
|
||||
p.tx(")");
|
||||
}
|
||||
else {
|
||||
p.code().tx(att.getContentType()+lang(att));
|
||||
}
|
||||
if (att.getData().length < LibraryRenderer.DATA_IMG_SIZE_CUTOFF) {
|
||||
x.img("data: "+att.getContentType()+">;base64,"+b64(att.getData()));
|
||||
} else {
|
||||
String filename = "Library-"+baseId+(counter == 0 ? "" : "-"+Integer.toString(counter))+"."+imgExtension(att.getContentType());
|
||||
x.img(filename);
|
||||
}
|
||||
} else if (txt != null && !noShowData) {
|
||||
XhtmlNode p = x.para();
|
||||
if (att.hasTitle()) {
|
||||
p.tx(att.getTitle());
|
||||
p.tx(": (");
|
||||
p.code().tx(att.getContentType());
|
||||
p.tx(lang(att));
|
||||
p.tx(")");
|
||||
}
|
||||
else {
|
||||
p.code().tx(att.getContentType()+lang(att));
|
||||
}
|
||||
String prismCode = determinePrismCode(att);
|
||||
if (prismCode != null) {
|
||||
x.pre().code().setAttribute("class", "language-"+prismCode).tx(txt);
|
||||
} else {
|
||||
x.pre().code().tx(txt);
|
||||
}
|
||||
} else {
|
||||
XhtmlNode p = x.para();
|
||||
if (att.hasTitle()) {
|
||||
p.tx(att.getTitle());
|
||||
p.tx(": ");
|
||||
}
|
||||
p.code().tx("Content not shown - (");
|
||||
p.code().tx(att.getContentType());
|
||||
p.tx(lang(att));
|
||||
p.tx(", size = "+Utilities.describeSize(att.getData().length)+")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String imgExtension(String contentType) {
|
||||
if (contentType != null && contentType.startsWith("image/")) {
|
||||
if (contentType.startsWith("image/png")) {
|
||||
return "png";
|
||||
}
|
||||
if (contentType.startsWith("image/jpeg")) {
|
||||
return "jpg";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String b64(byte[] data) {
|
||||
byte[] encodeBase64 = Base64.encodeBase64(data);
|
||||
return new String(encodeBase64);
|
||||
}
|
||||
|
||||
private boolean isImage(String contentType) {
|
||||
return imgExtension(contentType) != null;
|
||||
}
|
||||
|
||||
private String lang(Attachment att) {
|
||||
if (att.hasLanguage()) {
|
||||
return ", language = "+describeLang(att.getLanguage());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getText(Attachment att) {
|
||||
try {
|
||||
try {
|
||||
String src = new String(att.getData(), "UTF-8");
|
||||
if (checkString(src)) {
|
||||
return src;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
String src = new String(att.getData(), "UTF-16");
|
||||
if (checkString(src)) {
|
||||
return src;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
String src = new String(att.getData(), "ASCII");
|
||||
if (checkString(src)) {
|
||||
return src;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkString(String src) {
|
||||
for (char ch : src.toCharArray()) {
|
||||
if (ch < ' ' && ch != '\r' && ch != '\n' && ch != '\t') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String determinePrismCode(Attachment att) {
|
||||
if (att.hasContentType()) {
|
||||
String ct = att.getContentType();
|
||||
if (ct.contains(";")) {
|
||||
ct = ct.substring(0, ct.indexOf(";"));
|
||||
}
|
||||
switch (ct) {
|
||||
case "text/html" : return "html";
|
||||
case "text/xml" : return "xml";
|
||||
case "application/xml" : return "xml";
|
||||
case "text/markdown" : return "markdown";
|
||||
case "application/js" : return "JavaScript";
|
||||
case "application/css" : return "css";
|
||||
case "text/x-csrc" : return "c";
|
||||
case "text/x-csharp" : return "csharp";
|
||||
case "text/x-c++src" : return "cpp";
|
||||
case "application/graphql" : return "graphql";
|
||||
case "application/x-java" : return "java";
|
||||
case "application/json" : return "json";
|
||||
case "text/json" : return "json";
|
||||
case "application/liquid" : return "liquid";
|
||||
case "text/x-pascal" : return "pascal";
|
||||
case "text/x-python" : return "python";
|
||||
case "text/x-rsrc" : return "r";
|
||||
case "text/x-ruby" : return "ruby";
|
||||
case "text/x-sas" : return "sas";
|
||||
case "text/x-sql" : return "sql";
|
||||
case "application/typescript" : return "typescript";
|
||||
case "text/cql" : return "sql"; // not that bad...
|
||||
}
|
||||
if (att.getContentType().contains("json+") || att.getContentType().contains("+json")) {
|
||||
return "json";
|
||||
}
|
||||
if (att.getContentType().contains("xml+") || att.getContentType().contains("+xml")) {
|
||||
return "xml";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -106,13 +106,14 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
|||
}
|
||||
try {
|
||||
StructureDefinition sd = r.getDefinition();
|
||||
ElementDefinition ed = sd.getSnapshot().getElement().get(0);
|
||||
if (sd.getType().equals("NamingSystem") && "icd10".equals(r.getId())) {
|
||||
System.out.println("hah!");
|
||||
if (sd == null) {
|
||||
throw new FHIRException("Cannot find definition for "+r.fhirType());
|
||||
} else {
|
||||
ElementDefinition ed = sd.getSnapshot().getElement().get(0);
|
||||
containedIds.clear();
|
||||
hasExtensions = false;
|
||||
generateByProfile(r, sd, r.root(), sd.getSnapshot().getElement(), ed, context.getProfileUtilities().getChildList(sd, ed), x, r.fhirType(), false, 0);
|
||||
}
|
||||
containedIds.clear();
|
||||
hasExtensions = false;
|
||||
generateByProfile(r, sd, r.root(), sd.getSnapshot().getElement(), ed, context.getProfileUtilities().getChildList(sd, ed), x, r.fhirType(), false, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
x.para().b().style("color: maroon").tx("Exception generating Narrative: "+e.getMessage());
|
||||
|
@ -391,6 +392,8 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
|||
} else if (e instanceof DataRequirement) {
|
||||
DataRequirement p = (DataRequirement) e;
|
||||
renderDataRequirement(x, p);
|
||||
} else if (e instanceof PrimitiveType) {
|
||||
x.tx(((PrimitiveType) e).primitiveValue());
|
||||
} else if (e instanceof ElementDefinition) {
|
||||
x.tx("todo-bundle");
|
||||
} else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
|
||||
|
@ -485,7 +488,11 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
|||
renderAddress(x, (Address) e);
|
||||
return true;
|
||||
} else if (e instanceof ContactPoint) {
|
||||
renderContactPoint(x, (ContactPoint) e);
|
||||
if (allowLinks) {
|
||||
renderContactPoint(x, (ContactPoint) e);
|
||||
} else {
|
||||
displayContactPoint(x, (ContactPoint) e);
|
||||
}
|
||||
return true;
|
||||
} else if (e instanceof Timing) {
|
||||
renderTiming(x, (Timing) e);
|
||||
|
@ -527,7 +534,11 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
|||
boolean first = true;
|
||||
for (ContactPoint c : cd.getTelecom()) {
|
||||
if (first) first = false; else x.tx(",");
|
||||
renderContactPoint(x, c);
|
||||
if (allowLinks) {
|
||||
renderContactPoint(x, c);
|
||||
} else {
|
||||
displayContactPoint(x, c);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (e instanceof Range) {
|
||||
|
|
|
@ -59,6 +59,9 @@ public class RendererFactory {
|
|||
if ("Encounter".equals(resourceName)) {
|
||||
return new EncounterRenderer(context);
|
||||
}
|
||||
if ("Library".equals(resourceName)) {
|
||||
return new LibraryRenderer(context);
|
||||
}
|
||||
if ("List".equals(resourceName)) {
|
||||
return new ListRenderer(context);
|
||||
}
|
||||
|
@ -75,6 +78,9 @@ public class RendererFactory {
|
|||
if ("Parameters".equals(resourceName)) {
|
||||
return new ParametersRenderer(context);
|
||||
}
|
||||
if ("Bundle".equals(resourceName)) {
|
||||
return new BundleRenderer(context);
|
||||
}
|
||||
return new ProfileDrivenRenderer(context);
|
||||
}
|
||||
|
||||
|
@ -102,6 +108,9 @@ public class RendererFactory {
|
|||
if ("List".equals(resource.getName())) {
|
||||
return new ListRenderer(context);
|
||||
}
|
||||
if ("Library".equals(resource.getName())) {
|
||||
return new LibraryRenderer(context);
|
||||
}
|
||||
if ("DiagnosticReport".equals(resource.getName())) {
|
||||
return new DiagnosticReportRenderer(context);
|
||||
}
|
||||
|
|
|
@ -125,6 +125,44 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
public void renderCanonical(Resource res, XhtmlNode x, String url) throws UnsupportedEncodingException, IOException {
|
||||
ResourceWrapper rw = new ResourceWrapperDirect(this.context, res);
|
||||
renderCanonical(rw, x, url);
|
||||
}
|
||||
|
||||
public void renderCanonical(ResourceWrapper rw, XhtmlNode x, String url) throws UnsupportedEncodingException, IOException {
|
||||
renderCanonical(rw, x, url, true);
|
||||
}
|
||||
|
||||
public void renderCanonical(ResourceWrapper rw, XhtmlNode x, String url, boolean allowLinks) throws UnsupportedEncodingException, IOException {
|
||||
if (url == null) {
|
||||
return;
|
||||
}
|
||||
Resource target = context.getWorker().fetchResource(Resource.class, url);
|
||||
if (target == null || !(target instanceof CanonicalResource)) {
|
||||
x.code().tx(url);
|
||||
} else {
|
||||
CanonicalResource cr = (CanonicalResource) target;
|
||||
if (url.contains("|")) {
|
||||
if (target.hasUserData("path")) {
|
||||
x.ah(target.getUserString("path")).tx(cr.present()+" (version "+cr.getVersion()+")");
|
||||
} else {
|
||||
url = url.substring(0, url.indexOf("|"));
|
||||
x.code().tx(url);
|
||||
x.tx(": "+cr.present()+" (version "+cr.getVersion()+")");
|
||||
}
|
||||
} else {
|
||||
if (target.hasUserData("path")) {
|
||||
x.ah(target.getUserString("path")).tx(cr.present());
|
||||
} else {
|
||||
url = url.substring(0, url.indexOf("|"));
|
||||
x.code().tx(url);
|
||||
x.tx(": "+cr.present());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderReference(Resource res, XhtmlNode x, Reference r) throws UnsupportedEncodingException, IOException {
|
||||
ResourceWrapper rw = new ResourceWrapperDirect(this.context, res);
|
||||
renderReference(rw, x, r);
|
||||
|
|
|
@ -234,6 +234,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
}
|
||||
if (doDefinition) {
|
||||
tr.td().b().tx("Definition");
|
||||
doLangs = false;
|
||||
} else {
|
||||
// if we're not doing definitions and we don't have too many languages, we'll do them in line
|
||||
if (langs.size() < MAX_LANGS_IN_LINE) {
|
||||
|
@ -260,9 +261,9 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
x.para().b().tx("Additional Language Displays");
|
||||
t = x.table( "codes");
|
||||
tr = t.tr();
|
||||
tdDisp.b().tx("Code");
|
||||
tr.td().b().tx("Code");
|
||||
for (String lang : langs) {
|
||||
tdDisp.b().addText(describeLang(lang));
|
||||
tr.td().b().addText(describeLang(lang));
|
||||
}
|
||||
for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
|
||||
addLanguageRow(c, t, langs);
|
||||
|
@ -482,7 +483,6 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
if ("1.0m".equals(v)) return "Jul 1999";
|
||||
if ("1.0l".equals(v)) return "Jan 1998";
|
||||
if ("1.0ja".equals(v)) return "Oct 1997";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,9 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
td.i().tx("("+mapping.comp.getComment()+")");
|
||||
}
|
||||
}
|
||||
addLangaugesToRow(c, langs, tr);
|
||||
if (doLangs) {
|
||||
addLangaugesToRow(c, langs, tr);
|
||||
}
|
||||
for (ValueSetExpansionContainsComponent cc : c.getContains()) {
|
||||
addExpansionRowToTable(t, cc, i+1, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs);
|
||||
}
|
||||
|
@ -827,7 +829,8 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
boolean hasDefinition = false;
|
||||
for (ConceptReferenceComponent c : inc.getConcept()) {
|
||||
hasComments = hasComments || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT);
|
||||
hasDefinition = hasDefinition || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION);
|
||||
ConceptDefinitionComponent cc = definitions.get(c.getCode());
|
||||
hasDefinition = hasDefinition || ((cc != null && cc.hasDefinition()) || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION));
|
||||
}
|
||||
if (hasComments || hasDefinition)
|
||||
hasExtensions = true;
|
||||
|
@ -844,16 +847,19 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
else if (cc != null && !Utilities.noString(cc.getDisplay()))
|
||||
td.addText(cc.getDisplay());
|
||||
|
||||
if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION)) {
|
||||
if (hasDefinition) {
|
||||
td = tr.td();
|
||||
smartAddText(td, ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_DEFINITION));
|
||||
} else if (cc != null && !Utilities.noString(cc.getDefinition())) {
|
||||
td = tr.td();
|
||||
smartAddText(td, cc.getDefinition());
|
||||
if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION)) {
|
||||
smartAddText(td, ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_DEFINITION));
|
||||
} else if (cc != null && !Utilities.noString(cc.getDefinition())) {
|
||||
smartAddText(td, cc.getDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT)) {
|
||||
smartAddText(tr.td(), "Note: "+ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_VS_COMMENT));
|
||||
if (hasComments) {
|
||||
td = tr.td();
|
||||
if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT)) {
|
||||
smartAddText(td, "Note: "+ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_VS_COMMENT));
|
||||
}
|
||||
}
|
||||
if (doLangs) {
|
||||
addLangaugesToRow(c, langs, tr);
|
||||
|
|
|
@ -52,6 +52,7 @@ public class BaseWrappers {
|
|||
public void describe(XhtmlNode x) throws UnsupportedEncodingException, IOException;
|
||||
public void injectNarrative(XhtmlNode x, NarrativeStatus status) throws IOException;
|
||||
public BaseWrapper root();
|
||||
public PropertyWrapper getChildByName(String tail);
|
||||
public StructureDefinition getDefinition();
|
||||
public boolean hasNarrative();
|
||||
}
|
||||
|
|
|
@ -362,6 +362,16 @@ public class DOMWrappers {
|
|||
public String fhirType() {
|
||||
return wrapped.getNodeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyWrapper getChildByName(String name) {
|
||||
for (PropertyWrapper p : children())
|
||||
if (p.getName().equals(name))
|
||||
return p;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -267,6 +267,16 @@ public class DirectWrappers {
|
|||
public String fhirType() {
|
||||
return wrapped.fhirType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyWrapper getChildByName(String name) {
|
||||
Property p = wrapped.getChildByName(name);
|
||||
if (p == null)
|
||||
return null;
|
||||
else
|
||||
return new PropertyWrapperDirect(context, p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -246,7 +246,16 @@ public class ElementWrappers {
|
|||
public String fhirType() {
|
||||
return wrapped.fhirType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyWrapper getChildByName(String name) {
|
||||
for (PropertyWrapper p : children())
|
||||
if (p.getName().equals(name))
|
||||
return p;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class PropertyWrapperMetaElement extends RendererWrapperImpl implements PropertyWrapper {
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public class Resolver {
|
|||
if (containerElement != null) {
|
||||
for (org.hl7.fhir.r5.elementmodel.Element p : containerElement.getChildren("parameter")) {
|
||||
org.hl7.fhir.r5.elementmodel.Element res = p.getNamedChild("resource");
|
||||
if (value.equals(res.fhirType()+"/"+res.getChildValue("id")))
|
||||
if (res != null && value.equals(res.fhirType()+"/"+res.getChildValue("id")))
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,6 +164,9 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
|||
throw new FHIRException("Unable to evaluate based on empty code system");
|
||||
}
|
||||
res = validateCode(code, cs);
|
||||
} else if (cs == null && valueset.hasExpansion() && inExpansion) {
|
||||
// we just take the value set as face value then
|
||||
res = new ValidationResult(IssueSeverity.INFORMATION, null);
|
||||
} else {
|
||||
// well, we didn't find a code system - try the expansion?
|
||||
// disabled waiting for discussion
|
||||
|
|
|
@ -22,8 +22,8 @@ import org.hl7.fhir.utilities.CSFile;
|
|||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
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.hl7.fhir.utilities.tests.BaseTestingUtilities;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package org.hl7.fhir.r5.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.apache.poi.xssf.model.Comments;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
/*
|
||||
|
@ -34,7 +39,8 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
|
||||
import org.hl7.fhir.r5.model.ExpressionNode;
|
||||
import org.hl7.fhir.r5.model.ExpressionNode.SourceLocation;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.SourceLocation;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
// shared lexer for concrete syntaxes
|
||||
|
@ -65,6 +71,7 @@ public class FHIRLexer {
|
|||
private int cursor;
|
||||
private int currentStart;
|
||||
private String current;
|
||||
private List<String> comments = new ArrayList<>();
|
||||
private SourceLocation currentLocation;
|
||||
private SourceLocation currentStartLocation;
|
||||
private int id;
|
||||
|
@ -146,23 +153,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 +200,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 == '$') {
|
||||
|
@ -296,6 +287,37 @@ public class FHIRLexer {
|
|||
}
|
||||
}
|
||||
|
||||
private void skipWhitespaceAndComments() {
|
||||
comments.clear();
|
||||
boolean last13 = false;
|
||||
boolean done = false;
|
||||
while (cursor < source.length() && !done) {
|
||||
if (cursor < source.length() -1 && "//".equals(source.substring(cursor, cursor+2))) {
|
||||
int start = cursor+2;
|
||||
while (cursor < source.length() && !((source.charAt(cursor) == '\r') || source.charAt(cursor) == '\n')) {
|
||||
cursor++;
|
||||
}
|
||||
comments.add(source.substring(start, cursor).trim());
|
||||
} else if (cursor < source.length() - 1 && "/*".equals(source.substring(cursor, cursor+2))) {
|
||||
int start = 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 {
|
||||
comments.add(source.substring(start, cursor).trim());
|
||||
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;
|
||||
|
@ -321,9 +343,31 @@ public class FHIRLexer {
|
|||
this.current = current;
|
||||
}
|
||||
|
||||
public boolean hasComment() {
|
||||
return !done() && current.startsWith("//");
|
||||
public boolean hasComments() {
|
||||
return comments.size() > 0;
|
||||
}
|
||||
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public String getAllComments() {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder("\r\n");
|
||||
b.addAll(comments);
|
||||
comments.clear();
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public String getFirstComment() {
|
||||
if (hasComments()) {
|
||||
String s = comments.get(0);
|
||||
comments.remove(0);
|
||||
return s;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasToken(String kw) {
|
||||
return !done() && kw.equals(current);
|
||||
}
|
||||
|
@ -472,10 +516,6 @@ public class FHIRLexer {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
void skipComments() throws FHIRLexerException {
|
||||
while (!done() && hasComment())
|
||||
next();
|
||||
}
|
||||
public int getCurrentStart() {
|
||||
return currentStart;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -632,11 +632,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
|
||||
|
|
|
@ -62,9 +62,9 @@ import org.hl7.fhir.r5.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.NpmPackageIndexBuilder;
|
||||
import org.hl7.fhir.utilities.cache.PackageGenerator.PackageType;
|
||||
import org.hl7.fhir.utilities.cache.ToolsVersion;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackageIndexBuilder;
|
||||
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;
|
||||
|
@ -102,6 +102,7 @@ public class NPMPackageGenerator {
|
|||
private JsonObject packageJ;
|
||||
private JsonObject packageManifest;
|
||||
private NpmPackageIndexBuilder indexer;
|
||||
private String igVersion;
|
||||
|
||||
|
||||
public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date, boolean notForPublication) throws FHIRException, IOException {
|
||||
|
@ -184,6 +185,7 @@ public class NPMPackageGenerator {
|
|||
JsonObject npm = new JsonObject();
|
||||
npm.addProperty("name", ig.getPackageId());
|
||||
npm.addProperty("version", ig.getVersion());
|
||||
igVersion = ig.getVersion();
|
||||
npm.addProperty("tools-version", ToolsVersion.TOOLS_VERSION);
|
||||
npm.addProperty("type", kind.getCode());
|
||||
npm.addProperty("date", dt);
|
||||
|
@ -395,5 +397,9 @@ public class NPMPackageGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
public String version() {
|
||||
return igVersion;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -748,15 +748,12 @@ public class StructureMapUtilities {
|
|||
FHIRLexer lexer = new FHIRLexer(text, srcName);
|
||||
if (lexer.done())
|
||||
throw lexer.error("Map Input cannot be empty");
|
||||
lexer.skipComments();
|
||||
lexer.token("map");
|
||||
StructureMap result = new StructureMap();
|
||||
result.setUrl(lexer.readConstant("url"));
|
||||
lexer.token("=");
|
||||
result.setName(lexer.readConstant("name"));
|
||||
if (lexer.hasComment()) {
|
||||
result.setDescription(getMultiLineComments(lexer));
|
||||
}
|
||||
result.setDescription(lexer.getAllComments());
|
||||
while (lexer.hasToken("conceptmap"))
|
||||
parseConceptMap(result, lexer);
|
||||
|
||||
|
@ -782,7 +779,6 @@ public class StructureMapUtilities {
|
|||
map.setStatus(PublicationStatus.DRAFT); // todo: how to add this to the text format
|
||||
result.getContained().add(map);
|
||||
lexer.token("{");
|
||||
lexer.skipComments();
|
||||
// lexer.token("source");
|
||||
// map.setSource(new UriType(lexer.readConstant("source")));
|
||||
// lexer.token("target");
|
||||
|
@ -824,25 +820,11 @@ public class StructureMapUtilities {
|
|||
tgt.setCode(lexer.take());
|
||||
if (tgt.getCode().startsWith("\""))
|
||||
tgt.setCode(lexer.processConstant(tgt.getCode()));
|
||||
if (lexer.hasComment())
|
||||
tgt.setComment(lexer.take().substring(2).trim());
|
||||
tgt.setComment(lexer.getFirstComment());
|
||||
}
|
||||
lexer.token("}");
|
||||
}
|
||||
|
||||
private String getMultiLineComments(FHIRLexer lexer) {
|
||||
String comment = null;
|
||||
while (lexer.hasComment()) {
|
||||
String newComment = lexer.take().substring(2).trim();
|
||||
if (comment == null) {
|
||||
comment = newComment;
|
||||
} else {
|
||||
comment += "\r\n"+newComment;
|
||||
}
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
|
||||
private ConceptMapGroupComponent getGroup(ConceptMap map, String srcs, String tgts) {
|
||||
for (ConceptMapGroupComponent grp : map.getGroup()) {
|
||||
if (grp.getSource().equals(srcs))
|
||||
|
@ -895,9 +877,7 @@ public class StructureMapUtilities {
|
|||
lexer.token("as");
|
||||
st.setMode(StructureMapModelMode.fromCode(lexer.take()));
|
||||
lexer.skipToken(";");
|
||||
if (lexer.hasComment() && currentLine == lexer.getCurrentLocation().getLine()) {
|
||||
st.setDocumentation(lexer.take().substring(2).trim());
|
||||
}
|
||||
st.setDocumentation(lexer.getFirstComment());
|
||||
}
|
||||
|
||||
private void parseImports(StructureMap result, FHIRLexer lexer) throws FHIRException {
|
||||
|
@ -905,19 +885,11 @@ public class StructureMapUtilities {
|
|||
int currentLine = lexer.getCurrentLocation().getLine();
|
||||
result.addImport(lexer.readConstant("url"));
|
||||
lexer.skipToken(";");
|
||||
if (lexer.hasComment() && currentLine == lexer.getCurrentLocation().getLine()) {
|
||||
lexer.next();
|
||||
}
|
||||
lexer.getFirstComment();
|
||||
}
|
||||
|
||||
private void parseGroup(StructureMap result, FHIRLexer lexer) throws FHIRException {
|
||||
String comment = null;
|
||||
if (lexer.hasComment()) {
|
||||
comment = getMultiLineComments(lexer);
|
||||
if (lexer.done()) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
String comment = lexer.getAllComments();
|
||||
lexer.token("group");
|
||||
StructureMapGroupComponent group = result.addGroup();
|
||||
if (comment != null) {
|
||||
|
@ -975,7 +947,6 @@ public class StructureMapUtilities {
|
|||
parseRule(result, group.getRule(), lexer, true);
|
||||
}
|
||||
} else {
|
||||
lexer.skipComments();
|
||||
while (lexer.hasToken("input"))
|
||||
parseInput(group, lexer, false);
|
||||
while (!lexer.hasToken("endgroup")) {
|
||||
|
@ -1003,11 +974,8 @@ public class StructureMapUtilities {
|
|||
if (!newFmt) {
|
||||
lexer.token("as");
|
||||
input.setMode(StructureMapInputMode.fromCode(lexer.take()));
|
||||
if (lexer.hasComment()) {
|
||||
input.setDocumentation(lexer.take().substring(2).trim());
|
||||
}
|
||||
input.setDocumentation(lexer.getFirstComment());
|
||||
lexer.skipToken(";");
|
||||
lexer.skipComments();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1018,12 +986,7 @@ public class StructureMapUtilities {
|
|||
lexer.token(":");
|
||||
lexer.token("for");
|
||||
} else {
|
||||
if (lexer.hasComment()) {
|
||||
rule.setDocumentation(this.getMultiLineComments(lexer));
|
||||
if (lexer.hasToken("}")) {
|
||||
return ; // catched a comment at the end
|
||||
}
|
||||
}
|
||||
rule.setDocumentation(lexer.getFirstComment());
|
||||
}
|
||||
list.add(rule);
|
||||
boolean done = false;
|
||||
|
@ -1062,8 +1025,9 @@ public class StructureMapUtilities {
|
|||
lexer.next();
|
||||
}
|
||||
}
|
||||
} else if (lexer.hasComment()) {
|
||||
rule.setDocumentation(getMultiLineComments(lexer));
|
||||
}
|
||||
if (!rule.hasDocumentation() && lexer.hasComments()) {
|
||||
rule.setDocumentation(lexer.getFirstComment());
|
||||
}
|
||||
if (isSimpleSyntax(rule)) {
|
||||
rule.getSourceFirstRep().setVariable(AUTO_VAR_NAME);
|
||||
|
|
|
@ -180,6 +180,7 @@ public class ToolingExtensions {
|
|||
public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence";
|
||||
public static final String EXT_EXP_FRAGMENT = "http://hl7.org/fhir/tools/StructureDefinition/expansion-codesystem-fragment";
|
||||
public static final String EXT_EXP_TOOCOSTLY = "http://hl7.org/fhir/StructureDefinition/valueset-toocostly";
|
||||
public static final String EXT_MUST_SUPPORT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-type-must-support";
|
||||
|
||||
// specific extension helpers
|
||||
|
||||
|
@ -335,6 +336,8 @@ public class ToolingExtensions {
|
|||
return ((DecimalType) ex.getValue()).asStringValue();
|
||||
if ((ex.getValue() instanceof MarkdownType))
|
||||
return ((MarkdownType) ex.getValue()).getValue();
|
||||
if ((ex.getValue() instanceof PrimitiveType))
|
||||
return ((PrimitiveType) ex.getValue()).primitiveValue();
|
||||
if (!(ex.getValue() instanceof StringType))
|
||||
return null;
|
||||
return ((StringType) ex.getValue()).getValue();
|
||||
|
|
|
@ -13,8 +13,8 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
|||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
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.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.hl7.fhir.r5.model.Quantity;
|
|||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.test.FHIRPathTests.TestResultType;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
|
@ -41,6 +42,8 @@ import org.xml.sax.SAXException;
|
|||
|
||||
public class FHIRPathTests {
|
||||
|
||||
public enum TestResultType {OK, SYNTAX, SEMANTICS, EXECUTION}
|
||||
|
||||
public class FHIRPathTestEvaluationServices implements IEvaluationContext {
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +72,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");
|
||||
}
|
||||
|
||||
|
@ -111,6 +114,7 @@ public class FHIRPathTests {
|
|||
XMLUtil.getNamedChildren(dom.getDocumentElement(), "group", groups);
|
||||
for (Element g : groups) {
|
||||
XMLUtil.getNamedChildren(g, "test", list);
|
||||
XMLUtil.getNamedChildren(g, "modeTest", list);
|
||||
}
|
||||
|
||||
List<Arguments> objects = new ArrayList<>();
|
||||
|
@ -147,84 +151,118 @@ public class FHIRPathTests {
|
|||
public void test(String name, Element test) throws FileNotFoundException, IOException, FHIRException, org.hl7.fhir.exceptions.FHIRException, UcumException {
|
||||
// Setting timezone for this test. Grahame is in UTC+11, Travis is in GMT, and I'm here in Toronto, Canada with
|
||||
// all my time based tests failing locally...
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("UTC+1100"));
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("UTC+1100"));
|
||||
|
||||
fp.setHostServices(new FHIRPathTestEvaluationServices());
|
||||
String input = test.getAttribute("inputfile");
|
||||
String expression = XMLUtil.getNamedChild(test, "expression").getTextContent();
|
||||
boolean fail = Utilities.existsInList(XMLUtil.getNamedChild(test, "expression").getAttribute("invalid"), "true", "semantic");
|
||||
TestResultType fail = TestResultType.OK;
|
||||
if ("syntax".equals(XMLUtil.getNamedChild(test, "expression").getAttribute("invalid"))) {
|
||||
fail = TestResultType.SYNTAX;
|
||||
} else if ("semantic".equals(XMLUtil.getNamedChild(test, "expression").getAttribute("invalid"))) {
|
||||
fail = TestResultType.SEMANTICS;
|
||||
} else if ("execution".equals(XMLUtil.getNamedChild(test, "expression").getAttribute("invalid"))) {
|
||||
fail = TestResultType.EXECUTION;
|
||||
};
|
||||
fp.setAllowPolymorphicNames("lenient/polymorphics".equals(test.getAttribute("mode")));
|
||||
Resource res = null;
|
||||
|
||||
List<Base> outcome = new ArrayList<Base>();
|
||||
|
||||
ExpressionNode node = fp.parse(expression);
|
||||
System.out.println(name);
|
||||
|
||||
ExpressionNode node = null;
|
||||
try {
|
||||
if (Utilities.noString(input)) {
|
||||
fp.check(null, null, node);
|
||||
} else {
|
||||
res = resources.get(input);
|
||||
if (res == null) {
|
||||
res = new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", input));
|
||||
resources.put(input, res);
|
||||
}
|
||||
fp.check(res, res.getResourceType().toString(), res.getResourceType().toString(), node);
|
||||
}
|
||||
outcome = fp.evaluate(res, node);
|
||||
Assertions.assertFalse(fail, String.format("Expected exception parsing %s", expression));
|
||||
node = fp.parse(expression);
|
||||
Assertions.assertTrue(fail != TestResultType.SYNTAX, String.format("Expected exception didn't occur parsing %s", expression));
|
||||
} catch (Exception e) {
|
||||
Assertions.assertTrue(fail, String.format("Unexpected exception parsing %s: " + e.getMessage(), expression));
|
||||
System.out.println("Parsing Error: "+e.getMessage());
|
||||
Assertions.assertTrue(fail == TestResultType.SYNTAX, String.format("Unexpected exception parsing %s: " + e.getMessage(), expression));
|
||||
}
|
||||
|
||||
if ("true".equals(test.getAttribute("predicate"))) {
|
||||
boolean ok = fp.convertToBoolean(outcome);
|
||||
outcome.clear();
|
||||
outcome.add(new BooleanType(ok));
|
||||
if (node != null) {
|
||||
try {
|
||||
if (Utilities.noString(input)) {
|
||||
fp.check(null, null, node);
|
||||
} else {
|
||||
res = resources.get(input);
|
||||
if (res == null) {
|
||||
res = new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", input));
|
||||
resources.put(input, res);
|
||||
}
|
||||
fp.check(res, res.getResourceType().toString(), res.getResourceType().toString(), node);
|
||||
}
|
||||
Assertions.assertTrue(fail != TestResultType.SEMANTICS, String.format("Expected exception didn't occur checking %s", expression));
|
||||
} catch (Exception e) {
|
||||
System.out.println("Checking Error: "+e.getMessage());
|
||||
Assertions.assertTrue(fail == TestResultType.SEMANTICS, String.format("Unexpected exception checking %s: " + e.getMessage(), expression));
|
||||
node = null;
|
||||
}
|
||||
}
|
||||
System.out.println(name);
|
||||
|
||||
if (node != null) {
|
||||
try {
|
||||
outcome = fp.evaluate(res, node);
|
||||
Assertions.assertTrue(fail == TestResultType.OK, String.format("Expected exception didn't occur executing %s", expression));
|
||||
} catch (Exception e) {
|
||||
System.out.println("Execution Error: "+e.getMessage());
|
||||
Assertions.assertTrue(fail == TestResultType.EXECUTION, String.format("Unexpected exception executing %s: " + e.getMessage(), expression));
|
||||
node = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (fp.hasLog()) {
|
||||
System.out.println(name);
|
||||
System.out.println(fp.takeLog());
|
||||
}
|
||||
|
||||
List<Element> expected = new ArrayList<Element>();
|
||||
XMLUtil.getNamedChildren(test, "output", expected);
|
||||
Assertions.assertEquals(outcome.size(), expected.size(), String.format("Expected %d objects but found %d for expression %s", expected.size(), outcome.size(), expression));
|
||||
if ("false".equals(test.getAttribute("ordered"))) {
|
||||
for (int i = 0; i < Math.min(outcome.size(), expected.size()); i++) {
|
||||
String tn = outcome.get(i).fhirType();
|
||||
String s;
|
||||
if (outcome.get(i) instanceof Quantity) {
|
||||
s = fp.convertToString(outcome.get(i));
|
||||
} else {
|
||||
s = ((PrimitiveType) outcome.get(i)).asStringValue();
|
||||
}
|
||||
boolean found = false;
|
||||
for (Element e : expected) {
|
||||
if ((Utilities.noString(e.getAttribute("type")) || e.getAttribute("type").equals(tn)) &&
|
||||
(Utilities.noString(e.getTextContent()) || e.getTextContent().equals(s))) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(found, String.format("Outcome %d: Value %s of type %s not expected for %s", i, s, tn, expression));
|
||||
if (node != null) {
|
||||
if ("true".equals(test.getAttribute("predicate"))) {
|
||||
boolean ok = fp.convertToBoolean(outcome);
|
||||
outcome.clear();
|
||||
outcome.add(new BooleanType(ok));
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < Math.min(outcome.size(), expected.size()); i++) {
|
||||
String tn = expected.get(i).getAttribute("type");
|
||||
if (!Utilities.noString(tn)) {
|
||||
Assertions.assertEquals(tn, outcome.get(i).fhirType(), String.format("Outcome %d: Type should be %s but was %s", i, tn, outcome.get(i).fhirType()));
|
||||
}
|
||||
String v = expected.get(i).getTextContent();
|
||||
if (!Utilities.noString(v)) {
|
||||
|
||||
List<Element> expected = new ArrayList<Element>();
|
||||
XMLUtil.getNamedChildren(test, "output", expected);
|
||||
Assertions.assertEquals(outcome.size(), expected.size(), String.format("Expected %d objects but found %d for expression %s", expected.size(), outcome.size(), expression));
|
||||
if ("false".equals(test.getAttribute("ordered"))) {
|
||||
for (int i = 0; i < Math.min(outcome.size(), expected.size()); i++) {
|
||||
String tn = outcome.get(i).fhirType();
|
||||
String s;
|
||||
if (outcome.get(i) instanceof Quantity) {
|
||||
Quantity q = fp.parseQuantityString(v);
|
||||
Assertions.assertTrue(outcome.get(i).equalsDeep(q), String.format("Outcome %d: Value should be %s but was %s", i, v, outcome.get(i).toString()));
|
||||
s = fp.convertToString(outcome.get(i));
|
||||
} 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()));
|
||||
if (!(v.equals(((PrimitiveType) outcome.get(i)).asStringValue()))) {
|
||||
System.out.println(name);
|
||||
System.out.println(String.format("Outcome %d: Value should be %s but was %s for expression %s", i, v, outcome.get(i).toString(), expression));
|
||||
s = ((PrimitiveType) outcome.get(i)).asStringValue();
|
||||
}
|
||||
boolean found = false;
|
||||
for (Element e : expected) {
|
||||
if ((Utilities.noString(e.getAttribute("type")) || e.getAttribute("type").equals(tn)) &&
|
||||
(Utilities.noString(e.getTextContent()) || e.getTextContent().equals(s))) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(found, String.format("Outcome %d: Value %s of type %s not expected for %s", i, s, tn, expression));
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < Math.min(outcome.size(), expected.size()); i++) {
|
||||
String tn = expected.get(i).getAttribute("type");
|
||||
if (!Utilities.noString(tn)) {
|
||||
Assertions.assertEquals(tn, outcome.get(i).fhirType(), String.format("Outcome %d: Type should be %s but was %s", i, tn, outcome.get(i).fhirType()));
|
||||
}
|
||||
String v = expected.get(i).getTextContent();
|
||||
if (!Utilities.noString(v)) {
|
||||
if (outcome.get(i) instanceof Quantity) {
|
||||
Quantity q = fp.parseQuantityString(v);
|
||||
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()));
|
||||
if (!(v.equals(((PrimitiveType) outcome.get(i)).fpValue()))) {
|
||||
System.out.println(name);
|
||||
System.out.println(String.format("Outcome %d: Value should be %s but was %s for expression %s", i, v, ((PrimitiveType) outcome.get(i)).fpValue(), 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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.zip.ZipInputStream;
|
|||
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.cache.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ import org.hl7.fhir.r5.utils.IResourceValidator;
|
|||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
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.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.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
|
|
|
@ -42,9 +42,9 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
|||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
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.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.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
|
@ -380,7 +380,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);
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent;
|
|||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.StructureMapUtilities;
|
||||
import org.hl7.fhir.r5.utils.StructureMapUtilities.ITransformerServices;
|
||||
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.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
|||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
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.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.1.11-SNAPSHOT</version>
|
||||
<version>5.1.17-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.hl7.fhir.exceptions;
|
||||
|
||||
import org.hl7.fhir.utilities.SourceLocation;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
@ -33,20 +36,62 @@ package org.hl7.fhir.exceptions;
|
|||
|
||||
public class PathEngineException extends FHIRException {
|
||||
|
||||
private static final long serialVersionUID = 31969342112856390L;
|
||||
private SourceLocation location;
|
||||
private String expression;
|
||||
|
||||
public PathEngineException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PathEngineException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
public PathEngineException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public PathEngineException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public PathEngineException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public PathEngineException(Throwable cause) {
|
||||
public PathEngineException(String message, SourceLocation location, String expression, Throwable cause) {
|
||||
super(message+rep(location, expression), cause);
|
||||
}
|
||||
|
||||
public PathEngineException(String message, SourceLocation location, String expression) {
|
||||
super(message+rep(location, expression));
|
||||
}
|
||||
|
||||
private static String rep(SourceLocation loc, String expr) {
|
||||
if (loc != null) {
|
||||
if (loc.getLine() == 1) {
|
||||
return " (@char "+loc.getColumn()+")";
|
||||
} else {
|
||||
return " (@line "+loc.getLine()+" char "+loc.getColumn()+")";
|
||||
}
|
||||
} else if (Utilities.noString(expr)) { // can happen in some contexts...
|
||||
return " (@~"+expr+")";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public PathEngineException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
public void setExpression(String expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public SourceLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(SourceLocation location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.hl7.fhir.utilities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
@ -76,4 +78,11 @@ public class CommaSeparatedStringBuilder {
|
|||
append(s);
|
||||
|
||||
}
|
||||
|
||||
public void addAll(List<String> list) {
|
||||
for (String s : list) {
|
||||
append(s);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -90,4 +90,49 @@ public class MimeType {
|
|||
return source;
|
||||
}
|
||||
|
||||
public static String getExtension(String mimeType) {
|
||||
MimeType mt = new MimeType(mimeType);
|
||||
return mt.getExtension();
|
||||
}
|
||||
|
||||
public String getExtension() {
|
||||
switch (base) {
|
||||
case "text/html" : return "html";
|
||||
case "text/xml" : return "xml";
|
||||
case "application/xml" : return "xml";
|
||||
case "text/markdown" : return "md";
|
||||
case "application/js" : return "js";
|
||||
case "application/css" : return "css";
|
||||
case "text/x-csrc" : return "c";
|
||||
case "text/x-csharp" : return "cs";
|
||||
case "text/x-c++src" : return "c";
|
||||
case "application/graphql" : return "graphql";
|
||||
case "application/x-java" : return "java";
|
||||
case "application/json" : return "json";
|
||||
case "text/json" : return "json";
|
||||
case "application/liquid" : return "liquid";
|
||||
case "text/x-pascal" : return "pas";
|
||||
case "text/x-python" : return "py";
|
||||
case "text/x-rsrc" : return "r";
|
||||
case "text/x-ruby" : return "ruby";
|
||||
case "text/x-sas" : return "sas";
|
||||
case "text/x-sql" : return "sql";
|
||||
case "application/typescript" : return "ts";
|
||||
case "text/cql": return "cql";
|
||||
case "image/png": return "png";
|
||||
case "image/gif": return "gif";
|
||||
case "image/jpeg": return "jpg";
|
||||
}
|
||||
if (base.contains("xml+") || base.contains("+xml")) {
|
||||
return "xml";
|
||||
}
|
||||
if (base.contains("json+") || base.contains("+json")) {
|
||||
return "json";
|
||||
}
|
||||
if (base.contains("turtle+") || base.contains("+turtle")) {
|
||||
return "ttl";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.hl7.fhir.utilities;
|
||||
|
||||
public 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 void newLine() {
|
||||
setLine(getLine() + 1);
|
||||
setColumn(1);
|
||||
}
|
||||
public boolean checkChar(char ch, boolean last13) {
|
||||
if (ch == '\r') {
|
||||
newLine();
|
||||
return true;
|
||||
} else if (ch == '\n') {
|
||||
if (!last13) {
|
||||
newLine();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
setColumn(getColumn() + 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,6 +47,8 @@ import java.math.RoundingMode;
|
|||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
|
@ -320,13 +322,13 @@ public class Utilities {
|
|||
destFile.createNewFile();
|
||||
}
|
||||
|
||||
FileChannel source = null;
|
||||
FileChannel destination = null;
|
||||
FileInputStream source = null;
|
||||
FileOutputStream destination = null;
|
||||
|
||||
try {
|
||||
source = new FileInputStream(sourceFile).getChannel();
|
||||
destination = new FileOutputStream(destFile).getChannel();
|
||||
destination.transferFrom(source, 0, source.size());
|
||||
source = new FileInputStream(sourceFile);
|
||||
destination = new FileOutputStream(destFile);
|
||||
destination.getChannel().transferFrom(source.getChannel(), 0, source.getChannel().size());
|
||||
} finally {
|
||||
if (source != null) {
|
||||
source.close();
|
||||
|
@ -398,8 +400,8 @@ public class Utilities {
|
|||
clearDirectory(fh.getAbsolutePath());
|
||||
fh.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.cache.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
|
@ -182,6 +182,10 @@ public class VersionUtilities {
|
|||
if (version == null)
|
||||
return null;
|
||||
|
||||
if ("current".equals(version)) {
|
||||
return CURRENT_VERSION;
|
||||
}
|
||||
|
||||
if (Utilities.charCount(version, '.') == 1) {
|
||||
String[] p = version.split("\\.");
|
||||
return p[0]+"."+p[1];
|
||||
|
@ -193,6 +197,16 @@ public class VersionUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getPatch(String version) {
|
||||
if (version == null)
|
||||
return null;
|
||||
if (Utilities.charCount(version, '.') == 2) {
|
||||
String[] p = version.split("\\.");
|
||||
return p[2];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isSemVer(String version) {
|
||||
if (Utilities.charCount(version, '.') != 2) {
|
||||
return false;
|
||||
|
@ -202,7 +216,7 @@ public class VersionUtilities {
|
|||
}
|
||||
|
||||
/**
|
||||
* return true if the current vresion equals test, or later
|
||||
* return true if the current version equals test, or later
|
||||
*
|
||||
* so if a feature is defined in 4.0, if (VersionUtilities.isThisOrLater("4.0", version))...
|
||||
*
|
||||
|
@ -213,10 +227,36 @@ public class VersionUtilities {
|
|||
public static boolean isThisOrLater(String test, String current) {
|
||||
String t = getMajMin(test);
|
||||
String c = getMajMin(current);
|
||||
if (c.compareTo(t) == 0) {
|
||||
return isMajMinOrLaterPatch(test, current);
|
||||
}
|
||||
boolean ok = c.compareTo(t) >= 0;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if the current version equals test for major and min, or later patch
|
||||
*
|
||||
* @param test
|
||||
* @param current
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMajMinOrLaterPatch(String test, String current) {
|
||||
String t = getMajMin(test);
|
||||
String c = getMajMin(current);
|
||||
if (c != null && c.compareTo(t) == 0) {
|
||||
String pt = getPatch(test);
|
||||
String pc = getPatch(current);
|
||||
if (pt==null || "x".equals(pt)) {
|
||||
return true;
|
||||
}
|
||||
if (pc!=null) {
|
||||
return pc.compareTo(pt) >= 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String incMajorVersion(String v) {
|
||||
assert isSemVer(v);
|
||||
int[] parts = splitParts(v);
|
||||
|
|
|
@ -341,6 +341,8 @@ public class I18nConstants {
|
|||
public static final String RESOURCE_TYPE_MISMATCH_FOR___ = "Resource_type_mismatch_for___";
|
||||
public static final String SAME_ID_ON_MULTIPLE_ELEMENTS__IN_ = "Same_id_on_multiple_elements__in_";
|
||||
public static final String SD_MUST_HAVE_DERIVATION = "SD_MUST_HAVE_DERIVATION";
|
||||
public static final String SD_NESTED_MUST_SUPPORT_DIFF = "SD_NESTED_MUST_SUPPORT_DIFF";
|
||||
public static final String SD_NESTED_MUST_SUPPORT_SNAPSHOT = "SD_NESTED_MUST_SUPPORT_SNAPSHOT";
|
||||
public static final String SEARCHPARAMETER_BASE_WRONG = "SEARCHPARAMETER_BASE_WRONG";
|
||||
public static final String SEARCHPARAMETER_EXP_WRONG = "SEARCHPARAMETER_EXP_WRONG";
|
||||
public static final String SEARCHPARAMETER_NOTFOUND = "SEARCHPARAMETER_NOTFOUND";
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
|
@ -672,5 +674,12 @@ public class JsonTrackingParser {
|
|||
return gson.toJson(json);
|
||||
}
|
||||
|
||||
public static JsonObject fetchJson(String source) throws IOException {
|
||||
URL url = new URL(source+"?nocache=" + System.currentTimeMillis());
|
||||
HttpURLConnection c = (HttpURLConnection) url.openConnection();
|
||||
c.setInstanceFollowRedirects(true);
|
||||
return parseJson(c.getInputStream());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.utilities.cache;
|
||||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
@ -69,6 +69,9 @@ public abstract class BasePackageCacheManager implements IPackageCacheManager {
|
|||
if (Utilities.noString(version)) {
|
||||
version = packageClient.getLatestVersion(id);
|
||||
}
|
||||
if (version.endsWith(".x")) {
|
||||
version = packageClient.getLatestVersion(id, version);
|
||||
}
|
||||
InputStream stream = packageClient.fetch(id, version);
|
||||
String url = packageClient.url(id, version);
|
||||
return new InputStreamWithSrc(stream, url, version);
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.utilities.cache;
|
||||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.utilities.cache;
|
||||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
|
@ -39,8 +39,9 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.utilities.IniFile;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.cache.NpmPackage.NpmPackageFolder;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.json.JSONUtil;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage.NpmPackageFolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -283,7 +284,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
}
|
||||
|
||||
/**
|
||||
* Load the identified package from the cache - it it exists
|
||||
* Load the identified package from the cache - if it exists
|
||||
* <p>
|
||||
* This is for special purpose only (testing, control over speed of loading).
|
||||
* Generally, use the loadPackage method
|
||||
|
@ -307,11 +308,26 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
return p;
|
||||
}
|
||||
}
|
||||
String foundPackage = null;
|
||||
String foundVersion = null;
|
||||
for (String f : sorted(new File(cacheFolder).list())) {
|
||||
if (f.equals(id + "#" + version) || (Utilities.noString(version) && f.startsWith(id + "#"))) {
|
||||
return loadPackageInfo(Utilities.path(cacheFolder, f));
|
||||
File cf = new File(Utilities.path(cacheFolder, f));
|
||||
if (cf.isDirectory()) {
|
||||
if (f.equals(id + "#" + version) || (Utilities.noString(version) && f.startsWith(id + "#"))) {
|
||||
return loadPackageInfo(Utilities.path(cacheFolder, f));
|
||||
}
|
||||
if (version != null && version.endsWith(".x") && f.contains("#")) {
|
||||
String[] parts = f.split("#");
|
||||
if (parts[0].equals(id) && VersionUtilities.isMajMinOrLaterPatch((foundVersion!=null ? foundVersion : version),parts[1])) {
|
||||
foundVersion = parts[1];
|
||||
foundPackage = f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (foundPackage!=null) {
|
||||
return loadPackageInfo(Utilities.path(cacheFolder, foundPackage));
|
||||
}
|
||||
if ("dev".equals(version))
|
||||
return loadPackageFromCacheOnly(id, "current");
|
||||
else
|
||||
|
@ -895,33 +911,4 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//public List<String> getUrls() throws IOException {
|
||||
// if (allUrls == null)
|
||||
// {
|
||||
// IniFile ini = new IniFile(Utilities.path(cacheFolder, "packages.ini"));
|
||||
// allUrls = new ArrayList<>();
|
||||
// for (String s : ini.getPropertyNames("urls"))
|
||||
// allUrls.add(ini.getStringProperty("urls", s));
|
||||
// try {
|
||||
// URL url = new URL("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json?nocache=" + System.currentTimeMillis());
|
||||
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
// connection.setRequestMethod("GET");
|
||||
// InputStream json = connection.getInputStream();
|
||||
// JsonObject packages = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.streamToString(json));
|
||||
// JsonArray guides = packages.getAsJsonArray("guides");
|
||||
// for (JsonElement g : guides) {
|
||||
// JsonObject gi = (JsonObject) g;
|
||||
// if (gi.has("canonical"))
|
||||
// if (!allUrls.contains(gi.get("canonical").getAsString()))
|
||||
// allUrls.add(gi.get("canonical").getAsString());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Listing known Implementation Guides failed: "+e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// return allUrls;
|
||||
//}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.utilities.cache;
|
||||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.utilities.cache;
|
||||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
|
@ -61,10 +61,10 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.cache.NpmPackage.PackageResourceInformationSorter;
|
||||
import org.hl7.fhir.utilities.cache.PackageGenerator.PackageType;
|
||||
import org.hl7.fhir.utilities.json.JSONUtil;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformationSorter;
|
||||
import org.hl7.fhir.utilities.npm.PackageGenerator.PackageType;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
|
@ -814,7 +814,7 @@ public class NpmPackage {
|
|||
|
||||
public String getWebLocation() {
|
||||
if (npm.has("url")) {
|
||||
return npm.get("url").getAsString();
|
||||
return PackageHacker.fixPackageUrl(npm.get("url").getAsString());
|
||||
} else {
|
||||
return JSONUtil.str(npm, "canonical");
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.utilities.cache;
|
||||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue