public StructureMapStructureComponent addStructure() { //3 StructureMapStructureComponent t = new StructureMapStructureComponent(); if (this.structure == null) this.structure = new ArrayList<StructureMapStructureComponent>(); this.structure.add(t); return t; }
private static void renderUses(StringBuilder b, StructureMap map) { for (StructureMapStructureComponent s : map.getStructure()) { b.append("uses \""); b.append(s.getUrl()); b.append("\" "); if (s.hasAlias()) { b.append("alias "); b.append(s.getAlias()); b.append(" "); } b.append("as "); b.append(s.getMode().toCode()); b.append("\r\n"); renderDoco(b, s.getDocumentation()); } if (map.hasStructure()) b.append("\r\n"); }
private void parseUses(StructureMap result, FHIRLexer lexer) throws FHIRException { lexer.token("uses"); StructureMapStructureComponent st = result.addStructure(); st.setUrl(lexer.readConstant("url")); if (lexer.hasToken("alias")) { lexer.token("alias"); st.setAlias(lexer.take()); } lexer.token("as"); st.setMode(StructureMapModelMode.fromCode(lexer.take())); lexer.skipToken(";"); if (lexer.hasComment()) { st.setDocumentation(lexer.take().substring(2).trim()); } lexer.skipComments(); }
private boolean matchesType(StructureMap map, String actualType, String statedType) throws FHIRException { // check the aliases for (StructureMapStructureComponent imp : map.getStructure()) { if (imp.hasAlias() && statedType.equals(imp.getAlias())) { StructureDefinition sd = worker.fetchResource(StructureDefinition.class, imp.getUrl()); if (sd != null) statedType = sd.getType(); break; } } if (Utilities.isAbsoluteUrl(actualType)) { StructureDefinition sd = worker.fetchResource(StructureDefinition.class, actualType); if (sd != null) actualType = sd.getType(); } if (Utilities.isAbsoluteUrl(statedType)) { StructureDefinition sd = worker.fetchResource(StructureDefinition.class, statedType); if (sd != null) statedType = sd.getType(); } return actualType.equals(statedType); }
@Override public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case 116079: // url this.url = castToCanonical(value); // CanonicalType return value; case 3357091: // mode value = new StructureMapModelModeEnumFactory().fromType(castToCode(value)); this.mode = (Enumeration) value; // Enumeration<StructureMapModelMode> return value; case 92902992: // alias this.alias = castToString(value); // StringType return value; case 1587405498: // documentation this.documentation = castToString(value); // StringType return value; default: return super.setProperty(hash, name, value); } }
private static void renderUses(StringBuilder b, StructureMap map) { for (StructureMapStructureComponent s : map.getStructure()) { b.append("uses \""); b.append(s.getUrl()); b.append("\" "); if (s.hasAlias()) { b.append("alias "); b.append(s.getAlias()); b.append(" "); } b.append("as "); b.append(s.getMode().toCode()); b.append("\r\n"); renderDoco(b, s.getDocumentation()); } if (map.hasStructure()) b.append("\r\n"); }
public StructureDefinition getTargetType(StructureMap map) throws FHIRException { boolean found = false; StructureDefinition res = null; for (StructureMapStructureComponent uses : map.getStructure()) { if (uses.getMode() == StructureMapModelMode.TARGET) { if (found) throw new FHIRException("Multiple targets found in map "+map.getUrl()); found = true; res = worker.fetchResource(StructureDefinition.class, uses.getUrl()); if (res == null) throw new FHIRException("Unable to find "+uses.getUrl()+" referenced from map "+map.getUrl()); } } if (res == null) throw new FHIRException("No targets found in map "+map.getUrl()); return res; }
private void parseUses(StructureMap result, FHIRLexer lexer) throws FHIRException { lexer.token("uses"); StructureMapStructureComponent st = result.addStructure(); st.setUrl(lexer.readConstant("url")); if (lexer.hasToken("alias")) { lexer.token("alias"); st.setAlias(lexer.take()); } lexer.token("as"); st.setMode(StructureMapModelMode.fromCode(lexer.take())); lexer.skipToken(";"); if (lexer.hasComment()) { st.setDocumentation(lexer.take().substring(2).trim()); } lexer.skipComments(); }
@Override public Base setProperty(String name, Base value) throws FHIRException { if (name.equals("url")) { this.url = castToCanonical(value); // CanonicalType } else if (name.equals("mode")) { value = new StructureMapModelModeEnumFactory().fromType(castToCode(value)); this.mode = (Enumeration) value; // Enumeration<StructureMapModelMode> } else if (name.equals("alias")) { this.alias = castToString(value); // StringType } else if (name.equals("documentation")) { this.documentation = castToString(value); // StringType } else return super.setProperty(name, value); return value; }
private PropertyWithType resolveType(StructureMap map, String type, StructureMapInputMode mode) throws Exception { 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 Exception("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 Exception("Unable to find structure definition for "+type+" in imports"); }
private String getActualType(StructureMap map, String statedType) throws FHIRException { // check the aliases for (StructureMapStructureComponent imp : map.getStructure()) { if (imp.hasAlias() && statedType.equals(imp.getAlias())) { StructureDefinition sd = worker.fetchResource(StructureDefinition.class, imp.getUrl()); if (sd == null) throw new FHIRException("Unable to resolve structure "+imp.getUrl()); return sd.getId(); // should be sd.getType(), but R2... } } return statedType; }
public StructureMapStructureComponent copy() { StructureMapStructureComponent dst = new StructureMapStructureComponent(); copyValues(dst); dst.url = url == null ? null : url.copy(); dst.mode = mode == null ? null : mode.copy(); dst.alias = alias == null ? null : alias.copy(); dst.documentation = documentation == null ? null : documentation.copy(); return dst; }
public StructureMapStructureComponent addStructure() { //3 StructureMapStructureComponent t = new StructureMapStructureComponent(); if (this.structure == null) this.structure = new ArrayList<StructureMapStructureComponent>(); this.structure.add(t); return t; }
public boolean hasStructure() { if (this.structure == null) return false; for (StructureMapStructureComponent item : this.structure) if (!item.isEmpty()) return true; return false; }
public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent(); copyElement(src, tgt); tgt.setUrl(src.getUrl()); tgt.setMode(convertStructureMapStructureMode(src.getMode())); if (src.hasDocumentation()) tgt.setDocumentation(src.getDocumentation()); return tgt; }
public static org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent(); copyElement(src, tgt); tgt.setUrl(src.getUrl()); tgt.setMode(convertStructureMapStructureMode(src.getMode())); if (src.hasDocumentation()) tgt.setDocumentation(src.getDocumentation()); return tgt; }
private boolean matchesType(StructureMap map, String actualType, String statedType) throws FHIRException { // check the aliases for (StructureMapStructureComponent imp : map.getStructure()) { if (imp.hasAlias() && statedType.equals(imp.getAlias())) { StructureDefinition sd = worker.fetchResource(StructureDefinition.class, imp.getUrl()); if (sd != null) statedType = sd.getType(); break; } } if (Utilities.isAbsoluteUrl(actualType)) { StructureDefinition sd = worker.fetchResource(StructureDefinition.class, actualType); if (sd != null) actualType = sd.getType(); } if (Utilities.isAbsoluteUrl(statedType)) { StructureDefinition sd = worker.fetchResource(StructureDefinition.class, statedType); if (sd != null) statedType = sd.getType(); } return actualType.equals(statedType); }
@Override public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case 116079: // url this.url = castToCanonical(value); // CanonicalType return value; case 3357091: // mode value = new StructureMapModelModeEnumFactory().fromType(castToCode(value)); this.mode = (Enumeration) value; // Enumeration<StructureMapModelMode> return value; case 92902992: // alias this.alias = castToString(value); // StringType return value; case 1587405498: // documentation this.documentation = castToString(value); // StringType return value; default: return super.setProperty(hash, name, value); } }