private String getBaseType(StructureDefinition profile, String pr) { StructureDefinition p = resolveProfile(profile, pr); if (p == null) return null; else return p.getType(); }
public void checkAllInvariants(){ for (StructureDefinition sd : context.allStructures()) { if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) { for (ElementDefinition ed : sd.getSnapshot().getElement()) { for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) { if (inv.hasExpression()) { try { ExpressionNode n = (ExpressionNode) inv.getUserData("validator.expression.cache"); if (n == null) { n = fpe.parse(inv.getExpression()); inv.setUserData("validator.expression.cache", n); } fpe.check(null, sd.getKind() == StructureDefinitionKind.RESOURCE ? sd.getType() : "DomainResource", ed.getPath(), n); } catch (Exception e) { System.out.println("Error processing structure ["+sd.getId()+"] path "+ed.getPath()+":"+inv.getKey()+" (\""+inv.getExpression()+"\"): "+e.getMessage()); } } } } } } }
String type = defn.getKind() == StructureDefinitionKind.LOGICAL ? defn.getId() : defn.getType();
private String getBaseType(StructureDefinition profile, String pr) { StructureDefinition p = resolveProfile(profile, pr); if (p == null) return null; else return p.getType(); }
if (tgt.hasDifferential()) tgt.getDifferential().getElementFirstRep().getType().clear(); if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getId())) { tgt.setDerivation(TypeDerivationRule.SPECIALIZATION); tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/"+tgt.getType());
if (rule(errors, IssueType.BUSINESSRULE, profile.getId()+"::"+ed.getPath()+"::"+inv.getKey(), inv.hasExpression(), "The invariant has no FHIR Path expression ("+inv.getXpath()+")")) { try { new FHIRPathEngine(context).check(null, profile.getType(), ed.getPath(), inv.getExpression()); // , inv.hasXpath() && inv.getXpath().startsWith("@value") } catch (Exception e) {
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; } } return actualType.equals(statedType); }
public boolean hasType(IWorkerContext context, String... tn) { for (String n: tn) { String t = ProfiledType.ns(n); if (typesContains(t)) return true; } for (String n: tn) { String id = n.contains("#") ? n.substring(0, n.indexOf("#")) : n; String tail = null; if (n.contains("#")) { tail = n.substring( n.indexOf("#")+1); tail = tail.substring(tail.indexOf(".")); } String t = ProfiledType.ns(n); StructureDefinition sd = context.fetchResource(StructureDefinition.class, t); while (sd != null) { if (tail == null && typesContains(sd.getUrl())) return true; if (tail != null && typesContains(sd.getUrl()+"#"+sd.getType()+tail)) return true; if (sd.hasBaseDefinition()) sd = context.fetchResource(StructureDefinition.class, sd.getBaseDefinition()); else sd = null; } } return false; }
for (org.hl7.fhir.dstu3.model.StringType t : src.getContext()) tgt.addContext(t.getValue()); tgt.setConstrainedType(src.getType()); tgt.setBase(src.getBaseDefinition()); tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
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"); }
profile.setType(type); profile.setBaseDefinition(prop.getBaseProperty().getStructure().getUrl()); profile.setName("Profile for "+profile.getType()+" for "+sliceName); profile.setUrl(map.getUrl().replace("StructureMap", "StructureDefinition")+"-"+profile.getType()+suffix); ctxt.setUserData("profile", profile.getUrl()); // then we can easily assign this profile url for validation later when we actually transform profile.setId(map.getId()+"-"+profile.getType()+suffix); profile.setStatus(map.getStatus()); profile.setExperimental(map.getExperimental()); profile.setAbstract(false); ElementDefinition ed = profile.getDifferential().addElement(); ed.setPath(profile.getType()); prop.profileProperty = new Property(worker, ed, profile); return prop;
res.setCardinality(cardinality); res.setProfileLink(profile.getUserString("path")); res.setResType(profile.getType()); StructureDefinition base = context.fetchResource(StructureDefinition.class, res.getResType()); if (base != null)
String tn = null; if (t.getCode().equals("Element") || t.getCode().equals("BackboneElement")) tn = sdi.getType() + "#" + ed.getPath(); else tn = t.getCode(); for (TypeRefComponent t : ed.getType()) { if (t.getCode().equals("Element") || t.getCode().equals("BackboneElement")) result.addType(sdi.getType() + "#" + ed.getPath()); else if (t.getCode().equals("Resource")) result.addTypes(worker.getResourceNames());
String type = defn.getKind() == StructureDefinitionKind.LOGICAL ? defn.getId() : defn.getType();
public void checkAllInvariants(){ for (StructureDefinition sd : context.allStructures()) { if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) { for (ElementDefinition ed : sd.getSnapshot().getElement()) { for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) { if (inv.hasExpression()) { try { ExpressionNode n = (ExpressionNode) inv.getUserData("validator.expression.cache"); if (n == null) { n = fpe.parse(inv.getExpression()); inv.setUserData("validator.expression.cache", n); } fpe.check(null, sd.getKind() == StructureDefinitionKind.RESOURCE ? sd.getType() : "DomainResource", ed.getPath(), n); } catch (Exception e) { System.out.println("Error processing structure ["+sd.getId()+"] path "+ed.getPath()+":"+inv.getKey()+" (\""+inv.getExpression()+"\"): "+e.getMessage()); } } } } } } }
tgt.setBaseDefinition(src.getBaseDefinition()); if (src.hasType() && src.getDerivation() == org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.CONSTRAINT) tgt.setBaseType(src.getType()); tgt.setDerivation(convertTypeDerivationRule(src.getDerivation())); if (src.hasSnapshot())
if (rule(errors, IssueType.BUSINESSRULE, profile.getId()+"::"+ed.getPath()+"::"+inv.getKey(), inv.hasExpression(), "The invariant has no FHIR Path expression ("+inv.getXpath()+")")) { try { new FHIRPathEngine(context).check(null, profile.getType(), ed.getPath(), inv.getExpression()); // , inv.hasXpath() && inv.getXpath().startsWith("@value") } catch (Exception e) {
if (tgt.hasDifferential()) tgt.getDifferential().getElementFirstRep().getType().clear(); if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getId())) { tgt.setDerivation(TypeDerivationRule.SPECIALIZATION); tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/"+tgt.getType());
for (org.hl7.fhir.dstu3.model.StringType t : src.getContext()) tgt.addContext(t.getValue()); tgt.setConstrainedType(src.getType()); tgt.setBase(src.getBaseDefinition()); tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
tgt.setBaseDefinition(src.getBaseDefinition()); if (src.hasType() && src.getDerivation() == org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.CONSTRAINT) tgt.setBaseType(src.getType()); tgt.setDerivation(convertTypeDerivationRule(src.getDerivation())); if (src.hasSnapshot())