Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core
This commit is contained in:
commit
17b6b26ef2
|
@ -8258,6 +8258,9 @@ public class VersionConvertor_30_40 {
|
|||
tgt.addNote(convertAnnotation(t));
|
||||
return tgt;
|
||||
}
|
||||
|
||||
private static final String CODE_SYSTEM_CONDITION_CLINICAL_URL = "http://terminology.hl7.org/CodeSystem/condition-clinical";
|
||||
private static final String CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL = "http://hl7.org/fhir/condition-clinical";
|
||||
|
||||
private static org.hl7.fhir.r4.model.CodeableConcept convertConditionClinicalStatus(org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus src) throws FHIRException {
|
||||
if (src == null)
|
||||
|
@ -8265,19 +8268,19 @@ public class VersionConvertor_30_40 {
|
|||
org.hl7.fhir.r4.model.CodeableConcept cc = new org.hl7.fhir.r4.model.CodeableConcept();
|
||||
switch (src) {
|
||||
case ACTIVE:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("active");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("active");
|
||||
return cc;
|
||||
case RECURRENCE:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("recurrence");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("recurrence");
|
||||
return cc;
|
||||
case INACTIVE:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("inactive");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("inactive");
|
||||
return cc;
|
||||
case REMISSION:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("remission");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("remission");
|
||||
return cc;
|
||||
case RESOLVED:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("resolved");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("resolved");
|
||||
return cc;
|
||||
default: return null;
|
||||
}
|
||||
|
@ -8286,33 +8289,41 @@ public class VersionConvertor_30_40 {
|
|||
private static org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus convertConditionClinicalStatus(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "active")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.ACTIVE;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "recurrence")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RECURRENCE;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "inactive")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.INACTIVE;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "remission")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.REMISSION;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "resolved")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RESOLVED;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "active")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "active")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.ACTIVE;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "recurrence")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "recurrence")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RECURRENCE;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "inactive")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "inactive")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.INACTIVE;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "remission")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "remission")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.REMISSION;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "resolved")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "resolved")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RESOLVED;
|
||||
return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.NULL;
|
||||
}
|
||||
|
||||
private static final String CODE_SYSTEM_CONDITION_VER_CLINICAL_URL = "http://terminology.hl7.org/CodeSystem/condition-ver-status";
|
||||
private static final String CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL = "http://hl7.org/fhir/condition-ver-status";
|
||||
|
||||
private static org.hl7.fhir.r4.model.CodeableConcept convertConditionVerificationStatus(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
org.hl7.fhir.r4.model.CodeableConcept cc = new org.hl7.fhir.r4.model.CodeableConcept();
|
||||
switch (src) {
|
||||
case PROVISIONAL:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("provisional");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("provisional");
|
||||
return cc;
|
||||
case DIFFERENTIAL:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("differential");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("differential");
|
||||
return cc;
|
||||
case CONFIRMED:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("confirmed");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("confirmed");
|
||||
return cc;
|
||||
case REFUTED:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("refuted");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("refuted");
|
||||
return cc;
|
||||
case ENTEREDINERROR:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("entered-in-error");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("entered-in-error");
|
||||
return cc;
|
||||
default: return null;
|
||||
}
|
||||
|
@ -8321,15 +8332,19 @@ public class VersionConvertor_30_40 {
|
|||
private static org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus convertConditionVerificationStatus(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "provisional")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.PROVISIONAL;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "differential")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.DIFFERENTIAL;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "confirmed")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.CONFIRMED;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "refuted")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.REFUTED;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "entered-in-error")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.ENTEREDINERROR;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "provisional")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "provisional")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.PROVISIONAL;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "differential")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "differential")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.DIFFERENTIAL;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "confirmed")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "confirmed")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.CONFIRMED;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "refuted")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "refuted")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.REFUTED;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "entered-in-error")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "entered-in-error")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.ENTEREDINERROR;
|
||||
return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.NULL;
|
||||
}
|
||||
|
||||
|
||||
public static org.hl7.fhir.r4.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
|
|
|
@ -8249,25 +8249,28 @@ public class VersionConvertor_30_50 {
|
|||
return tgt;
|
||||
}
|
||||
|
||||
private static final String CODE_SYSTEM_CONDITION_CLINICAL_URL = "http://terminology.hl7.org/CodeSystem/condition-clinical";
|
||||
private static final String CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL = "http://hl7.org/fhir/condition-clinical";
|
||||
|
||||
private static org.hl7.fhir.r5.model.CodeableConcept convertConditionClinicalStatus(org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
org.hl7.fhir.r5.model.CodeableConcept cc = new org.hl7.fhir.r5.model.CodeableConcept();
|
||||
switch (src) {
|
||||
case ACTIVE:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("active");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("active");
|
||||
return cc;
|
||||
case RECURRENCE:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("recurrence");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("recurrence");
|
||||
return cc;
|
||||
case INACTIVE:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("inactive");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("inactive");
|
||||
return cc;
|
||||
case REMISSION:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("remission");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("remission");
|
||||
return cc;
|
||||
case RESOLVED:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-clinical").setCode("resolved");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_CLINICAL_URL).setCode("resolved");
|
||||
return cc;
|
||||
default: return null;
|
||||
}
|
||||
|
@ -8276,33 +8279,41 @@ public class VersionConvertor_30_50 {
|
|||
private static org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus convertConditionClinicalStatus(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "active")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.ACTIVE;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "recurrence")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RECURRENCE;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "inactive")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.INACTIVE;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "remission")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.REMISSION;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "resolved")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RESOLVED;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "active")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "active")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.ACTIVE;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "recurrence")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "recurrence")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RECURRENCE;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "inactive")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "inactive")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.INACTIVE;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "remission")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "remission")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.REMISSION;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_CLINICAL_URL, "resolved")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_CLINICAL_URL, "resolved")) return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.RESOLVED;
|
||||
return org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.NULL;
|
||||
}
|
||||
|
||||
private static final String CODE_SYSTEM_CONDITION_VER_CLINICAL_URL = "http://terminology.hl7.org/CodeSystem/condition-ver-status";
|
||||
private static final String CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL = "http://hl7.org/fhir/condition-ver-status";
|
||||
|
||||
private static org.hl7.fhir.r5.model.CodeableConcept convertConditionVerificationStatus(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
org.hl7.fhir.r5.model.CodeableConcept cc = new org.hl7.fhir.r5.model.CodeableConcept();
|
||||
switch (src) {
|
||||
case PROVISIONAL:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("provisional");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("provisional");
|
||||
return cc;
|
||||
case DIFFERENTIAL:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("differential");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("differential");
|
||||
return cc;
|
||||
case CONFIRMED:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("confirmed");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("confirmed");
|
||||
return cc;
|
||||
case REFUTED:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("refuted");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("refuted");
|
||||
return cc;
|
||||
case ENTEREDINERROR:
|
||||
cc.addCoding().setSystem("http://hl7.org/fhir/condition-ver-status").setCode("entered-in-error");
|
||||
cc.addCoding().setSystem(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL).setCode("entered-in-error");
|
||||
return cc;
|
||||
default: return null;
|
||||
}
|
||||
|
@ -8311,15 +8322,19 @@ public class VersionConvertor_30_50 {
|
|||
private static org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus convertConditionVerificationStatus(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "provisional")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.PROVISIONAL;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "differential")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.DIFFERENTIAL;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "confirmed")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.CONFIRMED;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "refuted")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.REFUTED;
|
||||
if (src.hasCoding("http://hl7.org/fhir/condition-clinical", "entered-in-error")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.ENTEREDINERROR;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "provisional")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "provisional")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.PROVISIONAL;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "differential")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "differential")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.DIFFERENTIAL;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "confirmed")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "confirmed")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.CONFIRMED;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "refuted")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "refuted")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.REFUTED;
|
||||
if (src.hasCoding(CODE_SYSTEM_CONDITION_VER_CLINICAL_URL, "entered-in-error")
|
||||
||src.hasCoding(CODE_SYSTEM_LEGACY_CONDITION_VER_CLINICAL_URL, "entered-in-error")) return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.ENTEREDINERROR;
|
||||
return org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.NULL;
|
||||
}
|
||||
|
||||
|
||||
public static org.hl7.fhir.r5.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,297 @@
|
|||
package org.hl7.fhir.convertors.misc;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.convertors.misc.SearchParameterProcessor.SPRelationship;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.ConceptMap;
|
||||
import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent;
|
||||
import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent;
|
||||
import org.hl7.fhir.r5.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
public class SearchParameterProcessor {
|
||||
|
||||
public class SPRelationship {
|
||||
private String r4;
|
||||
private String r3;
|
||||
private String r2b;
|
||||
private String r2;
|
||||
public SPRelationship(String r4, String r3, String r2b, String r2) {
|
||||
super();
|
||||
this.r4 = r4;
|
||||
this.r3 = r3;
|
||||
this.r2b = r2b;
|
||||
this.r2 = r2;
|
||||
}
|
||||
public String getR4() {
|
||||
return r4;
|
||||
}
|
||||
public String getR3() {
|
||||
return r3;
|
||||
}
|
||||
public String getR2b() {
|
||||
return r2b;
|
||||
}
|
||||
public String getR2() {
|
||||
return r2;
|
||||
}
|
||||
public String getByCode(String code) {
|
||||
if ("R4".equals(code))
|
||||
return r4;
|
||||
if ("R3".equals(code))
|
||||
return r3;
|
||||
if ("R2b".equals(code))
|
||||
return r2b;
|
||||
if ("R2".equals(code))
|
||||
return r2;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final String ROOT = "C:\\work\\org.hl7.fhir\\org.fhir.interversion\\package";
|
||||
|
||||
private List<SPRelationship> list = new ArrayList<>();
|
||||
|
||||
private List<String> list4 = new ArrayList<>();
|
||||
private List<String> list3 = new ArrayList<>();
|
||||
private List<String> list2 = new ArrayList<>();
|
||||
private List<String> list2b = new ArrayList<>();
|
||||
|
||||
private void load() throws FileNotFoundException, IOException, FHIRException {
|
||||
load4();
|
||||
load3();
|
||||
load2b();
|
||||
load2();
|
||||
loadCsv();
|
||||
|
||||
check4();
|
||||
check3();
|
||||
check2b();
|
||||
check2();
|
||||
|
||||
generate("R3", "R4", "STU3", "R4");
|
||||
generate("R4", "R3", "R4", "STU3");
|
||||
generate("R2", "R4", "DSTU2", "R4");
|
||||
generate("R4", "R2", "R4", "DSTU2");
|
||||
generate("R2", "R3", "DSTU2", "STU3");
|
||||
generate("R3", "R2", "STU3", "DSTU2");
|
||||
}
|
||||
|
||||
private void generate(String src, String dst, String srcURL, String tgtURL) throws FileNotFoundException, IOException {
|
||||
ConceptMap map = new ConceptMap();
|
||||
map.setId("search-parameters-"+src+"-to-"+dst);
|
||||
map.setUrl("http://hl7.org/fhir/interversion/ConceptMap/"+map.getId());
|
||||
map.setName("SearchParameterMap"+src+dst);
|
||||
map.setTitle("Search Parameter Map - "+src+" to "+dst);
|
||||
map.setStatus(PublicationStatus.DRAFT);
|
||||
map.setDate(new Date());
|
||||
map.setExperimental(false);
|
||||
map.setPublisher("HL7");
|
||||
ConceptMapGroupComponent group = map.addGroup();
|
||||
group.setSource("http://hl7.org/fhir/"+srcURL);
|
||||
group.setTarget("http://hl7.org/fhir/"+tgtURL);
|
||||
for (SPRelationship sp : list) {
|
||||
String s = sp.getByCode(src);
|
||||
String d = sp.getByCode(dst);
|
||||
if (!Utilities.noString(s) && !Utilities.noString(d)) {
|
||||
SourceElementComponent e = makeElement(s, group);
|
||||
e.addTarget().setCode(d).setEquivalence(ConceptMapEquivalence.RELATEDTO);
|
||||
}
|
||||
}
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(ROOT, "ConceptMap-"+map.getId()+".json")), map);
|
||||
}
|
||||
|
||||
private SourceElementComponent makeElement(String code, ConceptMapGroupComponent group) {
|
||||
for (SourceElementComponent e : group.getElement()) {
|
||||
if (e.getCode().equals(code))
|
||||
return e;
|
||||
}
|
||||
return group.addElement().setCode(code);
|
||||
}
|
||||
|
||||
private void check4() {
|
||||
for (String s : list4) {
|
||||
boolean ok = false;
|
||||
for (SPRelationship t : list) {
|
||||
if (s.equals(t.r4))
|
||||
ok = true;
|
||||
}
|
||||
if (!ok)
|
||||
System.out.println("R4 missing : "+s);
|
||||
}
|
||||
for (SPRelationship sp : list) {
|
||||
if (!Utilities.noString(sp.r4)) {
|
||||
boolean ok = list4.contains(sp.r4);
|
||||
if (!ok)
|
||||
System.out.println("R4 extra : "+sp.r4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void check3() {
|
||||
for (String s : list3) {
|
||||
boolean ok = false;
|
||||
for (SPRelationship t : list) {
|
||||
if (s.equals(t.r3))
|
||||
ok = true;
|
||||
}
|
||||
if (!ok)
|
||||
System.out.println("R3 : "+s);
|
||||
}
|
||||
for (SPRelationship sp : list) {
|
||||
if (!Utilities.noString(sp.r3)) {
|
||||
boolean ok = list3.contains(sp.r3);
|
||||
if (!ok)
|
||||
System.out.println("R3 extra : "+sp.r3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void check2b() {
|
||||
for (String s : list2b) {
|
||||
boolean ok = false;
|
||||
for (SPRelationship t : list) {
|
||||
if (s.equals(t.r2b))
|
||||
ok = true;
|
||||
}
|
||||
if (!ok)
|
||||
System.out.println("R2b : "+s);
|
||||
}
|
||||
for (SPRelationship sp : list) {
|
||||
if (!Utilities.noString(sp.r2b)) {
|
||||
boolean ok = list2b.contains(sp.r2b);
|
||||
if (!ok)
|
||||
System.out.println("R2b extra : "+sp.r2b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void check2() {
|
||||
for (String s : list2) {
|
||||
boolean ok = false;
|
||||
for (SPRelationship t : list) {
|
||||
if (s.equals(t.r2))
|
||||
ok = true;
|
||||
}
|
||||
if (!ok)
|
||||
System.out.println("R2 : "+s);
|
||||
}
|
||||
for (SPRelationship sp : list) {
|
||||
if (!Utilities.noString(sp.r2)) {
|
||||
boolean ok = list2.contains(sp.r2);
|
||||
if (!ok)
|
||||
System.out.println("R2 extra : "+sp.r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void load4() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) new org.hl7.fhir.r4.formats.JsonParser().parse(new FileInputStream("c:\\temp\\sp4.json"));
|
||||
for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.r4.model.SearchParameter sp = (org.hl7.fhir.r4.model.SearchParameter) be.getResource();
|
||||
for (org.hl7.fhir.r4.model.CodeType br : sp.getBase()) {
|
||||
if (!Utilities.existsInList(br.asStringValue(), "DomainResource", "Resource"))
|
||||
list4.add(br.asStringValue()+"."+sp.getCode());//+", "+sp.getType().toCode());
|
||||
}
|
||||
}
|
||||
Collections.sort(list4);
|
||||
System.out.println("R4 loaded - "+list4.size()+" parameters");
|
||||
}
|
||||
|
||||
private void load3() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
org.hl7.fhir.dstu3.model.Bundle bundle = (org.hl7.fhir.dstu3.model.Bundle) new org.hl7.fhir.dstu3.formats.JsonParser().parse(new FileInputStream("c:\\temp\\sp3.json"));
|
||||
for (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.dstu3.model.SearchParameter sp = (org.hl7.fhir.dstu3.model.SearchParameter) be.getResource();
|
||||
for (org.hl7.fhir.dstu3.model.CodeType br : sp.getBase()) {
|
||||
if (!Utilities.existsInList(br.asStringValue(), "DomainResource", "Resource"))
|
||||
list3.add(br.asStringValue()+"."+sp.getCode());//+", "+sp.getType().toCode());
|
||||
}
|
||||
}
|
||||
Collections.sort(list3);
|
||||
System.out.println("R3 loaded - "+list3.size()+" parameters");
|
||||
}
|
||||
|
||||
private void load2() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
org.hl7.fhir.dstu2.model.Bundle bundle = (org.hl7.fhir.dstu2.model.Bundle) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream("c:\\temp\\sp2.json"));
|
||||
for (org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.dstu2.model.SearchParameter sp = (org.hl7.fhir.dstu2.model.SearchParameter) be.getResource();
|
||||
String br = sp.getBase();
|
||||
if (!Utilities.existsInList(br, "DomainResource", "Resource"))
|
||||
list2.add(br+"."+sp.getCode());//+", "+sp.getType().toCode());
|
||||
}
|
||||
Collections.sort(list2);
|
||||
System.out.println("R2 loaded - "+list2.size()+" parameters");
|
||||
}
|
||||
|
||||
private void load2b() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
org.hl7.fhir.dstu2016may.model.Bundle bundle = (org.hl7.fhir.dstu2016may.model.Bundle) new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream("c:\\temp\\sp2b.json"));
|
||||
for (org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.dstu2016may.model.SearchParameter sp = (org.hl7.fhir.dstu2016may.model.SearchParameter) be.getResource();
|
||||
String br = sp.getBase();
|
||||
if (!Utilities.existsInList(br, "DomainResource", "Resource"))
|
||||
list2b.add(br+"."+sp.getCode());//+", "+sp.getType().toCode());
|
||||
}
|
||||
Collections.sort(list2b);
|
||||
System.out.println("R2b loaded - "+list2b.size()+" parameters");
|
||||
}
|
||||
|
||||
private void loadCsv() throws IOException, FHIRException {
|
||||
CSVReader csv = new CSVReader(new FileInputStream("C:\\work\\org.hl7.fhir\\org.fhir.interversion\\work\\search-params.csv"));
|
||||
csv.readHeaders();
|
||||
while (csv.line()) {
|
||||
String r4 = csv.cell("R4");
|
||||
String r3 = csv.cell("R3");
|
||||
String r2b = csv.cell("R2b");
|
||||
String r2 = csv.cell("R2");
|
||||
if (!Utilities.noString(r4) || !Utilities.noString(r3) || !Utilities.noString(r2b) || !Utilities.noString(r2)) {
|
||||
boolean ok = (!Utilities.noString(r4) && r4.contains(".")) ||
|
||||
(!Utilities.noString(r3) && r3.contains(".")) ||
|
||||
(!Utilities.noString(r2b) && r2b.contains(".")) ||
|
||||
(!Utilities.noString(r2) && r2.contains("."));
|
||||
if (ok) {
|
||||
list.add(new SPRelationship(r4, r3, r2b, r2));
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Map loaded - "+list.size()+" entries");
|
||||
}
|
||||
|
||||
// private void generate(String name) throws IOException {
|
||||
// StringBuilder b = new StringBuilder();
|
||||
//
|
||||
// String rn = "";
|
||||
// Collections.sort(list);
|
||||
// for (String s : list) {
|
||||
// String rnn = s.substring(0, s.indexOf("."));
|
||||
// if (!rnn.equals(rn)) {
|
||||
// rn = rnn;
|
||||
// b.append(rn+"\r\n");
|
||||
// }
|
||||
// b.append(s+"\r\n");
|
||||
// }
|
||||
// TextFile.stringToFile(b.toString(), name);
|
||||
// }
|
||||
//
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException, FHIRException {
|
||||
new SearchParameterProcessor().load();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -27,6 +27,7 @@ import org.hl7.fhir.dstu2.model.OperationOutcome.IssueSeverity;
|
|||
import org.hl7.fhir.dstu2.model.OperationOutcome.IssueType;
|
||||
import org.hl7.fhir.dstu2.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
import org.hl7.fhir.dstu2.model.StringType;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
||||
public class OperationOutcomeUtilities {
|
||||
|
@ -37,7 +38,7 @@ public class OperationOutcomeUtilities {
|
|||
issue.setCode(convert(message.getType()));
|
||||
if (message.getLocation() != null) {
|
||||
StringType s = new StringType();
|
||||
s.setValue(message.getLocation()+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
s.setValue(Utilities.fhirPathToXPath(message.getLocation())+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
issue.getLocation().add(s);
|
||||
}
|
||||
issue.setSeverity(convert(message.getLevel()));
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity;
|
|||
import org.hl7.fhir.dstu3.model.OperationOutcome.IssueType;
|
||||
import org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
||||
public class OperationOutcomeUtilities {
|
||||
|
@ -36,8 +37,11 @@ public class OperationOutcomeUtilities {
|
|||
OperationOutcomeIssueComponent issue = new OperationOutcome.OperationOutcomeIssueComponent();
|
||||
issue.setCode(convert(message.getType()));
|
||||
if (message.getLocation() != null) {
|
||||
// message location has a fhirPath in it. We need to populate the expression
|
||||
issue.addExpression(message.getLocation());
|
||||
// also, populate the XPath variant
|
||||
StringType s = new StringType();
|
||||
s.setValue(message.getLocation()+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
s.setValue(Utilities.fhirPathToXPath(message.getLocation())+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
issue.getLocation().add(s);
|
||||
}
|
||||
issue.setSeverity(convert(message.getLevel()));
|
||||
|
|
|
@ -289,6 +289,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
}
|
||||
}
|
||||
}
|
||||
this.version = pi.version();
|
||||
}
|
||||
|
||||
public void loadFromFile(String file, IContextResourceLoader loader) throws IOException, FHIRException {
|
||||
|
|
|
@ -73,8 +73,13 @@ public class XhtmlType extends Element {
|
|||
@Override
|
||||
public Base setProperty(int hash, String name, Base value) throws FHIRException {
|
||||
if ("value".equals(name)) {
|
||||
place.setDiv(castToXhtml(value));
|
||||
return value;
|
||||
if (value instanceof StringType) {
|
||||
// div is already generated with getValue, we cannot just overwrite it
|
||||
place.getDiv().setValueAsString(((StringType) value).asStringValue());
|
||||
} else {
|
||||
place.setDiv(castToXhtml(value));
|
||||
}
|
||||
return value;
|
||||
} else
|
||||
return super.setProperty(hash, name, value);
|
||||
}
|
||||
|
|
|
@ -2889,7 +2889,7 @@ public class FHIRPathEngine {
|
|||
|
||||
if (!Utilities.noString(f)) {
|
||||
|
||||
if (exp.getParameters().size() != 2) {
|
||||
if (exp.getParameters().size() == 2) {
|
||||
|
||||
String t = convertToString(execute(context, focus, exp.getParameters().get(0), true));
|
||||
String r = convertToString(execute(context, focus, exp.getParameters().get(1), true));
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
|
|||
import org.hl7.fhir.r4.model.OperationOutcome.IssueType;
|
||||
import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
||||
public class OperationOutcomeUtilities {
|
||||
|
@ -36,8 +37,11 @@ public class OperationOutcomeUtilities {
|
|||
OperationOutcomeIssueComponent issue = new OperationOutcome.OperationOutcomeIssueComponent();
|
||||
issue.setCode(convert(message.getType()));
|
||||
if (message.getLocation() != null) {
|
||||
// message location has a fhirPath in it. We need to populate the expression
|
||||
issue.addExpression(message.getLocation());
|
||||
// also, populate the XPath variant
|
||||
StringType s = new StringType();
|
||||
s.setValue(message.getLocation()+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
s.setValue(Utilities.fhirPathToXPath(message.getLocation())+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
issue.getLocation().add(s);
|
||||
}
|
||||
issue.setSeverity(convert(message.getLevel()));
|
||||
|
|
|
@ -1402,7 +1402,7 @@ public class StructureMapUtilities {
|
|||
}
|
||||
} else if (rule.getSource().size() == 1 && rule.getSourceFirstRep().hasVariable() && rule.getTarget().size() == 1 && rule.getTargetFirstRep().hasVariable() && rule.getTargetFirstRep().getTransform() == StructureMapTransform.CREATE && !rule.getTargetFirstRep().hasParameter()) {
|
||||
// simple inferred, map by type
|
||||
System.out.println(v.summary());
|
||||
log(v.summary());
|
||||
Base src = v.get(VariableMode.INPUT, rule.getSourceFirstRep().getVariable());
|
||||
Base tgt = v.get(VariableMode.OUTPUT, rule.getTargetFirstRep().getVariable());
|
||||
String srcType = src.fhirType();
|
||||
|
@ -1493,7 +1493,9 @@ public class StructureMapUtilities {
|
|||
if (value.contains("*")) {
|
||||
for (StructureMap sm : worker.listTransforms()) {
|
||||
if (urlMatches(value, sm.getUrl())) {
|
||||
res.add(sm);
|
||||
if (!res.contains(sm)) {
|
||||
res.add(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -277,6 +277,7 @@ public class SnapShotGenerationTests {
|
|||
@Parameters(name = "{index}: file {0}")
|
||||
public static Iterable<Object[]> data() throws ParserConfigurationException, IOException, FHIRFormatError {
|
||||
SnapShotGenerationTestsContext context = new SnapShotGenerationTestsContext();
|
||||
System.out.println("Snapshot tests using "+TestingUtilities.resourceNameToFile("snapshot-generation-tests.xml"));
|
||||
context.tests = (TestScript) new XmlParser().parse(new FileInputStream(TestingUtilities.resourceNameToFile("snapshot-generation-tests.xml")));
|
||||
|
||||
context.checkTestsDetails();
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ExpressionNode {
|
|||
|
||||
Empty, Not, Exists, SubsetOf, SupersetOf, IsDistinct, Distinct, Count, Where, Select, All, Repeat, Aggregate, Item /*implicit from name[]*/, As, Is, Single,
|
||||
First, Last, Tail, Skip, Take, Union, Combine, Intersect, Exclude, Iif, Upper, Lower, ToChars, Substring, StartsWith, EndsWith, Matches, ReplaceMatches, Contains, Replace, Length,
|
||||
Children, Descendants, MemberOf, Trace, Today, Now, Resolve, Extension, AllFalse, AnyFalse, AllTrue, AnyTrue,
|
||||
Children, Descendants, MemberOf, Trace, Check, Today, Now, Resolve, Extension, AllFalse, AnyFalse, AllTrue, AnyTrue,
|
||||
HasValue, AliasAs, Alias, HtmlChecks, OfType, Type,
|
||||
ConvertsToBoolean, ConvertsToInteger, ConvertsToString, ConvertsToDecimal, ConvertsToQuantity, ConvertsToDateTime, ConvertsToTime, ToBoolean, ToInteger, ToString, ToDecimal, ToQuantity, ToDateTime, ToTime, ConformsTo;
|
||||
|
||||
|
@ -108,6 +108,7 @@ public class ExpressionNode {
|
|||
if (name.equals("descendants")) return Function.Descendants;
|
||||
if (name.equals("memberOf")) return Function.MemberOf;
|
||||
if (name.equals("trace")) return Function.Trace;
|
||||
if (name.equals("check")) return Function.Check;
|
||||
if (name.equals("today")) return Function.Today;
|
||||
if (name.equals("now")) return Function.Now;
|
||||
if (name.equals("resolve")) return Function.Resolve;
|
||||
|
@ -183,6 +184,7 @@ public class ExpressionNode {
|
|||
case Descendants : return "descendants";
|
||||
case MemberOf : return "memberOf";
|
||||
case Trace : return "trace";
|
||||
case Check : return "check";
|
||||
case Today : return "today";
|
||||
case Now : return "now";
|
||||
case Resolve : return "resolve";
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.hl7.fhir.utilities.xhtml.NodeType;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
|
@ -72,7 +73,12 @@ public class XhtmlType extends Element {
|
|||
@Override
|
||||
public Base setProperty(int hash, String name, Base value) throws FHIRException {
|
||||
if ("value".equals(name)) {
|
||||
place.setDiv(castToXhtml(value));
|
||||
if (value instanceof StringType) {
|
||||
// div is already generated with getValue, we cannot just overwrite it
|
||||
place.getDiv().setValueAsString(((StringType) value).asStringValue());
|
||||
} else {
|
||||
place.setDiv(castToXhtml(value));
|
||||
}
|
||||
return value;
|
||||
} else
|
||||
return super.setProperty(hash, name, value);
|
||||
|
|
|
@ -1110,6 +1110,7 @@ public class FHIRPathEngine {
|
|||
case Descendants: return checkParamCount(lexer, location, exp, 0);
|
||||
case MemberOf: return checkParamCount(lexer, location, exp, 1);
|
||||
case Trace: return checkParamCount(lexer, location, exp, 1, 2);
|
||||
case Check: return checkParamCount(lexer, location, exp, 2);
|
||||
case Today: return checkParamCount(lexer, location, exp, 0);
|
||||
case Now: return checkParamCount(lexer, location, exp, 0);
|
||||
case Resolve: return checkParamCount(lexer, location, exp, 0);
|
||||
|
@ -2549,6 +2550,10 @@ public class FHIRPathEngine {
|
|||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return focus;
|
||||
}
|
||||
case Check : {
|
||||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return focus;
|
||||
}
|
||||
case Today :
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_DateTime);
|
||||
case Now :
|
||||
|
@ -2741,6 +2746,7 @@ public class FHIRPathEngine {
|
|||
case Descendants : return funcDescendants(context, focus, exp);
|
||||
case MemberOf : return funcMemberOf(context, focus, exp);
|
||||
case Trace : return funcTrace(context, focus, exp);
|
||||
case Check : return funcCheck(context, focus, exp);
|
||||
case Today : return funcToday(context, focus, exp);
|
||||
case Now : return funcNow(context, focus, exp);
|
||||
case Resolve : return funcResolve(context, focus, exp);
|
||||
|
@ -2896,7 +2902,7 @@ public class FHIRPathEngine {
|
|||
|
||||
if (!Utilities.noString(f)) {
|
||||
|
||||
if (exp.getParameters().size() != 2) {
|
||||
if (exp.getParameters().size() == 2) {
|
||||
|
||||
String t = convertToString(execute(context, focus, exp.getParameters().get(0), true));
|
||||
String r = convertToString(execute(context, focus, exp.getParameters().get(1), true));
|
||||
|
@ -3484,6 +3490,16 @@ public class FHIRPathEngine {
|
|||
return focus;
|
||||
}
|
||||
|
||||
private List<Base> funcCheck(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> n1 = execute(context, focus, exp.getParameters().get(0), true);
|
||||
if (!convertToBoolean(n1)) {
|
||||
List<Base> n2 = execute(context, focus, exp.getParameters().get(1), true);
|
||||
String name = n2.get(0).primitiveValue();
|
||||
throw new FHIRException("check failed: "+name);
|
||||
}
|
||||
return focus;
|
||||
}
|
||||
|
||||
private List<Base> funcDistinct(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||
if (focus.size() <= 1)
|
||||
return focus;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity;
|
|||
import org.hl7.fhir.r5.model.OperationOutcome.IssueType;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
||||
public class OperationOutcomeUtilities {
|
||||
|
@ -36,11 +37,16 @@ public class OperationOutcomeUtilities {
|
|||
public static OperationOutcomeIssueComponent convertToIssue(ValidationMessage message, OperationOutcome op) {
|
||||
OperationOutcomeIssueComponent issue = new OperationOutcome.OperationOutcomeIssueComponent();
|
||||
issue.setCode(convert(message.getType()));
|
||||
|
||||
if (message.getLocation() != null) {
|
||||
// message location has a fhirPath in it. We need to populate the expression
|
||||
issue.addExpression(message.getLocation());
|
||||
// also, populate the XPath variant
|
||||
StringType s = new StringType();
|
||||
s.setValue(message.getLocation()+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
s.setValue(Utilities.fhirPathToXPath(message.getLocation())+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
|
||||
issue.getLocation().add(s);
|
||||
}
|
||||
// pass through line/col if they're present
|
||||
if (message.getLine() != 0)
|
||||
issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_LINE).setValue(new IntegerType(message.getLine()));
|
||||
if (message.getCol() != 0)
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<a href="Patient/f201">Roel</a>
|
||||
</p>
|
||||
<p>
|
||||
<b>authored</b>: Jun 17, 2013 11:00:00 PM
|
||||
<b>authored</b>: 18/06/2013 9:00:00 AM
|
||||
</p>
|
||||
<p>
|
||||
<b>author</b>:
|
||||
|
|
|
@ -2086,7 +2086,7 @@
|
|||
</element>
|
||||
<element>
|
||||
<path value="Observation.value[x]"/>
|
||||
<sliceName value="quantity"/>
|
||||
<sliceName value="Quantity"/>
|
||||
<short value="some text for quantity"/>
|
||||
<type>
|
||||
<code value="Quantity"/>
|
||||
|
@ -2168,7 +2168,7 @@
|
|||
</element>
|
||||
<element>
|
||||
<path value="Observation.value[x]"/>
|
||||
<sliceName value="quantity"/>
|
||||
<sliceName value="Quantity"/>
|
||||
<short value="some text for quantity"/>
|
||||
<type>
|
||||
<code value="Quantity"/>
|
||||
|
@ -2180,7 +2180,7 @@
|
|||
</element>
|
||||
<element>
|
||||
<path value="Observation.value[x]"/>
|
||||
<sliceName value="codeable"/>
|
||||
<sliceName value="CodeableConcept"/>
|
||||
<short value="some text for CodeableConcept"/>
|
||||
<type>
|
||||
<code value="CodeableConcept"/>
|
||||
|
@ -4310,4 +4310,288 @@
|
|||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test40"/>
|
||||
<description value="40. Choice Types: constrain minimum cardinality"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t40o"/>
|
||||
<sourceId value="t40"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test40-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test40-2"/>
|
||||
<description value="There should only be one element definition for value[x]"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t40o').snapshot.element.where(path.startsWith('Observation.value')).count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test40-3"/>
|
||||
<description value="The element definition for value[x] should have min = 1"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t40o').snapshot.element.where(path.startsWith('Observation.value')).min = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test41"/>
|
||||
<description value="41. Choice Types: constrain list of choices to 2"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t41o"/>
|
||||
<sourceId value="t41"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test41-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test41-2"/>
|
||||
<description value="There should only be one element definition for value[x]"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t41o').snapshot.element.where(path.startsWith('Observation.value')).count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test41-3"/>
|
||||
<description value="The element definition for value[x] should have 2 types"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t41o').snapshot.element.where(path.startsWith('Observation.value')).type.count() = 2"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test42"/>
|
||||
<description value="Choice Types: constrain list of choices to 1"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t42o"/>
|
||||
<sourceId value="t42"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-2"/>
|
||||
<description value="There should only be one element definition for value[x]"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t42o').snapshot.element.where(path.startsWith('Observation.value')).count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-3"/>
|
||||
<description value="The element definition for value[x] should have 1 type"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t42o').snapshot.element.where(path.startsWith('Observation.value')).type.count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-4"/>
|
||||
<description value="The element definition for value[x] should have short = 'some text'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t42o').snapshot.element.where(path.startsWith('Observation.value')).short = 'some text'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test43"/>
|
||||
<description value="Choice Types: constrain list of choices to 1 and constrain the type (slicing)"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t43o"/>
|
||||
<sourceId value="t43"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-2"/>
|
||||
<description value="There should be 9 element definitions for value[x] (base + quantity + walking into quantity"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(path.startsWith('Observation.value')).count() = 9"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-3"/>
|
||||
<description value="The element definition for value[x] should have 1 type"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]').type.count().trace('count') = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-4"/>
|
||||
<description value="The element definition for value[x] should have short = 'some text'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]').short = 'some text'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-5"/>
|
||||
<description value="The element definition for value[x] quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]:Quantity').check(exists(), 'no slice').sliceName = 'Quantity'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-6"/>
|
||||
<description value="The element definition for value[x].value quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]:Quantity.value').check(exists(), 'no slice').min = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test44"/>
|
||||
<description value="Choice Types: constrain list of choices to 1 and constrain the type (shortcut)"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t44o"/>
|
||||
<sourceId value="t44"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-2"/>
|
||||
<description value="There should be 9 element definitions for value[x] (base + quantity + walking into quantity"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(path.startsWith('Observation.value')).count() = 9"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-3"/>
|
||||
<description value="The element definition for value[x] should have 1 type"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]').type.count().trace('count') = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-4"/>
|
||||
<description value="The element definition for value[x] should have short = 'some text'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]').short = 'some text'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-5"/>
|
||||
<description value="The element definition for value[x] quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]:Quantity').check(exists(), 'no slice').sliceName = 'Quantity'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-6"/>
|
||||
<description value="The element definition for value[x].value quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]:Quantity.value').check(exists(), 'no slice').min = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
</TestScript>
|
||||
|
|
|
@ -70,7 +70,7 @@ public class CSVProcessor {
|
|||
|
||||
public class DataReader extends CSVReader {
|
||||
|
||||
public DataReader(InputStream data) throws UnsupportedEncodingException {
|
||||
public DataReader(InputStream data) throws FHIRException, IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class CSVProcessor {
|
|||
this.source = source;
|
||||
}
|
||||
|
||||
public void setData(InputStream data) {
|
||||
public void setData(InputStream data) throws FHIRException, IOException {
|
||||
try {
|
||||
this.data = new DataReader(data);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
|
|
@ -65,11 +65,18 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
*/
|
||||
public class CSVReader extends InputStreamReader {
|
||||
|
||||
public CSVReader(InputStream in) throws UnsupportedEncodingException {
|
||||
public CSVReader(InputStream in) throws FHIRException, IOException {
|
||||
super(in, "UTF-8");
|
||||
checkBOM();
|
||||
}
|
||||
|
||||
private String[] cols;
|
||||
private void checkBOM() throws FHIRException, IOException {
|
||||
if (peek() == '\uFEFF')
|
||||
next();
|
||||
|
||||
}
|
||||
|
||||
private String[] cols;
|
||||
private String[] cells;
|
||||
|
||||
public void readHeaders() throws IOException, FHIRException {
|
||||
|
@ -92,7 +99,7 @@ public class CSVReader extends InputStreamReader {
|
|||
public String cell(String name) {
|
||||
int index = -1;
|
||||
for (int i = 0; i < cols.length; i++) {
|
||||
if (name.equals(cols[i]))
|
||||
if (name.equals(cols[i].trim()))
|
||||
index = i;
|
||||
}
|
||||
if (index == -1)
|
||||
|
|
|
@ -1195,6 +1195,32 @@ public class Utilities {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Only handles simple FHIRPath expressions of the type produced by the validator
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static String fhirPathToXPath(String path) {
|
||||
String[] p = path.split("\\.");
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(".");
|
||||
int i = 0;
|
||||
while (i < p.length) {
|
||||
String s = p[i];
|
||||
if (s.contains("[")) {
|
||||
String si = s.substring(s.indexOf("[")+1, s.length()-1);
|
||||
s = s.substring(0, s.indexOf("["))+"["+Integer.toString(Integer.parseInt(si)+1)+"]";
|
||||
}
|
||||
if (i < p.length - 1 && p[i+1].startsWith(".ofType(")) {
|
||||
i++;
|
||||
s = s + capitalize(p[i].substring(8, p.length-1));
|
||||
}
|
||||
b.append(s);
|
||||
i++;
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -479,7 +479,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
|
|||
private Source source;
|
||||
private int line;
|
||||
private int col;
|
||||
private String location;
|
||||
private String location; // fhirPath
|
||||
private String message;
|
||||
private IssueType type;
|
||||
private IssueSeverity level;
|
||||
|
|
|
@ -331,8 +331,8 @@ public class BaseValidator {
|
|||
protected boolean warning(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
|
||||
if (!thePass) {
|
||||
msg = formatMessage(msg, theMessageArguments);
|
||||
IssueSeverity severity = IssueSeverity.WARNING;
|
||||
addValidationMessage(errors, type, line, col, path, msg, severity);
|
||||
IssueSeverity severity = IssueSeverity.WARNING;
|
||||
addValidationMessage(errors, type, line, col, path, msg, severity);
|
||||
}
|
||||
return thePass;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.hl7.fhir.r5.validation;
|
|||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -2922,6 +2923,20 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
}
|
||||
}
|
||||
// security tags are a set (system|code)
|
||||
Element meta = element.getNamedChild("meta");
|
||||
if (meta != null) {
|
||||
Set<String> tags = new HashSet<>();
|
||||
List<Element> list = new ArrayList<>();
|
||||
meta.getNamedChildren("security", list);
|
||||
int i = 0;
|
||||
for (Element e : list) {
|
||||
String s = e.getNamedChildValue("system") + "#" + e.getNamedChildValue("code");
|
||||
rule(errors, IssueType.BUSINESSRULE, e.line(), e.col(), stack.getLiteralPath()+".meta.profile["+Integer.toString(i)+"]", !tags.contains(s), "Duplicate Security Label "+s);
|
||||
tags.add(s);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCodeSystem(List<ValidationMessage> errors, Element cs, NodeStack stack) {
|
||||
|
@ -4416,7 +4431,7 @@ private boolean isAnswerRequirementFulfilled(QuestionnaireItemComponent qItem, L
|
|||
String nb = cursor == 0 ? "--" : parent.getChildren().get(cursor-1).getName();
|
||||
String na = cursor >= parent.getChildren().size() - 1 ? "--" : parent.getChildren().get(cursor+1).getName();
|
||||
if (name().equals(nb) || name().equals(na) ) {
|
||||
return lastCount + 1;
|
||||
return lastCount;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
@ -4447,10 +4462,21 @@ private boolean isAnswerRequirementFulfilled(QuestionnaireItemComponent qItem, L
|
|||
public String path() {
|
||||
int i = count();
|
||||
String sfx = "";
|
||||
if (i > -1) {
|
||||
sfx = "[" + Integer.toString(lastCount + 1) + "]";
|
||||
String n = name();
|
||||
String fn = "";
|
||||
if (element().getProperty().isChoice()) {
|
||||
String en = element().getProperty().getName();
|
||||
en = en.substring(0, en.length()-3);
|
||||
String t = n.substring(en.length());
|
||||
if (isPrimitiveType(Utilities.uncapitalize(t)))
|
||||
t = Utilities.uncapitalize(t);
|
||||
n = en;
|
||||
fn = ".ofType("+t+")";
|
||||
}
|
||||
return basePath + "." + name() + sfx;
|
||||
if (i > -1 || (element().getSpecial() == null && element().isList())) {
|
||||
sfx = "[" + Integer.toString(lastCount) + "]";
|
||||
}
|
||||
return basePath + "." + n + sfx+fn;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4519,6 +4545,17 @@ private boolean isAnswerRequirementFulfilled(QuestionnaireItemComponent qItem, L
|
|||
res.literalPath = getLiteralPath() + "." + element.getName();
|
||||
if (count > -1)
|
||||
res.literalPath = res.literalPath + "[" + Integer.toString(count) + "]";
|
||||
else if (element.getSpecial() == null && element.getProperty().isList())
|
||||
res.literalPath = res.literalPath + "[0]";
|
||||
else if (element.getProperty().isChoice()) {
|
||||
String n = res.literalPath.substring(res.literalPath.lastIndexOf(".")+1);
|
||||
String en = element.getProperty().getName();
|
||||
en = en.substring(0, en.length()-3);
|
||||
String t = n.substring(en.length());
|
||||
if (isPrimitiveType(Utilities.uncapitalize(t)))
|
||||
t = Utilities.uncapitalize(t);
|
||||
res.literalPath = res.literalPath.substring(0, res.literalPath.lastIndexOf("."))+"."+en+".ofType("+t+")";
|
||||
}
|
||||
res.logicalPaths = new ArrayList<String>();
|
||||
if (type != null) {
|
||||
// type will be bull if we on a stitching point of a contained resource, or if....
|
||||
|
|
|
@ -72,6 +72,7 @@ import org.hl7.fhir.r5.model.Constants;
|
|||
import org.hl7.fhir.r5.model.DomainResource;
|
||||
import org.hl7.fhir.r5.model.FhirPublication;
|
||||
import org.hl7.fhir.r5.model.ImplementationGuide;
|
||||
import org.hl7.fhir.r5.model.IntegerType;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
|
@ -287,6 +288,7 @@ public class Validator {
|
|||
if ("1.0".equals(sv)) sv = "1.0.2";
|
||||
if ("1.4".equals(sv)) sv = "1.4.0";
|
||||
if ("3.0".equals(sv)) sv = "3.0.1";
|
||||
if ("4.0".equals(sv)) sv = "4.0.0";
|
||||
if (sv.startsWith(Constants.VERSION)) sv = Constants.VERSION;
|
||||
definitions = "hl7.fhir.core#"+sv;
|
||||
} else if (args[i].equals("-output"))
|
||||
|
@ -527,7 +529,19 @@ public class Validator {
|
|||
}
|
||||
|
||||
private static String getIssueSummary(OperationOutcomeIssueComponent issue) {
|
||||
return " " + issue.getSeverity().getDisplay() + " @ " + issue.getLocation().get(0).asStringValue() + " : " + issue.getDetails().getText();
|
||||
String loc = null;
|
||||
if (issue.hasExpression()) {
|
||||
int line = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_LINE, -1);
|
||||
int col = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_COL, -1);
|
||||
loc = issue.getExpression().get(0).asStringValue() + (line >= 0 && col >= 0 ? " (line "+Integer.toString(line)+", col"+Integer.toString(col)+")" : "");
|
||||
} else if (issue.hasLocation()) {
|
||||
loc = issue.getLocation().get(0).asStringValue();
|
||||
} else {
|
||||
int line = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_LINE, -1);
|
||||
int col = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_COL, -1);
|
||||
loc = (line >= 0 && col >= 0 ? "line "+Integer.toString(line)+", col"+Integer.toString(col) : "??");
|
||||
}
|
||||
return " " + issue.getSeverity().getDisplay() + " @ " + loc + " : " + issue.getDetails().getText();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,18 +33,20 @@ import org.hl7.fhir.r4.model.Resource;
|
|||
import org.hl7.fhir.r4.model.ResourceFactory;
|
||||
import org.hl7.fhir.r4.model.StructureDefinition;
|
||||
import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r4.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r4.model.StructureMap;
|
||||
import org.hl7.fhir.r4.model.UriType;
|
||||
import org.hl7.fhir.r4.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r4.utils.IResourceValidator;
|
||||
import org.hl7.fhir.r4.utils.IResourceValidator.IValidatorResourceFetcher;
|
||||
import org.hl7.fhir.r4.utils.IResourceValidator.ReferenceValidationPolicy;
|
||||
import org.hl7.fhir.r4.utils.StructureMapUtilities;
|
||||
import org.hl7.fhir.r4.utils.StructureMapUtilities.ITransformerServices;
|
||||
import org.hl7.fhir.r5.validation.InstanceValidatorFactory;
|
||||
import org.hl7.fhir.r4.validation.InstanceValidatorFactory;
|
||||
import org.hl7.fhir.utilities.IniFile;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.cache.PackageCacheManager;
|
||||
import org.hl7.fhir.utilities.cache.ToolsVersion;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.junit.Test;
|
||||
|
@ -63,12 +65,14 @@ import com.google.gson.JsonPrimitive;
|
|||
public class R3R4ConversionTests implements ITransformerServices, IValidatorResourceFetcher {
|
||||
|
||||
private static final boolean SAVING = true;
|
||||
private PackageCacheManager pcm = null;
|
||||
|
||||
@Parameters(name = "{index}: id {0}")
|
||||
public static Iterable<Object[]> data() throws ParserConfigurationException, SAXException, IOException {
|
||||
if (!(new File(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "outcomes.json")).exists()))
|
||||
throw new Error("You must set the default directory to the build directory when you execute these tests");
|
||||
r3r4Outcomes = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.fileToString(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "outcomes.json")));
|
||||
r3r4Outcomes = (JsonObject) new com.google.gson.JsonParser().parse(
|
||||
TextFile.fileToString(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "outcomes.json")));
|
||||
rules = new IniFile(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "test-rules.ini"));
|
||||
|
||||
String srcFile = Utilities.path(TestingUtilities.home(), "source", "release3", "examples.zip");
|
||||
|
@ -79,7 +83,7 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
filter = filter.toLowerCase();
|
||||
Map<String, byte[]> examples = new HashMap<String, byte[]>();
|
||||
ZipEntry entry;
|
||||
while((entry = stream.getNextEntry())!=null) {
|
||||
while ((entry = stream.getNextEntry()) != null) {
|
||||
String n = entry.getName();
|
||||
byte[] buffer = new byte[2048];
|
||||
ByteArrayOutputStream output = null;
|
||||
|
@ -97,7 +101,7 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
List<Object[]> objects = new ArrayList<Object[]>(examples.size());
|
||||
|
||||
for (String id : names) {
|
||||
objects.add(new Object[] { id, examples.get(id)});
|
||||
objects.add(new Object[] { id, examples.get(id) });
|
||||
}
|
||||
|
||||
return objects;
|
||||
|
@ -137,7 +141,8 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
extras = new ArrayList<Resource>();
|
||||
|
||||
// load the example (r3)
|
||||
org.hl7.fhir.r4.elementmodel.Element r3 = new org.hl7.fhir.r4.elementmodel.XmlParser(contextR3).parse(new ByteArrayInputStream(content));
|
||||
org.hl7.fhir.r4.elementmodel.Element r3 = new org.hl7.fhir.r4.elementmodel.XmlParser(contextR3)
|
||||
.parse(new ByteArrayInputStream(content));
|
||||
tn = r3.fhirType();
|
||||
workingid = r3.getChildValue("id");
|
||||
if (SAVING) {
|
||||
|
@ -145,13 +150,14 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
new org.hl7.fhir.r4.elementmodel.JsonParser(contextR3).compose(r3, bso, OutputStyle.PRETTY, null);
|
||||
cnt = bso.toByteArray();
|
||||
Utilities.createDirectory(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "test-output"));
|
||||
TextFile.bytesToFile(cnt, Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "test-output", tn+"-"+workingid+".input.json"));
|
||||
TextFile.bytesToFile(cnt, Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "test-output",
|
||||
tn + "-" + workingid + ".input.json"));
|
||||
}
|
||||
|
||||
// load the r3 to R4 map
|
||||
String mapFile = Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "R3toR4", r3.fhirType()+".map");
|
||||
if (new File(mapFile).exists()) {
|
||||
StructureMap sm = smu4.parse(TextFile.fileToString(mapFile), mapFile);
|
||||
|
||||
tn = smu4.getTargetType(sm).getType();
|
||||
|
||||
// convert from r3 to r4
|
||||
|
@ -161,11 +167,13 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||
new org.hl7.fhir.r4.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, r4);
|
||||
if (SAVING) {
|
||||
TextFile.bytesToFile(bs.toByteArray(), Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "test-output", tn+"-"+workingid+".r4.json"));
|
||||
TextFile.bytesToFile(bs.toByteArray(), Utilities.path(TestingUtilities.home(), "implementations", "r3maps",
|
||||
"test-output", tn + "-" + workingid + ".r4.json"));
|
||||
for (Resource r : extras) {
|
||||
bs = new ByteArrayOutputStream();
|
||||
new org.hl7.fhir.r4.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, r);
|
||||
TextFile.bytesToFile(bs.toByteArray(), Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "test-output", r.fhirType()+"-"+r.getId()+".r4.json"));
|
||||
TextFile.bytesToFile(bs.toByteArray(), Utilities.path(TestingUtilities.home(), "implementations", "r3maps",
|
||||
"test-output", r.fhirType() + "-" + r.getId() + ".r4.json"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,8 +184,6 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
validator.validate(null, r4validationErrors, r4);
|
||||
|
||||
// load the R4 to R3 map
|
||||
// mapFile = Utilities.path(root, "implementations", "r3maps", "R4toR3", r3.fhirType()+".map");
|
||||
// s = sm.parse(TextFile.fileToString(mapFile));
|
||||
mapFile = Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "R4toR3", getMapFor(r4.fhirType(), r3.fhirType())+".map");
|
||||
sm = smu3.parse(TextFile.fileToString(mapFile), mapFile);
|
||||
|
||||
|
@ -190,15 +196,17 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
bs = new ByteArrayOutputStream();
|
||||
new org.hl7.fhir.r4.elementmodel.JsonParser(contextR3).compose(ro3, bs, OutputStyle.PRETTY, null);
|
||||
if (SAVING)
|
||||
TextFile.bytesToFile(bs.toByteArray(), Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "test-output", tn+"-"+workingid+".output.json"));
|
||||
TextFile.bytesToFile(bs.toByteArray(), Utilities.path(TestingUtilities.home(), "implementations", "r3maps",
|
||||
"test-output", tn + "-" + workingid + ".output.json"));
|
||||
|
||||
// check(errors, tn, workingid);
|
||||
roundTripError = TestingUtilities.checkJsonSrcIsSame(new String(cnt), new String(bs.toByteArray()), filter != null);
|
||||
if (roundTripError != null && roundTripError.equals(rules.getStringProperty(tn+"/"+workingid, "roundtrip")))
|
||||
// check(errors, tn, workingid);
|
||||
roundTripError = TestingUtilities.checkJsonSrcIsSame(new String(cnt), new String(bs.toByteArray()),
|
||||
filter != null);
|
||||
if (roundTripError != null && roundTripError.equals(rules.getStringProperty(tn + "/" + workingid, "roundtrip")))
|
||||
roundTripError = null;
|
||||
} else {
|
||||
if (loadErrors.containsKey(r3.fhirType()+".map")) {
|
||||
executionError = loadErrors.get(r3.fhirType()+".map");
|
||||
if (loadErrors.containsKey(r3.fhirType() + ".map")) {
|
||||
executionError = loadErrors.get(r3.fhirType() + ".map");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -216,10 +224,11 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
if (r3.equals("ReferralRequest"))
|
||||
return "ServiceRequestRR";
|
||||
// if (r3.equals("ProcedureRequest"))
|
||||
return "ServiceRequestPR";
|
||||
return "ServiceRequestPR";
|
||||
}
|
||||
|
||||
private void updateOutcomes(String tn, String id, Exception executionError, List<ValidationMessage> r4validationErrors, String roundTripError) throws IOException {
|
||||
private void updateOutcomes(String tn, String id, Exception executionError,
|
||||
List<ValidationMessage> r4validationErrors, String roundTripError) throws IOException {
|
||||
JsonObject r = r3r4Outcomes.getAsJsonObject(tn);
|
||||
if (r == null) {
|
||||
r = new JsonObject();
|
||||
|
@ -238,7 +247,7 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
i.addProperty("execution", true);
|
||||
else
|
||||
i.addProperty("execution", executionError.getMessage());
|
||||
// round-trip check
|
||||
// round-trip check
|
||||
if (i.has("round-trip"))
|
||||
i.remove("round-trip");
|
||||
if (roundTripError != null)
|
||||
|
@ -251,11 +260,12 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
JsonArray arr = new JsonArray();
|
||||
i.add("r4.errors", arr);
|
||||
for (ValidationMessage e : r4validationErrors)
|
||||
arr.add(new JsonPrimitive(e.summary()));
|
||||
arr.add(new JsonPrimitive(e.summary()));
|
||||
}
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json = gson.toJson(r3r4Outcomes);
|
||||
TextFile.stringToFile(json, (Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "outcomes.json")));
|
||||
TextFile.stringToFile(json,
|
||||
(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "outcomes.json")));
|
||||
|
||||
}
|
||||
|
||||
|
@ -266,7 +276,7 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
break;
|
||||
if (vm.getMessage().contains("Error null validating Coding"))
|
||||
break;
|
||||
String s = rules.getStringProperty(tn+"/"+id, "validation");
|
||||
String s = rules.getStringProperty(tn + "/" + id, "validation");
|
||||
if (!Utilities.noString(s)) {
|
||||
boolean ok = false;
|
||||
for (String m : s.split("\\;"))
|
||||
|
@ -285,7 +295,7 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
break;
|
||||
}
|
||||
if (vm.getLevel() == IssueSeverity.ERROR || vm.getLevel() == IssueSeverity.FATAL) {
|
||||
b.append("[R4 validation error] "+vm.getLocation()+": "+vm.getMessage()+"\r\n");
|
||||
b.append("[R4 validation error] " + vm.getLocation() + ": " + vm.getMessage() + "\r\n");
|
||||
}
|
||||
}
|
||||
if (b.length() > 0)
|
||||
|
@ -293,32 +303,31 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
}
|
||||
|
||||
/*
|
||||
* Supporting multiple versions at once is a little tricky. We're going to have 2 contexts:
|
||||
* - an R3 context which is used to read/write R3 instances
|
||||
* - an R4 context which is used to perform the transforms
|
||||
* Supporting multiple versions at once is a little tricky. We're going to have
|
||||
* 2 contexts: - an R3 context which is used to read/write R3 instances - an R4
|
||||
* context which is used to perform the transforms
|
||||
*
|
||||
* R3 structure definitions are cloned into R3 context with a modified URL (as
|
||||
* 3.0/)
|
||||
*
|
||||
* R3 structure definitions are cloned into R3 context with a modified URL (as 3.0/)
|
||||
*
|
||||
*/
|
||||
private void checkLoad() throws IOException, FHIRException {
|
||||
private void checkLoad() throws IOException, FHIRException, Exception {
|
||||
if (contextR3 != null)
|
||||
return;
|
||||
|
||||
pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
R3ToR4Loader ldr = new R3ToR4Loader().setPatchUrls(true).setKillPrimitives(true);
|
||||
|
||||
System.out.println("loading R3");
|
||||
contextR3 = new SimpleWorkerContext();
|
||||
contextR3.setAllowLoadingDuplicates(true);
|
||||
contextR3.setOverrideVersionNs("http://hl7.org/fhir/3.0/StructureDefinition");
|
||||
contextR3.loadFromFile(Utilities.path(TestingUtilities.home(),"source","release3","profiles-types.xml"), ldr);
|
||||
contextR3.loadFromFile(Utilities.path(TestingUtilities.home(),"source","release3","profiles-resources.xml"), ldr);
|
||||
contextR3.loadFromFile(Utilities.path(TestingUtilities.home(),"source","release3","expansions.xml"), ldr);
|
||||
contextR3.loadFromPackage(pcm.loadPackage("hl7.fhir.core", "3.0.1"), ldr, new String[] {});
|
||||
|
||||
System.out.println("loading R4");
|
||||
contextR4 = new SimpleWorkerContext();
|
||||
contextR4.setAllowLoadingDuplicates(true);
|
||||
contextR4.loadFromFile(Utilities.path(TestingUtilities.content(),"profiles-types.xml"), null);
|
||||
contextR4.loadFromFile(Utilities.path(TestingUtilities.content(),"profiles-resources.xml"), null);
|
||||
contextR4.loadFromFile(Utilities.path(TestingUtilities.content(),"extension-definitions.xml"), null);
|
||||
contextR4.loadFromFile(Utilities.path(TestingUtilities.content(),"valuesets.xml"), null);
|
||||
|
||||
contextR4 = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0"));
|
||||
contextR4.setCanRunWithoutTerminology(true);
|
||||
|
||||
for (StructureDefinition sd : contextR3.allStructures()) {
|
||||
|
@ -332,7 +341,8 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
contextR3.cacheResource(sd);
|
||||
StructureDefinition sdn = sd.copy();
|
||||
sdn.setUrl(sdn.getUrl().replace("http://hl7.org/fhir/", "http://hl7.org/fhir/3.0/"));
|
||||
sdn.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("http://hl7.org/fhir"));
|
||||
sdn.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace")
|
||||
.setValue(new UriType("http://hl7.org/fhir"));
|
||||
contextR3.cacheResource(sdn);
|
||||
contextR4.cacheResource(sdn);
|
||||
}
|
||||
|
@ -342,11 +352,15 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
contextR4.setExpansionProfile(new org.hl7.fhir.r4.model.Parameters());
|
||||
contextR3.setName("R3");
|
||||
contextR4.setName("R4");
|
||||
|
||||
contextR4.setValidatorFactory(new InstanceValidatorFactory());
|
||||
// TODO: this has to be R% now... contextR4.setValidatorFactory(new InstanceValidatorFactory());
|
||||
|
||||
System.out.println("loading Maps");
|
||||
loadLib(Utilities.path(TestingUtilities.home(),"implementations","r3maps", "R3toR4"));
|
||||
loadLib(Utilities.path(TestingUtilities.home(),"implementations","r3maps", "R4toR3"));
|
||||
|
||||
loadLib(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "R4toR3"));
|
||||
loadLib(Utilities.path(TestingUtilities.home(), "implementations", "r3maps", "R3toR4"));
|
||||
|
||||
System.out.println("loaded");
|
||||
}
|
||||
|
||||
|
@ -361,30 +375,31 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
for (Resource r : sm.getContained()) {
|
||||
if (r instanceof MetadataResource) {
|
||||
MetadataResource mr = (MetadataResource) r.copy();
|
||||
mr.setUrl(sm.getUrl()+"#"+r.getId());
|
||||
mr.setUrl(sm.getUrl() + "#" + r.getId());
|
||||
contextR3.cacheResource(mr);
|
||||
contextR4.cacheResource(mr);
|
||||
}
|
||||
}
|
||||
} catch (FHIRException e) {
|
||||
System.out.println("Unable to load "+Utilities.path(dir, s)+": "+e.getMessage());
|
||||
System.out.println("Unable to load " + Utilities.path(dir, s) + ": " + e.getMessage());
|
||||
loadErrors.put(s, e);
|
||||
// e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
System.out.println(message);
|
||||
System.out.println(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base createResource(Object appInfo, Base res, boolean atRootofTransform) {
|
||||
if (res instanceof Resource && (res.fhirType().equals("CodeSystem") || res.fhirType().equals("CareTeam")) || res.fhirType().equals("PractitionerRole")) {
|
||||
if (res instanceof Resource && (res.fhirType().equals("CodeSystem") || res.fhirType().equals("CareTeam")
|
||||
|| res.fhirType().equals("PractitionerRole"))) {
|
||||
Resource r = (Resource) res;
|
||||
extras.add(r);
|
||||
r.setId(workingid+"-"+extras.size());
|
||||
r.setId(workingid + "-" + extras.size());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -398,9 +413,10 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
public Base createType(Object appInfo, String name) throws FHIRException {
|
||||
BaseWorkerContext context = (BaseWorkerContext) appInfo;
|
||||
if (context == contextR3) {
|
||||
StructureDefinition sd = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/3.0/StructureDefinition/"+name);
|
||||
StructureDefinition sd = context.fetchResource(StructureDefinition.class,
|
||||
"http://hl7.org/fhir/3.0/StructureDefinition/" + name);
|
||||
if (sd == null)
|
||||
throw new FHIRException("Type not found: '"+name+"'");
|
||||
throw new FHIRException("Type not found: '" + name + "'");
|
||||
return Manager.build(context, sd);
|
||||
} else
|
||||
return ResourceFactory.createResourceOrType(name);
|
||||
|
@ -414,7 +430,7 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
if (url.equals(mr.getUrl()))
|
||||
return mr;
|
||||
}
|
||||
if (url.equals(r.fhirType()+"/"+r.getId()))
|
||||
if (url.equals(r.fhirType() + "/" + r.getId()))
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -429,7 +445,8 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
String[] vals = parts[1].split("\\=");
|
||||
if (vals.length == 2 && vals[0].equals("practitioner"))
|
||||
for (Resource r : extras) {
|
||||
if (r instanceof PractitionerRole && ((PractitionerRole) r).getPractitioner().getReference().equals("Practitioner/"+vals[1])) {
|
||||
if (r instanceof PractitionerRole
|
||||
&& ((PractitionerRole) r).getPractitioner().getReference().equals("Practitioner/" + vals[1])) {
|
||||
results.add(r);
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +455,8 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
}
|
||||
|
||||
@Override
|
||||
public Element fetch(Object appContext, String url) throws FHIRFormatError, DefinitionException, IOException, FHIRException {
|
||||
public Element fetch(Object appContext, String url)
|
||||
throws FHIRFormatError, DefinitionException, IOException, FHIRException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -451,6 +469,4 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
public boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<Patient xmlns="http://hl7.org/fhir">
|
||||
<id value="pat-good"/>
|
||||
<meta>
|
||||
<security>
|
||||
<system value="http://test.org"/>
|
||||
<code value="x"/>
|
||||
</security>
|
||||
<security>
|
||||
<system value="http://test.org"/>
|
||||
<code value="y"/>
|
||||
</security>
|
||||
<security>
|
||||
<system value="http://test.org"/>
|
||||
<code value="x"/>
|
||||
</security>
|
||||
</meta>
|
||||
<text>
|
||||
<status value="generated"/>
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||
some text in no particular language
|
||||
</div>
|
||||
</text>
|
||||
</Patient>
|
|
@ -783,6 +783,10 @@
|
|||
"errorCount": 0,
|
||||
"warningCount": 0
|
||||
},
|
||||
"duplicate-security-tags.xml" : {
|
||||
"errorCount": 1,
|
||||
"warningCount": 3
|
||||
},
|
||||
"azatadha/example-params-1.xml" : {
|
||||
"errorCount": 0,
|
||||
"warningCount": 1,
|
||||
|
|
Loading…
Reference in New Issue