Java Code Examples for org.hl7.fhir.dstu3.model.StructureDefinition#hasSnapshot()
The following examples show how to use
org.hl7.fhir.dstu3.model.StructureDefinition#hasSnapshot() .
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: ProfileUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public void generateCsvs(OutputStream dest, StructureDefinition structure, boolean asXml) throws IOException, DefinitionException, Exception { if (!structure.hasSnapshot()) throw new DefinitionException("needs a snapshot"); CSVWriter csv = new CSVWriter(dest, structure, asXml); for (ElementDefinition child : structure.getSnapshot().getElement()) { csv.processElement(child); } csv.dump(); }
Example 3
Source File: ProfileUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public void setIds(StructureDefinition sd, boolean checkFirst) throws DefinitionException { if (!checkFirst || !sd.hasDifferential() || hasMissingIds(sd.getDifferential().getElement())) { if (!sd.hasDifferential()) sd.setDifferential(new StructureDefinitionDifferentialComponent()); generateIds(sd.getDifferential().getElement(), sd.getName()); } if (!checkFirst || !sd.hasSnapshot() || hasMissingIds(sd.getSnapshot().getElement())) { if (!sd.hasSnapshot()) sd.setSnapshot(new StructureDefinitionSnapshotComponent()); generateIds(sd.getSnapshot().getElement(), sd.getName()); } }
Example 4
Source File: ProfileUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public List<org.hl7.fhir.dstu3.elementmodel.Element> generateExamples(StructureDefinition sd, boolean evenWhenNoExamples) throws FHIRException { List<org.hl7.fhir.dstu3.elementmodel.Element> examples = new ArrayList<org.hl7.fhir.dstu3.elementmodel.Element>(); if (sd.hasSnapshot()) { if (evenWhenNoExamples || hasAnyExampleValues(sd)) examples.add(generateExample(sd, new BaseExampleValueAccessor())); for (int i = 1; i <= 50; i++) { if (hasAnyExampleValues(sd, Integer.toString(i))) examples.add(generateExample(sd, new ExtendedExampleValueAccessor(Integer.toString(i)))); } } return examples; }
Example 5
Source File: DefinitionNavigator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public DefinitionNavigator(IWorkerContext context, StructureDefinition structure) throws DefinitionException { if (!structure.hasSnapshot()) throw new DefinitionException("Snapshot required"); this.context = context; this.structure = structure; this.index = 0; this.path = current().getPath(); names.add(nameTail()); }
Example 6
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 7
Source File: ProfileComparer.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
/** * Compare left and right structure definitions to see whether they are consistent or not * * Note that left and right are arbitrary choices. In one respect, left * is 'preferred' - the left's example value and data sets will be selected * over the right ones in the common structure definition * @throws DefinitionException * @throws IOException * @throws FHIRFormatError * * @ */ public ProfileComparison compareProfiles(StructureDefinition left, StructureDefinition right) throws DefinitionException, IOException, FHIRFormatError { ProfileComparison outcome = new ProfileComparison(); outcome.left = left; outcome.right = right; if (left == null) throw new DefinitionException("No StructureDefinition provided (left)"); if (right == null) throw new DefinitionException("No StructureDefinition provided (right)"); if (!left.hasSnapshot()) throw new DefinitionException("StructureDefinition has no snapshot (left: "+outcome.leftName()+")"); if (!right.hasSnapshot()) throw new DefinitionException("StructureDefinition has no snapshot (right: "+outcome.rightName()+")"); if (left.getSnapshot().getElement().isEmpty()) throw new DefinitionException("StructureDefinition snapshot is empty (left: "+outcome.leftName()+")"); if (right.getSnapshot().getElement().isEmpty()) throw new DefinitionException("StructureDefinition snapshot is empty (right: "+outcome.rightName()+")"); for (ProfileComparison pc : comparisons) if (pc.left.getUrl().equals(left.getUrl()) && pc.right.getUrl().equals(right.getUrl())) return pc; outcome.id = Integer.toString(comparisons.size()+1); comparisons.add(outcome); DefinitionNavigator ln = new DefinitionNavigator(context, left); DefinitionNavigator rn = new DefinitionNavigator(context, right); // from here on in, any issues go in messages outcome.superset = new StructureDefinition(); outcome.subset = new StructureDefinition(); if (outcome.ruleEqual(ln.path(), null,ln.path(), rn.path(), "Base Type is not compatible", false)) { if (compareElements(outcome, ln.path(), ln, rn)) { outcome.subset.setName("intersection of "+outcome.leftName()+" and "+outcome.rightName()); outcome.subset.setStatus(PublicationStatus.DRAFT); outcome.subset.setKind(outcome.left.getKind()); outcome.subset.setType(outcome.left.getType()); outcome.subset.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/"+outcome.subset.getType()); outcome.subset.setDerivation(TypeDerivationRule.CONSTRAINT); outcome.subset.setAbstract(false); outcome.superset.setName("union of "+outcome.leftName()+" and "+outcome.rightName()); outcome.superset.setStatus(PublicationStatus.DRAFT); outcome.superset.setKind(outcome.left.getKind()); outcome.superset.setType(outcome.left.getType()); outcome.superset.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/"+outcome.subset.getType()); outcome.superset.setAbstract(false); outcome.superset.setDerivation(TypeDerivationRule.CONSTRAINT); } else { outcome.subset = null; outcome.superset = null; } } return outcome; }