fix problems setting owning committee consistently

This commit is contained in:
Grahame Grieve 2023-12-12 16:52:11 +13:00
parent f9e11e22c1
commit cc424a04e1
3 changed files with 35 additions and 6 deletions

View File

@ -64,6 +64,7 @@ import org.hl7.fhir.r5.model.IntegerType;
import org.hl7.fhir.r5.model.Meta; import org.hl7.fhir.r5.model.Meta;
import org.hl7.fhir.r5.model.StringType; import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.utils.CanonicalResourceUtilities;
import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor;
@ -504,7 +505,7 @@ public class CodeSystemUtilities extends TerminologyUtilities {
if (wg != null) { if (wg != null) {
if (!ToolingExtensions.hasExtension(cs, ToolingExtensions.EXT_WORKGROUP) || if (!ToolingExtensions.hasExtension(cs, ToolingExtensions.EXT_WORKGROUP) ||
(Utilities.existsInList(ToolingExtensions.readStringExtension(cs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && !Utilities.existsInList(wg, "fhir", "vocab"))) { (Utilities.existsInList(ToolingExtensions.readStringExtension(cs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && !Utilities.existsInList(wg, "fhir", "vocab"))) {
ToolingExtensions.setCodeExtension(cs, ToolingExtensions.EXT_WORKGROUP, wg); CanonicalResourceUtilities.setHl7WG(cs, wg);
} }
} }
if (status != null) { if (status != null) {

View File

@ -64,6 +64,7 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionPropertyComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionPropertyComponent;
import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.ConceptDefinitionComponentSorter; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.ConceptDefinitionComponentSorter;
import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.ConceptStatus; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.ConceptStatus;
import org.hl7.fhir.r5.utils.CanonicalResourceUtilities;
import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.StandardsStatus; import org.hl7.fhir.utilities.StandardsStatus;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
@ -139,7 +140,7 @@ public class ValueSetUtilities extends TerminologyUtilities {
if (wg != null) { if (wg != null) {
if (!ToolingExtensions.hasExtension(vs, ToolingExtensions.EXT_WORKGROUP) || if (!ToolingExtensions.hasExtension(vs, ToolingExtensions.EXT_WORKGROUP) ||
(!Utilities.existsInList(ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && Utilities.existsInList(wg, "fhir", "vocab"))) { (!Utilities.existsInList(ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && Utilities.existsInList(wg, "fhir", "vocab"))) {
ToolingExtensions.setCodeExtension(vs, ToolingExtensions.EXT_WORKGROUP, wg); CanonicalResourceUtilities.setHl7WG(vs, wg);
} }
} }
if (status != null) { if (status != null) {

View File

@ -6,6 +6,8 @@ import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CompartmentDefinition; import org.hl7.fhir.r5.model.CompartmentDefinition;
import org.hl7.fhir.r5.model.Constants; import org.hl7.fhir.r5.model.Constants;
import org.hl7.fhir.r5.model.ContactDetail;
import org.hl7.fhir.r5.model.ContactPoint;
import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem; import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem;
import org.hl7.fhir.utilities.HL7WorkGroups; import org.hl7.fhir.utilities.HL7WorkGroups;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
@ -14,17 +16,33 @@ import org.hl7.fhir.utilities.xml.XMLUtil;
public class CanonicalResourceUtilities { public class CanonicalResourceUtilities {
public static void setHl7WG(CanonicalResource cr, String wgc) { public static void setHl7WG(CanonicalResource cr, String wgc) {
if ("http://hl7.org/fhir/days-of-week".equals(cr.getUrl())) {
System.out.println("!");
}
var wg = HL7WorkGroups.find(wgc); var wg = HL7WorkGroups.find(wgc);
if (wg == null) { if (wg == null) {
throw new Error("Unknown WG "+wgc); throw new Error("Unknown WG "+wgc);
} }
ToolingExtensions.setCodeExtension(cr, ToolingExtensions.EXT_WORKGROUP, wg.getCode()); ToolingExtensions.setCodeExtension(cr, ToolingExtensions.EXT_WORKGROUP, wg.getCode());
cr.setPublisher("HL7 International / "+wg.getName()); cr.setPublisher("HL7 International / "+wg.getName());
cr.getContact().clear(); boolean found = false;
for (ContactDetail c : cr.getContact()) {
for (ContactPoint t : c.getTelecom()) {
if ((t.getSystem() == ContactPointSystem.URL) && wg.getLink().equals(t.getValue())) {
found = true;
}
}
}
if (!found) {
cr.addContact().addTelecom().setSystem(ContactPointSystem.URL).setValue(wg.getLink()); cr.addContact().addTelecom().setSystem(ContactPointSystem.URL).setValue(wg.getLink());
} }
}
public static void setHl7WG(CanonicalResource cr) { public static void setHl7WG(CanonicalResource cr) {
if ("http://hl7.org/fhir/days-of-week".equals(cr.getUrl())) {
System.out.println("!");
}
String wgc = ToolingExtensions.readStringExtension(cr, ToolingExtensions.EXT_WORKGROUP); String wgc = ToolingExtensions.readStringExtension(cr, ToolingExtensions.EXT_WORKGROUP);
if (wgc == null) { if (wgc == null) {
wgc = "fhir"; wgc = "fhir";
@ -35,9 +53,18 @@ public class CanonicalResourceUtilities {
} }
ToolingExtensions.setCodeExtension(cr, ToolingExtensions.EXT_WORKGROUP, wg.getCode()); ToolingExtensions.setCodeExtension(cr, ToolingExtensions.EXT_WORKGROUP, wg.getCode());
cr.setPublisher("HL7 International / "+wg.getName()); cr.setPublisher("HL7 International / "+wg.getName());
cr.getContact().clear(); boolean found = false;
for (ContactDetail c : cr.getContact()) {
for (ContactPoint t : c.getTelecom()) {
if ((t.getSystem() == ContactPointSystem.URL) && wg.getLink().equals(t.getValue())) {
found = true;
}
}
}
if (!found) {
cr.addContact().addTelecom().setSystem(ContactPointSystem.URL).setValue(wg.getLink()); cr.addContact().addTelecom().setSystem(ContactPointSystem.URL).setValue(wg.getLink());
} }
}
public static void setHl7WG(Element res, String code) { public static void setHl7WG(Element res, String code) {
if (VersionUtilities.getExtendedCanonicalResourceNames(res.getFHIRPublicationVersion().toCode()).contains(res.fhirType())) { if (VersionUtilities.getExtendedCanonicalResourceNames(res.getFHIRPublicationVersion().toCode()).contains(res.fhirType())) {