vsac improvements

This commit is contained in:
Grahame Grieve 2023-11-06 20:23:17 +11:00
parent b2c4da5aae
commit 841de5657e
4 changed files with 6058 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.r4.model.OperationOutcome.IssueType;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.utils.client.FHIRToolingClient;
import org.hl7.fhir.r4.terminologies.JurisdictionUtilities;
import org.hl7.fhir.utilities.CSVReader;
import org.hl7.fhir.utilities.Utilities;
@ -62,6 +63,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
errs.put(oid, "Expansion: " +e.getMessage());
System.out.println(e.getMessage());
}
if (vs.hasTitle()) {
if (vs.getTitle().equals(vs.getDescription())) {
vs.setTitle(vs.getName());
@ -75,6 +77,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
vs.setTitle(vs.getName());
}
vs.setName(makeValidName(vs.getName()));
JurisdictionUtilities.setJurisdictionCountry(vs.getJurisdiction(), "US");
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
}
i++;

View File

@ -52,6 +52,7 @@ import org.hl7.fhir.r4.model.Meta;
import org.hl7.fhir.r4.model.Type;
import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.utils.ToolingExtensions;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.utilities.StandardsStatus;
import org.hl7.fhir.utilities.Utilities;
@ -80,6 +81,11 @@ public class CodeSystemUtilities {
PropertyType.BOOLEAN);
}
public static Coding readCoding(String jurisdiction) {
return jurisdiction == null || !jurisdiction.contains("#") ? null : new Coding().setCode(jurisdiction.substring(jurisdiction.indexOf("#")+1)).setSystem(jurisdiction.substring(0, jurisdiction.indexOf("#")));
}
public enum ConceptStatus {
Active, Experimental, Deprecated, Retired;

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.r5.terminologies;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.utilities.Utilities;
@ -6015,5 +6019,16 @@ public class JurisdictionUtilities {
public static boolean isJurisdiction(String system) {
return Utilities.existsInList(system, "http://unstats.un.org/unsd/methods/m49/m49.htm", "urn:iso:std:iso:3166", "urn:iso:std:iso:3166:-2");
}
public static void setJurisdictionCountry(List<CodeableConcept> list, String code) {
CodeableConcept cc = new CodeableConcept();
cc.addCoding().setCode(code).setSystem("urn:iso:std:iso:3166");
String disp = country(cc.getCodingFirstRep());
if (disp.contains("Unknown country")) {
throw new FHIRException(disp);
}
list.clear();
list.add(cc);
}
}