Java Code Examples for org.hl7.fhir.dstu3.model.StructureDefinition#getName()
The following examples show how to use
org.hl7.fhir.dstu3.model.StructureDefinition#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfileUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public void generateSchematrons(OutputStream dest, StructureDefinition structure) throws IOException, DefinitionException { if (structure.getDerivation() != TypeDerivationRule.CONSTRAINT) throw new DefinitionException("not the right kind of structure to generate schematrons for"); if (!structure.hasSnapshot()) throw new DefinitionException("needs a snapshot"); StructureDefinition base = context.fetchResource(StructureDefinition.class, structure.getBaseDefinition()); SchematronWriter sch = new SchematronWriter(dest, SchematronType.PROFILE, base.getName()); ElementDefinition ed = structure.getSnapshot().getElement().get(0); generateForChildren(sch, "f:"+ed.getPath(), ed, structure, base); sch.dump(); }
Example 2
Source File: SimpleWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public void seeProfile(String url, StructureDefinition p) throws FHIRException { if (Utilities.noString(url)) url = p.getUrl(); if (!p.hasSnapshot() && p.getKind() != StructureDefinitionKind.LOGICAL) { if (!p.hasBaseDefinition()) throw new DefinitionException("Profile "+p.getName()+" ("+p.getUrl()+") has no base and no snapshot"); StructureDefinition sd = fetchResource(StructureDefinition.class, p.getBaseDefinition()); if (sd == null) throw new DefinitionException("Profile "+p.getName()+" ("+p.getUrl()+") base "+p.getBaseDefinition()+" could not be resolved"); List<ValidationMessage> msgs = new ArrayList<ValidationMessage>(); List<String> errors = new ArrayList<String>(); ProfileUtilities pu = new ProfileUtilities(this, msgs, this); pu.sortDifferential(sd, p, url, errors); for (String err : errors) msgs.add(new ValidationMessage(Source.ProfileValidator, IssueType.EXCEPTION,p.getUserString("path"), "Error sorting Differential: "+err, ValidationMessage.IssueSeverity.ERROR)); pu.generateSnapshot(sd, p, p.getUrl(), p.getName()); for (ValidationMessage msg : msgs) { if (msg.getLevel() == ValidationMessage.IssueSeverity.ERROR || msg.getLevel() == ValidationMessage.IssueSeverity.FATAL) throw new DefinitionException("Profile "+p.getName()+" ("+p.getUrl()+"). Error generating snapshot: "+msg.getMessage()); } if (!p.hasSnapshot()) throw new DefinitionException("Profile "+p.getName()+" ("+p.getUrl()+"). Error generating snapshot"); pu = null; } if (structures.containsKey(p.getUrl()) && !allowLoadingDuplicates) throw new DefinitionException("Duplicate structures " + p.getUrl()); structures.put(p.getId(), p); structures.put(p.getUrl(), p); if (!p.getUrl().equals(url)) structures.put(url, p); }
Example 3
Source File: ShExGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
/** * Emit a ShEx definition for the supplied StructureDefinition * @param sd Structure definition to emit * @param top_level True means outermost type, False means recursively called * @return ShEx definition */ private String genShapeDefinition(StructureDefinition sd, boolean top_level) { // xhtml is treated as an atom if("xhtml".equals(sd.getName()) || (completeModel && "Resource".equals(sd.getName()))) return ""; ST shape_defn; // Resources are either incomplete items or consist of everything that is defined as a resource (completeModel) if("Resource".equals(sd.getName())) { shape_defn = tmplt(RESOURCE_SHAPE_TEMPLATE); known_resources.add(sd.getName()); } else { shape_defn = tmplt(SHAPE_DEFINITION_TEMPLATE).add("id", sd.getId()); if (sd.getKind().equals(StructureDefinition.StructureDefinitionKind.RESOURCE)) { // || sd.getKind().equals(StructureDefinition.StructureDefinitionKind.COMPLEXTYPE)) { known_resources.add(sd.getName()); ST resource_decl = tmplt(RESOURCE_DECL_TEMPLATE). add("id", sd.getId()). add("root", tmplt(ROOT_TEMPLATE)); // add("root", top_level ? tmplt(ROOT_TEMPLATE) : ""); shape_defn.add("resourceDecl", resource_decl.render()); } else { shape_defn.add("resourceDecl", ""); } } // Generate the defining elements List<String> elements = new ArrayList<String>(); // Add the additional entries for special types String sdn = sd.getName(); if (sdn.equals("Coding")) elements.add(tmplt(CONCEPT_REFERENCE_TEMPLATE).render()); else if (sdn.equals("CodeableConcept")) elements.add(tmplt(CONCEPT_REFERENCES_TEMPLATE).render()); else if (sdn.equals("Reference")) elements.add(tmplt(RESOURCE_LINK_TEMPLATE).render()); // else if (sdn.equals("Extension")) // return tmplt(EXTENSION_TEMPLATE).render(); String root_comment = null; for (ElementDefinition ed : sd.getSnapshot().getElement()) { if(!ed.getPath().contains(".")) root_comment = ed.getShort(); else if (StringUtils.countMatches(ed.getPath(), ".") == 1 && !"0".equals(ed.getMax())) { elements.add(genElementDefinition(sd, ed)); } } shape_defn.add("elements", StringUtils.join(elements, "\n")); shape_defn.add("comment", root_comment == null? " " : "# " + root_comment); return shape_defn.render(); }