org.hl7.fhir.dstu3.model.BooleanType Java Examples

The following examples show how to use org.hl7.fhir.dstu3.model.BooleanType. 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: VersionConvertorPrimitiveType30_50Test.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: VersionConvertorPrimitiveType30_40Test.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: VersionConvertorPrimitiveType30_40Test.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: VersionConvertorPrimitiveType30_50Test.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: OrganizationResourceProvider.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * The "@Read" annotation indicates that this method supports the read operation. It takes one argument, the Resource type being returned.
 * 
 * @param theId
 *            The read operation takes one parameter, which must be of type IdDt and must be annotated with the "@Read.IdParam" annotation.
 * @return Returns a resource matching this identifier, or null if none exists.
 */
@Read()
public MyOrganization getResourceById(@IdParam IdType theId) {
	
	/*
	 * We only support one organization, so the follwing
	 * exception causes an HTTP 404 response if the 
	 * ID of "1" isn't used.
	 */
	if (!"1".equals(theId.getValue())) {
		throw new ResourceNotFoundException(theId);
	}
	
	MyOrganization retVal = new MyOrganization();
	retVal.setId("1");
	retVal.addIdentifier().setSystem("urn:example:orgs").setValue("FooOrganization");
	retVal.addAddress().addLine("123 Fake Street").setCity("Toronto");
	retVal.addTelecom().setUse(ContactPointUse.WORK).setValue("1-888-123-4567");
	
	// Populate the first, primitive extension
	retVal.setBillingCode(new CodeType("00102-1"));
	
	// The second extension is repeatable and takes a block type
	MyOrganization.EmergencyContact contact = new MyOrganization.EmergencyContact();
	contact.setActive(new BooleanType(true));
	contact.setContact(new ContactPoint());
	retVal.getEmergencyContact().add(contact);
	
	return retVal;
}
 
Example #6
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static boolean findBooleanExtension(Element c, String uri) {
  Extension ex = ExtensionHelper.getExtension(c, uri);
  if (ex == null)
    return false;
  if (!(ex.getValue() instanceof BooleanType))
    return false;
  return true;
}
 
Example #7
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static Boolean readBooleanExtension(Element c, String uri) {
  Extension ex = ExtensionHelper.getExtension(c, uri);
  if (ex == null)
    return null;
  if (!(ex.getValue() instanceof BooleanType))
    return null;
  return ((BooleanType) ex.getValue()).getValue();
}
 
Example #8
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with 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 #9
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static boolean isNotSelectable(CodeSystem cs, ConceptDefinitionComponent def) {
  for (ConceptPropertyComponent p : def.getProperty()) {
    if (p.getCode().equals("notSelectable") && p.hasValue() && p.getValue() instanceof BooleanType) 
      return ((BooleanType) p.getValue()).getValue();
  }
  return false;
}
 
Example #10
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static boolean isDeprecated(CodeSystem cs, ConceptDefinitionComponent def) {
  for (ConceptPropertyComponent p : def.getProperty()) {
    if (p.getCode().equals("deprecated") && p.hasValue() && p.getValue() instanceof BooleanType) 
      return ((BooleanType) p.getValue()).getValue();
    if (p.getCode().equals("deprecationDate") && p.hasValue() && p.getValue() instanceof DateTimeType) 
      return ((DateTimeType) p.getValue()).before(new DateTimeType());
  }
  return false;
}
 
Example #11
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private boolean orderMatches(BooleanType diff, BooleanType base) {
  return (diff == null) || (base == null) || (diff.getValue() == base.getValue());
}
 
Example #12
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public static void setInactive(CodeSystem cs, ConceptDefinitionComponent concept) throws FHIRFormatError {
  defineInactiveProperty(cs);
  concept.addProperty().setCode("inactive").setValue(new BooleanType(true));    
}
 
