Java Code Examples for org.hl7.fhir.dstu3.model.StringType

The following examples show how to use org.hl7.fhir.dstu3.model.StringType. These examples are extracted from open source projects. 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
public static Stream<Arguments> dstu3PrimitiveTypes() {
  return Stream.of(
    Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
    Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
    Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
    Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
    Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
    Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
    Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
    Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
    Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
    Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
    Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
    Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
    Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
    Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
    Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
    Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
 
Example 2
public static Stream<Arguments> r5PrimitiveTypes() {
  return Stream.of(
    Arguments.arguments(org.hl7.fhir.r5.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r5.model.BooleanType()),
    Arguments.arguments(org.hl7.fhir.r5.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r5.model.CodeType()),
    Arguments.arguments(org.hl7.fhir.r5.model.DateType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateType()),
    Arguments.arguments(org.hl7.fhir.r5.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateTimeType()),
    Arguments.arguments(org.hl7.fhir.r5.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r5.model.DecimalType()),
    Arguments.arguments(org.hl7.fhir.r5.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r5.model.InstantType()),
    Arguments.arguments(org.hl7.fhir.r5.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.PositiveIntType()),
    Arguments.arguments(org.hl7.fhir.r5.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.UnsignedIntType()),
    Arguments.arguments(org.hl7.fhir.r5.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r5.model.IntegerType()),
    Arguments.arguments(org.hl7.fhir.r5.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r5.model.MarkdownType()),
    Arguments.arguments(org.hl7.fhir.r5.model.OidType.class.getSimpleName(), new org.hl7.fhir.r5.model.OidType()),
    Arguments.arguments(org.hl7.fhir.r5.model.StringType.class.getSimpleName(), new org.hl7.fhir.r5.model.StringType()),
    Arguments.arguments(org.hl7.fhir.r5.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.TimeType()),
    Arguments.arguments(org.hl7.fhir.r5.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r5.model.UuidType()),
    Arguments.arguments(org.hl7.fhir.r5.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r5.model.Base64BinaryType()),
    Arguments.arguments(org.hl7.fhir.r5.model.UriType.class.getSimpleName(), new org.hl7.fhir.r5.model.UriType()));
}
 
Example 3
public static Stream<Arguments> dstu3PrimitiveTypes() {
  return Stream.of(
    Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
    Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
    Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
    Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
    Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
    Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
    Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
    Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
    Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
    Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
    Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
    Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
    Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
    Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
    Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
    Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
 
Example 4
public static Stream<Arguments> r4PrimitiveTypes() {
  return Stream.of(
    Arguments.arguments(org.hl7.fhir.r4.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r4.model.BooleanType()),
    Arguments.arguments(org.hl7.fhir.r4.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r4.model.CodeType()),
    Arguments.arguments(org.hl7.fhir.r4.model.DateType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateType()),
    Arguments.arguments(org.hl7.fhir.r4.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateTimeType()),
    Arguments.arguments(org.hl7.fhir.r4.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r4.model.DecimalType()),
    Arguments.arguments(org.hl7.fhir.r4.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r4.model.InstantType()),
    Arguments.arguments(org.hl7.fhir.r4.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.PositiveIntType()),
    Arguments.arguments(org.hl7.fhir.r4.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.UnsignedIntType()),
    Arguments.arguments(org.hl7.fhir.r4.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r4.model.IntegerType()),
    Arguments.arguments(org.hl7.fhir.r4.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r4.model.MarkdownType()),
    Arguments.arguments(org.hl7.fhir.r4.model.OidType.class.getSimpleName(), new org.hl7.fhir.r4.model.OidType()),
    Arguments.arguments(org.hl7.fhir.r4.model.StringType.class.getSimpleName(), new org.hl7.fhir.r4.model.StringType()),
    Arguments.arguments(org.hl7.fhir.r4.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.TimeType()),
    Arguments.arguments(org.hl7.fhir.r4.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r4.model.UuidType()),
    Arguments.arguments(org.hl7.fhir.r4.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r4.model.Base64BinaryType()),
    Arguments.arguments(org.hl7.fhir.r4.model.UriType.class.getSimpleName(), new org.hl7.fhir.r4.model.UriType()));
}
 
Example 5
Source Project: org.hl7.fhir.core   Source File: Element.java    License: Apache License 2.0 6 votes vote down vote up
public void setChildValue(String name, String value) {
  if (children == null)
    children = new ArrayList<Element>();
  for (Element child : children) {
    if (name.equals(child.getName())) {
      if (!child.isPrimitive())
        throw new Error("Cannot set a value of a non-primitive type ("+name+" on "+this.getName()+")");
      child.setValue(value);
    }
  }
  try {
    setProperty(name.hashCode(), name, new StringType(value));
  } catch (FHIRException e) {
    throw new Error(e);
  }
}
 
Example 6
Source Project: org.hl7.fhir.core   Source File: Element.java    License: Apache License 2.0 6 votes vote down vote up
@Override
	public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
  	if (isPrimitive() && (hash == "value".hashCode()) && !Utilities.noString(value)) {
//  		String tn = getType();
//  		throw new Error(tn+" not done yet");
  	  Base[] b = new Base[1];
  	  b[0] = new StringType(value);
  	  return b;
  	}
  		
  	List<Base> result = new ArrayList<Base>();
  	if (children != null) {
  	for (Element child : children) {
  		if (child.getName().equals(name))
  			result.add(child);
  		if (child.getName().startsWith(name) && child.getProperty().isChoice() && child.getProperty().getName().equals(name+"[x]"))
  			result.add(child);
  	}
  	}
  	if (result.isEmpty() && checkValid) {
//  		throw new FHIRException("not determined yet");
  	}
  	return result.toArray(new Base[result.size()]);
	}
 
Example 7
Source Project: org.hl7.fhir.core   Source File: StructureMapUtilities.java    License: Apache License 2.0 6 votes vote down vote up
private void executeDependency(String indent, TransformContext context, StructureMap map, Variables vin, StructureMapGroupComponent group, StructureMapGroupRuleDependentComponent dependent) throws FHIRException {
  ResolvedGroup rg = resolveGroupReference(map, group, dependent.getName());

	if (rg.target.getInput().size() != dependent.getVariable().size()) {
		throw new FHIRException("Rule '"+dependent.getName()+"' has "+Integer.toString(rg.target.getInput().size())+" but the invocation has "+Integer.toString(dependent.getVariable().size())+" variables");
	}
	Variables v = new Variables();
	for (int i = 0; i < rg.target.getInput().size(); i++) {
		StructureMapGroupInputComponent input = rg.target.getInput().get(i);
		StringType rdp = dependent.getVariable().get(i);
     String var = rdp.asStringValue();
		VariableMode mode = input.getMode() == StructureMapInputMode.SOURCE ? VariableMode.INPUT :   VariableMode.OUTPUT; 
		Base vv = vin.get(mode, var);
     if (vv == null && mode == VariableMode.INPUT) //* once source, always source. but target can be treated as source at user convenient
       vv = vin.get(VariableMode.OUTPUT, var);
		if (vv == null)
			throw new FHIRException("Rule '"+dependent.getName()+"' "+mode.toString()+" variable '"+input.getName()+"' named as '"+var+"' has no value");
		v.add(mode, input.getName(), vv);    	
	}
	executeGroup(indent+"  ", context, rg.targetMap, v, rg.target);
}
 
Example 8
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 6 votes vote down vote up
public static String readStringExtension(Element c, String uri) {
  Extension ex = ExtensionHelper.getExtension(c, uri);
  if (ex == null)
    return null;
  if (ex.getValue() instanceof UriType)
    return ((UriType) ex.getValue()).getValue();
  if (ex.getValue() instanceof CodeType)
    return ((CodeType) ex.getValue()).getValue();
  if (ex.getValue() instanceof IntegerType)
    return ((IntegerType) ex.getValue()).asStringValue();
  if ((ex.getValue() instanceof MarkdownType))
    return ((MarkdownType) ex.getValue()).getValue();
  if (!(ex.getValue() instanceof StringType))
    return null;
  return ((StringType) ex.getValue()).getValue();
}
 
Example 9
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 6 votes vote down vote up
public static String readStringExtension(DomainResource c, String uri) {
  Extension ex = getExtension(c, uri);
  if (ex == null)
    return null;
  if ((ex.getValue() instanceof StringType))
    return ((StringType) ex.getValue()).getValue();
  if ((ex.getValue() instanceof UriType))
    return ((UriType) ex.getValue()).getValue();
  if (ex.getValue() instanceof CodeType)
    return ((CodeType) ex.getValue()).getValue();
  if (ex.getValue() instanceof IntegerType)
    return ((IntegerType) ex.getValue()).asStringValue();
  if ((ex.getValue() instanceof MarkdownType))
    return ((MarkdownType) ex.getValue()).getValue();
  return null;
}
 
Example 10
Source Project: org.hl7.fhir.core   Source File: FHIRToolingClient.java    License: Apache License 2.0 6 votes vote down vote up
public ValueSet expandValueset(ValueSet source, ExpansionProfile profile, Map<String, String> params) {
  List<Header> headers = null;
  Parameters p = new Parameters();
  p.addParameter().setName("valueSet").setResource(source);
  if (profile != null)
    p.addParameter().setName("profile").setResource(profile);
  for (String n : params.keySet())
    p.addParameter().setName(n).setValue(new StringType(params.get(n)));
  ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), 
      utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers);
  result.addErrorStatus(410);//gone
  result.addErrorStatus(404);//unknown
  result.addErrorStatus(405);
  result.addErrorStatus(422);//Unprocessable Entity
  result.addSuccessStatus(200);
  result.addSuccessStatus(201);
  if(result.isUnsuccessfulRequest()) {
    throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload());
  }
  return (ValueSet) result.getPayload();
}
 
