sdTime = sdTime + (System.nanoTime() - t1); ed = sd.getSnapshot().getElementFirstRep(); continue; } else if (ed.getType().get(0).hasProfile()) { childDefinitions = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); if (tgt.hasSnapshot()) tgt.getSnapshot().getElementFirstRep().getType().clear(); if (tgt.hasDifferential()) tgt.getDifferential().getElementFirstRep().getType().clear();
private void copyElements(StructureDefinition sd, List<ElementDefinition> list) { for (ElementDefinition ed : list) { if (ed.getPath().contains(".")) { ElementDefinition n = ed.copy(); n.setPath(sd.getSnapshot().getElementFirstRep().getPath()+"."+ed.getPath().substring(ed.getPath().indexOf(".")+1)); sd.getSnapshot().addElement(n); } } }
if (sd == null || sd.getSnapshot() == null || sd.getSnapshot().getElementFirstRep().getMax().equals("1")) ToolingExtensions.removeExtension(dest, ex.getUrl()); dest.addExtension(ex);
sdTime = sdTime + (System.nanoTime() - t1); ed = sd.getSnapshot().getElementFirstRep(); continue; } else if (ed.getType().get(0).hasProfile()) { childDefinitions = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
String m = ""; boolean vdeep = false; if (ed.getSnapshot().getElementFirstRep().getIsModifier()) m = "modifier_"; for (ElementDefinition eld : ed.getSnapshot().getElement()) {
tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); if (tgt.hasSnapshot()) tgt.getSnapshot().getElementFirstRep().getType().clear(); if (tgt.hasDifferential()) tgt.getDifferential().getElementFirstRep().getType().clear();
if (src.hasSnapshot()) { tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); tgt.getSnapshot().getElementFirstRep().getType().clear();
if (sdn == null) throw new FHIRException("Unable to find definition for "+type.getType()); ElementDefinition edn = sdn.getSnapshot().getElementFirstRep(); PropertyWithType pn = createProfile(map, profiles, new PropertyWithType(sdn.getId(), new Property(worker, edn, sdn), null, type), sliceName, tgt);
if (!derived.getSnapshot().getElementFirstRep().getType().isEmpty()) throw new Error("type on first snapshot element for "+derived.getSnapshot().getElementFirstRep().getPath()+" in "+derived.getUrl()+" from "+base.getUrl()); updateMaps(base, derived); setIds(derived, false);
public StructureMap generateMapFromMappings(StructureDefinition sd) throws IOException, FHIRException { String id = getLogicalMappingId(sd); if (id == null) return null; String prefix = ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_MAPPING_PREFIX); String suffix = ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_MAPPING_SUFFIX); if (prefix == null || suffix == null) return null; // we build this by text. Any element that has a mapping, we put it's mappings inside it.... StringBuilder b = new StringBuilder(); b.append(prefix); ElementDefinition root = sd.getSnapshot().getElementFirstRep(); String m = getMapping(root, id); if (m != null) b.append(m+"\r\n"); addChildMappings(b, id, "", sd, root, false); b.append("\r\n"); b.append(suffix); b.append("\r\n"); StructureMap map = parse(b.toString()); map.setId(tail(map.getUrl())); if (!map.hasStatus()) map.setStatus(PublicationStatus.DRAFT); map.getText().setStatus(NarrativeStatus.GENERATED); map.getText().setDiv(new XhtmlNode(NodeType.Element, "div")); map.getText().getDiv().addTag("pre").addText(render(map)); return map; }
private Element convertElement(Property property, Base base) throws FHIRException { if (base == null) return null; String tn = base.fhirType(); StructureDefinition sd = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+tn); if (sd == null) throw new FHIRException("Unable to find definition for type "+tn); Element res = new Element(property.getName(), property); if (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE) res.setValue(((PrimitiveType) base).asStringValue()); List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep()); for (ElementDefinition child : children) { String n = tail(child.getPath()); if (sd.getKind() != StructureDefinitionKind.PRIMITIVETYPE || !"value".equals(n)) { Base[] values = base.getProperty(n.hashCode(), n, false); if (values != null) for (Base value : values) { res.getChildren().add(convertElement(new Property(context, child, sd), value)); } } } return res; }
private org.hl7.fhir.dstu3.elementmodel.Element generateExample(StructureDefinition profile, ExampleValueAccessor accessor) throws FHIRException { ElementDefinition ed = profile.getSnapshot().getElementFirstRep(); org.hl7.fhir.dstu3.elementmodel.Element r = new org.hl7.fhir.dstu3.elementmodel.Element(ed.getPath(), new Property(context, ed, profile)); List<ElementDefinition> children = getChildMap(profile, ed); for (ElementDefinition child : children) { if (child.getPath().endsWith(".id")) { org.hl7.fhir.dstu3.elementmodel.Element id = new org.hl7.fhir.dstu3.elementmodel.Element("id", new Property(context, child, profile)); id.setValue(profile.getId()+accessor.getId()); r.getChildren().add(id); } else { org.hl7.fhir.dstu3.elementmodel.Element e = createExampleElement(profile, child, accessor); if (e != null) r.getChildren().add(e); } } return r; }
if (src.hasSnapshot()) { tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); tgt.getSnapshot().getElementFirstRep().getType().clear();