Search in sources :

Example 1 with EventDefn

use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.

the class PageProcessor method getEventsTable.

private String getEventsTable(String resource) throws Exception {
    List<String> codes = new ArrayList<String>();
    codes.addAll(definitions.getEvents().keySet());
    Collections.sort(codes);
    StringBuilder s = new StringBuilder();
    s.append("<table class=\"grid\">\r\n");
    s.append(" <tr><th>Code</th><th>Category</th><th>Description</th><th>Request Resources</th><th>Response Resources</th><th>Notes</th></tr>\r\n");
    for (String c : codes) {
        EventDefn e = definitions.getEvents().get(c);
        if (e.getUsages().size() == 1) {
            EventUsage u = e.getUsages().get(0);
            s.append(" <tr><td>" + e.getCode() + "<a name=\"" + e.getCode() + "\"> </a></td><td>" + (e.getCategory() == null ? "??" : e.getCategory().toString()) + "</td><td>" + e.getDefinition() + "</td>");
            s.append("<td>" + describeMsg(u.getRequestResources(), u.getRequestAggregations()) + "</td><td>" + describeMsg(u.getResponseResources(), u.getResponseAggregations()) + "</td><td>" + combineNotes(resource, e.getFollowUps(), u.getNotes(), "") + "</td></tr>\r\n");
        } else {
            boolean first = true;
            for (EventUsage u : e.getUsages()) {
                if (first)
                    s.append(" <tr><td rowspan=\"" + Integer.toString(e.getUsages().size()) + "\">" + e.getCode() + "</td><td rowspan=\"" + Integer.toString(e.getUsages().size()) + "\">" + e.getDefinition() + "</td>");
                else
                    s.append(" <tr>");
                first = false;
                s.append("<td>" + describeMsg(u.getRequestResources(), u.getRequestAggregations()) + "</td><td>" + describeMsg(u.getResponseResources(), u.getResponseAggregations()) + "</td><td>" + combineNotes(resource, e.getFollowUps(), u.getNotes(), "") + "</td></tr>\r\n");
            }
        }
    }
    s.append("</table>\r\n");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) EventUsage(org.hl7.fhir.definitions.model.EventUsage) ArrayList(java.util.ArrayList) EventDefn(org.hl7.fhir.definitions.model.EventDefn)

Example 2 with EventDefn

use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.

the class ValueSetGenerator method genMessageEvents.

private void genMessageEvents(ValueSet vs) {
    if (!vs.hasCompose())
        vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/message-events");
    vs.setUserData("filename", "valueset-" + vs.getId());
    if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
        vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType("fhir"));
    } else {
        String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
        if (!ec.equals("fhir"))
            System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 10: is " + ec + ", want to set to " + "fhir");
    }
    vs.setUserData("path", "valueset-" + vs.getId() + ".html");
    CodeSystem cs = new CodeSystem();
    CodeSystemConvertor.populate(cs, vs);
    cs.setUserData("filename", vs.getUserString("filename").replace("valueset-", "codesystem-"));
    cs.setUserData("path", vs.getUserString("path").replace("valueset-", "codesystem-"));
    cs.setUrl("http://hl7.org/fhir/message-events");
    cs.setVersion(version);
    cs.setCaseSensitive(true);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    definitions.getCodeSystems().see(cs, packageInfo);
    List<String> codes = new ArrayList<String>();
    codes.addAll(definitions.getEvents().keySet());
    Collections.sort(codes);
    for (String s : codes) {
        ConceptDefinitionComponent c = cs.addConcept();
        EventDefn e = definitions.getEvents().get(s);
        c.setCode(s);
        c.setDisplay(transform(e.getCode(), e.getTitle()));
        c.setDefinition(e.getDefinition());
    }
    markSpecialStatus(vs, cs, false);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ArrayList(java.util.ArrayList) CodeType(org.hl7.fhir.r5.model.CodeType) EventDefn(org.hl7.fhir.definitions.model.EventDefn) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 3 with EventDefn

use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.

the class SourceParser method processEvent.