Example 11
Source Project: org.hl7.fhir.core   Source File: FHIRToolingClient.java    License: Apache License 2.0 6 votes vote down vote up
public ConceptMap initializeClosure(String name) {
  Parameters params = new Parameters();
  params.addParameter().setName("name").setValue(new StringType(name));
  List<Header> headers = null;
  ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
      utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers);
  result.addErrorStatus(410);//gone
  result.addErrorStatus(404);//unknown
  result.addErrorStatus(405);
  result.addErrorStatus(422);//Unprocessable Entity
  result.addSuccessStatus(200);
  result.addSuccessStatus(201);
  if(result.isUnsuccessfulRequest()) {
    throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload());
  }
  return (ConceptMap) result.getPayload();
}
 
Example 12
Source Project: org.hl7.fhir.core   Source File: FHIRToolingClient.java    License: Apache License 2.0 6 votes vote down vote up
public ConceptMap updateClosure(String name, Coding coding) {
  Parameters params = new Parameters();
  params.addParameter().setName("name").setValue(new StringType(name));
  params.addParameter().setName("concept").setValue(coding);
  List<Header> headers = null;
  ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
      utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers);
  result.addErrorStatus(410);//gone
  result.addErrorStatus(404);//unknown
  result.addErrorStatus(405);
  result.addErrorStatus(422);//Unprocessable Entity
  result.addSuccessStatus(200);
  result.addSuccessStatus(201);
  if(result.isUnsuccessfulRequest()) {
    throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload());
  }
  return (ConceptMap) result.getPayload();
}
 
