org.hl7.fhir.r4.model.IntegerType Java Examples

The following examples show how to use org.hl7.fhir.r4.model.IntegerType. 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: MultitenantServerR4IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateAndReadInTenantB() {
  ourLog.info("Base URL is: " + HapiProperties.getServerAddress());

  // Create tenant A
  ourClientTenantInterceptor.setTenantId("DEFAULT");
  ourClient
    .operation()
    .onServer()
    .named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION)
    .withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(2))
    .andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-B"))
    .execute();


  ourClientTenantInterceptor.setTenantId("TENANT-B");
  Patient pt = new Patient();
  pt.addName().setFamily("Family B");
  ourClient.create().resource(pt).execute().getId();

  Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
  assertEquals(1, searchResult.getEntry().size());
  Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
  assertEquals("Family B", pt2.getName().get(0).getFamily());
}
 
Example #2
Source File: ToolingExtensions.java    From org.hl7.fhir.core with 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 CanonicalType)
    return ((CanonicalType) 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 #3
Source File: ToolingExtensions.java    From org.hl7.fhir.core with 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 #4
Source File: MultitenantServerR4IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateAndReadInTenantA() {
  ourLog.info("Base URL is: " + HapiProperties.getServerAddress());

  // Create tenant A
  ourClientTenantInterceptor.setTenantId("DEFAULT");
  ourClient
    .operation()
    .onServer()
    .named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION)
    .withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(1))
    .andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-A"))
    .execute();


  ourClientTenantInterceptor.setTenantId("TENANT-A");
  Patient pt = new Patient();
  pt.addName().setFamily("Family A");
  ourClient.create().resource(pt).execute().getId();

  Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
  assertEquals(1, searchResult.getEntry().size());
  Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
  assertEquals("Family A", pt2.getName().get(0).getFamily());
}
 
Example #5
Source File: VersionConvertorPrimitiveType40_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 #6
Source File: VersionConvertorPrimitiveType40_50Test.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(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 #7
Source File: OperationOutcomeUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
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());
  }
  // pass through line/col if they're present
  if (message.getLine() != 0)
    issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_LINE).setValue(new IntegerType(message.getLine()));
  if (message.getCol() != 0)
    issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_COL).setValue(new IntegerType(message.getCol()));
  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 #8
Source File: ProfileComparer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private IntegerType unionMaxLength(int left, int right) {
  if (left == 0) 
    left = Integer.MAX_VALUE;
  if (right == 0) 
    right = Integer.MAX_VALUE;
  if (left < right)
    return right == Integer.MAX_VALUE ? null : new IntegerType(right);
  else
    return left == Integer.MAX_VALUE ? null : new IntegerType(left);
}
 
Example #9
Source File: RandomCodeGenerator.java    From synthea with Apache License 2.0 5 votes vote down vote up
private static void initializeCache() {
  responseCache = CacheBuilder.newBuilder()
      .maximumSize(RESPONSE_CACHE_SIZE)
      .build(
          new CacheLoader<ExpandInput, ValueSet>() {
            @Override
            public ValueSet load(@Nonnull ExpandInput key) {
              return terminologyClient
                  .expand(new UriType(key.getValueSetUri()), new IntegerType(EXPAND_PAGE_SIZE),
                      new IntegerType(key.getOffset()));
            }
          }
      );
}
 
Example #10
Source File: FhirEncodersTest.java    From bunsen with Apache License 2.0 5 votes vote down vote up
@Test
public void integer() {

  Assert.assertEquals(((IntegerType) patient.getMultipleBirth()).getValue(),
      patientDataset.select("multipleBirthInteger").head().get(0));
  Assert.assertEquals(((IntegerType) patient.getMultipleBirth()).getValue(),
      ((IntegerType) decodedPatient.getMultipleBirth()).getValue());
}
 
Example #11
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static int readIntegerExtension(Element e, String uri, int defaultValue) {
  Extension ex = ExtensionHelper.getExtension(e, uri);
  if (ex == null)
    return defaultValue;
  if (ex.getValue() instanceof IntegerType)
    return ((IntegerType) ex.getValue()).getValue();
  throw new Error("Unable to read extension "+uri+" as an integer");
}
 