Example #13
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private Base runTransform(String ruleId, TransformContext context, StructureMap map, StructureMapGroupComponent group, StructureMapGroupRuleTargetComponent tgt, Variables vars, Base dest, String element, String srcVar) throws FHIRException {
	  try {
	    switch (tgt.getTransform()) {
	    case CREATE :
	      String tn;
	      if (tgt.getParameter().isEmpty()) {
	        // we have to work out the type. First, we see if there is a single type for the target. If there is, we use that
	        String[] types = dest.getTypesForProperty(element.hashCode(), element);
	        if (types.length == 1 && !"*".equals(types[0]) && !types[0].equals("Resource"))
	          tn = types[0];
	        else if (srcVar != null) {
	          tn = determineTypeFromSourceType(map, group, vars.get(VariableMode.INPUT, srcVar), types);
	        } else
	          throw new Error("Cannot determine type implicitly because there is no single input variable");
	      } else
	        tn = getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString());
	      Base res = services != null ? services.createType(context.getAppInfo(), tn) : ResourceFactory.createResourceOrType(tn);
	      if (res.isResource() && !res.fhirType().equals("Parameters")) {
//	        res.setIdBase(tgt.getParameter().size() > 1 ? getParamString(vars, tgt.getParameter().get(0)) : UUID.randomUUID().toString().toLowerCase());
	        if (services != null) 
	          res = services.createResource(context.getAppInfo(), res);
	      }
	      if (tgt.hasUserData("profile"))
	        res.setUserData("profile", tgt.getUserData("profile"));
	      return res;
	    case COPY : 
	      return getParam(vars, tgt.getParameter().get(0));
	    case EVALUATE :
	      ExpressionNode expr = (ExpressionNode) tgt.getUserData(MAP_EXPRESSION);
	      if (expr == null) {
	        expr = fpe.parse(getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString()));
	        tgt.setUserData(MAP_WHERE_EXPRESSION, expr);
	      }
	      List<Base> v = fpe.evaluate(vars, null, tgt.getParameter().size() == 2 ? getParam(vars, tgt.getParameter().get(0)) : new BooleanType(false), expr);
	      if (v.size() == 0)
	        return null;
	      else if (v.size() != 1)
	        throw new FHIRException("Rule \""+ruleId+"\": Evaluation of "+expr.toString()+" returned "+Integer.toString(v.size())+" objects");
	      else
	        return v.get(0);

	    case TRUNCATE : 
	      String src = getParamString(vars, tgt.getParameter().get(0));
	      String len = getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString());
	      if (Utilities.isInteger(len)) {
	        int l = Integer.parseInt(len);
	        if (src.length() > l)
	          src = src.substring(0, l);
	      }
	      return new StringType(src);
	    case ESCAPE : 
	      throw new Error("Rule \""+ruleId+"\": Transform "+tgt.getTransform().toCode()+" not supported yet");
	    case CAST :
	      throw new Error("Rule \""+ruleId+"\": Transform "+tgt.getTransform().toCode()+" not supported yet");
	    case APPEND : 
	      throw new Error("Rule \""+ruleId+"\": Transform "+tgt.getTransform().toCode()+" not supported yet");
	    case TRANSLATE : 
	      return translate(context, map, vars, tgt.getParameter());
	    case REFERENCE :
	      Base b = getParam(vars, tgt.getParameter().get(0));
	      if (b == null)
	        throw new FHIRException("Rule \""+ruleId+"\": Unable to find parameter "+((IdType) tgt.getParameter().get(0).getValue()).asStringValue());
	      if (!b.isResource())
	        throw new FHIRException("Rule \""+ruleId+"\": Transform engine cannot point at an element of type "+b.fhirType());
	      else {
	        String id = b.getIdBase();
	        if (id == null) {
	          id = UUID.randomUUID().toString().toLowerCase();
	          b.setIdBase(id);
	        }
	        return new Reference().setReference(b.fhirType()+"/"+id);
	      }
	    case DATEOP :
	      throw new Error("Rule \""+ruleId+"\": Transform "+tgt.getTransform().toCode()+" not supported yet");
	    case UUID :
	      return new IdType(UUID.randomUUID().toString());
	    case POINTER :
	      b = getParam(vars, tgt.getParameter().get(0));
	      if (b instanceof Resource)
	        return new UriType("urn:uuid:"+((Resource) b).getId());
	      else
	        throw new FHIRException("Rule \""+ruleId+"\": Transform engine cannot point at an element of type "+b.fhirType());
	    case CC:
	      CodeableConcept cc = new CodeableConcept();
	      cc.addCoding(buildCoding(getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()), getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString())));
	      return cc;
	    case C: 
	      Coding c = buildCoding(getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()), getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString()));
	      return c;
	    default:
	      throw new Error("Rule \""+ruleId+"\": Transform Unknown: "+tgt.getTransform().toCode());
	    }
	  } catch (Exception e) {
	    throw new FHIRException("Exception executing transform "+tgt.toString()+" on Rule \""+ruleId+"\": "+e.getMessage(), e);
	  }
	}
 
