Search in sources :

Example 6 with ListResourceEntryComponent

use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class ResourceParser method parsePacks.

private void parsePacks(ResourceDefn r, String n, String t) throws Exception {
    Set<String> codes = new HashSet<>();
    ListResource list = (ListResource) parseXml("list-" + t + "-packs.xml");
    for (ListResourceEntryComponent le : list.getEntry()) {
        String id = le.getItem().getReference().substring(le.getItem().getReference().indexOf("/") + 1);
        if (codes.contains(id)) {
            throw new FHIRException("Duplicate code " + id + " for resource " + n);
        }
        codes.add(id);
        ImplementationGuide ig = (ImplementationGuide) parseXml("implementationguide-" + id + ".xml");
        if (!id.startsWith(r.getName() + "-")) {
            throw new FHIRException("Illegal ig name " + id + " - should start with " + r.getName() + "-");
        }
        id = id.substring(t.length() + 1);
        r.getConformancePackages().add(convertPack(ig, id, r.getWg()));
    }
}
Also used : ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) ListResource(org.hl7.fhir.r5.model.ListResource) FHIRException(org.hl7.fhir.exceptions.FHIRException) HashSet(java.util.HashSet)

Example 7 with ListResourceEntryComponent

use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class Regenerator method generatePacks.

public void generatePacks(ResourceDefn r, String root) throws IOException {
    ListResource list = new ListResource();
    list.setId(r.getName() + "-packs");
    list.setStatus(ListStatus.CURRENT);
    list.setMode(ListMode.WORKING);
    // }
    for (Profile p : r.getConformancePackages()) {
        ListResourceEntryComponent li = list.addEntry();
        li.getItem().setReference("ImplementationGuide/" + r.getName() + "-" + p.getCategory());
    }
    File fn = new File(Utilities.path(root, list.fhirType().toLowerCase() + "-" + list.getId() + ".gen.xml"));
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), list);
    fn.setLastModified(r.getTimestamp());
    // }
    for (Profile p : r.getConformancePackages()) {
        generateCP(root, r, p);
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) FileOutputStream(java.io.FileOutputStream) ListResource(org.hl7.fhir.r5.model.ListResource) File(java.io.File) Profile(org.hl7.fhir.definitions.model.Profile)

Example 8 with ListResourceEntryComponent

use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project org.hl7.fhir.core by hapifhir.

the class ListRenderer method render.

public boolean render(XhtmlNode x, ListResource list) throws FHIRFormatError, DefinitionException, IOException {
    if (list.hasTitle()) {
        x.h2().tx(list.getTitle());
    }
    XhtmlNode t = x.table("clstu");
    XhtmlNode tr = t.tr();
    if (list.hasDate()) {
        tr.td().tx("Date: " + list.getDate().toLocaleString());
    }
    if (list.hasMode()) {
        tr.td().tx("Mode: " + list.getMode().getDisplay());
    }
    if (list.hasStatus()) {
        tr.td().tx("Status: " + list.getStatus().getDisplay());
    }
    if (list.hasCode()) {
        tr.td().tx("Code: " + display(list.getCode()));
    }
    tr = t.tr();
    if (list.hasSubject()) {
        shortForRef(tr.td().txN("Subject: "), list.getSubject());
    }
    if (list.hasEncounter()) {
        shortForRef(tr.td().txN("Encounter: "), list.getEncounter());
    }
    if (list.hasSource()) {
        shortForRef(tr.td().txN("Source: "), list.getEncounter());
    }
    if (list.hasOrderedBy()) {
        tr.td().tx("Order: " + display(list.getOrderedBy()));
    }
    for (Annotation a : list.getNote()) {
        renderAnnotation(x, a);
    }
    boolean flag = false;
    boolean deleted = false;
    boolean date = false;
    for (ListResourceEntryComponent e : list.getEntry()) {
        flag = flag || e.hasFlag();
        deleted = deleted || e.hasDeleted();
        date = date || e.hasDate();
    }
    t = x.table("grid");
    tr = t.tr().style("backgound-color: #eeeeee");
    tr.td().b().tx("Items");
    if (date) {
        tr.td().tx("Date");
    }
    if (flag) {
        tr.td().tx("Flag");
    }
    if (deleted) {
        tr.td().tx("Deleted");
    }
    for (ListResourceEntryComponent e : list.getEntry()) {
        tr = t.tr();
        shortForRef(tr.td(), e.getItem());
        if (date) {
            tr.td().tx(e.hasDate() ? e.getDate().toLocaleString() : "");
        }
        if (flag) {
            tr.td().tx(e.hasFlag() ? display(e.getFlag()) : "");
        }
        if (deleted) {
            tr.td().tx(e.hasDeleted() ? Boolean.toString(e.getDeleted()) : "");
        }
    }
    return false;
}
Also used : ListResourceEntryComponent(org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent) Annotation(org.hl7.fhir.r4b.model.Annotation) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 9 with ListResourceEntryComponent

use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project org.hl7.fhir.core by hapifhir.

the class ListRenderer method render.

