@Test public void getConstructedTextWithoutPostcode() { final Address address = new Address().addLine( "Lower Road 20" ).addLine( "Apartment 19" ) .setCity( "Freetown" ).setState( "Other State" ).setCountry( "Sierra Leone" ); Assert.assertEquals( "Lower Road 20 / Apartment 19 / Freetown / Other State", utils.getConstructedText( address ) ); }
@Nullable @Override public String getConstructedText( @Nullable ICompositeType address, @Nonnull String delimiter ) { final Address convertedAddress = (Address) address; if ( address == null ) { return null; } final StringBuilder sb = new StringBuilder(); convertedAddress.getLine().stream().filter( l -> (l != null) && StringUtils.isNotBlank( l.getValue() ) ) .forEach( l -> sb.append( delimiter ).append( l.getValue() ) ); if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) && StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ).append( ' ' ).append( convertedAddress.getCity() ); } else if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ); } else if ( StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getCity() ); } if ( StringUtils.isNotBlank( convertedAddress.getState() ) ) { sb.append( delimiter ).append( convertedAddress.getState() ); } if ( sb.length() == 0 ) { return convertedAddress.getText(); } return sb.substring( delimiter.length() ); }
Dstu3AddressFhirToDhisTransformerUtils extends AbstractAddressFhirToDhisTransformerUtils { @Nullable @Override public String getConstructedText( @Nullable ICompositeType address, @Nonnull String delimiter ) { final Address convertedAddress = (Address) address; if ( address == null ) { return null; } final StringBuilder sb = new StringBuilder(); convertedAddress.getLine().stream().filter( l -> (l != null) && StringUtils.isNotBlank( l.getValue() ) ) .forEach( l -> sb.append( delimiter ).append( l.getValue() ) ); if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) && StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ).append( ' ' ).append( convertedAddress.getCity() ); } else if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ); } else if ( StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getCity() ); } if ( StringUtils.isNotBlank( convertedAddress.getState() ) ) { sb.append( delimiter ).append( convertedAddress.getState() ); } if ( sb.length() == 0 ) { return convertedAddress.getText(); } return sb.substring( delimiter.length() ); } }
Dstu3AddressFhirToDhisTransformerUtils extends AbstractAddressFhirToDhisTransformerUtils { @Nullable @Override public String getConstructedText( @Nullable ICompositeType address, @Nonnull String delimiter ) { final Address convertedAddress = (Address) address; if ( address == null ) { return null; } final StringBuilder sb = new StringBuilder(); convertedAddress.getLine().stream().filter( l -> (l != null) && StringUtils.isNotBlank( l.getValue() ) ) .forEach( l -> sb.append( delimiter ).append( l.getValue() ) ); if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) && StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ).append( ' ' ).append( convertedAddress.getCity() ); } else if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ); } else if ( StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getCity() ); } if ( StringUtils.isNotBlank( convertedAddress.getState() ) ) { sb.append( delimiter ).append( convertedAddress.getState() ); } if ( sb.length() == 0 ) { return convertedAddress.getText(); } return sb.substring( delimiter.length() ); } Dstu3AddressFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext, @Nonnull Dstu3DateTimeFhirToDhisTransformerUtils dateTimeTransformerUtils ); }
Dstu3AddressFhirToDhisTransformerUtils extends AbstractAddressFhirToDhisTransformerUtils { @Nullable @Override public String getConstructedText( @Nullable ICompositeType address, @Nonnull String delimiter ) { final Address convertedAddress = (Address) address; if ( address == null ) { return null; } final StringBuilder sb = new StringBuilder(); convertedAddress.getLine().stream().filter( l -> (l != null) && StringUtils.isNotBlank( l.getValue() ) ) .forEach( l -> sb.append( delimiter ).append( l.getValue() ) ); if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) && StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ).append( ' ' ).append( convertedAddress.getCity() ); } else if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ); } else if ( StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getCity() ); } if ( StringUtils.isNotBlank( convertedAddress.getState() ) ) { sb.append( delimiter ).append( convertedAddress.getState() ); } if ( sb.length() == 0 ) { return convertedAddress.getText(); } return sb.substring( delimiter.length() ); } Dstu3AddressFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext, @Nonnull Dstu3DateTimeFhirToDhisTransformerUtils dateTimeTransformerUtils ); @Nonnull @Override Set<FhirVersion> getFhirVersions(); @Nullable @Override ICompositeType getPrimaryAddress( @Nonnull List<? extends ICompositeType> addresses ); @Nullable @Override String getSingleLine( @Nullable ICompositeType address, @Nonnull String delimiter ); @Nullable @Override String getConstructedText( @Nullable ICompositeType address, @Nonnull String delimiter ); @Nullable @Override String getText( @Nullable ICompositeType address ); }
Dstu3AddressFhirToDhisTransformerUtils extends AbstractAddressFhirToDhisTransformerUtils { @Nullable @Override public String getConstructedText( @Nullable ICompositeType address, @Nonnull String delimiter ) { final Address convertedAddress = (Address) address; if ( address == null ) { return null; } final StringBuilder sb = new StringBuilder(); convertedAddress.getLine().stream().filter( l -> (l != null) && StringUtils.isNotBlank( l.getValue() ) ) .forEach( l -> sb.append( delimiter ).append( l.getValue() ) ); if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) && StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ).append( ' ' ).append( convertedAddress.getCity() ); } else if ( StringUtils.isNotBlank( convertedAddress.getPostalCode() ) ) { sb.append( delimiter ).append( convertedAddress.getPostalCode() ); } else if ( StringUtils.isNotBlank( convertedAddress.getCity() ) ) { sb.append( delimiter ).append( convertedAddress.getCity() ); } if ( StringUtils.isNotBlank( convertedAddress.getState() ) ) { sb.append( delimiter ).append( convertedAddress.getState() ); } if ( sb.length() == 0 ) { return convertedAddress.getText(); } return sb.substring( delimiter.length() ); } Dstu3AddressFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext, @Nonnull Dstu3DateTimeFhirToDhisTransformerUtils dateTimeTransformerUtils ); @Nonnull @Override Set<FhirVersion> getFhirVersions(); @Nullable @Override ICompositeType getPrimaryAddress( @Nonnull List<? extends ICompositeType> addresses ); @Nullable @Override String getSingleLine( @Nullable ICompositeType address, @Nonnull String delimiter ); @Nullable @Override String getConstructedText( @Nullable ICompositeType address, @Nonnull String delimiter ); @Nullable @Override String getText( @Nullable ICompositeType address );  }