org.hl7.fhir.instance.model.api.IPrimitiveType Java Examples
The following examples show how to use
org.hl7.fhir.instance.model.api.IPrimitiveType.
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: HumanName.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
/** * Joins a list of strings with a single space (' ') between each string * * TODO: replace with call to ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated when HAPI upgrades to 1.4 */ private static String joinStringsSpaceSeparated(List<? extends IPrimitiveType<String>> theStrings) { StringBuilder b = new StringBuilder(); for (IPrimitiveType<String> next : theStrings) { if (next.isEmpty()) { continue; } if (b.length() > 0) { b.append(' '); } b.append(next.getValue()); } return b.toString(); }
Example #2
Source File: HumanName.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
/** * Joins a list of strings with a single space (' ') between each string * * TODO: replace with call to ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated when HAPI upgrades to 1.4 */ private static String joinStringsSpaceSeparated(List<? extends IPrimitiveType<String>> theStrings) { StringBuilder b = new StringBuilder(); for (IPrimitiveType<String> next : theStrings) { if (next.isEmpty()) { continue; } if (b.length() > 0) { b.append(' '); } b.append(next.getValue()); } return b.toString(); }
Example #3
Source File: HumanName.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
/** * Joins a list of strings with a single space (' ') between each string * * TODO: replace with call to ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated when HAPI upgrades to 1.4 */ private static String joinStringsSpaceSeparated(List<? extends IPrimitiveType<String>> theStrings) { StringBuilder b = new StringBuilder(); for (IPrimitiveType<String> next : theStrings) { if (next.isEmpty()) { continue; } if (b.length() > 0) { b.append(' '); } b.append(next.getValue()); } return b.toString(); }
Example #4
Source File: CareConnectServerConformanceProvider.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
private DateTimeType conformanceDate() { IPrimitiveType<Date> buildDate = serverConfiguration.getConformanceDate(); if (buildDate != null) { try { return new DateTimeType(buildDate.getValue()); } catch (DataFormatException e) { // fall through } } return DateTimeType.now(); }
Example #5
Source File: PrimitiveConverter.java From bunsen with Apache License 2.0 | 5 votes |
@Override public void setField(IBase parentObject, BaseRuntimeChildDefinition fieldToSet, Object object) { IPrimitiveType element = (IPrimitiveType) elementDefinition .newInstance(fieldToSet.getInstanceConstructorArguments()); PrimitiveConverter.this.toHapi(object, element); fieldToSet.getMutator().setValue(parentObject, element); }
Example #6
Source File: CareConnectServerConformanceR4Provider.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
private DateTimeType conformanceDate() { IPrimitiveType<Date> buildDate = serverConfiguration.getConformanceDate(); if (buildDate != null) { try { return new DateTimeType(buildDate.getValue()); } catch (DataFormatException e) { // fall through } } return DateTimeType.now(); }
Example #7
Source File: DefinitionToAvroVisitor.java From bunsen with Apache License 2.0 | 5 votes |
@Override public Object fromHapi(Object input) { String uri = ((IPrimitiveType) input).getValueAsString(); return uri != null && uri.startsWith(prefix) ? uri.substring(uri.lastIndexOf('/') + 1) : null; }
Example #8
Source File: DefinitionToSparkVisitor.java From bunsen with Apache License 2.0 | 5 votes |
@Override public Object fromHapi(Object input) { String uri = ((IPrimitiveType) input).getValueAsString(); return uri != null && uri.startsWith(prefix) ? uri.substring(uri.lastIndexOf('/') + 1) : null; }
Example #9
Source File: BaseExtension.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
/** * Returns the value of this extension cast as a {@link IPrimitiveType}. This method is just a convenience method for easy chaining. */ public IPrimitiveType<?> getValueAsPrimitive() { return (IPrimitiveType<?>)getValue(); }
Example #10
Source File: FhirModelResolver.java From cql_engine with Apache License 2.0 | 4 votes |
protected Object resolveProperty(Object target, String path) { if (target == null) { return null; } if (target instanceof IBaseEnumeration && path.equals("value")) { return ((IBaseEnumeration) target).getValueAsString(); } // TODO: Consider using getResourceType everywhere? if (target instanceof IAnyResource && this.getResourceType((ResourceType) target).equals(path)) { return target; } IBase base = (IBase) target; BaseRuntimeElementCompositeDefinition<?> definition; if (base instanceof IPrimitiveType) { return toJavaPrimitive(path.equals("value") ? ((IPrimitiveType<?>) target).getValue() : target, base); } else { definition = resolveRuntimeDefinition(base); } BaseRuntimeChildDefinition child = definition.getChildByName(path); if (child == null) { child = resolveChoiceProperty(definition, path); } if (child == null) { return null; } List<IBase> values = child.getAccessor().getValues(base); if (values == null || values.isEmpty()) { return null; } if (child instanceof RuntimeChildChoiceDefinition && !child.getElementName().equalsIgnoreCase(path)) { if (!values.get(0).getClass().getSimpleName().equalsIgnoreCase(child.getChildByName(path).getImplementingClass().getSimpleName())) { return null; } } return toJavaPrimitive(child.getMax() < 1 ? values : values.get(0), base); }
Example #11
Source File: FhirModelResolver.java From cql_engine with Apache License 2.0 | 4 votes |
@Override public void setValue(Object target, String path, Object value) { if (target == null) { return; } if (target instanceof IBaseEnumeration && path.equals("value")) { ((IBaseEnumeration)target).setValueAsString((String)value); return; } IBase base = (IBase) target; BaseRuntimeElementCompositeDefinition<?> definition; if (base instanceof IPrimitiveType) { ((IPrimitiveType) target).setValue(fromJavaPrimitive(value, base)); return; } else { definition = resolveRuntimeDefinition(base); } BaseRuntimeChildDefinition child = definition.getChildByName(path); if (child == null) { child = resolveChoiceProperty(definition, path); } if (child == null) { throw new DataProviderException(String.format("Unable to resolve path %s.", path)); } try { if (value instanceof Iterable) { for (Object val : (Iterable<?>) value) { child.getMutator().addValue(base, (IBase) fromJavaPrimitive(val, base)); } } else { child.getMutator().setValue(base, (IBase) fromJavaPrimitive(value, base)); } } catch (IllegalArgumentException le) { if (value.getClass().getSimpleName().equals("Quantity")) { try { value = this.castToSimpleQuantity((BaseType) value); } catch (FHIRException e) { throw new InvalidCast("Unable to cast Quantity to SimpleQuantity"); } child.getMutator().setValue(base, (IBase) fromJavaPrimitive(value, base)); } else { throw new DataProviderException(String.format("Configuration error encountered: %s", le.getMessage())); } } }
Example #12
Source File: DefinitionToAvroVisitor.java From bunsen with Apache License 2.0 | 4 votes |
@Override public void toHapi(Object input, IPrimitiveType primitive) { primitive.setValue(input); }
Example #13
Source File: DefinitionToSparkVisitor.java From bunsen with Apache License 2.0 | 4 votes |
@Override public void toHapi(Object input, IPrimitiveType primitive) { primitive.setValueAsString(((BigDecimal) input).toPlainString()); }
Example #14
Source File: StringConverter.java From bunsen with Apache License 2.0 | 4 votes |
protected Object fromHapi(IPrimitiveType primitive) { return primitive.getValueAsString(); }
Example #15
Source File: StringConverter.java From bunsen with Apache License 2.0 | 4 votes |
@Override public void toHapi(Object input, IPrimitiveType primitive) { primitive.setValueAsString((String) input); }
Example #16
Source File: EnumConverter.java From bunsen with Apache License 2.0 | 4 votes |
protected Object fromHapi(IPrimitiveType primitive) { return "?".equals(primitive.getValueAsString()) ? null : primitive.getValueAsString(); }
Example #17
Source File: PrimitiveConverter.java From bunsen with Apache License 2.0 | 4 votes |
@Override public Object fromHapi(Object input) { return fromHapi((IPrimitiveType) input); }
Example #18
Source File: PrimitiveConverter.java From bunsen with Apache License 2.0 | 4 votes |
protected Object fromHapi(IPrimitiveType primitive) { return primitive.getValue(); }
Example #19
Source File: BaseExtension.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
/** * Returns the value of this extension cast as a {@link IPrimitiveType}. This method is just a convenience method for easy chaining. */ public IPrimitiveType<?> getValueAsPrimitive() { return (IPrimitiveType<?>)getValue(); }
Example #20
Source File: BaseExtension.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
/** * Returns the value of this extension cast as a {@link IPrimitiveType}. This method is just a convenience method for easy chaining. */ public IPrimitiveType<?> getValueAsPrimitive() { return (IPrimitiveType<?>)getValue(); }
Example #21
Source File: EnumConverter.java From bunsen with Apache License 2.0 | 3 votes |
@Override public void toHapi(Object input, IPrimitiveType primitive) { if ("?".equals(input)) { input = null; } primitive.setValueAsString((String) input); }
Example #22
Source File: PrimitiveConverter.java From bunsen with Apache License 2.0 | 3 votes |
@Override public IBase toHapi(Object input) { IPrimitiveType element = (IPrimitiveType) elementDefinition.newInstance(); PrimitiveConverter.this.toHapi(input, element); return element; }
Example #23
Source File: StringToHapiSetter.java From bunsen with Apache License 2.0 | 3 votes |
@Override public IBase toHapi(Object sparkObject) { IPrimitiveType element = (IPrimitiveType) elementDefinition.newInstance(); element.setValueAsString((String) sparkObject); return element; }
Example #24
Source File: DefinitionToAvroVisitor.java From bunsen with Apache License 2.0 | 2 votes |
protected Object fromHapi(IPrimitiveType primitive) { return primitive.getValue(); }
Example #25
Source File: PrimitiveConverter.java From bunsen with Apache License 2.0 | 2 votes |
/** * Helper method that will set the HAPI value. * @param input the input object * @param primitive the FHIR primitive to set */ public void toHapi(Object input, IPrimitiveType primitive) { primitive.setValue(input); }