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

The following examples show how to use org.hl7.fhir.r4.model.CodeType. 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: 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 #3
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 #4
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 #5
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 #6
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 #7
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setCodeExtension(Element element, String uri, String value) {
  if (Utilities.noString(value))
    return;
  
  Extension ext = getExtension(element, uri);
  if (ext != null)
    ext.setValue(new CodeType(value));
  else
    element.getExtension().add(new Extension(new UriType(uri)).setValue(new CodeType(value)));
}
 
Example #8
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addLanguageTranslation(Element element, String lang, String value) {
  if (Utilities.noString(lang) || Utilities.noString(value))
    return;
  
  Extension extension = new Extension().setUrl(EXT_TRANSLATION);
  extension.addExtension().setUrl("lang").setValue(new CodeType(lang));
  extension.addExtension().setUrl("content").setValue(new StringType(value));
  element.getExtension().add(extension);
}
 
Example #9
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static String getLanguageTranslation(Element element, String lang) {
  for (Extension e : element.getExtension()) {
    if (e.getUrl().equals(EXT_TRANSLATION)) {
      Extension e1 = ExtensionHelper.getExtension(e, "lang");

      if (e1 != null && e1.getValue() instanceof CodeType && ((CodeType) e.getValue()).getValue().equals(lang)) {
        e1 = ExtensionHelper.getExtension(e, "content");
        return ((StringType) e.getValue()).getValue();
      }
    }
  }
  return null;
}
 
Example #10
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static boolean hasLanguageTranslation(Element element, String lang) {
  for (Extension e : element.getExtension()) {
    if (e.getUrl().equals(EXT_TRANSLATION)) {
      Extension e1 = ExtensionHelper.getExtension(e, "lang");

      if (e1 != null && e1.getValue() instanceof CodeType && ((CodeType) e.getValue()).getValue().equals(lang))
        return true;
    }
  }
  return false;
}
 
Example #11
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setStatus(CodeSystem cs, ConceptDefinitionComponent concept, ConceptStatus status) throws FHIRFormatError {
  defineStatusProperty(cs);
  ConceptPropertyComponent p = getProperty(concept, "status");
  if (p != null)
    p.setValue(new CodeType(status.toCode()));
  else
    concept.addProperty().setCode("status").setValue(new CodeType(status.toCode()));    
}
 
Example #12
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setCodeExtension(DomainResource resource, String uri, String value) {
  if (Utilities.noString(value))
    return;
  
  Extension ext = getExtension(resource, uri);
  if (ext != null)
    ext.setValue(new CodeType(value));
  else
    resource.getExtension().add(new Extension(new UriType(uri)).setValue(new CodeType(value)));
}
 
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 addCodeExtension(DomainResource dr, String url, String value) {
  Extension ex = getExtension(dr, url);
  if (ex != null)
    ex.setValue(new CodeType(value));
  else
    dr.getExtension().add(Factory.newExtension(url, new CodeType(value), true));   
}
 
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 addCodeExtension(Element e, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(e, url);
    if (ex != null)
      ex.setValue(new CodeType(content));
    else
      e.getExtension().add(Factory.newExtension(url, new CodeType(content), true));   
  }
}
 
Example #15
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static Extension makeIssueSource(Source source) {
  Extension ex = new Extension();
  // todo: write this up and get it published with the pack (and handle the redirect?)
  ex.setUrl(ToolingExtensions.EXT_ISSUE_SOURCE);
  CodeType c = new CodeType();
  c.setValue(source.toString());
  ex.setValue(c);
  return ex;
}
 
Example #16
Source File: CountryCodesConverter.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void execute() throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
    Document src = load();
    CodeSystem cs1 = new CodeSystem();
    CodeSystem cs2 = new CodeSystem();
    CodeSystem cs3 = new CodeSystem();
    setMetadata(src, cs1, "iso3166", "urn:iso:std:iso:3166", "", "");
    setMetadata(src, cs2, "iso3166-2", "urn:iso:std:iso:3166:-2", "Part2", " Part 2");
    cs1.addProperty().setCode("canonical").setDescription("The 2 letter code that identifies the same country (so 2/3/numeric codes can be aligned)").setType(PropertyType.CODE);
    cs2.addProperty().setCode("country").setDescription("The 2 letter code that identifies the country for the subdivision").setType(PropertyType.CODE);
    for (Element e : XMLUtil.getNamedChildren(src.getDocumentElement(), "country")) {
      System.out.println(e.getAttribute("id"));
      String c2 = XMLUtil.getNamedChildText(e, "alpha-2-code");
      String c3 = XMLUtil.getNamedChildText(e, "alpha-3-code");
      String cN = XMLUtil.getNamedChildText(e, "numeric-code");
      Element n = XMLUtil.getNamedChildByAttribute(e, "short-name", "lang3code", "eng");
      if (n == null)
        n = XMLUtil.getNamedChildByAttribute(e, "short-name-upper-case", "lang3code", "eng");
      if (n == null)
        continue;
      String name = n.getTextContent();
      n = XMLUtil.getNamedChildByAttribute(e, "full-name", "lang3code", "eng");
      if (n == null)
        n = XMLUtil.getNamedChildByAttribute(e, "full-name-upper-case", "lang3code", "eng");
      if (n == null)
        n = XMLUtil.getNamedChildByAttribute(e, "short-name", "lang3code", "eng");
      if (n == null)
        n = XMLUtil.getNamedChildByAttribute(e, "short-name-upper-case", "lang3code", "eng");
      String desc = n.getTextContent();
      ConceptDefinitionComponent cc = cs1.addConcept();
      cc.setCode(c2);
      cc.setDisplay(name);
      cc.setDefinition(desc);
      poplang(e, cc);
      if (c3 != null) {
        cc = cs1.addConcept();
        cc.setCode(c3);
        cc.setDisplay(name);
        cc.setDefinition(desc);
        cc.addProperty().setCode("canonical").setValue(new CodeType(c2));
        poplang(e, cc);
      }
      if (cN != null) {
        cc = cs1.addConcept();
        cc.setCode(cN);
        cc.setDisplay(name);
        cc.setDefinition(desc);
        cc.addProperty().setCode("canonical").setValue(new CodeType(c2));
        poplang(e, cc);
      }
      for (Element sd : XMLUtil.getNamedChildren(e, "subdivision")) {
        cc = cs2.addConcept();
        cc.setCode(XMLUtil.getNamedChildText(sd, "subdivision-code"));
        Element l = XMLUtil.getNamedChild(sd, "subdivision-locale");
        cc.setDisplay(XMLUtil.getNamedChildText(l, "subdivision-locale-name"));
        cc.addProperty().setCode("country").setValue(new CodeType(c2));            
      }
    }
    cs1.setCount(cs1.getConcept().size());
    cs2.setCount(cs2.getConcept().size());
    throw new Error("Needs revisiting");
//    new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166.json")), cs1);
//    new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166.json")), cs1); // format hasn't changed
//    new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166-2.json")), cs2);
//    new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166-2.json")), cs2); // format hasn't changed
  }
 
Example #17
Source File: RdfParserBase.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
protected void decorateCode(Complex t, CodeType value) {
}
 
Example #18
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public static void addOtherChild(CodeSystem cs, ConceptDefinitionComponent owner, String code) {
  defineChildProperty(cs);
  owner.addProperty().setCode("child").setValue(new CodeType(code));
}