Example #12
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static int readIntegerExtension(DomainResource dr, String uri, int defaultValue) {
  Extension ex = ExtensionHelper.getExtension(dr, uri);
  if (ex == null)
    return defaultValue;
  if (ex.getValue() instanceof IntegerType)
    return ((IntegerType) ex.getValue()).getValue();
  throw new Error("Unable to read extension "+uri+" as an integer");
}
 
Example #13
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setIntegerExtension(DomainResource resource, String uri, int value) {
  Extension ext = getExtension(resource, uri);
  if (ext != null)
    ext.setValue(new IntegerType(value));
  else
    resource.getExtension().add(new Extension(new UriType(uri)).setValue(new IntegerType(value)));
}
 
Example #14
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addIntegerExtension(DomainResource dr, String url, int value) {
  Extension ex = getExtension(dr, url);
  if (ex != null)
    ex.setValue(new IntegerType(value));
  else
    dr.getExtension().add(Factory.newExtension(url, new IntegerType(value), true));   
}
 
Example #15
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 #16
Source File: ProfileComparer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private IntegerType intersectMaxLength(int left, int right) {
  if (left == 0) 
    left = Integer.MAX_VALUE;
  if (right == 0) 
    right = Integer.MAX_VALUE;
  if (left < right)
    return left == Integer.MAX_VALUE ? null : new IntegerType(left);
  else
    return right == Integer.MAX_VALUE ? null : new IntegerType(right);
}
 
Example #17
Source File: TerminologyClient.java    From synthea with Apache License 2.0 4 votes vote down vote up
@Operation(type = ValueSet.class, name = "$expand")
ValueSet expand(@OperationParam(name = "url") UriType url, 
    @OperationParam(name = "count") IntegerType count, 
    @OperationParam(name = "offset") IntegerType offset);
 
Example #18
Source File: HospitalExporterR4.java    From synthea with Apache License 2.0 4 votes vote down vote up
/**
 * Add FHIR extensions to capture additional information.
 */
public static void addHospitalExtensions(Provider h, Organization organizationResource) {
  Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
  // calculate totals for utilization
  int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream()
      .mapToInt(ai -> ai.get()).sum();
  Extension encountersExtension = new Extension(SYNTHEA_URI + "utilization-encounters-extension");
  IntegerType encountersValue = new IntegerType(totalEncounters);
  encountersExtension.setValue(encountersValue);
  organizationResource.addExtension(encountersExtension);

  int totalProcedures = utilization.column(Provider.PROCEDURES).values().stream()
      .mapToInt(ai -> ai.get()).sum();
  Extension proceduresExtension = new Extension(SYNTHEA_URI + "utilization-procedures-extension");
  IntegerType proceduresValue = new IntegerType(totalProcedures);
  proceduresExtension.setValue(proceduresValue);
  organizationResource.addExtension(proceduresExtension);

  int totalLabs = utilization.column(Provider.LABS).values().stream().mapToInt(ai -> ai.get())
      .sum();
  Extension labsExtension = new Extension(SYNTHEA_URI + "utilization-labs-extension");
  IntegerType labsValue = new IntegerType(totalLabs);
  labsExtension.setValue(labsValue);
  organizationResource.addExtension(labsExtension);

  int totalPrescriptions = utilization.column(Provider.PRESCRIPTIONS).values().stream()
      .mapToInt(ai -> ai.get()).sum();
  Extension prescriptionsExtension = new Extension(
      SYNTHEA_URI + "utilization-prescriptions-extension");
  IntegerType prescriptionsValue = new IntegerType(totalPrescriptions);
  prescriptionsExtension.setValue(prescriptionsValue);
  organizationResource.addExtension(prescriptionsExtension);

  Integer bedCount = h.getBedCount();
  if (bedCount != null) {
    Extension bedCountExtension = new Extension(SYNTHEA_URI + "bed-count-extension");
    IntegerType bedCountValue = new IntegerType(bedCount);
    bedCountExtension.setValue(bedCountValue);
    organizationResource.addExtension(bedCountExtension);
  }
}
 
Example #19
Source File: TestData.java    From bunsen with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a FHIR Patient for testing purposes.
 */
public static Patient newPatient() {

  Patient patient = new Patient();

  patient.setId("test-patient");
  patient.setMultipleBirth(new IntegerType(1));

  return patient;
}