utilities for OID rework in R5
This commit is contained in:
parent
4d4009f0e4
commit
fa22d50297
|
@ -120,7 +120,7 @@ public abstract class ParserBase {
|
|||
|
||||
public Element parseSingle(InputStream stream) throws IOException, FHIRFormatError, DefinitionException, FHIRException {
|
||||
List<NamedElement> res = parse(stream);
|
||||
if (res.size() == 1) {
|
||||
if (res.size() == 0) {
|
||||
throw new FHIRException("Parsing FHIR content returned no elements in a context where one element is required");
|
||||
}
|
||||
if (res.size() != 1) {
|
||||
|
|
|
@ -35,6 +35,10 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.JsonUtilities;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import org.hl7.fhir.r5.model.Enumerations.*;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
@ -568,5 +572,14 @@ public abstract class CanonicalResource extends DomainResource {
|
|||
return null;
|
||||
}
|
||||
|
||||
public String getOid() {
|
||||
for (Identifier id : getIdentifier()) {
|
||||
if ("urn:ietf:rfc:3986".equals(id.getSystem()) && id.hasValue() && id.getValue().startsWith("urn:oid:")) {
|
||||
return id.getValue().substring(8);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package org.hl7.fhir.r5.terminologies;
|
||||
|
||||
import org.hl7.fhir.r5.model.ConceptMap;
|
||||
import org.hl7.fhir.r5.model.Identifier;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
|
||||
public class ConceptMapUtilities {
|
||||
|
||||
public static boolean hasOID(ConceptMap cm) {
|
||||
return getOID(cm) != null;
|
||||
}
|
||||
|
||||
public static String getOID(ConceptMap cm) {
|
||||
for (Identifier id : cm.getIdentifier()) {
|
||||
if ("urn:ietf:rfc:3986".equals(id.getSystem()) && id.hasValue() && id.getValue().startsWith("urn:oid:"))
|
||||
return id.getValue().substring(8);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setOID(ConceptMap cm, String oid) {
|
||||
if (!oid.startsWith("urn:oid:"))
|
||||
oid = "urn:oid:" + oid;
|
||||
for (Identifier id : cm.getIdentifier()) {
|
||||
if ("urn:ietf:rfc:3986".equals(id.getSystem()) && id.hasValue() && id.getValue().startsWith("urn:oid:")) {
|
||||
id.setValue(oid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
cm.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue(oid);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -461,6 +461,13 @@ public class XMLUtil {
|
|||
return builder.parse(new FileInputStream(filename));
|
||||
}
|
||||
|
||||
public static Document parseFileToDom(String filename, boolean ns) throws ParserConfigurationException, SAXException, IOException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(ns);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
return builder.parse(new FileInputStream(filename));
|
||||
}
|
||||
|
||||
public static Element getLastChild(Element e) {
|
||||
if (e == null)
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue