Java Code Examples for org.hl7.fhir.r4.model.StructureDefinition#getUrl()

The following examples show how to use org.hl7.fhir.r4.model.StructureDefinition#getUrl() . 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: XmlSchemaGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void generateInner(StructureDefinition sd) throws IOException, FHIRException {
  if (processedLibs.contains(sd))
    return;
  processedLibs.add(sd);
  
  String ns = getNs(sd);
  String lang = start(sd, ns);

  if (sd.getSnapshot().getElement().isEmpty())
    throw new FHIRException("no snap shot on "+sd.getUrl());
  
  produceType(sd, sd.getSnapshot().getElement().get(0), tail(sd.getType()), getQN(sd, sd.getBaseDefinition()), lang);
  while (!queue.isEmpty()) {
    ElementToGenerate q = queue.poll();
    produceType(q.sd, q.ed, q.tname, getQN(q.sd, q.ed, "http://hl7.org/fhir/StructureDefinition/Element", false), lang);
  }
}
 
Example 2
Source File: SimpleWorkerContext.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public void generateSnapshot(StructureDefinition p) throws DefinitionException, FHIRException {
  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.setThrowException(false);
    pu.sortDifferential(sd, p, p.getUrl(), 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(), Utilities.extractBaseUrl(sd.getUserString("path")), p.getName());
    for (ValidationMessage msg : msgs) {
      if ((!ignoreProfileErrors && 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 FHIRException("Profile "+p.getName()+" ("+p.getUrl()+"). Error generating snapshot");
    pu = null;
  }
}
 
Example 3
Source File: XmlSchemaGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public boolean checkChain(List<StructureDefinition> chain1, StructureDefinition root, boolean chain1Done) throws FHIRException {
  if (!chain1Done) {
     StructureDefinition sd = chain1.get(chain1.size()-1);
    String bu = sd.getBaseDefinition();
     if (bu == null)
       throw new FHIRException("No base definition for "+sd.getUrl());
     StructureDefinition t = library.get(bu);
     if (t == null)
       chain1Done = true;
     else
       chain1.add(t);
   }
  return chain1Done;
}
 
Example 4
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private PropertyWithType resolveType(StructureMap map, String type, StructureMapInputMode mode) throws FHIRException {
  for (StructureMapStructureComponent imp : map.getStructure()) {
    if ((imp.getMode() == StructureMapModelMode.SOURCE && mode == StructureMapInputMode.SOURCE) || 
        (imp.getMode() == StructureMapModelMode.TARGET && mode == StructureMapInputMode.TARGET)) {
      StructureDefinition sd = worker.fetchResource(StructureDefinition.class, imp.getUrl());
      if (sd == null)
        throw new FHIRException("Import "+imp.getUrl()+" cannot be resolved");
      if (sd.getId().equals(type)) {
        return new PropertyWithType(sd.getType(), new Property(worker, sd.getSnapshot().getElement().get(0), sd), null, new TypeDetails(CollectionStatus.SINGLETON, sd.getUrl()));
      }
    }
  }
  throw new FHIRException("Unable to find structure definition for "+type+" in imports");
}