public boolean render(XhtmlNode x, ListResource list) throws FHIRFormatError, DefinitionException, IOException {
    if (list.hasTitle()) {
        x.h2().tx(list.getTitle());
    }
    XhtmlNode t = x.table("clstu");
    XhtmlNode tr = t.tr();
    if (list.hasDate()) {
        tr.td().tx("Date: " + list.getDate().toLocaleString());
    }
    if (list.hasMode()) {
        tr.td().tx("Mode: " + list.getMode().getDisplay());
    }
    if (list.hasStatus()) {
        tr.td().tx("Status: " + list.getStatus().getDisplay());
    }
    if (list.hasCode()) {
        tr.td().tx("Code: " + display(list.getCode()));
    }
    tr = t.tr();
    if (list.hasSubject()) {
        shortForRef(tr.td().txN("Subject: "), list.getSubject());
    }
    if (list.hasEncounter()) {
        shortForRef(tr.td().txN("Encounter: "), list.getEncounter());
    }
    if (list.hasSource()) {
        shortForRef(tr.td().txN("Source: "), list.getEncounter());
    }
    if (list.hasOrderedBy()) {
        tr.td().tx("Order: " + display(list.getOrderedBy()));
    }
    for (Annotation a : list.getNote()) {
        renderAnnotation(x, a);
    }
    boolean flag = false;
    boolean deleted = false;
    boolean date = false;
    for (ListResourceEntryComponent e : list.getEntry()) {
        flag = flag || e.hasFlag();
        deleted = deleted || e.hasDeleted();
        date = date || e.hasDate();
    }
    t = x.table("grid");
    tr = t.tr().style("backgound-color: #eeeeee");
    tr.td().b().tx("Items");
    if (date) {
        tr.td().tx("Date");
    }
    if (flag) {
        tr.td().tx("Flag");
    }
    if (deleted) {
        tr.td().tx("Deleted");
    }
    for (ListResourceEntryComponent e : list.getEntry()) {
        tr = t.tr();
        shortForRef(tr.td(), e.getItem());
        if (date) {
            tr.td().tx(e.hasDate() ? e.getDate().toLocaleString() : "");
        }
        if (flag) {
            tr.td().tx(e.hasFlag() ? display(e.getFlag()) : "");
        }
        if (deleted) {
            tr.td().tx(e.hasDeleted() ? Boolean.toString(e.getDeleted()) : "");
        }
    }
    return false;
}
Also used : ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) Annotation(org.hl7.fhir.r5.model.Annotation) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 10 with ListResourceEntryComponent

use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.

the class SpreadSheetReloader method processOperation.

private OperationDefinition processOperation(XSSFRow row, XSSFRow cols, String name, List<ListResourceEntryComponent> entry) throws IOException {
    String fn = fnOpDef(resourceName + "-" + name);
    OperationDefinition opd = null;
    if (new File(fn).exists()) {
        opd = (OperationDefinition) parseXml(fn);
    } else {
        opd = new OperationDefinition();
        opd.setId(name);
        opd.setUrl("http://hl7.org/fhir/Operationdefinition/" + name);
        opd.setName(name);
        opd.setCode(name);
    }
    opd.setSystem(false);
    opd.setType(false);
    opd.setInstance(false);
    for (String s : splitValue(row, cols, CN_USE, "\\|")) {
        String n = s.trim();
        switch(n) {
            case "System":
                opd.setSystem(true);
                break;
            case "Type":
                opd.setType(true);
                break;
            case "Instance":
                opd.setInstance(true);
                break;
        }
    }
    opd.setAffectsState(false);
    opd.setKind(null);
    for (String s : splitValue(row, cols, CN_TYPE, "\\|")) {
        String n = s.trim();
        if (n.equals("affects-state")) {
            opd.setAffectsState(true);
        } else {
            opd.setKind(OperationKind.fromCode(n));
        }
    }
    opd.setTitle(getValue(row, cols, CN_TITLE));
    opd.setDescription(getValue(row, cols, CN_DOCUMENTATION));
    opd.setComment(getValue(row, cols, CN_COMMENTS));
    readExt(opd, row, cols, CN_FOOTER, BuildExtensions.EXT_FOOTER, ExtensionType.Markdown);
    readExt(opd, row, cols, CN_FOOTER2, BuildExtensions.EXT_FOOTER2, ExtensionType.Markdown);
    opd.getExtension().removeIf(n -> ("1".equals(n.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST))));
    opd.getExtension().removeIf(n -> ("2".equals(n.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST))));
    for (String s : splitValue(row, cols, CN_EXAMPLE1_REQUEST, "\\|")) {
        Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("1"));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(false));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
    }
    for (String s : splitValue(row, cols, CN_EXAMPLE1_RESPONSE, "\\|")) {
        Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("1"));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(true));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
    }
    for (String s : splitValue(row, cols, CN_EXAMPLE2_REQUEST, "\\|")) {
        Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("2"));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(false));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
    }
    for (String s : splitValue(row, cols, CN_EXAMPLE2_RESPONSE, "\\|")) {
        Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("2"));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(true));
        ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
    }
    parseStatus(opd, getValue(row, cols, CN_STATUS));
    readExt(opd, row, cols, CN_COMMITTEE_NOTES, BuildExtensions.EXT_COMMITTEE_NOTES, ExtensionType.String);
    return opd;
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) StringType(org.hl7.fhir.r5.model.StringType) BooleanType(org.hl7.fhir.r5.model.BooleanType) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File)

Aggregations

ListResourceEntryComponent (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent)12 ListResource (org.hl7.fhir.r5.model.ListResource)10 File (java.io.File)4 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)4 FileOutputStream (java.io.FileOutputStream)3 XmlParser (org.hl7.fhir.r5.formats.XmlParser)3 OperationDefinition (org.hl7.fhir.r5.model.OperationDefinition)3 Example (org.hl7.fhir.definitions.model.Example)2 OperationExample (org.hl7.fhir.definitions.model.Operation.OperationExample)2 BooleanType (org.hl7.fhir.r5.model.BooleanType)2 StringType (org.hl7.fhir.r5.model.StringType)2 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 HashSet (java.util.HashSet)1 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)1 ExampleType (org.hl7.fhir.definitions.model.Example.ExampleType)1 Operation (org.hl7.fhir.definitions.model.Operation)1 Profile (org.hl7.fhir.definitions.model.Profile)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 Annotation (org.hl7.fhir.r4b.model.Annotation)1 ListResourceEntryComponent (org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent)1