Example 13
Source Project: org.hl7.fhir.core   Source File: NarrativeGenerator.java    License: Apache License 2.0 6 votes vote down vote up
public static String displayHumanName(HumanName name) {
  StringBuilder s = new StringBuilder();
  if (name.hasText())
    s.append(name.getText());
  else {
    for (StringType p : name.getGiven()) {
      s.append(p.getValue());
      s.append(" ");
    }
    if (name.hasFamily()) {
      s.append(name.getFamily());
      s.append(" ");
    }
  }
  if (name.hasUse() && name.getUse() != NameUse.USUAL)
    s.append("("+name.getUse().toString()+")");
  return s.toString();
}
 
Example 14
public static OperationOutcomeIssueComponent convertToIssue(ValidationMessage message, OperationOutcome op) {
  OperationOutcomeIssueComponent issue = new OperationOutcome.OperationOutcomeIssueComponent();
  issue.setCode(convert(message.getType()));
  if (message.getLocation() != null) {
    // message location has a fhirPath in it. We need to populate the expression
    issue.addExpression(message.getLocation());
    // also, populate the XPath variant
    StringType s = new StringType();
    s.setValue(Utilities.fhirPathToXPath(message.getLocation())+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
    issue.getLocation().add(s);
  }
  issue.setSeverity(convert(message.getLevel()));
  CodeableConcept c = new CodeableConcept();
  c.setText(message.getMessage());
  issue.setDetails(c);
  if (message.getSource() != null) {
    issue.getExtension().add(ToolingExtensions.makeIssueSource(message.getSource()));
  }
  return issue;
}
 
Example 15
Source Project: cqf-ruler   Source File: LibraryOperationsProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Operation(name = "$get-elm", idempotent = true, type = Library.class)
public Parameters getElm(@IdParam IdType theId, @OptionalParam(name="format") String format) {
    Library theResource = this.libraryResourceProvider.getDao().read(theId);
    // this.formatCql(theResource);

    ModelManager modelManager = this.getModelManager();
    LibraryManager libraryManager = this.getLibraryManager(modelManager);


    String elm = "";
    CqlTranslator translator = this.dataRequirementsProvider.getTranslator(theResource, libraryManager, modelManager);
    if (translator != null) {
        if (format.equals("json")) {
            elm = translator.toJson();
        }
        else {
            elm = translator.toXml();
        }
    }
    Parameters p = new Parameters();
    p.addParameter().setValue(new StringType(elm));
    return p;
}
 
Example 16
public static void main(String[] args) {

      // Create an Observation
      Observation obs = new Observation();
      obs.setStatus(Observation.ObservationStatus.FINAL);
      obs.setValue(new StringType("This is a value"));

      // Create a Patient
      Patient pat = new Patient();
      pat.addName().setFamily("Simpson").addGiven("Homer");

      // Assign the Patient to the Observation
      obs.getSubject().setResource(pat);

      FhirContext ctx = FhirContext.forDstu3();
      String output = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs);
      System.out.println(output);

   }
 
