more work on transifex support

This commit is contained in:
Grahame Grieve 2024-07-12 05:11:43 +08:00
parent 41bf1b5856
commit a2e6b001b3
9 changed files with 326 additions and 105 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.CompartmentDefinition;
import org.hl7.fhir.r5.model.Constants;
import org.hl7.fhir.r5.model.ContactDetail;
@ -71,9 +72,9 @@ public class CanonicalResourceUtilities {
ext = res.addElement("extension");
ext.setChildValue("url", ToolingExtensions.EXT_WORKGROUP);
}
ext.setChildValue("valueCode", code);
ext.setChildValue("valueCode", new CodeType(code));
res.setChildValue("publisher", "HL7 International / "+wg.getName());
while (res.hasChild("contact")) {
while (res.hasChildren("contact")) {
res.removeChild("contact");
}
Element c = res.addElement("contact");
@ -82,96 +83,96 @@ public class CanonicalResourceUtilities {
t.setChildValue("value", wg.getLink());
}
}
/**
* for use in the core build where the context is not fully populated. Only known safe for R6 resources
*
* @param res
* @param code
*/
public static void setHl7WG(org.w3c.dom.Element res, String code) {
String rt = res.getNodeName();
if (VersionUtilities.getExtendedCanonicalResourceNames("5.0.0").contains(rt)) {
var wg = HL7WorkGroups.find(code);
if (wg == null) {
throw new Error("Unknown WG "+code);
}
List<org.w3c.dom.Element> extensions = XMLUtil.getNamedChildren(res, "extension");
org.w3c.dom.Element wgext = null;
for (org.w3c.dom.Element ext : extensions) {
String url = ext.getAttribute("url");
if (ToolingExtensions.EXT_WORKGROUP.equals(url)) {
wgext = ext;
}
}
if (wgext == null) {
wgext = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "extension");
wgext.setAttribute("url", ToolingExtensions.EXT_WORKGROUP);
org.w3c.dom.Element after = XMLUtil.getLastChild(res, "id", "meta", "text", "implicitRules", "language", "text", "contained");
if (after != null) {
after = XMLUtil.getNextSibling(after);
}
res.insertBefore(wgext, after);
res.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
}
XMLUtil.clearChildren(wgext);
org.w3c.dom.Element valueCode = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "valueCode");
wgext.appendChild(valueCode);
valueCode.setAttribute("value", code);
org.w3c.dom.Element pub = XMLUtil.getNamedChild(res, "publisher");
if (pub == null) {
pub = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "publisher");
org.w3c.dom.Element after = XMLUtil.getLastChild(res, "id", "meta", "text", "implicitRules", "language", "text", "contained", "extension", "modifierExtension",
"url", "identifier", "version", "versionAlgorithmString", "versionAlgorithmCoding", "name", "title", "status", "experimental", "date", ("EvidenceReport".equals(rt) ? "subject" : "xx"));
if (after != null) {
after = XMLUtil.getNextSibling(after);
}
res.insertBefore(pub, after);
res.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
}
pub.setAttribute("value", "HL7 International / "+wg.getName());
org.w3c.dom.Element contact = XMLUtil.getNamedChild(res, "contact");
if (contact == null) {
contact = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "contact");
res.insertBefore(contact, XMLUtil.getNextSibling(pub));
res.insertBefore(res.getOwnerDocument().createTextNode("\n "), contact.getNextSibling());
}
org.w3c.dom.Element telecom = XMLUtil.getNamedChild(contact, "telecom");
if (telecom == null) {
contact.appendChild(res.getOwnerDocument().createTextNode("\n "));
telecom = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "telecom");
contact.appendChild(telecom);
contact.appendChild(res.getOwnerDocument().createTextNode("\n "));
}
org.w3c.dom.Element system = XMLUtil.getNamedChild(telecom, "system");
if (system == null) {
system = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "system");
org.w3c.dom.Element after = XMLUtil.getLastChild(telecom, "id", "extension");
if (after != null) {
after = XMLUtil.getNextSibling(after);
}
telecom.insertBefore(system, after);
telecom.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
}
system.setAttribute("value", "url");
org.w3c.dom.Element value = XMLUtil.getNamedChild(telecom, "value");
if (value == null) {
value = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "value");
org.w3c.dom.Element after = XMLUtil.getLastChild(telecom, "id", "extension", "system");
if (after != null) {
after = XMLUtil.getNextSibling(after);
}
telecom.insertBefore(system, after);
telecom.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
}
value.setAttribute("value", wg.getLink());
}
}
//
// /**
// * for use in the core build where the context is not fully populated. Only known safe for R6 resources
// *
// * @param res
// * @param code
// */
// public static void setHl7WG(org.w3c.dom.Element res, String code) {
// String rt = res.getNodeName();
// if (VersionUtilities.getExtendedCanonicalResourceNames("5.0.0").contains(rt)) {
// var wg = HL7WorkGroups.find(code);
// if (wg == null) {
// throw new Error("Unknown WG "+code);
// }
//
// List<org.w3c.dom.Element> extensions = XMLUtil.getNamedChildren(res, "extension");
// org.w3c.dom.Element wgext = null;
// for (org.w3c.dom.Element ext : extensions) {
// String url = ext.getAttribute("url");
// if (ToolingExtensions.EXT_WORKGROUP.equals(url)) {
// wgext = ext;
// }
// }
// if (wgext == null) {
// wgext = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "extension");
// wgext.setAttribute("url", ToolingExtensions.EXT_WORKGROUP);
// org.w3c.dom.Element after = XMLUtil.getLastChild(res, "id", "meta", "text", "implicitRules", "language", "text", "contained");
// if (after != null) {
// after = XMLUtil.getNextSibling(after);
// }
// res.insertBefore(wgext, after);
// res.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
// }
// XMLUtil.clearChildren(wgext);
// org.w3c.dom.Element valueCode = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "valueCode");
// wgext.appendChild(valueCode);
// valueCode.setAttribute("value", code);
//
// org.w3c.dom.Element pub = XMLUtil.getNamedChild(res, "publisher");
// if (pub == null) {
// pub = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "publisher");
// org.w3c.dom.Element after = XMLUtil.getLastChild(res, "id", "meta", "text", "implicitRules", "language", "text", "contained", "extension", "modifierExtension",
// "url", "identifier", "version", "versionAlgorithmString", "versionAlgorithmCoding", "name", "title", "status", "experimental", "date", ("EvidenceReport".equals(rt) ? "subject" : "xx"));
// if (after != null) {
// after = XMLUtil.getNextSibling(after);
// }
// res.insertBefore(pub, after);
// res.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
// }
// pub.setAttribute("value", "HL7 International / "+wg.getName());
//
// org.w3c.dom.Element contact = XMLUtil.getNamedChild(res, "contact");
// if (contact == null) {
// contact = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "contact");
// res.insertBefore(contact, XMLUtil.getNextSibling(pub));
// res.insertBefore(res.getOwnerDocument().createTextNode("\n "), contact.getNextSibling());
// }
//
// org.w3c.dom.Element telecom = XMLUtil.getNamedChild(contact, "telecom");
// if (telecom == null) {
// contact.appendChild(res.getOwnerDocument().createTextNode("\n "));
// telecom = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "telecom");
// contact.appendChild(telecom);
// contact.appendChild(res.getOwnerDocument().createTextNode("\n "));
// }
//
// org.w3c.dom.Element system = XMLUtil.getNamedChild(telecom, "system");
// if (system == null) {
// system = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "system");
// org.w3c.dom.Element after = XMLUtil.getLastChild(telecom, "id", "extension");
// if (after != null) {
// after = XMLUtil.getNextSibling(after);
// }
// telecom.insertBefore(system, after);
// telecom.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
// }
// system.setAttribute("value", "url");
//
//
// org.w3c.dom.Element value = XMLUtil.getNamedChild(telecom, "value");
// if (value == null) {
// value = res.getOwnerDocument().createElementNS(Constants.NS_FHIR_ROOT, "value");
// org.w3c.dom.Element after = XMLUtil.getLastChild(telecom, "id", "extension", "system");
// if (after != null) {
// after = XMLUtil.getNextSibling(after);
// }
// telecom.insertBefore(system, after);
// telecom.insertBefore(res.getOwnerDocument().createTextNode("\n "), after);
// }
// value.setAttribute("value", wg.getLink());
// }
// }
}