private void processEvent(EventDefn defn, ElementDefn root) throws Exception {
    // Exception("Event "+defn.getCode()+" has a mismatched request resource - should be "+root.getName()+", is "+defn.getUsages().get(0).getRequestResources().get(0));
    if (definitions.getEvents().containsKey(defn.getCode())) {
        EventDefn master = definitions.getEvents().get(defn.getCode());
        master.getUsages().add(defn.getUsages().get(0));
        if (!defn.getDefinition().startsWith("(see"))
            master.setDefinition(defn.getDefinition());
    } else
        definitions.getEvents().put(defn.getCode(), defn);
}
Also used : EventDefn(org.hl7.fhir.definitions.model.EventDefn)

Example 4 with EventDefn

use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.

the class OldSpreadsheetParser method readEvents.

private void readEvents(Sheet sheet, ResourceDefn root) throws Exception {
    if (sheet != null) {
        for (int row = 0; row < sheet.rows.size(); row++) {
            String code = sheet.getColumn(row, "Event Code");
            if (code != null && !code.equals("") && !code.startsWith("!")) {
                System.out.print("!!Lloyd Look at me! - event " + code + " on resource " + root.getName());
                EventDefn e = new EventDefn();
                events.add(e);
                e.setCode(code);
                e.setTitle(sheet.getColumn(row, "Title"));
                e.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Description")));
                e.setCategory(readCategory(sheet.getColumn(row, "Category")));
                EventUsage u = new EventUsage();
                e.getUsages().add(u);
                u.setNotes(sheet.getColumn(row, "Notes"));
                for (String s : sheet.getColumn(row, "Request Resources").split(",")) {
                    s = s.trim();
                    if (!s.isEmpty())
                        u.getRequestResources().add(s);
                }
                for (String s : sheet.getColumn(row, "Request Aggregations").split("\n")) {
                    s = s.trim();
                    if (!s.isEmpty())
                        u.getRequestAggregations().add(s);
                }
                for (String s : sheet.getColumn(row, "Response Resources").split(",")) {
                    s = s.trim();
                    if (!s.isEmpty())
                        u.getResponseResources().add(s);
                }
                for (String s : sheet.getColumn(row, "Response Aggregations").split("\n")) {
                    s = s.trim();
                    if (!s.isEmpty())
                        u.getResponseAggregations().add(s);
                }
                for (String s : sheet.getColumn(row, "Follow Ups").split(",")) {
                    s = s.trim();
                    if (!s.isEmpty())
                        e.getFollowUps().add(s);
                }
            }
        }
    }
}
Also used : EventUsage(org.hl7.fhir.definitions.model.EventUsage) EventDefn(org.hl7.fhir.definitions.model.EventDefn)

Example 5 with EventDefn

use of org.hl7.fhir.definitions.model.EventDefn in project kindling by HL7.

the class SourceParser method loadResource.