Example #14
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public static void setNotSelectable(CodeSystem cs, ConceptDefinitionComponent concept) throws FHIRFormatError {
  defineNotSelectableProperty(cs);
  concept.addProperty().setCode("notSelectable").setValue(new BooleanType(true));    
}
 
Example #15
Source File: BaseWorkerContext.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private ValidationResult serverValidateCode(Parameters pin, boolean doCache) throws Exception {
  if (noTerminologyServer) {
    return new ValidationResult(null, null, TerminologyServiceErrorClass.NOSERVICE);
  }
  String cacheName = doCache ? generateCacheName(pin) : null;
  ValidationResult res = loadFromCache(cacheName);
  if (res != null) {
    return res;
  }
  tlog("Terminology Server: $validate-code " + describeValidationParameters(pin));
  for (ParametersParameterComponent pp : pin.getParameter()) {
    if (pp.getName().equals("profile")) {
      throw new Error("Can only specify profile in the context");
    }
  }
  if (expProfile == null) {
    throw new Exception("No ExpansionProfile provided");
  }
  pin.addParameter().setName("profile").setResource(expProfile);

  Parameters pout = txServer.operateType(ValueSet.class, "validate-code", pin);
  boolean ok = false;
  String message = "No Message returned";
  String display = null;
  TerminologyServiceErrorClass err = TerminologyServiceErrorClass.UNKNOWN;
  for (ParametersParameterComponent p : pout.getParameter()) {
    if (p.getName().equals("result")) {
      ok = ((BooleanType) p.getValue()).getValue().booleanValue();
    } else if (p.getName().equals("message")) {
      message = ((StringType) p.getValue()).getValue();
    } else if (p.getName().equals("display")) {
      display = ((StringType) p.getValue()).getValue();
    } else if (p.getName().equals("cause")) {
      try {
        IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue());
        if (it == IssueType.UNKNOWN) {
          err = TerminologyServiceErrorClass.UNKNOWN;
        } else if (it == IssueType.NOTSUPPORTED) {
          err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED;
        }
      } catch (FHIRException e) {
      }
    }
  }
  if (!ok) {
    res = new ValidationResult(IssueSeverity.ERROR, message, err);
  } else if (display != null) {
    res = new ValidationResult(new ConceptDefinitionComponent().setDisplay(display));
  } else {
    res = new ValidationResult(new ConceptDefinitionComponent());
  }
  saveToCache(res, cacheName);
  return res;
}
 
Example #16
Source File: TranslationResults.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public BooleanType getResult() {
	return myResult;
}
 
Example #17
Source File: TranslationResults.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setResult(BooleanType theMatched) {
	myResult = theMatched;
}
 
Example #18
Source File: TranslationRequests.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public BooleanType getReverse() {
	return myReverse;
}
 
Example #19
Source File: TranslationRequests.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setReverse(BooleanType theReverse) {
	myReverse = theReverse;
}
 
Example #20
Source File: TranslationRequests.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setReverse(boolean theReverse) {
	myReverse = new BooleanType(theReverse);
}
 
Example #21
Source File: MyOrganization.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void setActive(BooleanType theActive) {
   myActive = theActive;
}