Example 17
Source Project: elexis-3-core   Source File: ObservationAccessor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public List<ObservationComponent> getComponents(DomainResource resource){
	org.hl7.fhir.dstu3.model.Observation fhirObservation =
		(org.hl7.fhir.dstu3.model.Observation) resource;
	List<ObservationComponent> components = new ArrayList<>();
	
	for (ObservationComponentComponent o : fhirObservation.getComponent()) {
		ObservationComponent component = new ObservationComponent(o.getId());
		CodeableConcept codeableConcept = o.getCode();
		if (codeableConcept != null) {
			component.setCoding(ModelUtil.getCodingsFromConcept(codeableConcept));
			component.setExtensions(getExtensions(o));
			
			if (o.hasValueQuantity()) {
				Quantity quantity = (Quantity) o.getValue();
				component.setNumericValue(quantity.getValue());
				component.setNumericValueUnit(quantity.getUnit());
			} else if (o.hasValueStringType()) {
				StringType stringType = (StringType) o.getValue();
				component.setStringValue(stringType.getValue());
			}
		}
		components.add(component);
	}
	return components;
}
 
Example 18
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 5 votes vote down vote up
private Observation processObservation(CDAUtilities cda, Convert convert, Context context, Element o) throws Exception {
	Observation obs = new Observation();
	obs.setId(context.baseId+"-results-"+Integer.toString(context.obsId));
	context.obsId++;
	obs.setSubject(context.subjectRef);
	obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId()));
	obs.setStatus(ObservationStatus.FINAL);
	obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
	obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));
	obs.setInterpretation(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "interpretationCode")), null));
	Element rr = cda.getChild(o, "referenceRange");
	if (rr != null)
		obs.addReferenceRange().setText(cda.getChild(cda.getChild(rr, "observationRange"), "text").getTextContent());

	Element v = cda.getChild(o, "value");
	String type = v.getAttribute("xsi:type");
	if ("ST".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobsother");
		obs.setValue(new StringType(v.getTextContent()));
	} else if ("CD".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobscode");
		obs.setValue(inspectCode(convert.makeCodeableConceptFromCD(v), null));
	} else if ("PQ".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobsquantity");
		String va = cda.getChild(o, "value").getAttribute("value");
		if (!Utilities.isDecimal(va, true)) {
			obs.setDataAbsentReason(inspectCode(new CodeableConcept().setText(va), null));
		} else
			obs.setValue(convert.makeQuantityFromPQ(cda.getChild(o, "value"), null));
	} else
		throw new Exception("Unknown type '"+type+"'");

	for (Element e : cda.getChildren(o, "id")) {
		Identifier id = convert.makeIdentifierFromII(e);
		obs.getIdentifier().add(id);
	}
	saveResource(obs, "-gen");
	return obs;
}
 
Example 19
Source Project: org.hl7.fhir.core   Source File: ProfileUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private boolean unbounded(ElementDefinition definition) {
  StringType max = definition.getMaxElement();
  if (max == null)
    return false; // this is not valid
  if (max.getValue().equals("1"))
    return false;
  if (max.getValue().equals("0"))
    return false;
  return true;
}
 
Example 20
Source Project: org.hl7.fhir.core   Source File: ProfileUtilities.java    License: Apache License 2.0 5 votes vote down vote up
public static String describeExtensionContext(StructureDefinition ext) {
  CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
  for (StringType t : ext.getContext())
    b.append(t.getValue());
  if (!ext.hasContextType())
    throw new Error("no context type on "+ext.getUrl());
  switch (ext.getContextType()) {
  case DATATYPE: return "Use on data type: "+b.toString();
  case EXTENSION: return "Use on extension: "+b.toString();
  case RESOURCE: return "Use on element: "+b.toString();
  default:
    return "??";
  }
}
 