private ResourceDefn loadResource(String n, Map<String, ResourceDefn> map, boolean isAbstract, boolean isTemplate, String t, boolean isInterface) throws Exception {
    String folder = n;
    WorkGroup wg = definitions.getWorkgroups().get(ini.getStringProperty("workgroups", n));
    if (wg == null)
        throw new Exception("No Workgroup found for resource " + n + ": '" + ini.getStringProperty("workgroups", n) + "'");
    File f = new File(Utilities.path(srcDir, folder, n + ".svg"));
    if (isTemplate) {
        File spreadsheet = new CSFile((srcDir) + folder + File.separatorChar + n + "-spreadsheet.xml");
        OldSpreadsheetParser sparser = new OldSpreadsheetParser("core", new CSFileInputStream(spreadsheet), spreadsheet.getName(), spreadsheet.getAbsolutePath(), definitions, srcDir, logger, registry, version, context, genDate, isAbstract, page, false, ini, wg, definitions.getProfileIds(), fpUsages, page.getConceptMaps(), exceptionIfExcelNotNormalised, page.packageInfo(), page.getRc());
        ResourceDefn root;
        try {
            root = sparser.parseResource(isTemplate);
        } catch (Exception e) {
            throw new Exception("Error Parsing Resource " + n + ": " + e.getMessage(), e);
        }
        root.setAbstract(isAbstract);
        root.setInterface(isInterface);
        errors.addAll(sparser.getErrors());
        setResourceProps(n, wg, root);
        String sc = ini.getStringProperty("security-categorization", root.getName().toLowerCase());
        if (sc != null) {
            root.setSecurityCategorization(SecurityCategorization.fromCode(sc));
        } else if (!Utilities.existsInList(root.getName(), "Resource", "DomainResource", "CanonicalResource", "MetadataResource", "MetadataPattern"))
            throw new Exception("Must have an entry in the security-categorization section of fhir.ini for the resource " + root.getName());
        for (EventDefn e : sparser.getEvents()) {
            processEvent(e, root.getRoot());
        }
        if (map != null) {
            map.put(root.getName(), root);
        }
        if (!isTemplate) {
            definitions.getKnownResources().put(root.getName(), new DefinedCode(root.getName(), root.getRoot().getDefinition(), n));
            context.getResourceNames().add(root.getName());
        }
        if (root.getNormativeVersion() != null || root.getNormativePackage() != null) {
            root.setStatus(StandardsStatus.NORMATIVE);
        }
        if (f.exists()) {
            parseSvgFile(f, root.getLayout(), f.getName());
        }
        if (map != null) {
            map.put(root.getName(), root);
        }
        return root;
    } else {
        try {
            new SpreadSheetReloader(context, srcDir, t, version.toCode()).process();
        } catch (Exception e) {
            System.out.println("Error loading spreadsheet for resource " + t + ": " + e.getMessage());
        }
        new SpreadSheetCreator(context, srcDir, t).generateSpreadsheet();
        ResourceDefn rootNew = new ResourceParser(srcDir, definitions, context, wg, registry, version.toCode(), page.getConceptMaps()).parse(n, t);
        if (f.exists()) {
            parseSvgFile(f, rootNew.getLayout(), f.getName());
        }
        if (!isTemplate) {
            definitions.getKnownResources().put(rootNew.getName(), new DefinedCode(rootNew.getName(), rootNew.getRoot().getDefinition(), n));
            context.getResourceNames().add(rootNew.getName());
        }
        setResourceProps(n, wg, rootNew);
        if (map != null) {
            map.put(rootNew.getName(), rootNew);
        }
        return rootNew;
    }
}
Also used : SpreadSheetCreator(org.hl7.fhir.definitions.parsers.spreadsheets.SpreadSheetCreator) EventDefn(org.hl7.fhir.definitions.model.EventDefn) CSFile(org.hl7.fhir.utilities.CSFile) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) WorkGroup(org.hl7.fhir.definitions.model.WorkGroup) DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) OldSpreadsheetParser(org.hl7.fhir.definitions.parsers.spreadsheets.OldSpreadsheetParser) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) SpreadSheetReloader(org.hl7.fhir.definitions.parsers.spreadsheets.SpreadSheetReloader) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream)

Aggregations

EventDefn (org.hl7.fhir.definitions.model.EventDefn)5 ArrayList (java.util.ArrayList)2 EventUsage (org.hl7.fhir.definitions.model.EventUsage)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 DefinedCode (org.hl7.fhir.definitions.model.DefinedCode)1 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)1 WorkGroup (org.hl7.fhir.definitions.model.WorkGroup)1 OldSpreadsheetParser (org.hl7.fhir.definitions.parsers.spreadsheets.OldSpreadsheetParser)1 SpreadSheetCreator (org.hl7.fhir.definitions.parsers.spreadsheets.SpreadSheetCreator)1 SpreadSheetReloader (org.hl7.fhir.definitions.parsers.spreadsheets.SpreadSheetReloader)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)1 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)1 CodeType (org.hl7.fhir.r5.model.CodeType)1 ValueSetComposeComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent)1 CSFile (org.hl7.fhir.utilities.CSFile)1 CSFileInputStream (org.hl7.fhir.utilities.CSFileInputStream)1