Search in sources :

Example 11 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class DataRequirement30_50 method convertDataRequirementCodeFilterComponent.

public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException {
    if (src == null)
        return null;
    org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent();
    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
    if (src.hasPath())
        tgt.setPathElement(String30_50.convertString(src.getPathElement()));
    if (src.hasValueSet()) {
        DataType t = ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValueSet());
        if (t instanceof org.hl7.fhir.r5.model.Reference)
            tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference());
        else
            tgt.setValueSet(t.primitiveValue());
        tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
    }
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getValueCode()) tgt.addCode(Coding30_50.convertCoding(t));
    for (org.hl7.fhir.dstu3.model.Coding t : src.getValueCoding()) tgt.addCode(Coding30_50.convertCoding(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getValueCodeableConcept()) tgt.addCode(Coding30_50.convertCoding(t));
    return tgt;
}
Also used : DataType(org.hl7.fhir.r5.model.DataType)

Example 12 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class ISO21090Importer method generateType.

private void generateType(DataType dt) throws Exception {
    StructureDefinition sd = new StructureDefinition();
    sd.setId(dt.getName());
    sd.setUrl("http://hl7.org/fhir/iso21090/StructureDefinition/" + sd.getId());
    sd.setName(dt.getName() + " data type");
    sd.setStatus(PublicationStatus.ACTIVE);
    sd.setExperimental(false);
    sd.setPublisher("HL7 / ISO");
    sd.setDate(new Date());
    sd.setDescription(dt.getDoco());
    sd.setKind(StructureDefinitionKind.LOGICAL);
    sd.setAbstract(Utilities.existsInList(dt.getName(), "HXIT", "QTY"));
    sd.setType("Element");
    if (dt.getParent() == null)
        sd.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
    else
        sd.setBaseDefinition("http://hl7.org/fhir/iso21090/StructureDefinition/" + dt.getParent());
    sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
    ElementDefinition ed = sd.getDifferential().addElement();
    ed.setPath(dt.getName());
    produceProperties(sd.getDifferential().getElement(), dt.getName(), dt.getProperties(), true, false);
    produceProperties(sd.getDifferential().getElement(), dt.getName(), dt.getProperties(), false, false);
    ed = sd.getSnapshot().addElement();
    ed.setPath(dt.getName());
    if (dt.getParent() != null)
        addParentProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getParent(), true, true);
    produceProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getProperties(), true, true);
    if (dt.getParent() != null)
        addParentProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getParent(), false, true);
    produceProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getProperties(), false, true);
    ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "iso21090\\StructureDefinition-" + dt.getName() + ".xml")), sd);
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) FileOutputStream(java.io.FileOutputStream) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition)

Example 13 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class ISO21090Importer method addParentProperties.

private void addParentProperties(List<ElementDefinition> elements, String name, String parent, boolean attrMode, boolean snapshot) throws FHIRFormatError {
    DataType dt = types.get(parent);
    if (dt == null)
        throw new Error("No find " + parent);
    if (dt.getParent() != null)
        addParentProperties(elements, name, dt.getParent(), attrMode, snapshot);
    produceProperties(elements, name, dt.getProperties(), attrMode, snapshot);
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 14 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class ExpansionProfile30_50 method convertExpansionProfile.

public static org.hl7.fhir.dstu3.model.ExpansionProfile convertExpansionProfile(org.hl7.fhir.r5.model.Parameters src) throws FHIRException {
    if (src == null)
        return null;
    org.hl7.fhir.dstu3.model.ExpansionProfile tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile();
    if (src.hasParameter("profile-url"))
        tgt.setUrl(src.getParameter("profile-url").primitiveValue());
    if (src.hasParameter("profile-version"))
        tgt.setVersion(src.getParameter("profile-version").primitiveValue());
    if (src.hasParameter("profile-name"))
        tgt.setName(src.getParameter("profile-name").primitiveValue());
    if (src.hasParameter("profile-status"))
        tgt.setStatus(PublicationStatus.fromCode(src.getParameter("profile-status").primitiveValue()));
    for (DataType t : src.getParameters("system-version")) {
        String[] v = t.primitiveValue().split("\\|");
        tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.DEFAULT);
    }
    for (DataType t : src.getParameters("force-system-version")) {
        String[] v = t.primitiveValue().split("\\|");
        tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.OVERRIDE);
    }
    for (DataType t : src.getParameters("check-system-version")) {
        String[] v = t.primitiveValue().split("\\|");
        tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.CHECK);
    }
    for (DataType t : src.getParameters("exclude-system")) {
        String[] v = t.primitiveValue().split("\\|");
        tgt.getExcludedSystem().setSystem(v[0]).setVersion(v[1]);
    }
    if (src.hasParameter("includeDesignations"))
        tgt.setIncludeDesignations(src.getParameterBool(""));
    for (DataType t : src.getParameters("designation")) {
        String[] v = t.primitiveValue().split("\\|");
        if ("urn:ietf:bcp:47".equals(v[0]))
            tgt.getDesignation().getInclude().addDesignation().setLanguage(v[1]);
        else
            tgt.getDesignation().getInclude().addDesignation().getUse().setSystem(v[0]).setCode(v[1]);
    }
    if (src.hasParameter("includeDefinition"))
        tgt.setIncludeDefinition(src.getParameterBool("includeDefinition"));
    if (src.hasParameter("activeOnly"))
        tgt.setActiveOnly(src.getParameterBool("activeOnly"));
    if (src.hasParameter("excludeNested"))
        tgt.setExcludeNested(src.getParameterBool("excludeNested"));
    if (src.hasParameter("excludeNotForUI"))
        tgt.setExcludeNotForUI(src.getParameterBool("excludeNotForUI"));
    if (src.hasParameter("excludeNotForUI"))
        tgt.setExcludePostCoordinated(src.getParameterBool("excludeNotForUI"));
    if (src.hasParameter("displayLanguage"))
        tgt.setDisplayLanguage(src.getParameter("displayLanguage").primitiveValue());
    if (src.hasParameter("limitedExpansion"))
        tgt.setLimitedExpansion(src.getParameterBool("getParameterBool"));
    return tgt;
}
Also used : DataType(org.hl7.fhir.r5.model.DataType)

