Java Code Examples for org.hl7.fhir.dstu3.model.StructureDefinition#getKind()
The following examples show how to use
org.hl7.fhir.dstu3.model.StructureDefinition#getKind() .
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: Property.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public boolean IsLogicalAndHasPrimitiveValue(String name) { // if (canBePrimitive!= null) // return canBePrimitive; canBePrimitive = false; if (structure.getKind() != StructureDefinitionKind.LOGICAL) return false; if (!hasType(name)) return false; StructureDefinition sd = context.fetchResource(StructureDefinition.class, structure.getUrl().substring(0, structure.getUrl().lastIndexOf("/")+1)+getType(name)); if (sd == null) sd = context.fetchTypeDefinition(getType(name)); if (sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE) return true; if (sd == null || sd.getKind() != StructureDefinitionKind.LOGICAL) return false; for (ElementDefinition ed : sd.getSnapshot().getElement()) { if (ed.getPath().equals(sd.getId()+".value") && ed.getType().size() == 1 && isPrimitive(ed.getType().get(0).getCode())) { canBePrimitive = true; return true; } } return false; }
Example 2
Source File: ObjectConverter.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private Element convertElement(Property property, Base base) throws FHIRException { if (base == null) return null; String tn = base.fhirType(); StructureDefinition sd = context.fetchTypeDefinition(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; }
Example 3
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 4
Source File: SimpleWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Override public List<String> getResourceNames() { List<String> result = new ArrayList<String>(); for (StructureDefinition sd : structures.values()) { if (sd.getKind() == StructureDefinitionKind.RESOURCE && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) result.add(sd.getName()); } Collections.sort(result); return result; }
Example 5
Source File: SimpleWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Override public List<String> getTypeNames() { List<String> result = new ArrayList<String>(); for (StructureDefinition sd : structures.values()) { if (sd.getKind() != StructureDefinitionKind.LOGICAL && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) result.add(sd.getName()); } Collections.sort(result); return result; }
Example 6
Source File: SimpleWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Override public boolean isResource(String t) { StructureDefinition sd; try { sd = fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+t); } catch (Exception e) { return false; } if (sd == null) return false; if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) return false; return sd.getKind() == StructureDefinitionKind.RESOURCE; }
Example 7
Source File: ProfileUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private boolean isDataType(String value) { StructureDefinition sd = context.fetchTypeDefinition(value); return sd != null && sd.getKind() == StructureDefinitionKind.COMPLEXTYPE; }
Example 8
Source File: ProfileUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public boolean isPrimitive(String value) { StructureDefinition sd = context.fetchTypeDefinition(value); return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE; }
Example 9
Source File: QuestionnaireBuilder.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private boolean isPrimitive(TypeRefComponent t) { String code = t.getCode(); StructureDefinition sd = context.fetchTypeDefinition(code); return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE; }
Example 10
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private boolean isPrimitive(String code) { StructureDefinition sd = context.fetchTypeDefinition(code); return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE; }