Example 21
Source Project: org.hl7.fhir.core   Source File: ProfileUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private String describeCardinality(ElementDefinition definition, ElementDefinition fallback, UnusedTracker tracker) {
  IntegerType min = definition.hasMinElement() ? definition.getMinElement() : new IntegerType();
  StringType max = definition.hasMaxElement() ? definition.getMaxElement() : new StringType();
  if (min.isEmpty() && fallback != null)
    min = fallback.getMinElement();
  if (max.isEmpty() && fallback != null)
    max = fallback.getMaxElement();

  tracker.used = !max.isEmpty() && !max.getValue().equals("0");

  if (min.isEmpty() && max.isEmpty())
    return null;
  else
    return (!min.hasValue() ? "" : Integer.toString(min.getValue())) + ".." + (!max.hasValue() ? "" : max.getValue());
}
 
Example 22
Source Project: org.hl7.fhir.core   Source File: ProfileComparer.java    License: Apache License 2.0 5 votes vote down vote up
private List<StringType> mergeStrings(List<StringType> left, List<StringType> right) {
  List<StringType> result = new ArrayList<StringType>();
  result.addAll(left);
  for (StringType c : right) {
    boolean found = false;
    for (StringType ct : left)
      if (Utilities.equals(c.getValue(), ct.getValue()))
        found = true;
    if (!found)
      result.add(c);
  }
  return result;
}
 
Example 23
Source Project: org.hl7.fhir.core   Source File: StructureMapUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private void parseParameter(StructureMapGroupRuleTargetComponent target, FHIRLexer lexer) throws FHIRLexerException, FHIRFormatError {
	if (!lexer.isConstant(true)) {
		target.addParameter().setValue(new IdType(lexer.take()));
	} else if (lexer.isStringConstant())
		target.addParameter().setValue(new StringType(lexer.readConstant("??")));
	else {
		target.addParameter().setValue(readConstant(lexer.take(), lexer));
	}
}
 
Example 24
Source Project: org.hl7.fhir.core   Source File: StructureMapUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private Type readConstant(String s, FHIRLexer lexer) throws FHIRLexerException {
	if (Utilities.isInteger(s))
		return new IntegerType(s);
	else if (Utilities.isDecimal(s, false))
		return new DecimalType(s);
	else if (Utilities.existsInList(s, "true", "false"))
		return new BooleanType(s.equals("true"));
	else 
		return new StringType(lexer.processConstant(s));        
}
 
Example 25
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 5 votes vote down vote up
public static void addMarkdownExtension(DomainResource dr, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(dr, url);
    if (ex != null)
      ex.setValue(new StringType(content));
    else
      dr.getExtension().add(Factory.newExtension(url, new MarkdownType(content), true));   
  }
}
 
Example 26
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 5 votes vote down vote up
public static void addStringExtension(Element e, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(e, url);
    if (ex != null)
      ex.setValue(new StringType(content));
    else
      e.getExtension().add(Factory.newExtension(url, new StringType(content), true));   
  }
}
 
Example 27
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 5 votes vote down vote up
public static void addStringExtension(DomainResource e, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(e, url);
    if (ex != null)
      ex.setValue(new StringType(content));
    else
      e.getExtension().add(Factory.newExtension(url, new StringType(content), true));   
  }
}
 
Example 28
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean findStringExtension(Element c, String uri) {
  Extension ex = ExtensionHelper.getExtension(c, uri);
  if (ex == null)
    return false;
  if (!(ex.getValue() instanceof StringType))
    return false;
  return !StringUtils.isBlank(((StringType) ex.getValue()).getValue());
}
 
Example 29
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 5 votes vote down vote up
public static void setStringExtension(DomainResource resource, String uri, String value) {
  Extension ext = getExtension(resource, uri);
  if (ext != null)
    ext.setValue(new StringType(value));
  else
    resource.getExtension().add(new Extension(new UriType(uri)).setValue(new StringType(value)));
}
 
Example 30
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 5 votes vote down vote up
public static void setStringExtension(Element element, String uri, String value) {
  Extension ext = getExtension(element, uri);
  if (ext != null)
    ext.setValue(new StringType(value));
  else
    element.getExtension().add(new Extension(new UriType(uri)).setValue(new StringType(value)));
}