View File

@ -137,4 +137,7 @@ public class NamedItemList<T extends org.hl7.fhir.utilities.NamedItemList.NamedI
Collections.sort(list, sorter);
}
public void clearMap() {
map = null;
}
}

View File

@ -2,6 +2,7 @@ package org.hl7.fhir.utilities;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringJoiner;
@ -650,6 +651,15 @@ public class VersionUtilities {
String mm2 = getMajMin(v2);
return mm1 != null && mm2 != null && mm1.equals(mm2);
}
public static boolean versionsMatch(String v1, List<String> v2l) {
for (String v2 : v2l) {
if (versionsMatch(v1, v2)) {
return true;
}
}
return false;
}
public static boolean isR5VerOrLater(String version) {
if (version == null) {

View File

@ -1168,11 +1168,11 @@ public class HierarchicalTableGenerator {
}
public String prefixAnchor(String anchor) {
return uniqueLocalPrefix == null ? anchor : uniqueLocalPrefix+"-" + anchor;
return Utilities.noString(uniqueLocalPrefix) ? anchor : uniqueLocalPrefix+"-" + anchor;
}
public String prefixLocalHref(String url) {
if (url == null || uniqueLocalPrefix == null || !url.startsWith("#")) {
if (url == null || Utilities.noString(uniqueLocalPrefix) || !url.startsWith("#")) {
return url;
}
return "#"+uniqueLocalPrefix+"-"+url.substring(1);

View File

@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseXhtml;
@ -1127,4 +1128,15 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
default: return 0;
}
}
public void stripAnchorsByName(Set<String> anchors) {
if (hasChildren()) {
childNodes.removeIf(n -> "a".equals(n.getName()) && anchors.contains(n.getAttribute("name")));
for (XhtmlNode c : childNodes) {
c.stripAnchorsByName(anchors);
}
}
}
}

View File

@ -3547,7 +3547,6 @@ v: {
"code" : "image/png",
"system" : "urn:ietf:bcp:13",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -3568,6 +3567,26 @@ v: {
"code" : "image/png",
"system" : "urn:ietf:bcp:13",
"server" : "http://tx-dev.fhir.org/r4",
"issues" : {
"resourceType" : "OperationOutcome"
}
}
-------------------------------------------------------------------------------------
{"code" : {
"code" : "en-AU"
}, "url": "http://hl7.org/fhir/ValueSet/languages", "version": "4.0.1", "langs":"en-AU", "useServer":"true", "useClient":"true", "guessSystem":"true", "activeOnly":"false", "membershipOnly":"false", "displayWarningMode":"false", "versionFlexible":"true", "profile": {
"resourceType" : "Parameters",
"parameter" : [{
"name" : "profile-url",
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
}]
}}####
v: {
"display" : "English (Australia)",
"code" : "en-AU",
"system" : "urn:ietf:bcp:47",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"

View File

@ -7522,6 +7522,29 @@ v: {
"system" : "http://loinc.org",
"version" : "2.77",
"server" : "http://tx-dev.fhir.org/r4",
"issues" : {
"resourceType" : "OperationOutcome"
}
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://loinc.org",
"code" : "3150-0",
"display" : "Inhaled oxygen concentration"
}, "valueSet" :null, "langs":"", "useServer":"true", "useClient":"false", "guessSystem":"false", "activeOnly":"false", "membershipOnly":"false", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
"resourceType" : "Parameters",
"parameter" : [{
"name" : "profile-url",
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
}]
}}####
v: {
"display" : "Inhaled oxygen concentration",
"code" : "3150-0",
"system" : "http://loinc.org",
"version" : "2.77",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"

View File

@ -511,6 +511,23 @@ v: {
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
"valueUrl" : "http://tx-dev.fhir.org/r4"
}],
"severity" : "information",
"code" : "invalid",
"details" : {
"coding" : [{
"system" : "http://hl7.org/fhir/tools/CodeSystem/tx-issue-type",
"code" : "code-rule"
}],
"text" : "The code '1419004' is valid but is not active"
},
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
@ -867,6 +884,23 @@ v: {
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
"valueUrl" : "http://tx-dev.fhir.org/r4"
}],
"severity" : "information",
"code" : "invalid",
"details" : {
"coding" : [{
"system" : "http://hl7.org/fhir/tools/CodeSystem/tx-issue-type",
"code" : "code-rule"
}],
"text" : "The code '324252006' is valid but is not active"
},
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
@ -1126,6 +1160,23 @@ v: {
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
"valueUrl" : "http://tx-dev.fhir.org/r4"
}],
"severity" : "information",
"code" : "invalid",
"details" : {
"coding" : [{
"system" : "http://hl7.org/fhir/tools/CodeSystem/tx-issue-type",
"code" : "code-rule"
}],
"text" : "The code '602001' is valid but is not active"
},
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
@ -1707,6 +1758,23 @@ v: {
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
"valueUrl" : "http://tx-dev.fhir.org/r4"
}],
"severity" : "information",
"code" : "invalid",
"details" : {
"coding" : [{
"system" : "http://hl7.org/fhir/tools/CodeSystem/tx-issue-type",
"code" : "code-rule"
}],
"text" : "The code '1419004' is valid but is not active"
},
"location" : ["CodeableConcept.coding[0].code"],
"expression" : ["CodeableConcept.coding[0].code"]
},
{
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-server",
@ -8395,7 +8463,6 @@ v: {
"system" : "http://snomed.info/sct",
"version" : "http://snomed.info/sct/900000000000207008/version/20240201",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -8418,6 +8485,77 @@ v: {
"system" : "http://snomed.info/sct",
"version" : "http://snomed.info/sct/900000000000207008/version/20240201",
"server" : "http://tx-dev.fhir.org/r4",
"issues" : {
"resourceType" : "OperationOutcome"
}
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "442476006",
"display" : "Arterial oxygen saturation"
}, "valueSet" :null, "langs":"", "useServer":"true", "useClient":"false", "guessSystem":"false", "activeOnly":"false", "membershipOnly":"false", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
"resourceType" : "Parameters",
"parameter" : [{
"name" : "profile-url",
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
}]
}}####
v: {
"display" : "Arterial oxygen saturation",
"code" : "442476006",
"system" : "http://snomed.info/sct",
"version" : "http://snomed.info/sct/900000000000207008/version/20240201",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "427081008",
"display" : "Delivered oxygen flow rate"
}, "valueSet" :null, "langs":"", "useServer":"true", "useClient":"false", "guessSystem":"false", "activeOnly":"false", "membershipOnly":"false", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
"resourceType" : "Parameters",
"parameter" : [{
"name" : "profile-url",
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
}]
}}####
v: {
"display" : "Delivered oxygen flow rate (observable entity)",
"code" : "427081008",
"system" : "http://snomed.info/sct",
"version" : "http://snomed.info/sct/900000000000207008/version/20240201",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "250774007",
"display" : "Inspired oxygen concentration"
}, "valueSet" :null, "langs":"", "useServer":"true", "useClient":"false", "guessSystem":"false", "activeOnly":"false", "membershipOnly":"false", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
"resourceType" : "Parameters",
"parameter" : [{
"name" : "profile-url",
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
}]
}}####
v: {
"display" : "Inspired oxygen concentration",
"code" : "250774007",
"system" : "http://snomed.info/sct",
"version" : "http://snomed.info/sct/900000000000207008/version/20240201",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"

View File

@ -1272,7 +1272,6 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -1295,7 +1294,6 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -1318,7 +1316,6 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -1341,7 +1338,6 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -1364,7 +1360,6 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -1387,7 +1382,6 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -1410,7 +1404,6 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"
}
@ -1433,6 +1426,28 @@ v: {
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"issues" : {
"resourceType" : "OperationOutcome"
}
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://unitsofmeasure.org",
"code" : "%"
}, "url": "http://hl7.org/fhir/test/ValueSet/UcumVitalsCommonDE", "version": "1.5.0", "langs":"", "useServer":"true", "useClient":"true", "guessSystem":"false", "activeOnly":"false", "membershipOnly":"false", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
"resourceType" : "Parameters",
"parameter" : [{
"name" : "profile-url",
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
}]
}}####
v: {
"display" : "%",
"code" : "%",
"system" : "http://unitsofmeasure.org",
"version" : "2.0.1",
"server" : "http://tx-dev.fhir.org/r4",
"unknown-systems" : "",
"issues" : {
"resourceType" : "OperationOutcome"