001package org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.exceptions.FHIRException; 005import org.hl7.fhir.r4b.model.DataType; 006import org.hl7.fhir.r4b.model.PrimitiveType; 007import org.hl7.fhir.r5.model.UriType; 008 009public class Uri43_50 { 010 public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.r4b.model.UriType src) throws FHIRException { 011 org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValueAsString()) : new org.hl7.fhir.r5.model.UriType(); 012 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 013 return tgt; 014 } 015 016 public static org.hl7.fhir.r4b.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { 017 org.hl7.fhir.r4b.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4b.model.UriType(src.getValueAsString()) : new org.hl7.fhir.r4b.model.UriType(); 018 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 019 return tgt; 020 } 021 022 public static UriType convertToUri(DataType src) { 023 if (src instanceof PrimitiveType<?>) { 024 PrimitiveType<?> p = (PrimitiveType<?>) src; 025 org.hl7.fhir.r5.model.UriType tgt = p.hasValue() ? new org.hl7.fhir.r5.model.UriType(p.getValueAsString()) : new org.hl7.fhir.r5.model.UriType(); 026 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 027 return tgt; 028 } else { 029 throw new FHIRException("Unable to convert "+src.fhirType()+" to a URI Type"); 030 } 031 } 032}