use of org.hl7.v3.TS in project kindling by HL7.
the class CDAGenerator method addValueAttribute.
private void addValueAttribute(List<ElementDefinition> list, String dtn, String t) {
ElementDefinition ed = new ElementDefinition();
ed.setPath(dtn + ".value");
seePath(ed);
ed.setMin(0);
ed.setMax("1");
ed.addType().setCode(t);
if (dtn.equals("ST"))
ed.addRepresentation(PropertyRepresentation.XMLTEXT);
else
ed.addRepresentation(PropertyRepresentation.XMLATTR);
if (dtn.equals("TS"))
ed.addExtension().setUrl("http://www.healthintersections.com.au/fhir/StructureDefinition/elementdefinition-dateformat").setValue(new StringType("v3"));
list.add(ed);
}
use of org.hl7.v3.TS in project kindling by HL7.
the class CDAGenerator method processDataType.
private void processDataType(Element dt, String n, String p) throws FileNotFoundException, IOException, FHIRFormatError, DefinitionException {
if (!Utilities.existsInList(n, "TYPE", "BN", "BIN", "CO", "UID", "OID", "UUID", "RUID", "URL", "ADXP", "ENXP", "PN", "TN", "ON", "RTO", "CAL", "CLCY", "SET", "LIST", "GLIST", "SLIST", "BAG", "HXIT", "HIST", "UVP", "NPPD", "PPD")) {
if (n.equals("GTS"))
n = "SXCM_TS";
System.out.print(" " + n);
StructureDefinition sd = new StructureDefinition();
sd.setId(fix(n));
sd.setUrl("http://hl7.org/fhir/cda/StructureDefinition/" + fix(n));
library.put(sd.getUrl(), sd);
sd.setName("V3 Data type " + n + " (" + dt.getAttribute("title") + ")");
sd.setTitle(sd.getName());
sd.setStatus(PublicationStatus.ACTIVE);
sd.setExperimental(false);
sd.setPublisher("HL7");
sd.setDescription(getDefinition(dt));
sd.setType(sd.getUrl());
sd.setKind(StructureDefinitionKind.LOGICAL);
sd.setAbstract("true".equals(dt.getAttribute("isAbstract")));
sd.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:v3"));
Element derived = XMLUtil.getNamedChild(dt, "mif:derivedFrom");
if (Utilities.existsInList(n, "ST", "ED", "TEL", "AD", "EN", "IVL_PQ", "IVL_INT", "TS")) {
sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/ANY");
} else if (Utilities.existsInList(n, "SXCM_TS")) {
sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/TS");
} else if (n.equals("PIVL_TS") || n.equals("EIVL_TS") || n.equals("IVL_TS")) {
sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/SXCM_TS");
} else if (derived != null) {
sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/" + XMLUtil.getNamedChildAttribute(derived, "mif:targetDatatype", "name"));
} else
sd.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
ElementDefinition edb = new ElementDefinition();
edb.setPath(sd.getId());
seePath(edb);
edb.setMin(1);
edb.setMax("*");
edb.addType().setCode("Element");
sd.getDifferential().getElement().add(edb);
if (n.equals("ED"))
addEDElements(sd.getDifferential().getElement());
if (n.equals("SC"))
copyAttributes(sd, getDefinition("CV"), "code", "codeSystem", "codeSystemVersion", "displayName");
if (primitiveTypes.containsKey(n))
addValueAttribute(sd.getDifferential().getElement(), n, primitiveTypes.get(n));
if (n.equals("TS"))
edb.addExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-timeformat", new CodeType("YYYYMMDDHHMMSS.UUUU[+|-ZZzz]"));
if (n.equals("TEL"))
addValueAttribute(sd.getDifferential().getElement(), n, "uri");
if (n.equals("SXCM_TS")) {
addOperatorAttribute(sd.getDifferential().getElement(), "SXCM_TS");
sd.setAbstract(true);
}
if (n.equals("AD")) {
addParts(sd.getDifferential().getElement(), n, "delimiter", "country", "state", "county", "city", "postalCode", "streetAddressLine", "houseNumber", "houseNumberNumeric", "direction", "streetName", "streetNameBase", "streetNameType", "additionalLocator", "unitID", "unitType", "careOf", "censusTract", "deliveryAddressLine", "deliveryInstallationType", "deliveryInstallationArea", "deliveryInstallationQualifier", "deliveryMode", "deliveryModeIdentifier", "buildingNumberSuffix", "postBox", "precinct");
addTextItem(sd.getDifferential().getElement(), n);
}
if (n.equals("EN")) {
addParts(sd.getDifferential().getElement(), n, "delimiter", "family", "given", "prefix", "suffix");
addTextItem(sd.getDifferential().getElement(), n);
}
List<Element> props = new ArrayList<Element>();
XMLUtil.getNamedChildren(dt, "mif:property", props);
for (Element prop : props) {
processProperty(sd.getDifferential().getElement(), n, prop, p);
}
if (n.equals("TS") || n.equals("PQ"))
addInclusiveAttribute(sd.getDifferential().getElement(), n);
if (n.equals("CE") || n.equals("CV") || n.equals("CD"))
addCDExtensions(sd.getDifferential().getElement(), n);
new ProfileUtilities(null, null, null).setIds(sd, true);
structures.add(sd);
}
}
use of org.hl7.v3.TS in project kindling by HL7.
the class CDAGenerator method processDataTypes.
private void processDataTypes(String filename) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException, FHIRFormatError, DefinitionException {
System.out.println("Process Data Types");
Document dtMif = XMLUtil.parseFileToDom(filename);
List<Element> dts = new ArrayList<Element>();
XMLUtil.getNamedChildren(dtMif.getDocumentElement(), "mif:datatype", dts);
for (Element dt : dts) {
String n = dt.getAttribute("name");
types.put(n, dt);
if (n.equals("IVL")) {
processDataType(dt, n + "_TS", "TS");
processDataType(dt, n + "_PQ", "PQ");
processDataType(dt, n + "_INT", "INT");
} else if (n.equals("PIVL")) {
processDataType(dt, n + "_TS", null);
} else if (n.equals("EIVL")) {
processDataType(dt, n + "_TS", null);
} else if (n.equals("RTO")) {
processDataType(dt, n + "_PQ_PQ", "PQ");
} else if (!"Binding".equals(dt.getAttribute("datatypeKind")))
processDataType(dt, n, null);
}
buildSXPR();
buildInfrastructureRoot();
for (StructureDefinition sd : structures) {
// if (!sd.getAbstract())
generateSnapShot(sd);
}
System.out.println(" ... done");
}
use of org.hl7.v3.TS in project kindling by HL7.
the class SourceParser method loadCompositeType.
private String loadCompositeType(String n, Map<String, org.hl7.fhir.definitions.model.TypeDefn> map, String fmm, boolean isAbstract) throws Exception {
TypeParser tp = new TypeParser(version.toString());
List<TypeRef> ts = tp.parse(n, false, null, context, true);
definitions.getKnownTypes().addAll(ts);
StandardsStatus status = loadStatus(n);
String nv = loadNormativeVersion(n);
try {
TypeRef t = ts.get(0);
File csv = new CSFile(dtDir + t.getName().toLowerCase() + ".xml");
if (csv.exists()) {
OldSpreadsheetParser p = new OldSpreadsheetParser("core", new CSFileInputStream(csv), csv.getName(), csv.getAbsolutePath(), definitions, srcDir, logger, registry, version, context, genDate, isAbstract, page, true, ini, wg("fhir"), definitions.getProfileIds(), fpUsages, page.getConceptMaps(), exceptionIfExcelNotNormalised, page.packageInfo(), page.getRc());
org.hl7.fhir.definitions.model.TypeDefn el = p.parseCompositeType();
el.setFmmLevel(fmm);
el.setStandardsStatus(status);
el.setNormativeVersion(nv);
map.put(t.getName(), el);
genTypeProfile(el);
errors.addAll(p.getErrors());
return el.getName();
} else {
String p = ini.getStringProperty("types", n);
csv = new CSFile(dtDir + p.toLowerCase() + ".xml");
if (!csv.exists())
throw new Exception("unable to find a definition for " + n + " in " + p);
XLSXmlParser xls = new XLSXmlParser(new CSFileInputStream(csv), csv.getAbsolutePath());
new XLSXmlNormaliser(csv.getAbsolutePath(), exceptionIfExcelNotNormalised).go();
Sheet sheet = xls.getSheets().get("Restrictions");
boolean found = false;
for (int i = 0; i < sheet.rows.size(); i++) {
if (sheet.getColumn(i, "Name").equals(n)) {
found = true;
Invariant inv = new Invariant();
inv.setId(n);
inv.setEnglish(sheet.getColumn(i, "Rules"));
inv.setOcl(sheet.getColumn(i, "OCL"));
inv.setXpath(sheet.getColumn(i, "XPath"));
inv.setExpression(sheet.getColumn(i, "Expression"));
inv.setExplanation(sheet.getColumn(i, "Explanation"));
inv.setTurtle(sheet.getColumn(i, "RDF"));
ProfiledType pt = new ProfiledType();
pt.setDefinition(sheet.getColumn(i, "Definition"));
pt.setDescription(sheet.getColumn(i, "Rules"));
String structure = sheet.getColumn(i, "Structure");
if (!Utilities.noString(structure)) {
String[] parts = structure.split("\\;");
for (String pp : parts) {
String[] words = pp.split("\\=");
pt.getRules().put(words[0], words[1]);
}
}
pt.setName(n);
pt.setBaseType(p);
pt.setInvariant(inv);
definitions.getConstraints().put(n, pt);
}
}
if (!found)
throw new Exception("Unable to find definition for " + n);
return n;
}
} catch (Exception e) {
throw new Exception("Unable to load " + n + ": " + e.getMessage(), e);
}
}
use of org.hl7.v3.TS in project kindling by HL7.
the class ElementDefn method typeCodeBase.
public String typeCodeBase() {
List<String> ts = new ArrayList<>();
for (TypeRef t : types) {
ts.add(t.getName());
}
Collections.sort(ts);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String t : ts) b.append(t);
return b.toString();
}
Aggregations