Example 15 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class TurtleParser method parseResource.

private void parseResource(Turtle src, String npath, TTLComplex object, Element context, Property property, String name, TTLObject e) throws FHIRFormatError, DefinitionException {
    TTLComplex obj;
    if (e instanceof TTLComplex)
        obj = (TTLComplex) e;
    else if (e instanceof TTLURL) {
        String url = ((TTLURL) e).getUri();
        obj = src.getObject(url);
        if (obj == null) {
            logError(e.getLine(), e.getCol(), npath, IssueType.INVALID, "reference to " + url + " cannot be resolved", IssueSeverity.FATAL);
            return;
        }
    } else
        throw new FHIRFormatError("Wrong type for resource");
    TTLObject type = obj.getPredicates().get("http://www.w3.org/2000/01/rdf-schema#type");
    if (type == null) {
        logError(object.getLine(), object.getCol(), npath, IssueType.INVALID, "Unknown resource type (missing rdfs:type)", IssueSeverity.FATAL);
        return;
    }
    if (type instanceof TTLList) {
        // this is actually broken - really we have to look through the structure definitions at this point
        for (TTLObject tobj : ((TTLList) type).getList()) {
            if (tobj instanceof TTLURL && ((TTLURL) tobj).getUri().startsWith(FHIR_URI_BASE)) {
                type = tobj;
                break;
            }
        }
    }
    if (!(type instanceof TTLURL)) {
        logError(object.getLine(), object.getCol(), npath, IssueType.INVALID, "Unexpected datatype for rdfs:type)", IssueSeverity.FATAL);
        return;
    }
    String rt = ((TTLURL) type).getUri();
    String ns = rt.substring(0, rt.lastIndexOf("/"));
    rt = rt.substring(rt.lastIndexOf("/") + 1);
    StructureDefinition sd = getDefinition(object.getLine(), object.getCol(), ns, rt);
    if (sd == null)
        return;
    Element n = new Element(tail(name), property).markLocation(object.getLine(), object.getCol());
    context.getChildren().add(n);
    n.updateProperty(new Property(this.context, sd.getSnapshot().getElement().get(0), sd), SpecialElement.fromProperty(n.getProperty()), property);
    n.setType(rt);
    parseChildren(src, npath, obj, n, false);
}
Also used : TTLComplex(org.hl7.fhir.dstu3.utils.formats.Turtle.TTLComplex) StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) SpecialElement(org.hl7.fhir.dstu3.elementmodel.Element.SpecialElement) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) TTLURL(org.hl7.fhir.dstu3.utils.formats.Turtle.TTLURL) TTLObject(org.hl7.fhir.dstu3.utils.formats.Turtle.TTLObject) TTLList(org.hl7.fhir.dstu3.utils.formats.Turtle.TTLList)

Aggregations

DataType (org.hl7.fhir.r5.model.DataType)14 FHIRException (org.hl7.fhir.exceptions.FHIRException)11 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)11 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)8 HashMap (java.util.HashMap)7 List (java.util.List)7 Map (java.util.Map)7 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)7 Collectors (java.util.stream.Collectors)6 DataType (org.hl7.cql.model.DataType)6 ModelInfo (org.hl7.elm_modelinfo.r1.ModelInfo)6 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)6 ArrayList (java.util.ArrayList)5 StructType (org.apache.spark.sql.types.StructType)5 BooleanType (org.hl7.fhir.r5.model.BooleanType)5 ValueSet (org.hl7.fhir.r5.model.ValueSet)5 Arrays (java.util.Arrays)4 QName (javax.xml.namespace.QName)4 DataType (org.hl7.fhir.r4b.model.DataType)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3